From e8531676814fbc744fb7aae1574bad4521ac35a0 Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Sun, 12 Oct 2025 08:21:46 +0100 Subject: [PATCH] Fix Flex Signed-off-by: Charles de Dreuille --- packages/ui/report.api.md | 2 +- .../ui/src/components/Flex/Flex.stories.tsx | 110 ++++++++++++++---- packages/ui/src/components/Flex/types.ts | 2 +- packages/ui/src/utils/utilityClassMap.ts | 2 +- 4 files changed, 88 insertions(+), 28 deletions(-) diff --git a/packages/ui/report.api.md b/packages/ui/report.api.md index 2d6871f7c8..da143dc5cc 100644 --- a/packages/ui/report.api.md +++ b/packages/ui/report.api.md @@ -835,7 +835,7 @@ export interface FlexProps extends SpaceProps { // (undocumented) align?: Responsive<'start' | 'center' | 'end' | 'baseline' | 'stretch'>; // (undocumented) - children: React.ReactNode; + children?: React.ReactNode; // (undocumented) className?: string; // (undocumented) diff --git a/packages/ui/src/components/Flex/Flex.stories.tsx b/packages/ui/src/components/Flex/Flex.stories.tsx index c7bc814f1b..87854e89c7 100644 --- a/packages/ui/src/components/Flex/Flex.stories.tsx +++ b/packages/ui/src/components/Flex/Flex.stories.tsx @@ -25,20 +25,17 @@ const meta = { argTypes: { align: { control: 'inline-radio', - options: ['left', 'center', 'right'], + options: ['start', 'center', 'end', 'baseline', 'stretch'], }, - children: { - control: false, + justify: { + control: 'inline-radio', + options: ['start', 'center', 'end', 'between'], }, - className: { - control: 'text', + direction: { + control: 'inline-radio', + options: ['row', 'column', 'row-reverse', 'column-reverse'], }, }, - args: { - align: 'stretch', - gap: '4', - children: 'hello world', - }, } satisfies Meta; export default meta; @@ -107,9 +104,13 @@ export const RowDirection: Story = { }, }; -export const AlignStart: Story = { - render: () => ( - +export const AlignStartInColumn: Story = { + args: { + align: 'start', + direction: 'column', + }, + render: args => ( + @@ -117,9 +118,13 @@ export const AlignStart: Story = { ), }; -export const AlignCenter: Story = { - render: () => ( - +export const AlignStartInRow: Story = { + args: { + align: 'start', + direction: 'row', + }, + render: args => ( + @@ -127,9 +132,55 @@ export const AlignCenter: Story = { ), }; -export const AlignEnd: Story = { - render: () => ( - +export const AlignCenterInColumn: Story = { + args: { + align: 'center', + direction: 'column', + }, + render: args => ( + + + + + + ), +}; + +export const AlignCenterInRow: Story = { + args: { + align: 'center', + direction: 'row', + }, + render: args => ( + + + + + + ), +}; + +export const AlignEndInColumn: Story = { + args: { + align: 'end', + direction: 'column', + }, + render: args => ( + + + + + + ), +}; + +export const AlignEndInRow: Story = { + args: { + align: 'end', + direction: 'row', + }, + render: args => ( + @@ -138,8 +189,11 @@ export const AlignEnd: Story = { }; export const ResponsiveAlign: Story = { - render: () => ( - + args: { + align: { xs: 'start', md: 'center', lg: 'end' }, + }, + render: args => ( + @@ -148,8 +202,11 @@ export const ResponsiveAlign: Story = { }; export const ResponsiveGap: Story = { - render: () => ( - + args: { + gap: { xs: '4', md: '8', lg: '12' }, + }, + render: args => ( + @@ -158,8 +215,11 @@ export const ResponsiveGap: Story = { }; export const LargeGap: Story = { - render: () => ( - + args: { + gap: '8', + }, + render: args => ( + diff --git a/packages/ui/src/components/Flex/types.ts b/packages/ui/src/components/Flex/types.ts index b823d579a8..7699e0ddc5 100644 --- a/packages/ui/src/components/Flex/types.ts +++ b/packages/ui/src/components/Flex/types.ts @@ -18,7 +18,7 @@ import type { Responsive, Space, SpaceProps } from '../../types'; /** @public */ export interface FlexProps extends SpaceProps { - children: React.ReactNode; + children?: React.ReactNode; gap?: Responsive; align?: Responsive<'start' | 'center' | 'end' | 'baseline' | 'stretch'>; justify?: Responsive<'start' | 'center' | 'end' | 'between'>; diff --git a/packages/ui/src/utils/utilityClassMap.ts b/packages/ui/src/utils/utilityClassMap.ts index ffcbd48776..261d43632d 100644 --- a/packages/ui/src/utils/utilityClassMap.ts +++ b/packages/ui/src/utils/utilityClassMap.ts @@ -172,7 +172,7 @@ export const utilityClassMap: Record< values: ['start', 'center', 'end', 'baseline', 'stretch'], }, justify: { - class: 'bui-justify', + class: 'bui-jc', values: ['start', 'center', 'end', 'between'], }, direction: {