/** * Copyright (c) 2014-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * @flow * @format */ import React, {Component} from 'react'; import {Row, Col, Button, Tabs, Input} from 'antd'; import YogaEnumSelect from './YogaEnumSelect'; import type {LayoutRecordT} from './LayoutRecord'; import type {Yoga$Direction} from 'yoga-layout'; import InfoText from './InfoText'; import YogaPositionEditor from './YogaPositionEditor'; import './Editor.css'; const TabPane = Tabs.TabPane; type Props = { node: ?LayoutRecordT, onChangeLayout: (key: string, value: any) => void, onChangeSetting: (key: string, value: any) => void, direction: Yoga$Direction, selectedNodeIsRoot: boolean, onRemove?: () => void, onAdd?: () => void, }; export default class Editor extends Component { componentDidMount() { document.addEventListener('keydown', this.onKeyDown); } componentWillUnmount() { document.removeEventListener('keydown', this.onKeyDown); } onKeyDown = (e: KeyboardEvent) => { if ( (e.key === 'Delete' || e.key === 'Backspace') && this.props.onRemove && !(e.target instanceof HTMLInputElement) ) { this.props.onRemove(); } }; render() { const {node, selectedNodeIsRoot} = this.props; const disabled = !Boolean(node); return (

Direction The direction property specifies the text direction/writing direction

this.props.onChangeSetting('direction', e)} />

Flex direction Defining the direction of the main-axis

this.props.onChangeLayout('flexDirection', e)} />

Flex grow Grow factor defined how much space this element should take up, relative to it's siblings

this.props.onChangeLayout('flexGrow', e.target.value) } />

Flex shrink Shrink factor if elements don't fit into the parent node anymore.

this.props.onChangeLayout('flexShrink', e.target.value) } />

Flex wrap Wrapping behaviour when child nodes don't fit into a single line

this.props.onChangeLayout('flexWrap', e)} />

Justify content Aligns child nodes along the main-axis

this.props.onChangeLayout('justifyContent', e)} />

Align items Aligns child nodes along the cross-axis

this.props.onChangeLayout('alignItems', e)} />

Align self Specifies alignment on the cross-axis for the node itself

this.props.onChangeLayout('alignSelf', e)} />

Align content Alignment of lines along the cross-axis when wrapping

this.props.onChangeLayout('alignContent', e)} />

Width × height Dimensions of the node

this.props.onChangeLayout('width', e.target.value) } /> this.props.onChangeLayout('height', e.target.value) } />

Aspect ratio Aspect radio is an additon by Yoga which is handy e.g. for nodes displaying videos

this.props.onChangeLayout('aspectRatio', e.target.value) } />

Box model

{['padding', 'border', 'margin'].map(property => ( this.props.onChangeLayout(property, value)} /> ))}

Position Relative position offsets the node from it's calculated position. Absolute position removes the node from the flexbox flow and positions it at the given position.

this.props.onChangeLayout('positionType', e)} /> this.props.onChangeLayout('position', value)} />
); } }