import * as React from 'react'; import { Dropdown, IDropdownOption } from '@fluentui/react/lib/Dropdown'; import { Slider } from '@fluentui/react/lib/Slider'; import { Stack, IStackProps, IStackStyles, IStackTokens } from '@fluentui/react/lib/Stack'; import { DefaultPalette } from '@fluentui/react/lib/Styling'; import { range } from '@fluentui/example-data'; export type Overflow = 'visible' | 'auto' | 'hidden'; export interface IExampleOptions { stackWidth: number; containerHeight: number; horizontalAlignment: IStackProps['horizontalAlign']; verticalAlignment: IStackProps['verticalAlign']; overflow: Overflow; } // Non-mutating styles definition const itemStyles: React.CSSProperties = { alignItems: 'center', background: DefaultPalette.themePrimary, color: DefaultPalette.white, display: 'flex', height: 50, justifyContent: 'center', width: 50, }; // Alignment options const horizontalAlignmentOptions: IDropdownOption[] = [ { key: 'start', text: 'Left' }, { key: 'center', text: 'Center' }, { key: 'end', text: 'Right' }, { key: 'space-around', text: 'Space around' }, { key: 'space-between', text: 'Space between' }, { key: 'space-evenly', text: 'Space evenly' }, ]; const verticalAlignmentOptions: IDropdownOption[] = [ { key: 'start', text: 'Top' }, { key: 'center', text: 'Center' }, { key: 'end', text: 'Bottom' }, ]; const overflowOptions: IDropdownOption[] = [ { key: 'visible', text: 'Visible' }, { key: 'auto', text: 'Auto' }, { key: 'hidden', text: 'Hidden' }, ]; // Tokens definition const sectionStackTokens: IStackTokens = { childrenGap: 10 }; const configureStackTokens: IStackTokens = { childrenGap: 20 }; const wrapStackTokens: IStackTokens = { childrenGap: 30 }; const HorizontalStackWrapAdvancedExampleContent: React.FunctionComponent = props => { const { stackWidth, containerHeight, overflow, horizontalAlignment, verticalAlignment } = props; // Mutating styles definition const stackStyles: IStackStyles = { root: { background: DefaultPalette.themeTertiary, width: `${stackWidth}%`, overflow, }, }; const containerStyles: React.CSSProperties = { height: containerHeight }; return (
{range(1, 10).map(n => ( {n} ))}
); }; export const HorizontalStackWrapAdvancedExample: React.FunctionComponent = () => { const [stackWidth, setStackWidth] = React.useState(100); const [containerHeight, setContainerHeight] = React.useState(150); const [horizontalAlignment, setHorizontalAlignment] = React.useState('start'); const [verticalAlignment, setVerticalAlignment] = React.useState('start'); const [overflow, setOverflow] = React.useState('visible'); return ( , option: IDropdownOption): void => setHorizontalAlignment(option.key as IStackProps['horizontalAlign']) } /> , option: IDropdownOption): void => setVerticalAlignment(option.key as IStackProps['verticalAlign']) } /> , option: IDropdownOption): void => setOverflow(option.key as Overflow) } /> ); };