From 60224fb0fd0668503920c810172b3547a23bb0be Mon Sep 17 00:00:00 2001 From: MT Lewis Date: Thu, 16 Apr 2026 12:53:40 +0100 Subject: [PATCH] ui: add story for testing flex-item props to Flex storybook Signed-off-by: MT Lewis --- .../ui/src/components/Flex/Flex.stories.tsx | 135 ++++++++++++++++-- 1 file changed, 125 insertions(+), 10 deletions(-) diff --git a/packages/ui/src/components/Flex/Flex.stories.tsx b/packages/ui/src/components/Flex/Flex.stories.tsx index 91d4088004..940c71f272 100644 --- a/packages/ui/src/components/Flex/Flex.stories.tsx +++ b/packages/ui/src/components/Flex/Flex.stories.tsx @@ -16,7 +16,9 @@ import preview from '../../../../../.storybook/preview'; import { Flex } from './Flex'; import { Text } from '../Text'; -import { Box } from '../Box'; +import { Box, BoxProps } from '../Box'; +import { Card, CardHeader, CardBody, CardFooter } from '../Card'; +import { Grid } from '../Grid'; const meta = preview.meta({ title: 'Backstage UI/Flex', @@ -38,13 +40,7 @@ const meta = preview.meta({ args: { children: null }, }); -const DecorativeBox = ({ - width = '48px', - height = '48px', -}: { - width?: string; - height?: string; -}) => { +const DecorativeBox = (props: Omit) => { const diagonalStripePattern = (() => { const svg = ` @@ -58,8 +54,8 @@ const DecorativeBox = ({ return ( ); @@ -199,6 +196,124 @@ export const ResponsiveAlign = meta.story({ ), }); +export const FlexItems = meta.story({ + args: { + component: 'Box', + grow: 1, + shrink: 0, + basis: 'auto', + }, + argTypes: { + component: { + control: { type: 'select' }, + options: ['Box', 'Card', 'Grid', 'Flex'], + mapping: { + Box: props => , + Card: props => ( + + + Header + + + + This is the first paragraph of a long body text that + demonstrates how the Card component handles extensive content. + The card should adjust accordingly to display all the text + properly while maintaining its structure. + + + Here's a second paragraph that adds more content to our card + body. Having multiple paragraphs helps to visualize how spacing + works within the card component. + + + This third paragraph continues to add more text to ensure we + have a proper demonstration of a card with significant content. + This makes it easier to test scrolling behavior and overall + layout when content exceeds the initial view. + + + + Footer + + + ), + Grid: props => ( + + + + + + + + + + + + ), + Flex: props => ( + + + + + + ), + }, + }, + grow: { + control: 'radio', + options: [undefined, 0, 1, false, true], + }, + shrink: { + control: 'radio', + options: [undefined, 0, 1, false, true], + }, + basis: { + control: 'radio', + options: [undefined, '0%', '25%', '50%', '100%', 'auto'], + }, + }, + render: args => { + const Component = args.component; + + return ( + +
+ + + +
+ + ); + }, +}); + export const ResponsiveGap = meta.story({ args: { gap: { xs: '4', md: '8', lg: '12' },