flexWrap, alignContent, initialPlayground
Summary: Adds `initialPlayground` to the markdown header. Adds contents fro alignContent and flexWrap. Reviewed By: emilsjolander Differential Revision: D6987513 fbshipit-source-id: 41de309d427a9f42e09477170fb8512ce1e7a816
This commit is contained in:
committed by
Facebook Github Bot
parent
8c5cbf698b
commit
740ef6cd9e
@@ -2,8 +2,12 @@
|
|||||||
path: "docs/align-content"
|
path: "docs/align-content"
|
||||||
title: "Align Content"
|
title: "Align Content"
|
||||||
hasPlayground: true
|
hasPlayground: true
|
||||||
|
initialPlayground: eyJ3aWR0aCI6NTAwLCJoZWlnaHQiOjUwMCwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbe30se30se30se30se30se30se30se30se30se30se30se31dfQ==
|
||||||
---
|
---
|
||||||
|
|
||||||
## Align Content
|
## Align Content
|
||||||
|
|
||||||
|
The property defines the distribution of lines along the cross-axis. This only
|
||||||
|
has effect when items are wrapped to multiple lines (see [flexWrap](flex-wrap)).
|
||||||
|
|
||||||
<controls prop="alignContent"></controls>
|
<controls prop="alignContent"></controls>
|
||||||
|
@@ -2,8 +2,20 @@
|
|||||||
path: "docs/flex-wrap"
|
path: "docs/flex-wrap"
|
||||||
title: "Flex Wrap"
|
title: "Flex Wrap"
|
||||||
hasPlayground: true
|
hasPlayground: true
|
||||||
|
initialPlayground: eyJ3aWR0aCI6NTAwLCJoZWlnaHQiOjUwMCwiY2hpbGRyZW4iOlt7fSx7fSx7fSx7fSx7fSx7fSx7fSx7fV19
|
||||||
---
|
---
|
||||||
|
|
||||||
## Flex Wrap
|
## Flex Wrap
|
||||||
|
|
||||||
|
The `flexWrap` property is set on containers and controls what happens when
|
||||||
|
children overflow the size of the container along the main axis. By default
|
||||||
|
children are forced into a single line (which can shrink elements).
|
||||||
|
|
||||||
|
If wrapping is allowed items are wrapped into multiple lines along the main
|
||||||
|
axis if needed. `WRAP_REVERSE` behaves the same, but the order of the lines is
|
||||||
|
reversed.
|
||||||
|
|
||||||
<controls prop="flexWrap"></controls>
|
<controls prop="flexWrap"></controls>
|
||||||
|
|
||||||
|
When wrapping lines [alignContent](align-content) can be used to specify how the
|
||||||
|
lines are placed in the container.
|
||||||
|
@@ -25,6 +25,7 @@ exports.createPages = ({boundActionCreators, graphql}) => {
|
|||||||
frontmatter {
|
frontmatter {
|
||||||
path
|
path
|
||||||
hasPlayground
|
hasPlayground
|
||||||
|
initialPlayground
|
||||||
}
|
}
|
||||||
html
|
html
|
||||||
}
|
}
|
||||||
|
@@ -110,6 +110,7 @@ export default class YogaNode extends Component<Props, State> {
|
|||||||
root.setJustifyContent(layoutDefinition.justifyContent);
|
root.setJustifyContent(layoutDefinition.justifyContent);
|
||||||
root.setAlignItems(layoutDefinition.alignItems);
|
root.setAlignItems(layoutDefinition.alignItems);
|
||||||
root.setAlignSelf(layoutDefinition.alignSelf);
|
root.setAlignSelf(layoutDefinition.alignSelf);
|
||||||
|
root.setAlignContent(layoutDefinition.alignContent);
|
||||||
root.setFlexGrow(layoutDefinition.flexGrow);
|
root.setFlexGrow(layoutDefinition.flexGrow);
|
||||||
root.setFlexShrink(layoutDefinition.flexShrink);
|
root.setFlexShrink(layoutDefinition.flexShrink);
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ import type {Yoga$Direction} from 'yoga-layout';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
layoutDefinition: LayoutRecordT,
|
layoutDefinition: Object,
|
||||||
direction: Yoga$Direction,
|
direction: Yoga$Direction,
|
||||||
maxDepth: number,
|
maxDepth: number,
|
||||||
maxChildren?: number,
|
maxChildren?: number,
|
||||||
@@ -53,11 +53,11 @@ export default class Playground extends Component<Props, State> {
|
|||||||
_containerRef: ?HTMLElement;
|
_containerRef: ?HTMLElement;
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
layoutDefinition: LayoutRecord({
|
layoutDefinition: {
|
||||||
width: 500,
|
width: 500,
|
||||||
height: 500,
|
height: 500,
|
||||||
children: List([LayoutRecord(), LayoutRecord(), LayoutRecord()]),
|
children: [{}, {}, []],
|
||||||
}),
|
},
|
||||||
direction: yoga.DIRECTION_LTR,
|
direction: yoga.DIRECTION_LTR,
|
||||||
maxDepth: 3,
|
maxDepth: 3,
|
||||||
showCode: false,
|
showCode: false,
|
||||||
@@ -65,9 +65,19 @@ export default class Playground extends Component<Props, State> {
|
|||||||
persist: false,
|
persist: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
rehydrate = (node: Object): LayoutRecord => {
|
||||||
|
let record = LayoutRecord(node);
|
||||||
|
record = record.set('padding', PositionRecord(record.padding));
|
||||||
|
record = record.set('border', PositionRecord(record.border));
|
||||||
|
record = record.set('margin', PositionRecord(record.margin));
|
||||||
|
record = record.set('position', PositionRecord(record.position));
|
||||||
|
record = record.set('children', List(record.children.map(this.rehydrate)));
|
||||||
|
return record;
|
||||||
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
selectedNodePath: this.props.selectedNodePath,
|
selectedNodePath: this.props.selectedNodePath,
|
||||||
layoutDefinition: this.props.layoutDefinition,
|
layoutDefinition: this.rehydrate(this.props.layoutDefinition),
|
||||||
direction: this.props.direction,
|
direction: this.props.direction,
|
||||||
showCode: false,
|
showCode: false,
|
||||||
};
|
};
|
||||||
@@ -90,16 +100,6 @@ export default class Playground extends Component<Props, State> {
|
|||||||
document.removeEventListener('keydown', this.onKeyDown);
|
document.removeEventListener('keydown', this.onKeyDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
rehydrate = (node: Object): LayoutRecord => {
|
|
||||||
let record = LayoutRecord(node);
|
|
||||||
record = record.set('padding', PositionRecord(record.padding));
|
|
||||||
record = record.set('border', PositionRecord(record.border));
|
|
||||||
record = record.set('margin', PositionRecord(record.margin));
|
|
||||||
record = record.set('position', PositionRecord(record.position));
|
|
||||||
record = record.set('children', List(record.children.map(this.rehydrate)));
|
|
||||||
return record;
|
|
||||||
};
|
|
||||||
|
|
||||||
onKeyDown = (e: KeyboardEvent) => {
|
onKeyDown = (e: KeyboardEvent) => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
this.hideSidePanes();
|
this.hideSidePanes();
|
||||||
@@ -276,8 +276,8 @@ export default class Playground extends Component<Props, State> {
|
|||||||
<Sidebar
|
<Sidebar
|
||||||
width={500}
|
width={500}
|
||||||
visible={this.state.showCode}
|
visible={this.state.showCode}
|
||||||
onClose={() => this.setState({showCode: false})}>
|
onClose={() => this.setState({showCode: false})}
|
||||||
</Sidebar>
|
/>
|
||||||
{this.props.persist && <URLShortener />}
|
{this.props.persist && <URLShortener />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -22,16 +22,25 @@ import './index.css';
|
|||||||
type Props = {
|
type Props = {
|
||||||
pathContext: {
|
pathContext: {
|
||||||
html: string,
|
html: string,
|
||||||
frontmatter: {},
|
frontmatter: {
|
||||||
|
initialPlayground?: string,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const REGEX = /<controls prop="([A-Za-z]+)"\s?\/>/gi;
|
const REGEX = /<controls prop="([A-Za-z]+)"\s?\/>/gi;
|
||||||
|
|
||||||
export default class withPlayground extends Component<Props> {
|
export default class withPlayground extends Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
|
let layoutDefinition;
|
||||||
|
if (this.props.pathContext.frontmatter.initialPlayground) {
|
||||||
|
layoutDefinition = JSON.parse(
|
||||||
|
atob(this.props.pathContext.frontmatter.initialPlayground),
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Page className="doc-block playground">
|
<Page className="doc-block playground">
|
||||||
<Playground
|
<Playground
|
||||||
|
layoutDefinition={layoutDefinition}
|
||||||
selectedNodePath={[]}
|
selectedNodePath={[]}
|
||||||
showGuides={false}
|
showGuides={false}
|
||||||
renderSidebar={(layout, onChange) => (
|
renderSidebar={(layout, onChange) => (
|
||||||
|
Reference in New Issue
Block a user