import React from 'react'; import { StoryFn, Meta } from '@storybook/react'; import { BlockSize, BorderStyle, BorderRadius, TextColor, BorderColor, BackgroundColor, Display, AlignItems, JustifyContent, TextAlign, FlexDirection, FlexWrap, } from '../../../helpers/constants/design-system'; import { Text } from '..'; import { Box } from './box'; import README from './README.mdx'; const sizeControlOptions = [ undefined, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ]; const marginSizeControlOptions = [...sizeControlOptions, 'auto']; export default { title: 'Components/ComponentLibrary/Box', component: Box, parameters: { docs: { page: README, }, }, argTypes: { children: { table: { category: 'children' }, }, display: { options: Object.values(Display), control: 'select', table: { category: 'display' }, }, width: { options: Object.values(BlockSize), control: 'multi-select', table: { category: 'display' }, }, height: { options: Object.values(BlockSize), control: 'select', table: { category: 'display' }, }, gap: { control: 'select', options: sizeControlOptions, table: { category: 'display' }, }, backgroundColor: { options: Object.values(BackgroundColor), control: 'select', table: { category: 'background', }, }, color: { options: Object.values(TextColor), control: 'select', table: { category: 'color' }, }, borderStyle: { options: Object.values(BorderStyle), control: 'select', table: { category: 'border' }, }, borderWidth: { options: sizeControlOptions, control: 'select', table: { category: 'border' }, }, borderColor: { options: Object.values(BorderColor), control: 'select', table: { category: 'border' }, }, borderRadius: { options: Object.values(BorderRadius), control: 'select', table: { category: 'border' }, }, flexWrap: { options: Object.values(FlexWrap), control: 'select', table: { category: 'display' }, }, flexDirection: { options: Object.values(FlexDirection), control: 'select', table: { category: 'display' }, }, justifyContent: { options: Object.values(JustifyContent), control: 'select', table: { category: 'display' }, }, alignItems: { options: Object.values(AlignItems), control: 'select', table: { category: 'display' }, }, textAlign: { options: Object.values(TextAlign), control: 'select', table: { category: 'text' }, }, margin: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginTop: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginRight: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginBottom: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginLeft: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginInline: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginInlineStart: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, marginInlineEnd: { options: marginSizeControlOptions, control: 'select', table: { category: 'margin' }, }, padding: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingTop: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingRight: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingBottom: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingLeft: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingInline: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingInlineStart: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, paddingInlineEnd: { options: sizeControlOptions, control: 'select', table: { category: 'padding' }, }, as: { control: 'select', options: ['div', 'ul', 'li', 'span', 'a', 'button'], table: { category: 'as (root html element)' }, }, }, } as Meta; export const BoxDefaultStory: StoryFn = (args) => ; BoxDefaultStory.args = { children: 'Box component', display: Display.Flex, justifyContent: JustifyContent.center, alignItems: AlignItems.center, width: BlockSize.Half, height: BlockSize.Half, borderColor: BorderColor.borderDefault, padding: 4, }; BoxDefaultStory.storyName = 'Default'; export const Margin: StoryFn = (args) => { return ( Static margin Responsive margin changes based on breakpoint ); }; export const Padding: StoryFn = (args) => { return ( Static padding Responsive padding changes based on breakpoint ); }; export const ColorStory: StoryFn = (args) => { return ( <> TextColor.textDefault TextColor.textAlternative TextColor.textMuted TextColor.primaryDefault TextColor.primaryInverse TextColor.errorDefault TextColor.errorInverse TextColor.successDefault TextColor.successInverse TextColor.warningDefault TextColor.warningInverse TextColor.infoDefault TextColor.infoInverse TextColor.inherit TextColor.sepoliaInverse TextColor.goerliInverse ); }; ColorStory.storyName = 'Color'; export const BackgroundColorStory = () => { return ( <> BackgroundColor.backgroundDefault BackgroundColor.backgroundAlternative BackgroundColor.overlayDefault BackgroundColor.primaryDefault BackgroundColor.primaryMuted BackgroundColor.errorDefault BackgroundColor.errorMuted BackgroundColor.successDefault BackgroundColor.successMuted BackgroundColor.warningDefault BackgroundColor.warningMuted BackgroundColor.sepolia BackgroundColor.goerli ); }; BackgroundColorStory.storyName = 'BackgroundColor'; export const BorderColorStory = () => { return ( <> BorderColor.borderDefault BorderColor.borderMuted BorderColor.primaryDefault BorderColor.errorDefault BorderColor.successDefault BorderColor.warningDefault ); }; BorderColorStory.storyName = 'BorderColor'; export const BorderRadiusStory = () => { return ( <> BorderRadius.NONE 0px BorderRadius.XS 2px BorderRadius.SM 4px BorderRadius.MD 6px BorderRadius.LG 8px BorderRadius.XL 12px BorderRadius.pill 9999px BorderRadius.full 50% ); }; BorderRadiusStory.storyName = 'BorderRadius'; export const ResponsiveProps = () => { return ( <> Responsive props example. Stacks vertically on small screens and aligns horizontally on large screens. Padding is also adjusted between small and large screens responsive props example Responsive Border Radius 1 Responsive Border Radius 2 ); }; export const As: StoryFn = (args) => { return ( <> You can change the root element of the Box component using the as prop. Inspect the below elements to see the underlying HTML elements div(default) Box as 'button' tag
Box as 'button' tag and disabled
Box as 'a' tag with href
Box as 'p' tag with href and data-testid
Box as 'p' tag and disabled
Box as 'span' tag (default)
Box as 'p' tag
Box as 'li' tag
Box as 'h1' tag ); }; export const Width: StoryFn = () => { const getColumns = (): JSX.Element[] => { const content: JSX.Element[] = []; for (let i = 0; i < 12; i++) { content.push( , ); } return content; }; return ( <>

Static widths

{getColumns()} BlockSize.Full BlockSize.Half BlockSize.Half BlockSize.OneThird BlockSize.OneThird BlockSize.OneThird BlockSize.OneFourth BlockSize.OneFourth BlockSize.OneFourth BlockSize.OneFourth

Responsive widths

{getColumns()} BlockSize.Full, BlockSize.Half, BlockSize.OneThird, BlockSize.OneFourth, BlockSize.Full, BlockSize.Half, BlockSize.OneThird, BlockSize.OneFourth, BlockSize.Full, BlockSize.Half, BlockSize.OneThird, BlockSize.OneFourth, BlockSize.Full, BlockSize.Half, BlockSize.OneThird, BlockSize.OneFourth, ); };