From bddb8420c365ad25c807f2ae4127371f7f65cb94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kry=C5=A1p=C3=ADn?= Date: Tue, 3 Dec 2024 17:42:54 +0100 Subject: [PATCH] Docs(web-react): Move Container into DocsSection using `container` enum prop This way the Container can be optional - see Footer, Header & Container demos. This allows us to create nice demos for full width components. --- .../partials/web-react/layout/default.hbs | 2 -- packages/web-react/docs/DocsSections.tsx | 34 +++++++++++++------ .../Button/demo/ButtonDemoFactory.tsx | 2 +- .../ButtonLink/demo/ButtonLinkDemoFactory.tsx | 2 +- .../Container/demo/ContainerDefault.tsx | 7 +++- .../src/components/Container/demo/index.tsx | 2 +- .../src/components/Footer/demo/index.tsx | 4 +-- .../src/components/Header/demo/index.tsx | 10 +++--- .../src/components/Tag/demo/TagDefault.tsx | 2 +- 9 files changed, 40 insertions(+), 25 deletions(-) diff --git a/apps/demo/partials/web-react/layout/default.hbs b/apps/demo/partials/web-react/layout/default.hbs index 55085376b6..35e5f9a0bc 100644 --- a/apps/demo/partials/web-react/layout/default.hbs +++ b/apps/demo/partials/web-react/layout/default.hbs @@ -8,11 +8,9 @@ {{> cover}}
-
{{> @partial-block }} -
{{> footer}} diff --git a/packages/web-react/docs/DocsSections.tsx b/packages/web-react/docs/DocsSections.tsx index 6deaba1b04..d709a503ad 100644 --- a/packages/web-react/docs/DocsSections.tsx +++ b/packages/web-react/docs/DocsSections.tsx @@ -1,9 +1,10 @@ import React, { ReactNode } from 'react'; -import { StyleProps, Tag, useStyleProps } from '../src'; +import { Container, StyleProps, Tag, useStyleProps } from '../src'; import DocsStack from './DocsStack'; interface DocsSectionProps extends StyleProps { children: ReactNode; + container?: 'none' | 'all' | 'heading-only'; hasStack?: boolean; stackAlignment?: 'start' | 'center' | 'end' | 'stretch'; tag?: string; @@ -11,6 +12,7 @@ interface DocsSectionProps extends StyleProps { } const defaultProps: Partial = { + container: 'all', hasStack: true, stackAlignment: 'start', tag: '', @@ -18,20 +20,30 @@ const defaultProps: Partial = { const DocsSection = (props: DocsSectionProps) => { const propsWithDefaults = { ...defaultProps, ...props }; - const { children, hasStack = true, stackAlignment = 'start', title, tag, ...restProps } = propsWithDefaults; + const { children, container, hasStack, stackAlignment, title, tag, ...restProps } = propsWithDefaults; const { styleProps, props: transferProps } = useStyleProps(restProps); + const heading = ( +

+ {title} + {tag && ( + + {tag} + + )} +

+ ); + + const content = ( + <> + {container === 'heading-only' ? {heading} : heading} + {hasStack ? {children} : children} + + ); + return (
-

- {title} - {tag && ( - - {tag} - - )} -

- {hasStack ? {children} : children} + {container === 'all' ? {content} : content}
); }; diff --git a/packages/web-react/src/components/Button/demo/ButtonDemoFactory.tsx b/packages/web-react/src/components/Button/demo/ButtonDemoFactory.tsx index 1874a9a31f..78de71c589 100644 --- a/packages/web-react/src/components/Button/demo/ButtonDemoFactory.tsx +++ b/packages/web-react/src/components/Button/demo/ButtonDemoFactory.tsx @@ -14,7 +14,7 @@ const ButtonDemoFactory = ({ ...props }: ButtonBaseProps) => { return ( <> {sizes.map((size) => ( - + {colors.map((color) => (