import * as React from 'react'; import { Checkbox, ICheckboxStyles } from '@fluentui/react/lib/Checkbox'; import { Dropdown, IDropdownOption } from '@fluentui/react/lib/Dropdown'; import { Slider } from '@fluentui/react/lib/Slider'; import { Stack, IStackStyles, IStackTokens, IStackItemStyles, IStackProps } from '@fluentui/react/lib/Stack'; import { mergeStyles, DefaultPalette } from '@fluentui/react/lib/Styling'; import { TextField } from '@fluentui/react/lib/TextField'; import { useBoolean } from '@fluentui/react-hooks'; import { range } from '@fluentui/example-data'; export interface IExampleOptions { numItems: number; showBoxShadow: boolean; preventOverflow: boolean; disableShrink: boolean; wrap: boolean; stackHeight: number; autoHeight: boolean; childrenGap: number; paddingLeft: number; paddingRight: number; paddingTop: number; paddingBottom: number; verticalAlignment: IStackProps['verticalAlign']; horizontalAlignment: IStackProps['horizontalAlign']; hideEmptyChildren: boolean; emptyChildren: string[]; } const checkboxStyles: Partial = { root: { marginRight: 10 } }; // Alignment options const verticalAlignmentOptions: IDropdownOption[] = [ { key: 'start', text: 'Top' }, { key: 'center', text: 'Center' }, { key: 'end', text: 'Bottom' }, { key: 'space-around', text: 'Space around' }, { key: 'space-between', text: 'Space between' }, { key: 'space-evenly', text: 'Space evenly' }, ]; const horizontalAlignmentOptions: IDropdownOption[] = [ { key: 'start', text: 'Left' }, { key: 'center', text: 'Center' }, { key: 'end', text: 'Right' }, ]; // Non-mutating tokens definition const sectionStackTokens: IStackTokens = { childrenGap: 10 }; const configureStackTokens: IStackTokens = { childrenGap: 20 }; const VerticalStackConfigureExampleContent: React.FunctionComponent = props => { const { numItems, showBoxShadow, preventOverflow, disableShrink, wrap, stackHeight, autoHeight, childrenGap, paddingLeft, paddingRight, paddingTop, paddingBottom, verticalAlignment, horizontalAlignment, hideEmptyChildren, emptyChildren, } = props; // Styles definition const stackStyles: IStackStyles = { root: [ { background: DefaultPalette.themeTertiary, height: autoHeight ? 'auto' : stackHeight, marginLeft: 10, marginRight: 10, }, preventOverflow && { overflow: 'hidden' as 'hidden', }, ], }; const stackItemStyles: IStackItemStyles = { root: { alignItems: 'center', background: DefaultPalette.themePrimary, boxShadow: showBoxShadow ? `0px 0px 10px 5px ${DefaultPalette.themeDarker}` : '', color: DefaultPalette.white, display: 'flex', height: 50, justifyContent: 'center', width: 50, }, }; // Tokens definition const exampleStackTokens: IStackTokens = { childrenGap: childrenGap + ' ' + 0, padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`, }; return ( {range(1, numItems).map((value: number, index: number) => { if (emptyChildren.indexOf(value.toString()) !== -1) { return hideEmptyChildren ? ( ) : ( ); } return ( {value} ); })} ); }; export const VerticalStackConfigureExample: React.FunctionComponent = () => { const [numItems, setNumItems] = React.useState(5); const [showBoxShadow, { toggle: toggleShowBoxShadow }] = useBoolean(false); const [preventOverflow, { toggle: togglePreventOverflow }] = useBoolean(false); const [wrap, { toggle: toggleWrap }] = useBoolean(false); const [disableShrink, { toggle: toggleDisableShrink }] = useBoolean(true); const [stackHeight, setStackHeight] = React.useState(200); const [autoHeight, { toggle: toggleAutoHeight }] = useBoolean(true); const [childrenGap, setChildrenGap] = React.useState(0); const [paddingLeft, setPaddingLeft] = React.useState(0); const [paddingRight, setPaddingRight] = React.useState(0); const [paddingTop, setPaddingTop] = React.useState(0); const [paddingBottom, setPaddingBottom] = React.useState(0); const [horizontalAlignment, setHorizontalAlignment] = React.useState('start'); const [verticalAlignment, setVerticalAlignment] = React.useState('start'); const [hideEmptyChildren, { toggle: toggleHideEmptyChildren }] = useBoolean(false); const [emptyChildren, setEmptyChildren] = React.useState([]); return ( , option: IDropdownOption): void => setVerticalAlignment(option.key as IStackProps['verticalAlign']) } /> , option: IDropdownOption): void => setHorizontalAlignment(option.key as IStackProps['horizontalAlign']) } /> , value?: string): void => { if (value === undefined) { return; } setEmptyChildren(value.replace(/,/g, '').split(' ')); }} /> ); };