import React from 'react'; import { StoryFn, Meta } from '@storybook/react'; import { Display, BackgroundColor, BorderColor, FontWeight, FontStyle, TextColor, TextAlign, OverflowWrap, TextTransform, BlockSize, FlexDirection, TextVariant, Color, } from '../../../helpers/constants/design-system'; import { Box } from '..'; import README from './README.mdx'; import { Text } from './text'; import { TextDirection } from './text.types'; export default { title: 'Components/ComponentLibrary/Text', component: Text, parameters: { docs: { page: README, }, }, } as Meta; function renderBackgroundColor(color) { let bgColor; switch (color) { case Color.overlayInverse: bgColor = BackgroundColor.overlayDefault; break; case Color.primaryInverse: bgColor = BackgroundColor.primaryDefault; break; case Color.errorInverse: bgColor = BackgroundColor.errorDefault; break; case Color.warningInverse: bgColor = BackgroundColor.warningDefault; break; case Color.successInverse: bgColor = BackgroundColor.successDefault; break; case Color.infoInverse: bgColor = BackgroundColor.infoDefault; break; case Color.goerliInverse: bgColor = BackgroundColor.goerli; break; case Color.sepoliaInverse: bgColor = BackgroundColor.sepolia; break; case Color.lineaGoerliInverse: bgColor = BackgroundColor.lineaGoerli; break; case Color.lineaMainnetInverse: bgColor = BackgroundColor.lineaMainnet; break; default: bgColor = null; break; } return bgColor; } const Template: StoryFn = (args) => ( {args.children} ); export const DefaultStory = Template.bind({}); DefaultStory.args = { children: 'The quick orange fox jumped over the lazy dog.', }; DefaultStory.storyName = 'Default'; export const Variant = (args) => ( <> {Object.values(TextVariant).map((variant) => ( {args.children || variant} ))} ); export const ColorStory: StoryFn = (args) => { // Index of last valid color in TextColor array return ( <> {Object.values(TextColor).map((color) => { return ( {color} ); })} ); }; ColorStory.storyName = 'Color'; export const FontWeightStory: StoryFn = (args) => ( <> {Object.values(FontWeight).map((weight) => ( {weight} ))} ); FontWeightStory.storyName = 'Font Weight'; export const FontStyleStory: StoryFn = (args) => ( <> {Object.values(FontStyle).map((style) => ( {style} ))} ); FontStyleStory.storyName = 'Font Style'; export const TextTransformStory: StoryFn = (args) => ( <> {Object.values(TextTransform).map((transform) => ( {transform} ))} ); TextTransformStory.storyName = 'Text Transform'; export const TextAlignStory: StoryFn = (args) => ( <> {Object.values(TextAlign).map((align) => ( {align} ))} ); TextAlignStory.storyName = 'Text Align'; export const OverflowWrapStory: StoryFn = (args) => ( {OverflowWrap.Normal}: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d {OverflowWrap.BreakWord}: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d ); OverflowWrapStory.storyName = 'Overflow Wrap'; export const Ellipsis: StoryFn = (args) => ( Ellipsis: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d No Ellipsis: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d ); export const As: StoryFn = (args) => ( <> dd div dt em h1 h2 h3 h4 h5 h6 li p span strong ul label header ); export const TextDirectionStory: StoryFn = (args) => ( This is left to right (ltr) for English and most languages This is right to left (rtl) for use with other laguanges such as Arabic. This Enlgish example is incorrect usage. Let the user agent decide with the auto option ); export const Strong: StoryFn = (args) => ( <> Text as="strong" tag This is a strong tag as a child inside of Text );