Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs(web-react, web): Add Stack demo #DS-908 #1066

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,15 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithInnerAndOuterDividersAndVerticalSpacing = () => (
<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,15 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithInnerDividersAndVerticalSpacing = () => (
<Stack elementType="ul" hasSpacing hasIntermediateDividers>
{[1, 2, 3].map((i) => (
pavelklibani marked this conversation as resolved.
Show resolved Hide resolved
<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,15 @@
import React from 'react';
import DocsBox from '../../../../docs/DocsBox';
import Stack from '../Stack';

const StackBlocksWithInnerDividersWithoutVerticalSpacing = () => (
<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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import Stack from '../Stack';
import { TextField } from '../../TextField';

const StackFormFields = () => (
<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>,
);
Loading