diff --git a/apps/fabric-website-resources/src/AppDefinition.tsx b/apps/fabric-website-resources/src/AppDefinition.tsx index 4d716c4bc75cc..379c7edba8541 100644 --- a/apps/fabric-website-resources/src/AppDefinition.tsx +++ b/apps/fabric-website-resources/src/AppDefinition.tsx @@ -384,6 +384,12 @@ export const AppDefinition: IAppDefinition = { name: 'Spinner', url: '#/examples/spinner' }, + { + component: require('./components/pages/StackPage').StackPage, + key: 'Stack', + name: 'Stack', + url: '#/examples/stack' + }, { component: require('./components/pages/SwatchColorPickerPage').SwatchColorPickerPage, key: 'SwatchColorPicker', diff --git a/apps/fabric-website-resources/src/components/pages/StackPage.tsx b/apps/fabric-website-resources/src/components/pages/StackPage.tsx new file mode 100644 index 0000000000000..11057ba1818e7 --- /dev/null +++ b/apps/fabric-website-resources/src/components/pages/StackPage.tsx @@ -0,0 +1,6 @@ +import * as React from 'react'; +import { DemoPage } from '../DemoPage'; + +import { StackPageProps } from 'office-ui-fabric-react/lib/components/Stack/Stack.doc'; + +export const StackPage = (props: { isHeaderVisible: boolean }) => ; diff --git a/apps/vr-tests/src/stories/HorizontalStack.stories.tsx b/apps/vr-tests/src/stories/HorizontalStack.stories.tsx index 17f60882b6cb6..7ddf3744e638a 100644 --- a/apps/vr-tests/src/stories/HorizontalStack.stories.tsx +++ b/apps/vr-tests/src/stories/HorizontalStack.stories.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import Screener, { Steps } from 'screener-storybook/src/screener'; import { storiesOf } from '@storybook/react'; import { FabricDecoratorFullWidth } from '../utilities'; -import { HorizontalStack } from '@uifabric/experiments/lib/Stack'; +import { Stack } from 'office-ui-fabric-react'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; const rootStyles = { @@ -52,110 +52,122 @@ const styles = mergeStyleSets({ const defaultProps = { className: styles.root, children: [ - 1, - 2, - 3 + + 1 + , + + 2 + , + + 3 + ] }; storiesOf('HorizontalStack', module) .addDecorator(FabricDecoratorFullWidth) - .addDecorator(story => ( - {story()} - )) - .addStory('Default', () => ( - - ), { rtl: true }) - .addStory('Padding', () => ( - - )) - .addStory('Gap', () => ( - - ), { rtl: true }) - .addStory('Horizontally centered', () => ( - - )) - .addStory('Right-aligned', () => ( - - ), { rtl: true }) - .addStory('Space around', () => ( - - )) - .addStory('Space between', () => ( - - )) - .addStory('Space evenly', () => ( - - )) - .addStory('Vertically centered', () => ( - - )) - .addStory('Bottom-aligned', () => ( - - )) - .addStory('Item alignments', () => ( - - Auto-aligned item - Stretch-aligned item - Baseline-aligned item - Start-aligned item - Center-aligned item - End-aligned item - - ), { rtl: true }) + .addDecorator(story => {story()}) + .addStory('Default', () => , { rtl: true }) + .addStory('Padding', () => ) + .addStory('Gap', () => , { rtl: true }) + .addStory('Horizontally centered', () => ) + .addStory('Right-aligned', () => , { rtl: true }) + .addStory('Space around', () => ) + .addStory('Space between', () => ) + .addStory('Space evenly', () => ) + .addStory('Vertically centered', () => ) + .addStory('Bottom-aligned', () => ) + .addStory( + 'Item alignments', + () => ( + + + Auto-aligned item + + + Stretch-aligned item + + + Baseline-aligned item + + + Start-aligned item + + + Center-aligned item + + + End-aligned item + + + ), + { rtl: true } + ) .addStory('Growing items', () => ( - - Grow is 3 - Grow is 2 - Grow is 1 - + + + Grow is 3 + + + Grow is 2 + + + Grow is 1 + + )) .addStory('Shrinking items', () => ( - - 1 - 2 (does not shrink) - 3 - 4 - 5 - 6 - 7 - + + 1 + + 2 (does not shrink) + + 3 + 4 + 5 + 6 + 7 + )) - .addStory('Wrap', () => ( - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - - ), { rtl: true }) + .addStory( + 'Wrap', + () => ( + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + + ), + { rtl: true } + ) .addStory('Wrap with specified vertical gap', () => ( - + 1 2 3 @@ -185,14 +197,14 @@ storiesOf('HorizontalStack', module) 28 29 30 - + )) .addStory('Box shadow around items', () => ( - + 1 2 3 4 5 - - )); \ No newline at end of file + + )); diff --git a/apps/vr-tests/src/stories/VerticalStack.stories.tsx b/apps/vr-tests/src/stories/VerticalStack.stories.tsx index b3b369d9ca5c4..c3c8a635e7b16 100644 --- a/apps/vr-tests/src/stories/VerticalStack.stories.tsx +++ b/apps/vr-tests/src/stories/VerticalStack.stories.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import Screener, { Steps } from 'screener-storybook/src/screener'; import { storiesOf } from '@storybook/react'; import { FabricDecoratorFullWidth } from '../utilities'; -import { VerticalStack } from '@uifabric/experiments/lib/Stack'; +import { Stack } from 'office-ui-fabric-react'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; const rootStyles = { @@ -52,79 +52,87 @@ const styles = mergeStyleSets({ const defaultProps = { className: styles.root, children: [ - 1, - 2, - 3 + + 1 + , + + 2 + , + + 3 + ] }; storiesOf('VerticalStack', module) .addDecorator(FabricDecoratorFullWidth) - .addDecorator(story => ( - {story()} - )) - .addStory('Default', () => ( - - ), { rtl: true }) - .addStory('Padding', () => ( - - )) - .addStory('Gap', () => ( - - )) - .addStory('Vertically centered', () => ( - - )) - .addStory('Bottom-aligned', () => ( - - )) - .addStory('Space around', () => ( - - )) - .addStory('Space between', () => ( - - )) - .addStory('Space evenly', () => ( - - )) - .addStory('Horizontally centered', () => ( - - )) - .addStory('Right-aligned', () => ( - - ), { rtl: true }) - .addStory('Item alignments', () => ( - - Auto-aligned item - Stretch-aligned item - Baseline-aligned item - Start-aligned item - Center-aligned item - End-aligned item - - ), { rtl: true }) + .addDecorator(story => {story()}) + .addStory('Default', () => , { rtl: true }) + .addStory('Padding', () => ) + .addStory('Gap', () => ) + .addStory('Vertically centered', () => ) + .addStory('Bottom-aligned', () => ) + .addStory('Space around', () => ) + .addStory('Space between', () => ) + .addStory('Space evenly', () => ) + .addStory('Horizontally centered', () => ) + .addStory('Right-aligned', () => , { rtl: true }) + .addStory( + 'Item alignments', + () => ( + + + Auto-aligned item + + + Stretch-aligned item + + + Baseline-aligned item + + + Start-aligned item + + + Center-aligned item + + + End-aligned item + + + ), + { rtl: true } + ) .addStory('Growing items', () => ( - - Grow is 3 - Grow is 2 - Grow is 1 - + + + Grow is 3 + + + Grow is 2 + + + Grow is 1 + + )) .addStory('Shrinking items', () => ( - - 1 - 2 (does not shrink) - 3 - 4 - 5 - + + 1 + + 2 (does not shrink) + + 3 + 4 + 5 + )) .addStory('Box shadow around items', () => ( - + 1 2 3 4 5 - - )); \ No newline at end of file + + )); diff --git a/common/changes/@uifabric/experiments/stackPromotion_2018-11-27-01-47.json b/common/changes/@uifabric/experiments/stackPromotion_2018-11-27-01-47.json new file mode 100644 index 0000000000000..b3ff6c507e34f --- /dev/null +++ b/common/changes/@uifabric/experiments/stackPromotion_2018-11-27-01-47.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@uifabric/experiments", + "comment": "Stack: Promoting from experiments to OUFR package.", + "type": "minor" + } + ], + "packageName": "@uifabric/experiments", + "email": "Humberto.Morimoto@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/fabric-website-resources/stackPromotion_2018-11-29-01-20.json b/common/changes/@uifabric/fabric-website-resources/stackPromotion_2018-11-29-01-20.json new file mode 100644 index 0000000000000..310aed3c6078d --- /dev/null +++ b/common/changes/@uifabric/fabric-website-resources/stackPromotion_2018-11-29-01-20.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@uifabric/fabric-website-resources", + "comment": "Stack: Promoting from experiments to OUFR package.", + "type": "minor" + } + ], + "packageName": "@uifabric/fabric-website-resources", + "email": "Humberto.Morimoto@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/office-ui-fabric-react/stackPromotion_2018-11-27-01-47.json b/common/changes/office-ui-fabric-react/stackPromotion_2018-11-27-01-47.json new file mode 100644 index 0000000000000..cc55a1feb229a --- /dev/null +++ b/common/changes/office-ui-fabric-react/stackPromotion_2018-11-27-01-47.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "Stack: Promoting from experiments to OUFR package.", + "type": "minor" + } + ], + "packageName": "office-ui-fabric-react", + "email": "Humberto.Morimoto@microsoft.com" +} diff --git a/packages/experiments/src/components/Button/Button.view.tsx b/packages/experiments/src/components/Button/Button.view.tsx index 501a637918e24..0da61110f2fbd 100644 --- a/packages/experiments/src/components/Button/Button.view.tsx +++ b/packages/experiments/src/components/Button/Button.view.tsx @@ -1,8 +1,7 @@ import * as React from 'react'; import { IButtonComponent, IButtonViewProps } from './Button.types'; import { Text } from '../../Text'; -import { HorizontalStack } from '../../Stack'; -import { Icon, IIconProps } from 'office-ui-fabric-react'; +import { Icon, IIconProps, Stack } from 'office-ui-fabric-react'; import { getNativeProps, buttonProperties } from '../../Utilities'; export const ButtonView: IButtonComponent['view'] = props => { @@ -30,7 +29,7 @@ export const ButtonView: IButtonComponent['view'] = props => { aria-disabled={disabled} className={classNames.root} > - + {IconProp && typeof IconProp === 'string' && } {IconProp && typeof IconProp === 'object' && @@ -48,11 +47,11 @@ export const ButtonView: IButtonComponent['view'] = props => { {text && {text}} {children} {Menu && ( - + - + )} - + {expanded && Menu && } ); diff --git a/packages/experiments/src/components/Button/examples/Button.Example.tsx b/packages/experiments/src/components/Button/examples/Button.Example.tsx index e4625802b0cb6..bdbe25bc289b1 100644 --- a/packages/experiments/src/components/Button/examples/Button.Example.tsx +++ b/packages/experiments/src/components/Button/examples/Button.Example.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Button } from '../index'; -import { HorizontalStack, Text, VerticalStack } from '@uifabric/experiments'; -import { ContextualMenu, IContextualMenuProps, Icon, CommandBar } from 'office-ui-fabric-react'; +import { Text } from '@uifabric/experiments'; +import { ContextualMenu, IContextualMenuProps, Icon, CommandBar, Stack } from 'office-ui-fabric-react'; const menuItems = [{ key: 'a', name: 'Item a' }, { key: 'b', name: 'Item b' }]; const buttonMenu = (props: IContextualMenuProps) => ; @@ -10,12 +10,16 @@ const sectionGap = 32; const headingGap = 16; const buttonGap = 12; -const ButtonStack = (props: { children: JSX.Element[] }) => {props.children}; +const ButtonStack = (props: { children: JSX.Element[] }) => ( + + {props.children} + +); const ButtonSet = () => ( - +
- +
-
+ ); export class ButtonExample extends React.Component<{}, {}> { public render(): JSX.Element { return ( - + - + ); } } diff --git a/packages/experiments/src/components/CollapsibleSection/examples/CollapsibleSection.Controlled.Example.tsx b/packages/experiments/src/components/CollapsibleSection/examples/CollapsibleSection.Controlled.Example.tsx index 7f20b3c07948f..5b0aa7d7843a2 100644 --- a/packages/experiments/src/components/CollapsibleSection/examples/CollapsibleSection.Controlled.Example.tsx +++ b/packages/experiments/src/components/CollapsibleSection/examples/CollapsibleSection.Controlled.Example.tsx @@ -1,8 +1,6 @@ import * as React from 'react'; -import { FocusZone } from 'office-ui-fabric-react/lib/FocusZone'; -import { DefaultButton } from 'office-ui-fabric-react/lib/Button'; +import { DefaultButton, FocusZone, Stack } from 'office-ui-fabric-react'; import { CollapsibleSection } from '@uifabric/experiments/lib/CollapsibleSection'; -import { HorizontalStack } from '@uifabric/experiments/lib/Stack'; export interface ICollapsibleSectionControlledExampleState { collapsed: boolean; @@ -28,7 +26,7 @@ export class CollapsibleSectionControlledExample extends React.Component<{}, ICo component's output when the controlled prop has a value passed in automatically. As a result, clicking on the titles in this example does not affect collapsed state, only clicking on the Toggle button does.

- + { @@ -36,7 +34,7 @@ export class CollapsibleSectionControlledExample extends React.Component<{}, ICo }} />

Number of title clicks: {this.state.clicks}

-
+ { - const { wrap, gap, verticalGap, fillHorizontal, fillVertical, maxWidth, maxHeight, className, theme } = props; - - const vertGap = verticalGap !== undefined ? verticalGap : gap; - - const hGap = parseGap(gap, theme); - const vGap = parseGap(vertGap, theme); - - const horizontalMargin = `${-0.5 * hGap.value}${hGap.unit}`; - const verticalMargin = `${-0.5 * vGap.value}${vGap.unit}`; - - const classNames = getGlobalClassNames(GlobalClassNames, theme); - - if (wrap) { - return { - root: [ - classNames.root, - theme.fonts.medium, - { - maxWidth, - maxHeight, - width: fillHorizontal ? '100%' : 'auto', - height: fillVertical ? '100%' : 'auto', - overflow: 'visible' - }, - className, - { - // not allowed to be overridden by className - // since this is necessary in order to prevent collapsing margins - display: 'inline-block' - } - ], - - inner: [ - classNames.inner, - { - flexWrap: 'wrap', - marginLeft: horizontalMargin, - marginRight: horizontalMargin, - marginTop: verticalMargin, - marginBottom: verticalMargin, - overflow: 'visible', - maxWidth: '100vw', - - // avoid unnecessary calc() calls if vertical gap is 0 - height: fillVertical ? (vGap.value === 0 ? '100%' : `calc(100% + ${vGap.value}${vGap.unit})`) : 'auto' - } - ] - } as IHorizontalStackStyles; - } - - return { - root: [classNames.root, className, theme.fonts.medium] - // TODO: this cast may be hiding some potential issues with styling and name - // lookups and should be removed - } as IHorizontalStackStyles; -}; diff --git a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.test.tsx b/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.test.tsx deleted file mode 100644 index 2a9e1249d6bf6..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.test.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import * as React from 'react'; -import { mount } from 'enzyme'; -import * as renderer from 'react-test-renderer'; -import { HorizontalStack } from '../index'; - -describe('HorizontalStack', () => { - it('can handle having no children', () => { - const createEmptyStack = () => { - mount(); - }; - - expect(createEmptyStack).not.toThrow(); - }); - - it('renders default HorizontalStack correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders gap correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders growing items correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders shrinking items correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders item alignments correctly', () => { - const component = renderer.create( - - Auto - Stretch - Baseline - Start - Center - End - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders wrapped HorizontalStack correctly', () => { - const component = renderer.create( - - 1 - 2 - 3 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); -}); diff --git a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.tsx b/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.tsx deleted file mode 100644 index b2e5c661924cd..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import * as React from 'react'; -import { createStatelessComponent } from '../../../Foundation'; -import { Stack } from '../Stack'; -import { StackItem } from '../StackItem/StackItem'; -import { IStackItemProps } from '../StackItem/StackItem.types'; -import { getVerticalAlignment, getHorizontalAlignment } from '../StackUtils'; -import { IHorizontalStackComponent, IHorizontalStackProps, IHorizontalStackStyles } from './HorizontalStack.types'; -import { styles } from './HorizontalStack.styles'; - -const view: IHorizontalStackComponent['view'] = props => { - const { horizontalAlign, verticalAlign, gap, verticalGap, classNames, children, styles: customStyles, ...rest } = props; - - const vertGap = verticalGap !== undefined ? verticalGap : gap; - - if (props.wrap) { - return ( -
- - {children} - -
- ); - } - - return ( - - {children} - - ); -}; - -const HorizontalStackStatics = { - Item: StackItem, - defaultProps: {} -}; -type IHorizontalStackStatics = typeof HorizontalStackStatics; - -export const HorizontalStack: React.StatelessComponent & { - Item: React.StatelessComponent; -} = createStatelessComponent({ - displayName: 'HorizontalStack', - styles, - view, - statics: HorizontalStackStatics -}); - -export default HorizontalStack; diff --git a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.types.ts b/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.types.ts deleted file mode 100644 index 0ae1d15c9b2af..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStack.types.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { IPartialStackProps } from '../Stack.types'; -import { IStatelessComponent, IStylesProp } from '../../../Foundation'; -import { IStyle } from '../../../Styling'; - -export type IHorizontalStackComponent = IStatelessComponent; - -export interface IHorizontalStackProps extends IPartialStackProps { - /** - * How to render the HorizontalStack. - */ - as?: string | React.ReactType; - - /** - * How to align child elements horizontally. - */ - horizontalAlign?: 'left' | 'right' | 'center' | 'space-around' | 'space-between' | 'space-evenly'; - - /** - * How to align child elements vertically. - */ - verticalAlign?: 'top' | 'bottom' | 'center' | 'baseline' | 'stretch'; - - /** - * Whether to allow child elements to wrap onto multiple rows. - */ - wrap?: boolean; - - /** - * Vertical space between children when children wrap onto multiple rows. - * Defaults to the value of the gap property. - */ - verticalGap?: number | string; - - /** - * Custom styles to apply to the HorizontalStack. - */ - styles?: IStylesProp; -} - -export interface IHorizontalStackStyles { - /** - * Style set for the root element. - */ - root: IStyle; - - /** - * Style set for the inner element (only when the wrap property is true). - */ - inner: IStyle; -} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStackPage.tsx b/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStackPage.tsx deleted file mode 100644 index 89d1c4a58f5ae..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/HorizontalStackPage.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import * as React from 'react'; -import { ExampleCard, IComponentDemoPageProps, ComponentPage, PropertiesTableSet } from '@uifabric/example-app-base'; - -import { HorizontalStackBasicExample } from './examples/HorizontalStack.Basic.Example'; -const HorizontalStackBasicExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Basic.Example.tsx') as string; - -import { HorizontalStackSpacingExample } from './examples/HorizontalStack.Spacing.Example'; -const HorizontalStackSpacingExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Spacing.Example.tsx') as string; - -import { HorizontalStackGrowExample } from './examples/HorizontalStack.Grow.Example'; -const HorizontalStackGrowExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Grow.Example.tsx') as string; - -import { HorizontalStackShrinkExample } from './examples/HorizontalStack.Shrink.Example'; -const HorizontalStackShrinkExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Shrink.Example.tsx') as string; - -import { HorizontalStackWrapExample } from './examples/HorizontalStack.Wrap.Example'; -const HorizontalStackWrapExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Wrap.Example.tsx') as string; - -import { HorizontalStackWrapAdvancedExample } from './examples/HorizontalStack.WrapAdvanced.Example'; -const HorizontalStackWrapAdvancedExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapAdvanced.Example.tsx') as string; - -import { HorizontalStackWrapNestedExample } from './examples/HorizontalStack.WrapNested.Example'; -const HorizontalStackWrapNestedExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapNested.Example.tsx') as string; - -import { HorizontalStackHorizontalAlignExample } from './examples/HorizontalStack.HorizontalAlign.Example'; -const HorizontalStackHorizontalAlignExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.HorizontalAlign.Example.tsx') as string; - -import { HorizontalStackVerticalAlignExample } from './examples/HorizontalStack.VerticalAlign.Example'; -const HorizontalStackVerticalAlignExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.VerticalAlign.Example.tsx') as string; - -import { HorizontalStackConfigureExample } from './examples/HorizontalStack.Configure.Example'; -const HorizontalStackConfigureExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Configure.Example.tsx') as string; - -export class HorizontalStackPage extends React.Component { - public render(): JSX.Element { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - propertiesTables={ - ('!raw-loader!@uifabric/experiments/src/components/Stack/HorizontalStack/HorizontalStack.types.ts'), - require('!raw-loader!@uifabric/experiments/src/components/Stack/Stack.types.ts'), - require('!raw-loader!@uifabric/experiments/src/components/Stack/StackItem/StackItem.types.ts') - ]} - /> - } - overview={
} - bestPractices={
} - dos={ -
-
    -
  • -
-
- } - donts={ -
-
    -
  • -
-
- } - isHeaderVisible={this.props.isHeaderVisible} - /> - ); - } -} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/__snapshots__/HorizontalStack.test.tsx.snap b/packages/experiments/src/components/Stack/HorizontalStack/__snapshots__/HorizontalStack.test.tsx.snap deleted file mode 100644 index e8aa7bd085582..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/__snapshots__/HorizontalStack.test.tsx.snap +++ /dev/null @@ -1,437 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`HorizontalStack renders default HorizontalStack correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-left: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`HorizontalStack renders gap correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-left: 5px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`HorizontalStack renders growing items correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-left: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Item 1 - - - Item 2 - -
-`; - -exports[`HorizontalStack renders item alignments correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-left: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Auto - - - Stretch - - - Baseline - - - Start - - - Center - - - End - -
-`; - -exports[`HorizontalStack renders shrinking items correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-left: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 1; - } -> - - Item 1 - - - Item 2 - -
-`; - -exports[`HorizontalStack renders wrapped HorizontalStack correctly 1`] = ` -
-
* { - margin-bottom: 0px; - margin-left: 0px; - margin-right: 0px; - margin-top: 0px; - max-width: 100%; - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } - > - - 1 - - - 2 - - - 3 - -
-
-`; diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Basic.Example.tsx b/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Basic.Example.tsx deleted file mode 100644 index 1b383ff63e22f..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Basic.Example.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class HorizontalStackBasicExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary - }, - - item: { - color: DefaultPalette.white, - background: DefaultPalette.themePrimary, - padding: 5 - } - }); - - return ( - - Default horizontal stack - - Item One - Item Two - Item Three - - - Horizontal gap between items - - Item One - Item Two - Item Three - - - Item alignments - - - Auto-aligned item - - - Stretch-aligned item - - - Baseline-aligned item - - - Start-aligned item - - - Center-aligned item - - - End-aligned item - - - - Clickable stack - - Click inside this box - - - ); - } - - private _onClick = (): void => { - alert('Clicked HorizontalStack'); - }; -} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.HorizontalAlign.Example.tsx b/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.HorizontalAlign.Example.tsx deleted file mode 100644 index 883a90a6bf83d..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.HorizontalAlign.Example.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class HorizontalStackHorizontalAlignExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary, - selectors: { - '> *': { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - } - } - }); - - return ( - - Left-aligned - - 1 - 2 - 3 - - - Horizontally centered - - 1 - 2 - 3 - - - Right-aligned - - 1 - 2 - 3 - - - Horizontal space around items - - 1 - 2 - 3 - - - Horizontal space between items - - 1 - 2 - 3 - - - Items horizontally evenly spaced - - 1 - 2 - 3 - - - ); - } -} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Spacing.Example.tsx b/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Spacing.Example.tsx deleted file mode 100644 index 1b7c7b4e36866..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Spacing.Example.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class HorizontalStackSpacingExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary, - width: 300, - selectors: { - '> *': { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - } - }, - - item: { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - }); - - return ( - - - - Numerical spacing - - 1 - 2 - 3 - - - - Custom spacing - - 1 - 2 - 3 - - - - - - - Themed spacing (extra small) - - 1 - 2 - 3 - - - - Themed spacing (small) - - 1 - 2 - 3 - - - - Themed spacing (medium) - - 1 - 2 - 3 - - - - - - - Themed spacing (large) - - 1 - 2 - 3 - - - - Themed spacing (extra large) - - 1 - 2 - 3 - - - - - ); - } -} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.VerticalAlign.Example.tsx b/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.VerticalAlign.Example.tsx deleted file mode 100644 index 937d87e075650..0000000000000 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.VerticalAlign.Example.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class HorizontalStackVerticalAlignExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary, - height: 100, - selectors: { - '> *': { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - } - } - }); - - return ( - - Top-aligned - - 1 - 2 - 3 - - - Vertically centered - - 1 - 2 - 3 - - - Bottom-aligned - - 1 - 2 - 3 - - - ); - } -} diff --git a/packages/experiments/src/components/Stack/Stack.styles.ts b/packages/experiments/src/components/Stack/Stack.styles.ts deleted file mode 100644 index e3b3b6d241bfb..0000000000000 --- a/packages/experiments/src/components/Stack/Stack.styles.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { IStackComponent, IStackStyles } from './Stack.types'; -import { parseGap, parsePadding } from './StackUtils'; - -const nameMap: { [key: string]: string } = { - start: 'flex-start', - end: 'flex-end' -}; - -export const styles: IStackComponent['styles'] = props => { - const { - fillHorizontal, - fillVertical, - maxWidth, - maxHeight, - horizontal, - grow, - wrap, - padding, - horizontalAlignment, - verticalAlignment, - horizontalGap, - verticalGap, - shrinkItems, - theme, - className - } = props; - - const hGap = parseGap(horizontalGap, theme); - const vGap = parseGap(verticalGap, theme); - - // styles to be applied to all direct children regardless of wrap or direction - const childStyles = { - whiteSpace: 'nowrap', - textOverflow: 'ellipsis' - }; - - // selectors to be applied regardless of wrap or direction - const commonSelectors = { - // flexShrink styles are applied by the StackItem - '> *:not(.ms-StackItem)': { - flexShrink: shrinkItems ? 1 : 0 - } - }; - - return { - root: [ - theme.fonts.medium, - { - display: 'flex', - flexDirection: horizontal ? 'row' : 'column', - flexWrap: 'nowrap', - width: fillHorizontal && !wrap ? '100%' : 'auto', - height: fillVertical && !wrap ? '100%' : 'auto', - maxWidth, - maxHeight, - padding: parsePadding(padding, theme), - boxSizing: 'border-box' - }, - grow && { - flexGrow: grow === true ? 1 : grow, - overflow: 'hidden' - }, - horizontalAlignment && { - [horizontal ? 'justifyContent' : 'alignItems']: nameMap[horizontalAlignment] || horizontalAlignment - }, - verticalAlignment && { - [horizontal ? 'alignItems' : 'justifyContent']: nameMap[verticalAlignment] || verticalAlignment - }, - wrap && { - selectors: { - '> *': { - margin: `${0.5 * vGap.value}${vGap.unit} ${0.5 * hGap.value}${hGap.unit}`, - - // avoid unnecessary calc() calls if horizontal gap is 0 - maxWidth: hGap.value === 0 ? '100%' : `calc(100% - ${hGap.value}${hGap.unit})`, - - ...childStyles - }, - ...commonSelectors - } - }, - !wrap && { - selectors: { - '> *': childStyles, - - // apply gap margin to every direct child except the first direct child - '> *:not(:first-child)': [ - horizontal && { - marginLeft: `${hGap.value}${hGap.unit}` - }, - !horizontal && { - marginTop: `${vGap.value}${vGap.unit}` - } - ], - ...commonSelectors - } - }, - className - ] - // TODO: this cast may be hiding some potential issues with styling and name - // lookups and should be removed - } as IStackStyles; -}; diff --git a/packages/experiments/src/components/Stack/Stack.test.tsx b/packages/experiments/src/components/Stack/Stack.test.tsx deleted file mode 100644 index 6d28c6bd817d5..0000000000000 --- a/packages/experiments/src/components/Stack/Stack.test.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import * as React from 'react'; -import * as renderer from 'react-test-renderer'; -import { mergeStyles } from 'office-ui-fabric-react'; - -import { Stack } from './Stack'; - -const sampleClass = mergeStyles({ - background: 'red' -}); - -describe('Stack', () => { - it('renders vertical Stack correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders horizontal Stack correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders Stack with vertical and horizontal alignment correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders Stack with vertical and horizontal fill correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders Stack with grow correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - Item 3 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders Stack with StackItems correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders Stack with a gap correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders Stack with shrinking StackItems correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('accepts custom className on child items', () => { - const component = renderer.create( - - Item 1 -
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); -}); diff --git a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.styles.ts b/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.styles.ts deleted file mode 100644 index 71d3a808af197..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.styles.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { getGlobalClassNames } from '../../../Styling'; -import { IVerticalStackComponent, IVerticalStackStyles } from './VerticalStack.types'; - -const GlobalClassNames = { - root: 'ms-VerticalStack' -}; - -export const styles: IVerticalStackComponent['styles'] = props => { - const { className, theme } = props; - const classNames = getGlobalClassNames(GlobalClassNames, theme); - - return { - root: [classNames.root, className, theme.fonts.medium] - // TODO: this cast may be hiding some potential issues with styling and name - // lookups and should be removed - } as IVerticalStackStyles; -}; diff --git a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.test.tsx b/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.test.tsx deleted file mode 100644 index 2a37ebda112fa..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.test.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import * as React from 'react'; -import { mount } from 'enzyme'; -import * as renderer from 'react-test-renderer'; -import { VerticalStack } from '../index'; - -describe('VerticalStack', () => { - it('can handle having no children', () => { - const createEmptyStack = () => { - mount(); - }; - - expect(createEmptyStack).not.toThrow(); - }); - - it('renders default VerticalStack correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders gap correctly', () => { - const component = renderer.create( - -
Item 1
-
Item 2
-
- ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders growing items correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders shrinking items correctly', () => { - const component = renderer.create( - - Item 1 - Item 2 - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); - - it('renders item alignments correctly', () => { - const component = renderer.create( - - Auto - Stretch - Baseline - Start - Center - End - - ); - const tree = component.toJSON(); - expect(tree).toMatchSnapshot(); - }); -}); diff --git a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.tsx b/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.tsx deleted file mode 100644 index 99cb47bf5668e..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import * as React from 'react'; -import { createStatelessComponent } from '../../../Foundation'; -import { Stack } from '../Stack'; -import { StackItem } from '../StackItem/StackItem'; -import { IStackItemProps } from '../StackItem/StackItem.types'; -import { getVerticalAlignment, getHorizontalAlignment } from '../StackUtils'; -import { IVerticalStackComponent, IVerticalStackProps, IVerticalStackStyles } from './VerticalStack.types'; -import { styles } from './VerticalStack.styles'; - -const view: IVerticalStackComponent['view'] = props => { - const { verticalAlign, horizontalAlign, gap, classNames, children, styles: customStyles, ...rest } = props; - - return ( - - {children} - - ); -}; - -const VerticalStackStatics = { - Item: StackItem, - defaultProps: {} -}; -type IVerticalStackStatics = typeof VerticalStackStatics; - -export const VerticalStack: React.StatelessComponent & { - Item: React.StatelessComponent; -} = createStatelessComponent({ - displayName: 'VerticalStack', - styles, - view, - statics: VerticalStackStatics -}); - -export default VerticalStack; diff --git a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.types.ts b/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.types.ts deleted file mode 100644 index da817935cd421..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/VerticalStack.types.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { IPartialStackProps } from '../Stack.types'; -import { IStatelessComponent, IStylesProp } from '../../../Foundation'; -import { IStyle } from '../../../Styling'; - -export type IVerticalStackComponent = IStatelessComponent; - -export interface IVerticalStackProps extends IPartialStackProps { - /** - * How to render the VerticalStack. - */ - as?: string | React.ReactType; - - /** - * How to align child elements vertically. - */ - verticalAlign?: 'top' | 'bottom' | 'center' | 'space-around' | 'space-between' | 'space-evenly'; - - /** - * How to align child elements horizontally. - */ - horizontalAlign?: 'left' | 'right' | 'center' | 'baseline' | 'stretch'; - - /** - * Custom styles to apply to the VerticalStack. - */ - styles?: IStylesProp; -} - -export interface IVerticalStackStyles { - /** - * Style set for the root element. - */ - root: IStyle; -} diff --git a/packages/experiments/src/components/Stack/VerticalStack/VerticalStackPage.tsx b/packages/experiments/src/components/Stack/VerticalStack/VerticalStackPage.tsx deleted file mode 100644 index 279dbde64e75b..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/VerticalStackPage.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import * as React from 'react'; -import { ExampleCard, IComponentDemoPageProps, ComponentPage, PropertiesTableSet } from '@uifabric/example-app-base'; - -import { VerticalStackBasicExample } from './examples/VerticalStack.Basic.Example'; -const VerticalStackBasicExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Basic.Example.tsx') as string; - -import { VerticalStackSpacingExample } from './examples/VerticalStack.Spacing.Example'; -const VerticalStackSpacingExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Spacing.Example.tsx') as string; - -import { VerticalStackGrowExample } from './examples/VerticalStack.Grow.Example'; -const VerticalStackGrowExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Grow.Example.tsx') as string; - -import { VerticalStackShrinkExample } from './examples/VerticalStack.Shrink.Example'; -const VerticalStackShrinkExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Shrink.Example.tsx') as string; - -import { VerticalStackVerticalAlignExample } from './examples/VerticalStack.VerticalAlign.Example'; -const VerticalStackVerticalAlignExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.VerticalAlign.Example.tsx') as string; - -import { VerticalStackHorizontalAlignExample } from './examples/VerticalStack.HorizontalAlign.Example'; -const VerticalStackHorizontalAlignExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.HorizontalAlign.Example.tsx') as string; - -import { VerticalStackConfigureExample } from './examples/VerticalStack.Configure.Example'; -const VerticalStackConfigureExampleCode = require('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Configure.Example.tsx') as string; - -export class VerticalStackPage extends React.Component { - public render(): JSX.Element { - return ( - - - - - - - - - - - - - - - - - - - - - - -
- } - propertiesTables={ - ('!raw-loader!@uifabric/experiments/src/components/Stack/VerticalStack/VerticalStack.types.ts'), - require('!raw-loader!@uifabric/experiments/src/components/Stack/Stack.types.ts'), - require('!raw-loader!@uifabric/experiments/src/components/Stack/StackItem/StackItem.types.ts') - ]} - /> - } - overview={
} - bestPractices={
} - dos={ -
-
    -
  • -
-
- } - donts={ -
-
    -
  • -
-
- } - isHeaderVisible={this.props.isHeaderVisible} - /> - ); - } -} diff --git a/packages/experiments/src/components/Stack/VerticalStack/__snapshots__/VerticalStack.test.tsx.snap b/packages/experiments/src/components/Stack/VerticalStack/__snapshots__/VerticalStack.test.tsx.snap deleted file mode 100644 index 56fe338617baa..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/__snapshots__/VerticalStack.test.tsx.snap +++ /dev/null @@ -1,334 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`VerticalStack renders default VerticalStack correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`VerticalStack renders gap correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 5px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`VerticalStack renders growing items correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Item 1 - - - Item 2 - -
-`; - -exports[`VerticalStack renders item alignments correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Auto - - - Stretch - - - Baseline - - - Start - - - Center - - - End - -
-`; - -exports[`VerticalStack renders shrinking items correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 1; - } -> - - Item 1 - - - Item 2 - -
-`; diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Basic.Example.tsx b/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Basic.Example.tsx deleted file mode 100644 index d9a6361b85412..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Basic.Example.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import * as React from 'react'; -import { VerticalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class VerticalStackBasicExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary - }, - - item: { - color: DefaultPalette.white, - background: DefaultPalette.themePrimary, - padding: 5 - } - }); - - return ( - - Default vertical stack - - Item One - Item Two - Item Three - - - Vertical gap between items - - Item One - Item Two - Item Three - - - Item alignments - - - Auto-aligned item - - - Stretch-aligned item - - - Baseline-aligned item - - - Start-aligned item - - - Center-aligned item - - - End-aligned item - - - - Clickable stack - - Click inside this box - - - ); - } - - private _onClick = (): void => { - alert('Clicked VerticalStack'); - }; -} diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.HorizontalAlign.Example.tsx b/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.HorizontalAlign.Example.tsx deleted file mode 100644 index 322881117fae1..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.HorizontalAlign.Example.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import * as React from 'react'; -import { VerticalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class VerticalStackHorizontalAlignExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary, - selectors: { - '> *': { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - } - } - }); - - return ( - - Left-aligned - - 1 - 2 - - - Horizontally centered - - 1 - 2 - - - Right-aligned - - 1 - 2 - - - ); - } -} diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Spacing.Example.tsx b/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Spacing.Example.tsx deleted file mode 100644 index 4fe4cb92b0d31..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Spacing.Example.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class VerticalStackSpacingExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary - }, - - item: { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - }); - - return ( - - - - Numerical spacing - - 1 - 2 - 3 - - - - - Custom spacing - - 1 - 2 - 3 - - - - - - - Themed spacing (extra small) - - 1 - 2 - 3 - - - - - Themed spacing (small) - - 1 - 2 - 3 - - - - - Themed spacing (medium) - - 1 - 2 - 3 - - - - - Themed spacing (large) - - 1 - 2 - 3 - - - - - Themed spacing (extra large) - - 1 - 2 - 3 - - - - - ); - } -} diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.VerticalAlign.Example.tsx b/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.VerticalAlign.Example.tsx deleted file mode 100644 index ef6036e922f78..0000000000000 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.VerticalAlign.Example.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; - -export class VerticalStackVerticalAlignExample extends React.Component<{}, {}> { - public render(): JSX.Element { - const styles = mergeStyleSets({ - root: { - background: DefaultPalette.themeTertiary, - height: 250, - selectors: { - '> *': { - width: 50, - height: 50, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - background: DefaultPalette.themePrimary, - color: DefaultPalette.white - } - } - } - }); - - return ( - - - - Top-aligned - - 1 - 2 - 3 - - - - - Vertically centered - - 1 - 2 - 3 - - - - - Bottom-aligned - - 1 - 2 - 3 - - - - - - - Vertical space around items - - 1 - 2 - 3 - - - - - Vertical space between items - - 1 - 2 - 3 - - - - - Items vertically evenly spaced - - 1 - 2 - 3 - - - - - ); - } -} diff --git a/packages/experiments/src/components/Stack/__snapshots__/Stack.test.tsx.snap b/packages/experiments/src/components/Stack/__snapshots__/Stack.test.tsx.snap deleted file mode 100644 index a3fb5f5e6824d..0000000000000 --- a/packages/experiments/src/components/Stack/__snapshots__/Stack.test.tsx.snap +++ /dev/null @@ -1,521 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Stack accepts custom className on child items 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Item 1 - -
- Item 2 -
-
-`; - -exports[`Stack renders Stack with StackItems correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Item 1 - - - Item 2 - -
-`; - -exports[`Stack renders Stack with a gap correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> - - Item 1 - - - Item 2 - -
-`; - -exports[`Stack renders Stack with grow correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } - > - Item 1 -
-
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } - > - Item 2 -
-
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } - > - Item 3 -
-
-`; - -exports[`Stack renders Stack with shrinking StackItems correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 1; - } -> - - Item 1 - - - Item 2 - -
-`; - -exports[`Stack renders Stack with vertical and horizontal alignment correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`Stack renders Stack with vertical and horizontal fill correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`Stack renders horizontal Stack correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-left: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; - -exports[`Stack renders vertical Stack correctly 1`] = ` -
* { - text-overflow: ellipsis; - white-space: nowrap; - } - & > *:not(:first-child) { - margin-top: 0px; - } - & > *:not(.ms-StackItem) { - flex-shrink: 0; - } -> -
- Item 1 -
-
- Item 2 -
-
-`; diff --git a/packages/experiments/src/components/Stack/index.ts b/packages/experiments/src/components/Stack/index.ts deleted file mode 100644 index bdf42aaabb67d..0000000000000 --- a/packages/experiments/src/components/Stack/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './StackItem/StackItem'; -export * from './VerticalStack/VerticalStack'; -export * from './VerticalStack/VerticalStack.types'; -export * from './HorizontalStack/HorizontalStack'; -export * from './HorizontalStack/HorizontalStack.types'; diff --git a/packages/experiments/src/components/Text/examples/Text.Ramp.Example.tsx b/packages/experiments/src/components/Text/examples/Text.Ramp.Example.tsx index e471d859b99df..ddfe354404085 100644 --- a/packages/experiments/src/components/Text/examples/Text.Ramp.Example.tsx +++ b/packages/experiments/src/components/Text/examples/Text.Ramp.Example.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; -import { Text, VerticalStack } from '@uifabric/experiments'; +import { Stack } from 'office-ui-fabric-react'; +import { Text } from '@uifabric/experiments'; import { IFontVariants, IFontSizes, IFontWeights, IFontFamilies, IStyle } from '@uifabric/experiments/lib/Styling'; import { ISemanticTextColors, IPalette } from '@uifabric/experiments/lib/Styling'; import { createStatelessComponent, IStyleableComponentProps, IStatelessComponent } from '@uifabric/experiments/lib/Foundation'; @@ -70,7 +71,7 @@ interface ITableProps extends IStyleableComponentProps; const TableView: ITableComponent['view'] = props => ( - + {props.title} @@ -84,7 +85,7 @@ const TableView: ITableComponent['view'] = props => ( {props.children}
-
+ ); const Table = createStatelessComponent({ @@ -115,7 +116,7 @@ const TableRow: React.StatelessComponent = (props: ITableRowProp ); export const TextRampExample = () => ( - + Default text should render using the "default" variant. @@ -191,5 +192,5 @@ export const TextRampExample = () => ( /> ))}
-
+ ); diff --git a/packages/experiments/src/demo/AppDefinition.tsx b/packages/experiments/src/demo/AppDefinition.tsx index 587d1c80c5df6..d872f4772c778 100644 --- a/packages/experiments/src/demo/AppDefinition.tsx +++ b/packages/experiments/src/demo/AppDefinition.tsx @@ -52,12 +52,6 @@ export const AppDefinition: IAppDefinition = { name: 'FileTypeIcon', url: '#/examples/filetypeicon' }, - { - component: require('../components/Stack/HorizontalStack/HorizontalStackPage').HorizontalStackPage, - key: 'HorizontalStack', - name: 'HorizontalStack', - url: '#/examples/horizontalstack' - }, { component: require('../components/LayoutGroup/LayoutGroupPage').LayoutGroupPage, key: 'LayoutGroup', @@ -118,12 +112,6 @@ export const AppDefinition: IAppDefinition = { name: 'Shimmer', url: '#/examples/shimmer' }, - { - component: require('../components/Stack/VerticalStack/VerticalStackPage').VerticalStackPage, - key: 'VerticalStack', - name: 'VerticalStack', - url: '#/examples/verticalstack' - }, { component: require('../components/VirtualizedList/VirtualizedListPage').VirtualizedListPage, key: 'VirtualizedList', diff --git a/packages/experiments/src/index.ts b/packages/experiments/src/index.ts index 232412250d646..0877b7f7d516b 100644 --- a/packages/experiments/src/index.ts +++ b/packages/experiments/src/index.ts @@ -7,7 +7,6 @@ export * from './LayoutGroup'; export * from './Shimmer'; export * from './Sidebar'; export * from './Signals'; -export * from './Stack'; export * from './StaticList'; export * from './Text'; export * from './Tile'; diff --git a/packages/experiments/src/theming/examples/Themes.tsx b/packages/experiments/src/theming/examples/Themes.tsx index 734434efa2bdd..f2f5e56c37705 100644 --- a/packages/experiments/src/theming/examples/Themes.tsx +++ b/packages/experiments/src/theming/examples/Themes.tsx @@ -1,9 +1,9 @@ import { getNeutralVariant, getSoftVariant, getStrongVariant } from '@uifabric/variants'; -import { IHorizontalStackComponent } from '@uifabric/experiments/lib/Stack'; +import { IStackComponent } from 'office-ui-fabric-react'; import { createTheme, IPalette, ITheme, getTheme } from 'office-ui-fabric-react/lib/Styling'; -export const regionStyles: IHorizontalStackComponent['styles'] = props => ({ +export const regionStyles: IStackComponent['styles'] = props => ({ root: { backgroundColor: props.theme.semanticColors.bodyBackground, color: props.theme.semanticColors.bodyText diff --git a/packages/experiments/src/theming/examples/Theming.Schemes.Example.tsx b/packages/experiments/src/theming/examples/Theming.Schemes.Example.tsx index 6eb142ded4889..59480d1aac843 100644 --- a/packages/experiments/src/theming/examples/Theming.Schemes.Example.tsx +++ b/packages/experiments/src/theming/examples/Theming.Schemes.Example.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; -import { CommandBar, Customizer, Toggle } from 'office-ui-fabric-react'; +import { CommandBar, Customizer, Stack, Toggle } from 'office-ui-fabric-react'; import { farItems, items, overflowItems } from 'office-ui-fabric-react/lib/components/CommandBar/examples/data'; -import { HorizontalStack, Text, VerticalStack } from '@uifabric/experiments'; +import { Text } from '@uifabric/experiments'; // tslint:disable:max-line-length import { CollapsibleSectionRecursiveExample } from '@uifabric/experiments/lib/components/CollapsibleSection/examples/CollapsibleSection.Recursive.Example'; @@ -42,54 +42,54 @@ export class ThemingExample extends React.Component<{}, IThemingExampleState> { // TODO: Even though this styles function is the same for all regions, it has to be provided whenever the scheme // is changed to apply the new semanticColors. Is this the best way we can do this? return ( - - + + - + {sideCaption} - + - - - + + + - - + + {topCaption} - + - + - - + + {bodyCaption} - + - + - + - + - + - + - + - + - - - + + + ); } diff --git a/packages/office-ui-fabric-react/etc/office-ui-fabric-react.api.ts b/packages/office-ui-fabric-react/etc/office-ui-fabric-react.api.ts index c6a87fc3ae3aa..6f9095878d777 100644 --- a/packages/office-ui-fabric-react/etc/office-ui-fabric-react.api.ts +++ b/packages/office-ui-fabric-react/etc/office-ui-fabric-react.api.ts @@ -10365,6 +10365,33 @@ interface ISpinnerStyles { // @public (undocumented) export function isRelativeUrl(url: string): boolean; +// @public (undocumented) +interface IStackProps extends IStyleableComponentProps, React.HTMLAttributes { + as?: string | React.ReactType; + className?: string; + fillHorizontal?: boolean; + fillVertical?: boolean; + gap?: number | string; + grow?: boolean | number | 'inherit' | 'initial' | 'unset'; + horizontal?: boolean; + horizontalAlignment?: Alignment; + maxHeight?: number | string; + maxWidth?: number | string; + padding?: number | string; + shrinkItems?: boolean; + style?: React.CSSProperties; + styles?: IStylesProp; + verticalAlignment?: 'top' | 'bottom' | Alignment; + verticalGap?: number | string; + wrap?: boolean; +} + +// @public (undocumented) +interface IStackStyles { + inner: IStyle; + root: IStyle; +} + // @public (undocumented) interface IStickyContext { // (undocumented) @@ -12620,6 +12647,10 @@ module ZIndexes { // WARNING: Unsupported export: ISliderStyleProps // WARNING: Unsupported export: Spinner // WARNING: Unsupported export: SpinnerLabelPosition +// WARNING: Unsupported export: StackItem +// WARNING: Unsupported export: Stack +// WARNING: Unsupported export: Alignment +// WARNING: Unsupported export: IStackComponent // WARNING: Unsupported export: AnimationClassNames // WARNING: Unsupported export: FontClassNames // WARNING: Unsupported export: ColorClassNames diff --git a/packages/office-ui-fabric-react/package.json b/packages/office-ui-fabric-react/package.json index 91b9b701baf67..74c40131f78c1 100644 --- a/packages/office-ui-fabric-react/package.json +++ b/packages/office-ui-fabric-react/package.json @@ -62,6 +62,7 @@ }, "dependencies": { "@microsoft/load-themed-styles": "^1.7.13", + "@uifabric/foundation": ">=0.5.7 <1.0.0", "@uifabric/icons": ">=6.3.0 <7.0.0", "@uifabric/merge-styles": ">=6.15.0 <7.0.0", "@uifabric/set-version": ">=1.1.3 <2.0.0", diff --git a/packages/office-ui-fabric-react/src/Foundation.ts b/packages/office-ui-fabric-react/src/Foundation.ts new file mode 100644 index 0000000000000..ecf9a04a5503a --- /dev/null +++ b/packages/office-ui-fabric-react/src/Foundation.ts @@ -0,0 +1,147 @@ +import { + createComponent as foundationCreateComponent, + createStatelessComponent as foundationCreateStatelessComponent, + IComponent, + IStateComponentType, + IStatelessComponent, + IStyleableComponentProps, + IStylesFunction, + IStylesProp, + IComponentProviders, + IThemeProviderProps, + IThemeProviders, + IViewComponent, + themeProvider +} from '@uifabric/foundation'; +export { IStateComponentProps } from '@uifabric/foundation'; +import { getThemedContext, IProcessedStyleSet, ISchemeNames, IStyleSet, ITheme, mergeStyleSets } from './Styling'; +import { Customizations, Customizer, CustomizerContext, ICustomizerContext, ICustomizerProps } from './Utilities'; + +// This module centralizes Foundation interaction for use throughout this package. These convenience types automatically +// inject types that are global for all of OUFR, such as ITheme and IProcessedStyleSet. + +/** + * Helper extension for declaring common props for styleable components. + * If these props are present, they will automatically be used by Foundation when applying theming and styling. + */ +export type IStyleableComponentProps = IStyleableComponentProps; + +/** + * Styles functions that take in view props and foundation supplied properties for processing. + * This type should rarely need to be used directly. In most cases using IComponent and lookup types should suffice. + */ +export type IStylesFunction = IStylesFunction; + +/** + * Styles can be a function or an object taking in TViewProps for processing. + * This type should rarely need to be used directly. In most cases using IComponent and lookup types should suffice. + */ +export type IStylesProp = IStylesProp; + +/** + * Enforce props contract on state components, including the view prop and its shape. + * Required properties for state components. + */ +export type IStateComponentType> = IStateComponentType< + TComponentProps, + TViewProps +>; + +/** + * A helper type for defining view components, including its properties. + * This type should rarely need to be used directly. In most cases using IComponent and lookup types should suffice. + */ +export type IViewComponent> = IViewComponent>; + +/** + * Primary type for defining stateful components. + */ +export type IComponent, TStatics = {}> = IComponent< + TComponentProps, + TViewProps, + TStyleSet, + IProcessedStyleSet, + ITheme, + TStatics +>; + +/** + * Primary type for defining stateless components. + */ +export type IStatelessComponent, TStatics = {}> = IStatelessComponent< + TComponentProps, + TStyleSet, + IProcessedStyleSet, + ITheme, + TStatics +>; + +// tslint:disable-next-line:no-any +const providers: IComponentProviders = { + mergeStyleSets, + getCustomizations, + CustomizerContext +}; + +const themeProviders: IThemeProviders = { + getThemedContext, + CustomizerComponent: Customizer +}; + +/** + * A helper for Foundation's createComponent that automatically passes in constant types. + * See Foundation's createComponent for more detail. + * @param {IComponent} component + */ +export function createStatelessComponent, TStatics = {}>( + component: IStatelessComponent, ITheme, TStatics> +): React.StatelessComponent & TStatics { + return foundationCreateStatelessComponent< + TComponentProps, + TStyleSet, + IProcessedStyleSet, + ICustomizerContext, + ITheme, + ISchemeNames, + TStatics + >(component, providers); +} + +/** + * A helper for Foundation's createComponent that automatically passes in constant types. + * See Foundation's createComponent for more detail. + * @param {IComponent} component + * @param {IStateComponent} state + */ +export function createComponent, TStatics = {}>( + component: IComponent, ITheme, TStatics> +): React.StatelessComponent & TStatics { + return foundationCreateComponent< + TComponentProps, + TViewProps, + TStyleSet, + IProcessedStyleSet, + ICustomizerContext, + ITheme, + ISchemeNames, + TStatics + >(component, providers); +} + +export const ThemeProvider: React.StatelessComponent> = themeProvider< + ICustomizerContext, + ITheme, + ISchemeNames, + ICustomizerProps +>(themeProviders); + +function getCustomizations( + displayName: string, + context: ICustomizerContext, + fields?: string[] +): IStyleableComponentProps { + // TODO: do we want field props? should fields be part of IComponent and used here? + // TODO: should we centrally define DefaultFields? (not exported from styling) + const DefaultFields = ['theme', 'styles', 'styleVariables']; + return Customizations.getSettings(fields || DefaultFields, displayName, context.customizations); +} diff --git a/packages/experiments/src/Stack.ts b/packages/office-ui-fabric-react/src/Stack.ts similarity index 100% rename from packages/experiments/src/Stack.ts rename to packages/office-ui-fabric-react/src/Stack.ts diff --git a/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx b/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx index 3710dc3388847..fa81a1606a0be 100644 --- a/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx +++ b/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx @@ -70,6 +70,9 @@ const requiredProps: { [key: string]: any } = { onRenderItem: () =>
, selectedItems: ['TestItem'] }, + StackItem: { + children: ['TestChild'] + }, Suggestions: { suggestions: [] }, diff --git a/packages/office-ui-fabric-react/src/components/Stack/Stack.checklist.ts b/packages/office-ui-fabric-react/src/components/Stack/Stack.checklist.ts new file mode 100644 index 0000000000000..f2f06b6fd185b --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/Stack.checklist.ts @@ -0,0 +1,9 @@ +import { ChecklistStatus } from '../../common/DocPage.types'; + +export const StackStatus = { + keyboardAccessibilitySupport: ChecklistStatus.unknown, + markupSupport: ChecklistStatus.unknown, + highContrastSupport: ChecklistStatus.unknown, + rtlSupport: ChecklistStatus.unknown, + testCoverage: ChecklistStatus.good +}; diff --git a/packages/office-ui-fabric-react/src/components/Stack/Stack.doc.tsx b/packages/office-ui-fabric-react/src/components/Stack/Stack.doc.tsx new file mode 100644 index 0000000000000..8946033fcc8f4 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/Stack.doc.tsx @@ -0,0 +1,224 @@ +import * as React from 'react'; +import { IDocPageProps } from '../../common/DocPage.types'; +import { StackStatus } from './Stack.checklist'; + +// Vertical stack examples +import { VerticalStackBasicExample } from './examples/Stack.Vertical.Basic.Example'; +const VerticalStackBasicExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Basic.Example.tsx') as string; +const VerticalStackBasicExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.Basic.Example.Codepen.txt') as string; + +import { VerticalStackSpacingExample } from './examples/Stack.Vertical.Spacing.Example'; +const VerticalStackSpacingExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Spacing.Example.tsx') as string; +const VerticalStackSpacingExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.Spacing.Example.Codepen.txt') as string; + +import { VerticalStackGrowExample } from './examples/Stack.Vertical.Grow.Example'; +const VerticalStackGrowExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Grow.Example.tsx') as string; +const VerticalStackGrowExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.Grow.Example.Codepen.txt') as string; + +import { VerticalStackShrinkExample } from './examples/Stack.Vertical.Shrink.Example'; +const VerticalStackShrinkExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Shrink.Example.tsx') as string; +const VerticalStackShrinkExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.Shrink.Example.Codepen.txt') as string; + +import { VerticalStackWrapExample } from './examples/Stack.Vertical.Wrap.Example'; +const VerticalStackWrapExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Wrap.Example.tsx') as string; +const VerticalStackWrapExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.Wrap.Example.Codepen.txt') as string; + +import { VerticalStackWrapAdvancedExample } from './examples/Stack.Vertical.WrapAdvanced.Example'; +const VerticalStackWrapAdvancedExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapAdvanced.Example.tsx') as string; +const VerticalStackWrapAdvancedExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.WrapAdvanced.Example.Codepen.txt') as string; + +import { VerticalStackWrapNestedExample } from './examples/Stack.Vertical.WrapNested.Example'; +const VerticalStackWrapNestedExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapNested.Example.tsx') as string; +const VerticalStackWrapNestedExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.WrapNested.Example.Codepen.txt') as string; + +import { VerticalStackVerticalAlignExample } from './examples/Stack.Vertical.VerticalAlign.Example'; +const VerticalStackVerticalAlignExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.VerticalAlign.Example.tsx') as string; +const VerticalStackVerticalAlignExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.VerticalAlign.Example.Codepen.txt') as string; + +import { VerticalStackHorizontalAlignExample } from './examples/Stack.Vertical.HorizontalAlign.Example'; +const VerticalStackHorizontalAlignExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.HorizontalAlign.Example.tsx') as string; +const VerticalStackHorizontalAlignExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.HorizontalAlign.Example.Codepen.txt') as string; + +import { VerticalStackConfigureExample } from './examples/Stack.Vertical.Configure.Example'; +const VerticalStackConfigureExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Configure.Example.tsx') as string; +const VerticalStackConfigureExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Vertical.Configure.Example.Codepen.txt') as string; + +// Horizontal stack examples +import { HorizontalStackBasicExample } from './examples/Stack.Horizontal.Basic.Example'; +const HorizontalStackBasicExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Basic.Example.tsx') as string; +const HorizontalStackBasicExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.Basic.Example.Codepen.txt') as string; + +import { HorizontalStackSpacingExample } from './examples/Stack.Horizontal.Spacing.Example'; +const HorizontalStackSpacingExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Spacing.Example.tsx') as string; +const HorizontalStackSpacingExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.Spacing.Example.Codepen.txt') as string; + +import { HorizontalStackGrowExample } from './examples/Stack.Horizontal.Grow.Example'; +const HorizontalStackGrowExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Grow.Example.tsx') as string; +const HorizontalStackGrowExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.Grow.Example.Codepen.txt') as string; + +import { HorizontalStackShrinkExample } from './examples/Stack.Horizontal.Shrink.Example'; +const HorizontalStackShrinkExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Shrink.Example.tsx') as string; +const HorizontalStackShrinkExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.Shrink.Example.Codepen.txt') as string; + +import { HorizontalStackWrapExample } from './examples/Stack.Horizontal.Wrap.Example'; +const HorizontalStackWrapExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Wrap.Example.tsx') as string; +const HorizontalStackWrapExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.Wrap.Example.Codepen.txt') as string; + +import { HorizontalStackWrapAdvancedExample } from './examples/Stack.Horizontal.WrapAdvanced.Example'; +const HorizontalStackWrapAdvancedExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapAdvanced.Example.tsx') as string; +const HorizontalStackWrapAdvancedExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.WrapAdvanced.Example.Codepen.txt') as string; + +import { HorizontalStackWrapNestedExample } from './examples/Stack.Horizontal.WrapNested.Example'; +const HorizontalStackWrapNestedExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapNested.Example.tsx') as string; +const HorizontalStackWrapNestedExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.WrapNested.Example.Codepen.txt') as string; + +import { HorizontalStackHorizontalAlignExample } from './examples/Stack.Horizontal.HorizontalAlign.Example'; +const HorizontalStackHorizontalAlignExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.HorizontalAlign.Example.tsx') as string; +const HorizontalStackHorizontalAlignExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.HorizontalAlign.Example.Codepen.txt') as string; + +import { HorizontalStackVerticalAlignExample } from './examples/Stack.Horizontal.VerticalAlign.Example'; +const HorizontalStackVerticalAlignExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.VerticalAlign.Example.tsx') as string; +const HorizontalStackVerticalAlignExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.VerticalAlign.Example.Codepen.txt') as string; + +import { HorizontalStackConfigureExample } from './examples/Stack.Horizontal.Configure.Example'; +const HorizontalStackConfigureExampleCode = require('!raw-loader!office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Configure.Example.tsx') as string; +const HorizontalStackConfigureExampleCodepen = require('!raw-loader!office-ui-fabric-react/lib/codepen/components/Stack/Stack.Horizontal.Configure.Example.Codepen.txt') as string; + +export const StackPageProps: IDocPageProps = { + title: 'Stack', + componentName: 'StackPageProps', + componentUrl: 'https://github.com/OfficeDev/office-ui-fabric-react/tree/master/packages/office-ui-fabric-react/src/components/Stack', + componentStatus: StackStatus, + examples: [ + { + title: 'Basic Vertical Stack', + code: VerticalStackBasicExampleCode, + view: , + codepenJS: VerticalStackBasicExampleCodepen + }, + { + title: 'Vertical Stack - Gap and Padding Sizes', + code: VerticalStackSpacingExampleCode, + view: , + codepenJS: VerticalStackSpacingExampleCodepen + }, + { + title: 'Vertical Stack - Growing Items', + code: VerticalStackGrowExampleCode, + view: , + codepenJS: VerticalStackGrowExampleCodepen + }, + { + title: 'Vertical Stack - Shrinking Items', + code: VerticalStackShrinkExampleCode, + view: , + codepenJS: VerticalStackShrinkExampleCodepen + }, + { + title: 'Vertical Stack - Wrapping - Basic', + code: VerticalStackWrapExampleCode, + view: , + codepenJS: VerticalStackWrapExampleCodepen + }, + { + title: 'Vertical Stack - Wrapping - Advanced', + code: VerticalStackWrapAdvancedExampleCode, + view: , + codepenJS: VerticalStackWrapAdvancedExampleCodepen + }, + { + title: 'Vertical Stack - Wrapping - Nested', + code: VerticalStackWrapNestedExampleCode, + view: , + codepenJS: VerticalStackWrapNestedExampleCodepen + }, + { + title: 'Vertical Stack - Vertical Alignments', + code: VerticalStackVerticalAlignExampleCode, + view: , + codepenJS: VerticalStackVerticalAlignExampleCodepen + }, + { + title: 'Vertical Stack - Horizontal Alignments', + code: VerticalStackHorizontalAlignExampleCode, + view: , + codepenJS: VerticalStackHorizontalAlignExampleCodepen + }, + { + title: 'Vertical Stack - Configure Properties', + code: VerticalStackConfigureExampleCode, + view: , + codepenJS: VerticalStackConfigureExampleCodepen + }, + { + title: 'Basic Horizontal Stack', + code: HorizontalStackBasicExampleCode, + view: , + codepenJS: HorizontalStackBasicExampleCodepen + }, + { + title: 'Horizontal Stack - Gap and Padding Sizes', + code: HorizontalStackSpacingExampleCode, + view: , + codepenJS: HorizontalStackSpacingExampleCodepen + }, + { + title: 'Horizontal Stack - Growing Items', + code: HorizontalStackGrowExampleCode, + view: , + codepenJS: HorizontalStackGrowExampleCodepen + }, + { + title: 'Horizontal Stack - Shrinking Items', + code: HorizontalStackShrinkExampleCode, + view: , + codepenJS: HorizontalStackShrinkExampleCodepen + }, + { + title: 'Horizontal Stack - Wrapping - Basic', + code: HorizontalStackWrapExampleCode, + view: , + codepenJS: HorizontalStackWrapExampleCodepen + }, + { + title: 'Horizontal Stack - Wrapping - Advanced', + code: HorizontalStackWrapAdvancedExampleCode, + view: , + codepenJS: HorizontalStackWrapAdvancedExampleCodepen + }, + { + title: 'Horizontal Stack - Wrapping - Nested', + code: HorizontalStackWrapNestedExampleCode, + view: , + codepenJS: HorizontalStackWrapNestedExampleCodepen + }, + { + title: 'Horizontal Stack - Horizontal Alignments', + code: HorizontalStackHorizontalAlignExampleCode, + view: , + codepenJS: HorizontalStackHorizontalAlignExampleCodepen + }, + { + title: 'Horizontal Stack - Vertical Alignments', + code: HorizontalStackVerticalAlignExampleCode, + view: , + codepenJS: HorizontalStackVerticalAlignExampleCodepen + }, + { + title: 'Horizontal Stack - Configure Properties', + code: HorizontalStackConfigureExampleCode, + view: , + codepenJS: HorizontalStackConfigureExampleCodepen + } + ], + propertiesTablesSources: [ + require('!raw-loader!office-ui-fabric-react/src/components/Stack/Stack.types.ts'), + require('!raw-loader!office-ui-fabric-react/src/components/Stack/StackItem/StackItem.types.ts') + ], + overview: '', + bestPractices: '', + dos: '', + donts: '', + isHeaderVisible: true, + isFeedbackVisible: true +}; diff --git a/packages/office-ui-fabric-react/src/components/Stack/Stack.styles.ts b/packages/office-ui-fabric-react/src/components/Stack/Stack.styles.ts new file mode 100644 index 0000000000000..4ec49939b971f --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/Stack.styles.ts @@ -0,0 +1,209 @@ +import { IStackComponent, IStackStyles, IStackProps } from './Stack.types'; +import { getVerticalAlignment, parseGap, parsePadding } from './StackUtils'; +import { getGlobalClassNames } from '../../Styling'; + +const nameMap: { [key: string]: string } = { + start: 'flex-start', + end: 'flex-end' +}; + +const GlobalClassNames = { + root: 'ms-Stack', + inner: 'ms-Stack-inner' +}; + +export const styles: IStackComponent['styles'] = props => { + const { + fillHorizontal, + fillVertical, + maxWidth, + maxHeight, + horizontal, + gap, + verticalGap, + grow, + wrap, + padding, + horizontalAlignment, + verticalAlignment, + shrinkItems, + theme, + className + } = props; + + const classNames = getGlobalClassNames(GlobalClassNames, theme); + + const vertAlignment = getVerticalAlignment(verticalAlignment); + + let horiGap: IStackProps['gap']; + let vertGap: IStackProps['gap']; + + horiGap = gap; + vertGap = verticalGap !== undefined ? verticalGap : gap; + + const hGap = parseGap(horiGap, theme); + const vGap = parseGap(vertGap, theme); + + const horizontalMargin = `${-0.5 * hGap.value}${hGap.unit}`; + const verticalMargin = `${-0.5 * vGap.value}${vGap.unit}`; + + // styles to be applied to all direct children regardless of wrap or direction + const childStyles = { + whiteSpace: 'nowrap', + textOverflow: 'ellipsis' + }; + + // selectors to be applied regardless of wrap or direction + const commonSelectors = { + // flexShrink styles are applied by the StackItem + '> *:not(.ms-StackItem)': { + flexShrink: shrinkItems ? 1 : 0 + } + }; + + if (wrap) { + return { + root: [ + classNames.root, + { + maxWidth, + maxHeight, + width: fillHorizontal ? '100%' : 'auto', + overflow: 'visible' + }, + horizontal && { + height: fillVertical ? '100%' : 'auto', + width: 'auto' + }, + !horizontal && { + height: '100%' + }, + className, + { + // not allowed to be overridden by className + // since this is necessary in order to prevent collapsing margins + display: 'inline-block' + } + ], + + inner: [ + classNames.inner, + { + display: 'flex', + flexWrap: 'wrap', + marginLeft: horizontalMargin, + marginRight: horizontalMargin, + marginTop: verticalMargin, + marginBottom: verticalMargin, + overflow: 'visible', + boxSizing: 'border-box', + + selectors: { + '> *': { + margin: `${0.5 * vGap.value}${vGap.unit} ${0.5 * hGap.value}${hGap.unit}`, + + ...childStyles + }, + ...commonSelectors + } + }, + horizontalAlignment && { + [horizontal ? 'justifyContent' : 'alignItems']: nameMap[horizontalAlignment] || horizontalAlignment + }, + vertAlignment && { + [horizontal ? 'alignItems' : 'justifyContent']: nameMap[vertAlignment] || vertAlignment + }, + horizontal && { + flexDirection: 'row', + width: fillHorizontal ? '100%' : 'auto', + maxWidth: '100vw', + + // avoid unnecessary calc() calls if vertical gap is 0 + height: fillVertical ? (vGap.value === 0 ? '100%' : `calc(100% + ${vGap.value}${vGap.unit})`) : 'auto', + + selectors: { + '> *': { + maxWidth: hGap.value === 0 ? '100%' : `calc(100% - ${hGap.value}${hGap.unit})` + } + } + }, + !horizontal && { + height: `calc(100% + ${vGap.value}${vGap.unit})`, + flexDirection: 'column', + justifyContent: 'start', + alignContent: 'end', + alignItems: 'start', + selectors: { + '> *': { + maxHeight: vGap.value === 0 ? '100%' : `calc(100% - ${vGap.value}${vGap.unit})` + } + } + } + ] + } as IStackStyles; + } + + return { + root: [ + classNames.root, + { + display: 'flex', + flexDirection: horizontal ? 'row' : 'column', + flexWrap: 'nowrap', + width: fillHorizontal && !wrap ? '100%' : 'auto', + height: fillVertical && !wrap ? '100%' : 'auto', + maxWidth, + maxHeight, + padding: parsePadding(padding, theme), + boxSizing: 'border-box' + }, + grow && { + flexGrow: grow === true ? 1 : grow, + overflow: 'hidden' + }, + horizontalAlignment && { + [horizontal ? 'justifyContent' : 'alignItems']: nameMap[horizontalAlignment] || horizontalAlignment + }, + vertAlignment && { + [horizontal ? 'alignItems' : 'justifyContent']: nameMap[vertAlignment] || vertAlignment + }, + wrap && { + maxWidth, + maxHeight, + width: fillHorizontal ? '100%' : 'auto', + height: fillVertical ? '100%' : 'auto', + overflow: 'visible', + selectors: { + '> *': { + margin: `${0.5 * vGap.value}${vGap.unit} ${0.5 * hGap.value}${hGap.unit}`, + + // avoid unnecessary calc() calls if horizontal gap is 0 + maxWidth: hGap.value === 0 ? '100%' : `calc(100% - ${hGap.value}${hGap.unit})`, + + ...childStyles + }, + ...commonSelectors + } + }, + !wrap && { + selectors: { + '> *': childStyles, + + // apply gap margin to every direct child except the first direct child + '> *:not(:first-child)': [ + horizontal && { + marginLeft: `${hGap.value}${hGap.unit}` + }, + !horizontal && { + marginTop: `${vGap.value}${vGap.unit}` + } + ], + ...commonSelectors + } + }, + className + ] + // TODO: this cast may be hiding some potential issues with styling and name + // lookups and should be removed + } as IStackStyles; +}; diff --git a/packages/office-ui-fabric-react/src/components/Stack/Stack.test.tsx b/packages/office-ui-fabric-react/src/components/Stack/Stack.test.tsx new file mode 100644 index 0000000000000..df79b3f9a44cb --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/Stack.test.tsx @@ -0,0 +1,265 @@ +import * as React from 'react'; +import { mount } from 'enzyme'; +import * as renderer from 'react-test-renderer'; +import { mergeStyles } from '@uifabric/merge-styles'; + +import { Stack } from './Stack'; + +const sampleClass = mergeStyles({ + background: 'red' +}); + +describe('Stack', () => { + it('can handle having no children in vertical Stack', () => { + const createEmptyStack = () => { + mount(); + }; + + expect(createEmptyStack).not.toThrow(); + }); + + it('can handle having no children in horizontal Stack', () => { + const createEmptyStack = () => { + mount(); + }; + + expect(createEmptyStack).not.toThrow(); + }); + + it('renders default vertical Stack correctly', () => { + const component = renderer.create( + +
Item 1
+
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders default horizontal Stack correctly', () => { + const component = renderer.create( + +
Item 1
+
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with vertical and horizontal alignment correctly', () => { + const component = renderer.create( + +
Item 1
+
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with vertical and horizontal alignment correctly', () => { + const component = renderer.create( + +
Item 1
+
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with vertical and horizontal fill correctly', () => { + const component = renderer.create( + +
Item 1
+
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with vertical and horizontal fill correctly', () => { + const component = renderer.create( + +
Item 1
+
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with grow correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + Item 3 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with grow correctly', () => { + const component = renderer.create( + + + Item 1 + + + Item 2 + + + Item 3 + + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with StackItems correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with StackItems correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with a gap correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with a gap correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with shrinking StackItems correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with shrinking StackItems correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with shrinking StackItems correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack with shrinking StackItems correctly', () => { + const component = renderer.create( + + Item 1 + Item 2 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders vertical Stack with item alignments correctly', () => { + const component = renderer.create( + + Auto + Stretch + Baseline + Start + Center + End + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders horizontal Stack item alignments correctly', () => { + const component = renderer.create( + + Auto + Stretch + Baseline + Start + Center + End + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('renders wrapped horizontal Stack correctly', () => { + const component = renderer.create( + + 1 + 2 + 3 + + ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('accepts custom className on child items', () => { + const component = renderer.create( + + Item 1 +
Item 2
+
+ ); + const tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/packages/experiments/src/components/Stack/Stack.tsx b/packages/office-ui-fabric-react/src/components/Stack/Stack.tsx similarity index 93% rename from packages/experiments/src/components/Stack/Stack.tsx rename to packages/office-ui-fabric-react/src/components/Stack/Stack.tsx index 1242402f073a6..2cb6222c9b804 100644 --- a/packages/experiments/src/components/Stack/Stack.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/Stack.tsx @@ -50,6 +50,16 @@ const view: IStackComponent['view'] = props => { const nativeProps = getNativeProps(rest, htmlElementProperties); + if (wrap) { + return ( +
+ + {stackChildren} + +
+ ); + } + return ( {stackChildren} diff --git a/packages/experiments/src/components/Stack/Stack.types.ts b/packages/office-ui-fabric-react/src/components/Stack/Stack.types.ts similarity index 76% rename from packages/experiments/src/components/Stack/Stack.types.ts rename to packages/office-ui-fabric-react/src/components/Stack/Stack.types.ts index d777204a1622f..4ceb054d2a9c1 100644 --- a/packages/experiments/src/components/Stack/Stack.types.ts +++ b/packages/office-ui-fabric-react/src/components/Stack/Stack.types.ts @@ -1,23 +1,15 @@ import { IStyle } from '../../Styling'; -import { IStatelessComponent, IStyleableComponentProps } from '../../Foundation'; +import { IStatelessComponent, IStyleableComponentProps, IStylesProp } from '../../Foundation'; export type Alignment = 'start' | 'end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | 'baseline' | 'stretch'; -export type Omit = Pick>; - export type IStackComponent = IStatelessComponent; -// contains the members of IStackProps that are common to both VerticalStack and HorizontalStack -export type IPartialStackProps = Omit< - IStackProps, - 'verticalAlignment' | 'horizontalAlignment' | 'horizontal' | 'verticalGap' | 'horizontalGap' | 'wrap' | 'styles' ->; - export interface IStackProps extends IStyleableComponentProps, React.HTMLAttributes { /** * How to render the Stack. */ - as?: string | React.ReactType; + as?: string | React.ReactType; /** * CSS class name used to style the Stack. @@ -31,6 +23,7 @@ export interface IStackProps extends IStyleableComponentProps; } export interface IStackStyles { @@ -105,4 +99,9 @@ export interface IStackStyles { * Style set for the root element. */ root: IStyle; + + /** + * Style set for the inner element (only when the wrap property is true). + */ + inner: IStyle; } diff --git a/packages/experiments/src/components/Stack/StackItem/StackItem.styles.ts b/packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.styles.ts similarity index 100% rename from packages/experiments/src/components/Stack/StackItem/StackItem.styles.ts rename to packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.styles.ts diff --git a/packages/experiments/src/components/Stack/StackItem/StackItem.test.tsx b/packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.test.tsx similarity index 100% rename from packages/experiments/src/components/Stack/StackItem/StackItem.test.tsx rename to packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.test.tsx diff --git a/packages/experiments/src/components/Stack/StackItem/StackItem.tsx b/packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.tsx similarity index 100% rename from packages/experiments/src/components/Stack/StackItem/StackItem.tsx rename to packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.tsx diff --git a/packages/experiments/src/components/Stack/StackItem/StackItem.types.ts b/packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.types.ts similarity index 100% rename from packages/experiments/src/components/Stack/StackItem/StackItem.types.ts rename to packages/office-ui-fabric-react/src/components/Stack/StackItem/StackItem.types.ts diff --git a/packages/experiments/src/components/Stack/StackUtils.test.ts b/packages/office-ui-fabric-react/src/components/Stack/StackUtils.test.ts similarity index 85% rename from packages/experiments/src/components/Stack/StackUtils.test.ts rename to packages/office-ui-fabric-react/src/components/Stack/StackUtils.test.ts index 88d402bcd6161..34506e3d3cfc4 100644 --- a/packages/experiments/src/components/Stack/StackUtils.test.ts +++ b/packages/office-ui-fabric-react/src/components/Stack/StackUtils.test.ts @@ -1,24 +1,7 @@ -import { getHorizontalAlignment, getVerticalAlignment, parseGap, parsePadding } from './StackUtils'; +import { getVerticalAlignment, parseGap, parsePadding } from './StackUtils'; import { loadTheme, getTheme } from 'office-ui-fabric-react/lib/Styling'; describe('StackUtils', () => { - describe('getHorizontalAlignment', () => { - it('returns start when given left', () => { - expect(getHorizontalAlignment('left')).toEqual('start'); - }); - - it('returns end when given right', () => { - expect(getHorizontalAlignment('right')).toEqual('end'); - }); - - it('returns its argument when given a value other than left and right', () => { - const args = ['center', 'space-around', 'space-between', 'space-evenly']; - args.forEach((arg: string) => { - expect(getHorizontalAlignment(arg)).toEqual(arg); - }); - }); - }); - describe('getVerticalAlignment', () => { it('returns start when given top', () => { expect(getVerticalAlignment('top')).toEqual('start'); diff --git a/packages/experiments/src/components/Stack/StackUtils.ts b/packages/office-ui-fabric-react/src/components/Stack/StackUtils.ts similarity index 87% rename from packages/experiments/src/components/Stack/StackUtils.ts rename to packages/office-ui-fabric-react/src/components/Stack/StackUtils.ts index e2db70f95213b..244940cd378d2 100644 --- a/packages/experiments/src/components/Stack/StackUtils.ts +++ b/packages/office-ui-fabric-react/src/components/Stack/StackUtils.ts @@ -5,21 +5,11 @@ import { Alignment } from './Stack.types'; import { ITheme } from '../../Styling'; -const horizontalAlignmentMap: { [key: string]: string } = { - left: 'start', - right: 'end' -}; - const verticalAlignmentMap: { [key: string]: string } = { top: 'start', bottom: 'end' }; -// Converts the alignment expected by a HorizontalStack to an alignment expected by a Stack. -export const getHorizontalAlignment = (alignment: string | undefined): Alignment => { - return (horizontalAlignmentMap[alignment!] || alignment) as Alignment; -}; - // Converts the alignment expected by a VerticalStack to an alignment expected by a Stack. export const getVerticalAlignment = (alignment: string | undefined): Alignment => { return (verticalAlignmentMap[alignment!] || alignment) as Alignment; diff --git a/packages/office-ui-fabric-react/src/components/Stack/__snapshots__/Stack.test.tsx.snap b/packages/office-ui-fabric-react/src/components/Stack/__snapshots__/Stack.test.tsx.snap new file mode 100644 index 0000000000000..6dc67b73705c7 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/__snapshots__/Stack.test.tsx.snap @@ -0,0 +1,1270 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Stack accepts custom className on child items 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Item 1 + +
+ Item 2 +
+
+`; + +exports[`Stack renders default horizontal Stack correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ Item 1 +
+
+ Item 2 +
+
+`; + +exports[`Stack renders default vertical Stack correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ Item 1 +
+
+ Item 2 +
+
+`; + +exports[`Stack renders horizontal Stack item alignments correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Auto + + + Stretch + + + Baseline + + + Start + + + Center + + + End + +
+`; + +exports[`Stack renders horizontal Stack with StackItems correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders horizontal Stack with a gap correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders horizontal Stack with grow correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + Item 1 +
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + Item 2 +
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + Item 3 +
+
+`; + +exports[`Stack renders horizontal Stack with shrinking StackItems correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 1; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders horizontal Stack with shrinking StackItems correctly 2`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 1; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders horizontal Stack with vertical and horizontal alignment correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ Item 1 +
+
+ Item 2 +
+
+`; + +exports[`Stack renders horizontal Stack with vertical and horizontal fill correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ Item 1 +
+
+ Item 2 +
+
+`; + +exports[`Stack renders vertical Stack with StackItems correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders vertical Stack with a gap correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders vertical Stack with grow correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + Item 1 +
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + Item 2 +
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + Item 3 +
+
+`; + +exports[`Stack renders vertical Stack with item alignments correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Auto + + + Stretch + + + Baseline + + + Start + + + Center + + + End + +
+`; + +exports[`Stack renders vertical Stack with shrinking StackItems correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 1; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders vertical Stack with shrinking StackItems correctly 2`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 1; + } +> + + Item 1 + + + Item 2 + +
+`; + +exports[`Stack renders vertical Stack with vertical and horizontal alignment correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ Item 1 +
+
+ Item 2 +
+
+`; + +exports[`Stack renders vertical Stack with vertical and horizontal fill correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ Item 1 +
+
+ Item 2 +
+
+`; + +exports[`Stack renders wrapped horizontal Stack correctly 1`] = ` +
+
* { + margin-bottom: 0px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; + max-width: 100%; + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Basic.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Basic.Example.tsx new file mode 100644 index 0000000000000..57f1bb1961ca0 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Basic.Example.tsx @@ -0,0 +1,69 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class HorizontalStackBasicExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary + }, + + item: { + color: DefaultPalette.white, + background: DefaultPalette.themePrimary, + padding: 5 + } + }); + + return ( + + Default horizontal stack + + Item One + Item Two + Item Three + + + Horizontal gap between items + + Item One + Item Two + Item Three + + + Item alignments + + + Auto-aligned item + + + Stretch-aligned item + + + Baseline-aligned item + + + Start-aligned item + + + Center-aligned item + + + End-aligned item + + + + Clickable stack + + Click inside this box + + + ); + } + + private _onClick = (): void => { + alert('Clicked Stack'); + }; +} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Configure.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Configure.Example.tsx similarity index 79% rename from packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Configure.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Configure.Example.tsx index 861b77e3280f6..444871a0bbb4c 100644 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Configure.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Configure.Example.tsx @@ -1,10 +1,13 @@ +// @codepen import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { Slider, Checkbox, Dropdown, IDropdownOption, TextField } from 'office-ui-fabric-react'; +import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox'; +import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; +import { TextField } from 'office-ui-fabric-react/lib/TextField'; -export type HorizontalAlignment = 'left' | 'center' | 'right' | 'space-around' | 'space-between' | 'space-evenly'; +export type HorizontalAlignment = 'start' | 'center' | 'end' | 'space-around' | 'space-between' | 'space-evenly'; export type VerticalAlignment = 'top' | 'center' | 'bottom'; export interface IExampleState { @@ -42,7 +45,7 @@ export class HorizontalStackConfigureExample extends React.Component<{}, IExampl paddingRight: 0, paddingTop: 0, paddingBottom: 0, - horizontalAlignment: 'left', + horizontalAlignment: 'start', verticalAlignment: 'top', hideEmptyChildren: false, emptyChildren: [] @@ -102,10 +105,10 @@ export class HorizontalStackConfigureExample extends React.Component<{}, IExampl }; return ( - - - - + + + + - + - - - - - - +
+
+ + + + - - + + - - - - + + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - {this._range(1, numItems).map((value: number, index: number) => { if (emptyChildren.indexOf(value.toString()) !== -1) { - return hideEmptyChildren ? ( - - ) : ( - - ); + return hideEmptyChildren ? : ; } return ( - + {value} - + ); })} - - + + ); } diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Grow.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Grow.Example.tsx similarity index 59% rename from packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Grow.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Grow.Example.tsx index 7f803f204050c..77bfb9e5f0761 100644 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Grow.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Grow.Example.tsx @@ -1,5 +1,6 @@ +// @codepen import * as React from 'react'; -import { HorizontalStack } from '@uifabric/experiments/lib/Stack'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; export class HorizontalStackGrowExample extends React.Component<{}, {}> { @@ -20,17 +21,17 @@ export class HorizontalStackGrowExample extends React.Component<{}, {}> { }); return ( - - + + Grow is 3 - - + + Grow is 2 - - + + Grow is 1 - - + + ); } } diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.HorizontalAlign.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.HorizontalAlign.Example.tsx new file mode 100644 index 0000000000000..2f2f3807e0482 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.HorizontalAlign.Example.tsx @@ -0,0 +1,71 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class HorizontalStackHorizontalAlignExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + selectors: { + '> *': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + } + }); + + return ( + + Left-aligned + + 1 + 2 + 3 + + + Horizontally centered + + 1 + 2 + 3 + + + Right-aligned + + 1 + 2 + 3 + + + Horizontal space around items + + 1 + 2 + 3 + + + Horizontal space between items + + 1 + 2 + 3 + + + Items horizontally evenly spaced + + 1 + 2 + 3 + + + ); + } +} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Shrink.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Shrink.Example.tsx similarity index 64% rename from packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Shrink.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Shrink.Example.tsx index 7b4a885dec99b..bcd36e46f3b5c 100644 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Shrink.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Shrink.Example.tsx @@ -1,6 +1,7 @@ +// @codepen import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Slider } from 'office-ui-fabric-react'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; export interface IExampleState { @@ -35,7 +36,7 @@ export class HorizontalStackShrinkExample extends React.Component<{}, IExampleSt }); return ( - + - - + + I shrink - - + + I shrink - - + + I don't shrink - - + + I shrink - - - + + + ); } diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Spacing.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Spacing.Example.tsx new file mode 100644 index 0000000000000..009094b950521 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Spacing.Example.tsx @@ -0,0 +1,105 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class HorizontalStackSpacingExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + width: 300, + selectors: { + '> *': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + }, + + item: { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + }); + + return ( + + + + Numerical spacing + + 1 + 2 + 3 + + + + Custom spacing + + 1 + 2 + 3 + + + + + + + Themed spacing (extra small) + + 1 + 2 + 3 + + + + Themed spacing (small) + + 1 + 2 + 3 + + + + Themed spacing (medium) + + 1 + 2 + 3 + + + + + + + Themed spacing (large) + + 1 + 2 + 3 + + + + Themed spacing (extra large) + + 1 + 2 + 3 + + + + + ); + } +} diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.VerticalAlign.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.VerticalAlign.Example.tsx new file mode 100644 index 0000000000000..1826fe128a286 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.VerticalAlign.Example.tsx @@ -0,0 +1,51 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class HorizontalStackVerticalAlignExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + height: 100, + selectors: { + '> *': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + } + }); + + return ( + + Top-aligned + + 1 + 2 + 3 + + + Vertically centered + + 1 + 2 + 3 + + + Bottom-aligned + + 1 + 2 + 3 + + + ); + } +} diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Wrap.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Wrap.Example.tsx similarity index 68% rename from packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Wrap.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Wrap.Example.tsx index d5c7e547b37a6..dec6d289108bf 100644 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.Wrap.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Wrap.Example.tsx @@ -1,7 +1,7 @@ +// @codepen import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { Slider } from 'office-ui-fabric-react'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; export interface IExampleState { @@ -36,7 +36,7 @@ export class HorizontalStackWrapExample extends React.Component<{}, IExampleStat }); return ( - + - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + ); } diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapAdvanced.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapAdvanced.Example.tsx similarity index 73% rename from packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapAdvanced.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapAdvanced.Example.tsx index 38afbd362800a..5d4079e8a5b3f 100644 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapAdvanced.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapAdvanced.Example.tsx @@ -1,10 +1,11 @@ +// @codepen import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { Slider, Dropdown, IDropdownOption } from 'office-ui-fabric-react'; +import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; -export type HorizontalAlignment = 'left' | 'center' | 'right' | 'space-around' | 'space-between' | 'space-evenly'; +export type HorizontalAlignment = 'start' | 'center' | 'end' | 'space-around' | 'space-between' | 'space-evenly'; export type VerticalAlignment = 'top' | 'center' | 'bottom'; export type Overflow = 'visible' | 'auto' | 'hidden'; @@ -22,7 +23,7 @@ export class HorizontalStackWrapAdvancedExample extends React.Component<{}, IExa this.state = { stackWidth: 100, containerHeight: 150, - horizontalAlignment: 'left', + horizontalAlignment: 'start', verticalAlignment: 'top', overflow: 'visible' }; @@ -55,12 +56,12 @@ export class HorizontalStackWrapAdvancedExample extends React.Component<{}, IExa }); return ( - - - + + + - - + + - - + + - - + + - - + + - - + + - - + +
- - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 +
-
+ ); } diff --git a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapNested.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapNested.Example.tsx similarity index 60% rename from packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapNested.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapNested.Example.tsx index 06e1186e7d5dd..a24b4d092866e 100644 --- a/packages/experiments/src/components/Stack/HorizontalStack/examples/HorizontalStack.WrapNested.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.WrapNested.Example.tsx @@ -1,7 +1,7 @@ +// @codepen import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { Slider } from 'office-ui-fabric-react'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, IStyleSet, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; export interface IExampleState { @@ -64,7 +64,7 @@ export class HorizontalStackWrapNestedExample extends React.Component<{}, IExamp }); return ( - + - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + - - 1 - 2 - 3 - + + 1 + 2 + 3 + - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + ); } diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Basic.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Basic.Example.tsx new file mode 100644 index 0000000000000..719998d60701f --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Basic.Example.tsx @@ -0,0 +1,69 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class VerticalStackBasicExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary + }, + + item: { + color: DefaultPalette.white, + background: DefaultPalette.themePrimary, + padding: 5 + } + }); + + return ( + + Default vertical stack + + Item One + Item Two + Item Three + + + Vertical gap between items + + Item One + Item Two + Item Three + + + Item alignments + + + Auto-aligned item + + + Stretch-aligned item + + + Baseline-aligned item + + + Start-aligned item + + + Center-aligned item + + + End-aligned item + + + + Clickable vertical stack + + Click inside this box + + + ); + } + + private _onClick = (): void => { + alert('Clicked VerticalStack'); + }; +} diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Configure.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Configure.Example.tsx similarity index 79% rename from packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Configure.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Configure.Example.tsx index 2df1e3746d763..5b38b6abb8b7a 100644 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Configure.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Configure.Example.tsx @@ -1,11 +1,14 @@ +// @codepen import * as React from 'react'; -import { VerticalStack, HorizontalStack } from '@uifabric/experiments/lib/Stack'; -import { Text } from '@uifabric/experiments/lib/Text'; -import { Slider, Checkbox, Dropdown, IDropdownOption, TextField } from 'office-ui-fabric-react'; +import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox'; +import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; +import { TextField } from 'office-ui-fabric-react/lib/TextField'; export type VerticalAlignment = 'top' | 'center' | 'bottom' | 'space-around' | 'space-between' | 'space-evenly'; -export type HorizontalAlignment = 'left' | 'center' | 'right'; +export type HorizontalAlignment = 'start' | 'center' | 'end'; export interface IExampleState { numItems: number; @@ -41,7 +44,7 @@ export class VerticalStackConfigureExample extends React.Component<{}, IExampleS paddingTop: 0, paddingBottom: 0, verticalAlignment: 'top', - horizontalAlignment: 'left', + horizontalAlignment: 'start', hideEmptyChildren: false, emptyChildren: [] }; @@ -92,10 +95,10 @@ export class VerticalStackConfigureExample extends React.Component<{}, IExampleS }); return ( - - - - + + + + - + - - - - - + + + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - - - - - + + + + + + - - - - + + + + - - - + + + - {this._range(1, numItems).map((value: number, index: number) => { if (emptyChildren.indexOf(value.toString()) !== -1) { - return hideEmptyChildren ? ( - - ) : ( - - ); + return hideEmptyChildren ? : ; } return ( - + {value} - + ); })} - - + + ); } diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Grow.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Grow.Example.tsx similarity index 56% rename from packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Grow.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Grow.Example.tsx index de31d18cf24e3..35ff8858263b9 100644 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Grow.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Grow.Example.tsx @@ -1,5 +1,6 @@ +// @codepen import * as React from 'react'; -import { VerticalStack } from '@uifabric/experiments/lib/Stack'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; export class VerticalStackGrowExample extends React.Component<{}, {}> { @@ -20,19 +21,19 @@ export class VerticalStackGrowExample extends React.Component<{}, {}> { }); return ( - - - + + + Grow is 3 - - + + Grow is 2 - - + + Grow is 1 - - - + + + ); } } diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.HorizontalAlign.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.HorizontalAlign.Example.tsx new file mode 100644 index 0000000000000..dc4be56bea87a --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.HorizontalAlign.Example.tsx @@ -0,0 +1,47 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class VerticalStackHorizontalAlignExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + selectors: { + '> *': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + } + }); + + return ( + + Left-aligned + + 1 + 2 + + + Horizontally centered + + 1 + 2 + + + Right-aligned + + 1 + 2 + + + ); + } +} diff --git a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Shrink.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Shrink.Example.tsx similarity index 66% rename from packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Shrink.Example.tsx rename to packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Shrink.Example.tsx index 3bfe7ebb9c383..cee36594f957c 100644 --- a/packages/experiments/src/components/Stack/VerticalStack/examples/VerticalStack.Shrink.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Shrink.Example.tsx @@ -1,6 +1,7 @@ +// @codepen import * as React from 'react'; -import { VerticalStack } from '@uifabric/experiments/lib/Stack'; -import { Slider } from 'office-ui-fabric-react'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; export interface IExampleState { @@ -38,7 +39,7 @@ export class VerticalStackShrinkExample extends React.Component<{}, IExampleStat }); return ( - +
- - + + I shrink - - + + I shrink - - + + I don't shrink - - + + I shrink - - + +
-
+ ); } diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Spacing.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Spacing.Example.tsx new file mode 100644 index 0000000000000..15b50d3016a36 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Spacing.Example.tsx @@ -0,0 +1,95 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class VerticalStackSpacingExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary + }, + + item: { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + }); + + return ( + + + + Numerical spacing + + 1 + 2 + 3 + + + + + Custom spacing + + 1 + 2 + 3 + + + + + + + Themed spacing (extra small) + + 1 + 2 + 3 + + + + + Themed spacing (small) + + 1 + 2 + 3 + + + + + Themed spacing (medium) + + 1 + 2 + 3 + + + + + Themed spacing (large) + + 1 + 2 + 3 + + + + + Themed spacing (extra large) + + 1 + 2 + 3 + + + + + ); + } +} diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.VerticalAlign.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.VerticalAlign.Example.tsx new file mode 100644 index 0000000000000..590c17afa04cf --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.VerticalAlign.Example.tsx @@ -0,0 +1,88 @@ +// @codepen +import * as React from 'react'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export class VerticalStackVerticalAlignExample extends React.Component<{}, {}> { + public render(): JSX.Element { + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + height: 250, + selectors: { + '> *': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + } + }); + + return ( + + + + Top-aligned + + 1 + 2 + 3 + + + + + Vertically centered + + 1 + 2 + 3 + + + + + Bottom-aligned + + 1 + 2 + 3 + + + + + + + Vertical space around items + + 1 + 2 + 3 + + + + + Vertical space between items + + 1 + 2 + 3 + + + + + Items vertically evenly spaced + + 1 + 2 + 3 + + + + + ); + } +} diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Wrap.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Wrap.Example.tsx new file mode 100644 index 0000000000000..aa71d06e5afcd --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.Wrap.Example.tsx @@ -0,0 +1,67 @@ +// @codepen +import * as React from 'react'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export interface IExampleState { + stackHeight: number; +} + +export class VerticalStackWrapExample extends React.Component<{}, IExampleState> { + constructor(props: {}) { + super(props); + this.state = { + stackHeight: 420 + }; + } + + public render(): JSX.Element { + const { stackHeight } = this.state; + + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + height: stackHeight, + selectors: { + '& span': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + } + }); + + return ( + + + + + 1 + 2 + 3 + 4 + 5 + 6 + + + ); + } + + private _onHeightChange = (value: number): void => { + this.setState({ stackHeight: value }); + }; +} diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapAdvanced.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapAdvanced.Example.tsx new file mode 100644 index 0000000000000..04c93018ba779 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapAdvanced.Example.tsx @@ -0,0 +1,154 @@ +// @codepen +import * as React from 'react'; +import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export type HorizontalAlignment = 'start' | 'center' | 'end' | 'space-around' | 'space-between' | 'space-evenly'; +export type VerticalAlignment = 'top' | 'center' | 'bottom'; +export type Overflow = 'visible' | 'auto' | 'hidden'; + +export interface IExampleState { + stackWidth: number; + containerHeight: number; + horizontalAlignment: HorizontalAlignment; + verticalAlignment: VerticalAlignment; + overflow: Overflow; +} + +export class VerticalStackWrapAdvancedExample extends React.Component<{}, IExampleState> { + constructor(props: {}) { + super(props); + this.state = { + stackWidth: 100, + containerHeight: 420, + horizontalAlignment: 'start', + verticalAlignment: 'top', + overflow: 'visible' + }; + } + + public render(): JSX.Element { + const { stackWidth, containerHeight, overflow, horizontalAlignment, verticalAlignment } = this.state; + + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + width: `${stackWidth}%`, + overflow, + selectors: { + '& span': { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: DefaultPalette.themePrimary, + color: DefaultPalette.white + } + } + }, + + container: { + height: containerHeight + } + }); + + return ( + + + + + + + + + + + + + + + + + + + + + + +
+ + 1 + 2 + 3 + 4 + 5 + 6 + +
+
+ ); + } + + private _onWidthChange = (value: number): void => { + this.setState({ stackWidth: value }); + }; + + private _onHeightChange = (value: number): void => { + this.setState({ containerHeight: value }); + }; + + private _onHorizontalAlignChange = (ev: React.FormEvent, option: IDropdownOption): void => { + this.setState({ horizontalAlignment: option.key as HorizontalAlignment }); + }; + + private _onVerticalAlignChange = (ev: React.FormEvent, option: IDropdownOption): void => { + this.setState({ verticalAlignment: option.key as VerticalAlignment }); + }; + + private _onOverflowChange = (ev: React.FormEvent, option: IDropdownOption): void => { + this.setState({ overflow: option.key as Overflow }); + }; +} diff --git a/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapNested.Example.tsx b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapNested.Example.tsx new file mode 100644 index 0000000000000..c1b10eed7fa37 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Vertical.WrapNested.Example.tsx @@ -0,0 +1,117 @@ +// @codepen +import * as React from 'react'; +import { Slider } from 'office-ui-fabric-react/lib/Slider'; +import { Stack } from 'office-ui-fabric-react/lib/Stack'; +import { mergeStyleSets, IStyleSet, DefaultPalette } from 'office-ui-fabric-react/lib/Styling'; + +export interface IExampleState { + stackHeight: number; +} + +export class VerticalStackWrapNestedExample extends React.Component<{}, IExampleState> { + constructor(props: {}) { + super(props); + this.state = { + stackHeight: 420 + }; + } + + public render(): JSX.Element { + const textStyles = { + width: 50, + height: 50, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + color: DefaultPalette.white + } as IStyleSet<{}>; + + const { stackHeight } = this.state; + + const styles = mergeStyleSets({ + root: { + background: DefaultPalette.themeTertiary, + height: stackHeight + }, + + stackOne: { + background: DefaultPalette.neutralTertiary, + selectors: { + '& span': { + ...textStyles, + background: DefaultPalette.themePrimary + } + } + }, + + stackTwo: { + background: DefaultPalette.neutralSecondary, + selectors: { + '& span': { + ...textStyles, + background: DefaultPalette.themeDark + } + } + }, + + stackThree: { + background: DefaultPalette.neutralPrimary, + selectors: { + '& span': { + ...textStyles, + background: DefaultPalette.themeDarker + } + } + } + }); + + return ( + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + + 1 + 2 + 3 + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + + ); + } + + private _onHeightChange = (value: number): void => { + this.setState({ stackHeight: value }); + }; +} diff --git a/packages/office-ui-fabric-react/src/components/Stack/index.ts b/packages/office-ui-fabric-react/src/components/Stack/index.ts new file mode 100644 index 0000000000000..8ccdc2c7462e3 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Stack/index.ts @@ -0,0 +1,3 @@ +export * from './StackItem/StackItem'; +export * from './Stack'; +export * from './Stack.types'; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Basic.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Basic.Example.tsx.shot new file mode 100644 index 0000000000000..492780cbc8384 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Basic.Example.tsx.shot @@ -0,0 +1,319 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.Basic.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Default horizontal stack + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Item One + + + Item Two + + + Item Three + +
+ + Horizontal gap between items + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Item One + + + Item Two + + + Item Three + +
+ + Item alignments + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + + Auto-aligned item + + + + + Stretch-aligned item + + + + + Baseline-aligned item + + + + + Start-aligned item + + + + + Center-aligned item + + + + + End-aligned item + + +
+ + Clickable stack + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + onClick={[Function]} + > + + Click inside this box + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Configure.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Configure.Example.tsx.shot new file mode 100644 index 0000000000000..6b81523a8c5fd --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Configure.Example.tsx.shot @@ -0,0 +1,3798 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.Configure.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + +
+
+
+ +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + +
+ +
+ +
+
+
+ + + +
+
+ +
+
+
+
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+ + + +
+
+ +
+
+
+
+ +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+ + + +
+
+ +
+
+
+
+ +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+ + + +
+
+ +
+
+
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
+ + +
+
+ +
+ + +
+
+ + + + +
+
+ +
+ +
+
+
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Grow.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Grow.Example.tsx.shot new file mode 100644 index 0000000000000..3394eefe1220c --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Grow.Example.tsx.shot @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.Grow.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Grow is 3 + + + Grow is 2 + + + Grow is 1 + +
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.HorizontalAlign.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.HorizontalAlign.Example.tsx.shot new file mode 100644 index 0000000000000..351511a5bf786 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.HorizontalAlign.Example.tsx.shot @@ -0,0 +1,291 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.HorizontalAlign.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Left-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Horizontally centered + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Right-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Horizontal space around items + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Horizontal space between items + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Items horizontally evenly spaced + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Shrink.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Shrink.Example.tsx.shot new file mode 100644 index 0000000000000..7285c82ccf565 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Shrink.Example.tsx.shot @@ -0,0 +1,393 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.Shrink.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ +
+
+
+ + + +
+
+ +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 1; + } + > + + I shrink + + + I shrink + + + I don't shrink + + + I shrink + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Spacing.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Spacing.Example.tsx.shot new file mode 100644 index 0000000000000..6eee09c2aad61 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Spacing.Example.tsx.shot @@ -0,0 +1,589 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.Spacing.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Numerical spacing + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Custom spacing + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 10%; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (extra small) + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 4px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (small) + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 8px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (medium) + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 16px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (large) + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (extra large) + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 32px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.VerticalAlign.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.VerticalAlign.Example.tsx.shot new file mode 100644 index 0000000000000..18e1b016623b1 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.VerticalAlign.Example.tsx.shot @@ -0,0 +1,159 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.VerticalAlign.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Top-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Vertically centered + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+ + Bottom-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Wrap.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Wrap.Example.tsx.shot new file mode 100644 index 0000000000000..64789d3334650 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.Wrap.Example.tsx.shot @@ -0,0 +1,354 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.Wrap.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ +
+
+
+ + + +
+
+ +
+
+
+
* { + margin-bottom: 15px; + margin-left: 15px; + margin-right: 15px; + margin-top: 15px; + max-width: calc(100% - 30px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + +
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.WrapAdvanced.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.WrapAdvanced.Example.tsx.shot new file mode 100644 index 0000000000000..14b8c2de65b83 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.WrapAdvanced.Example.tsx.shot @@ -0,0 +1,1366 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.WrapAdvanced.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+
+ + + +
+
+ +
+
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+
+
+
* { + margin-bottom: 15px; + margin-left: 15px; + margin-right: 15px; + margin-top: 15px; + max-width: calc(100% - 30px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + +
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.WrapNested.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.WrapNested.Example.tsx.shot new file mode 100644 index 0000000000000..e7d9b302cde55 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Horizontal.WrapNested.Example.tsx.shot @@ -0,0 +1,531 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Horizontal.WrapNested.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ +
+
+
+ + + +
+
+ +
+
+
+
* { + margin-bottom: 15px; + margin-left: 20px; + margin-right: 20px; + margin-top: 15px; + max-width: calc(100% - 40px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+
* { + margin-bottom: 5px; + margin-left: 15px; + margin-right: 15px; + margin-top: 5px; + max-width: calc(100% - 30px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + +
+
+
+
* { + margin-bottom: 10px; + margin-left: 25px; + margin-right: 25px; + margin-top: 10px; + max-width: calc(100% - 50px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
* { + margin-bottom: 0px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; + max-width: 100%; + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + +
+
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Basic.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Basic.Example.tsx.shot new file mode 100644 index 0000000000000..50eb25eae1ca4 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Basic.Example.tsx.shot @@ -0,0 +1,319 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.Basic.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Default vertical stack + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Item One + + + Item Two + + + Item Three + +
+ + Vertical gap between items + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Item One + + + Item Two + + + Item Three + +
+ + Item alignments + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + + Auto-aligned item + + + + + Stretch-aligned item + + + + + Baseline-aligned item + + + + + Start-aligned item + + + + + Center-aligned item + + + + + End-aligned item + + +
+ + Clickable vertical stack + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + onClick={[Function]} + > + + Click inside this box + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Configure.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Configure.Example.tsx.shot new file mode 100644 index 0000000000000..1762967c4f277 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Configure.Example.tsx.shot @@ -0,0 +1,3495 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.Configure.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + + +
+
+
+ +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+ +
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
+ + +
+
+ +
+ + +
+
+ + + + +
+
+ +
+ +
+
+
+
+
+
+
+ +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+ + + +
+
+ +
+
+
+
+ +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+ + + +
+
+ +
+
+
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Grow.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Grow.Example.tsx.shot new file mode 100644 index 0000000000000..92351496ec4c5 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Grow.Example.tsx.shot @@ -0,0 +1,118 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.Grow.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Grow is 3 + + + Grow is 2 + + + Grow is 1 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.HorizontalAlign.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.HorizontalAlign.Example.tsx.shot new file mode 100644 index 0000000000000..96489c14e0f86 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.HorizontalAlign.Example.tsx.shot @@ -0,0 +1,150 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.HorizontalAlign.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> + + Left-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + +
+ + Horizontally centered + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + +
+ + Right-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + +
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Shrink.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Shrink.Example.tsx.shot new file mode 100644 index 0000000000000..1bf0b26a3a8c1 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Shrink.Example.tsx.shot @@ -0,0 +1,401 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.Shrink.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ +
+
+
+ + + +
+
+ +
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 5px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 1; + } + > + + I shrink + + + I shrink + + + I don't shrink + + + I shrink + +
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Spacing.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Spacing.Example.tsx.shot new file mode 100644 index 0000000000000..43a6bc2e853a8 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Spacing.Example.tsx.shot @@ -0,0 +1,767 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.Spacing.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 50px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Numerical spacing + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Custom spacing + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 20%; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (extra small) + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 4px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (small) + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 8px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (medium) + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 16px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (large) + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Themed spacing (extra large) + +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 32px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.VerticalAlign.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.VerticalAlign.Example.tsx.shot new file mode 100644 index 0000000000000..bfd283dc33249 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.VerticalAlign.Example.tsx.shot @@ -0,0 +1,489 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.VerticalAlign.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 30px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Top-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Vertically centered + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Bottom-aligned + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 30px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Vertical space around items + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Vertical space between items + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + Items vertically evenly spaced + +
* { + align-items: center; + background: #0078d4; + color: #ffffff; + display: flex; + height: 50px; + justify-content: center; + text-overflow: ellipsis; + white-space: nowrap; + width: 50px; + } + & > *:not(:first-child) { + margin-top: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Wrap.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Wrap.Example.tsx.shot new file mode 100644 index 0000000000000..4a87791ccab0e --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.Wrap.Example.tsx.shot @@ -0,0 +1,343 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.Wrap.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ +
+
+
+ + + +
+
+ +
+
+
+
* { + margin-bottom: 10px; + margin-left: 10px; + margin-right: 10px; + margin-top: 10px; + max-height: calc(100% - 20px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + +
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.WrapAdvanced.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.WrapAdvanced.Example.tsx.shot new file mode 100644 index 0000000000000..43c01b8c28e85 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.WrapAdvanced.Example.tsx.shot @@ -0,0 +1,1353 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.WrapAdvanced.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 0px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
+ +
+
+
+ + + +
+
+ +
+
+
+ +
+ +
+
+
+ + + +
+
+ +
+
+
+
+
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-left: 20px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + +
+ + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+
+
+
* { + margin-bottom: 10px; + margin-left: 10px; + margin-right: 10px; + margin-top: 10px; + max-height: calc(100% - 20px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + +
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.WrapNested.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.WrapNested.Example.tsx.shot new file mode 100644 index 0000000000000..5ddd0e65dc039 --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/Stack.Vertical.WrapNested.Example.tsx.shot @@ -0,0 +1,535 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders Stack.Vertical.WrapNested.Example.tsx correctly 1`] = ` +
* { + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(:first-child) { + margin-top: 10px; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } +> +
+ +
+
+
+ + + +
+
+ +
+
+
+
* { + margin-bottom: 15px; + margin-left: 20px; + margin-right: 20px; + margin-top: 15px; + max-height: calc(100% - 30px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > +
+
* { + margin-bottom: 5px; + margin-left: 15px; + margin-right: 15px; + margin-top: 5px; + max-height: calc(100% - 10px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + +
+
+
+
* { + margin-bottom: 10px; + margin-left: 25px; + margin-right: 25px; + margin-top: 10px; + max-height: calc(100% - 20px); + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + +
+
+
+
* { + margin-bottom: 0px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; + max-height: 100%; + text-overflow: ellipsis; + white-space: nowrap; + } + & > *:not(.ms-StackItem) { + flex-shrink: 0; + } + > + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 7 + + + 8 + + + 9 + + + 10 + +
+
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/index.ts b/packages/office-ui-fabric-react/src/index.ts index c9e3affd8d14a..a7b1a3dd1a0fc 100644 --- a/packages/office-ui-fabric-react/src/index.ts +++ b/packages/office-ui-fabric-react/src/index.ts @@ -66,6 +66,7 @@ export * from './ShimmeredDetailsList'; export * from './Slider'; export * from './SpinButton'; export * from './Spinner'; +export * from './Stack'; export * from './Sticky'; export * from './Styling'; export * from './SwatchColorPicker'; diff --git a/scripts/tasks/codepen-examples-transform.js b/scripts/tasks/codepen-examples-transform.js index 6727bc8268dbf..c5dab53c9b0a9 100644 --- a/scripts/tasks/codepen-examples-transform.js +++ b/scripts/tasks/codepen-examples-transform.js @@ -18,7 +18,7 @@ function parseRaw(code) { const parse = source => babylon.parse(source, { sourceType: 'module', - plugins: ['jsx', 'typescript', 'classProperties'] + plugins: ['jsx', 'typescript', 'classProperties', 'objectRestSpread'] }); return recast.parse(code, { parser: { parse } }).program.body; } @@ -27,7 +27,7 @@ function transform(file, api) { const parse = source => babylon.parse(source, { sourceType: 'module', - plugins: ['jsx', 'typescript', 'classProperties'] + plugins: ['jsx', 'typescript', 'classProperties', 'objectRestSpread'] }); const j = api.jscodeshift; @@ -85,10 +85,12 @@ function transform(file, api) { let exampleName; // remove exports and replace with variable or class declarations, whichever the original example used - source.find(j.ExportNamedDeclaration, node => node.declaration.type == 'VariableDeclaration').replaceWith(p => { - exampleName = p.node.declaration.declarations[0].id.name; - return p.node.declaration; - }); + source + .find(j.ExportNamedDeclaration, node => node.declaration.type == 'VariableDeclaration') + .replaceWith(p => { + exampleName = p.node.declaration.declarations[0].id.name; + return p.node.declaration; + }); source .find(