Skip to content

Commit

Permalink
Docs(web-react): Add Stack demo #DS-908
Browse files Browse the repository at this point in the history
- Stack demo in web-react is now same as demo in web and web-twig
  • Loading branch information
pavelklibani committed Sep 16, 2023
1 parent 4e1b5eb commit ac1e9aa
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/web-react/docs/DocsSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DocsStack from './DocsStack';
interface DocsSectionProps {
children: ReactNode;
hasStack?: boolean;
stackAlignment?: 'start' | 'center' | 'end';
stackAlignment?: 'start' | 'center' | 'end' | 'stretch';
tag?: string;
title: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-react/docs/DocsStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';

interface DocsStackProps {
children: ReactNode;
stackAlignment?: 'start' | 'center' | 'end';
stackAlignment?: 'start' | 'center' | 'end' | 'stretch';
}

const DocsStack = ({ children, stackAlignment }: DocsStackProps) => {
Expand Down
29 changes: 0 additions & 29 deletions packages/web-react/src/components/Stack/demo/Stack.tsx

This file was deleted.

15 changes: 15 additions & 0 deletions packages/web-react/src/components/Stack/demo/StackBlocks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocks = () => (
<Stack elementType="ul">
{[1, 2, 3].map((i) => (
<li key={i}>
<DocsBox>Block {i}</DocsBox>
</li>
))}
</Stack>
);

export default StackBlocks;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithInnerAndOuterDividersAndVerticalSpacing = () => {
return (
<Stack elementType="ul" hasSpacing hasIntermediateDividers hasStartDivider hasEndDivider>
{[1, 2, 3].map((i) => (
<li key={i}>
<DocsBox>Block {i}</DocsBox>
</li>
))}
</Stack>
);
};

export default StackBlocksWithInnerAndOuterDividersAndVerticalSpacing;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithInnerDividersAndVerticalSpacing = () => {
return (
<Stack elementType="ul" hasSpacing hasIntermediateDividers>
{[1, 2, 3].map((i) => (
<li key={i}>
<DocsBox>Block {i}</DocsBox>
</li>
))}
</Stack>
);
};

export default StackBlocksWithInnerDividersAndVerticalSpacing;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithInnerDividersWithoutVerticalSpacing = () => {
return (
<Stack elementType="ul" hasIntermediateDividers>
{[1, 2, 3].map((i) => (
<li key={i}>
<DocsBox>Block {i}</DocsBox>
</li>
))}
</Stack>
);
};

export default StackBlocksWithInnerDividersWithoutVerticalSpacing;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithVerticalSpacing = () => (
<Stack elementType="ul" hasSpacing>
{[1, 2, 3].map((i) => (
<li key={i}>
<DocsBox>Block {i}</DocsBox>
</li>
))}
</Stack>
);

export default StackBlocksWithVerticalSpacing;
14 changes: 14 additions & 0 deletions packages/web-react/src/components/Stack/demo/StackFormFields.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import Stack from '../Stack';
import { TextField } from '../../TextField';

const StackFormFields = () => {
return (
<Stack hasSpacing>
<TextField id="textfieldStack1" label="Label" name="textfieldStack1" placeholder="Placeholder" isRequired />
<TextField id="textfieldStack2" label="Label" name="textfieldStack2" placeholder="Placeholder" isRequired />
</Stack>
);
};

export default StackFormFields;
34 changes: 24 additions & 10 deletions packages/web-react/src/components/Stack/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@
/* eslint-disable import/no-extraneous-dependencies, import/extensions, import/no-unresolved */
import React from 'react';
import ReactDOM from 'react-dom/client';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, import/extensions, import/no-unresolved
// @ts-ignore: No declaration file
import icons from '@lmc-eu/spirit-icons/dist/icons';
import { IconsProvider } from '../../../context';
import DocsSection from '../../../../docs/DocsSections';
import Stack from './Stack';
import StackFormFields from './StackFormFields';
import StackBlocks from './StackBlocks';
import StackBlocksWithVerticalSpacing from './StackBlocksWithVerticalSpacing';
import StackBlocksWithInnerDividersAndVerticalSpacing from './StackBlocksWithInnerDividersAndVerticalSpacing';
import StackBlocksWithInnerAndOuterDividersAndVerticalSpacing from './StackBlocksWithInnerAndOuterDividersAndVerticalSpacing';
import StackBlocksWithInnerDividersWithoutVerticalSpacing from './StackBlocksWithInnerDividersWithoutVerticalSpacing';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<IconsProvider value={icons}>
<DocsSection title="Default">
<Stack {...Stack.args} />
</DocsSection>
</IconsProvider>
<DocsSection title="Stacked Form Fields" stackAlignment="stretch">
<StackFormFields />
</DocsSection>
<DocsSection title="Stacked Blocks" stackAlignment="stretch">
<StackBlocks />
</DocsSection>
<DocsSection title="Stacked Blocks with Vertical Spacing" stackAlignment="stretch">
<StackBlocksWithVerticalSpacing />
</DocsSection>
<DocsSection title="Stacked Blocks with Inner Dividers and Vertical Spacing" stackAlignment="stretch">
<StackBlocksWithInnerDividersAndVerticalSpacing />
</DocsSection>
<DocsSection title="Stacked Blocks with Inner and Outer Dividers and Vertical Spacing" stackAlignment="stretch">
<StackBlocksWithInnerAndOuterDividersAndVerticalSpacing />
</DocsSection>
<DocsSection title="Stacked Blocks with Inner Dividers without Vertical Spacing" stackAlignment="stretch">
<StackBlocksWithInnerDividersWithoutVerticalSpacing />
</DocsSection>
</React.StrictMode>,
);

0 comments on commit ac1e9aa

Please sign in to comment.