import React from 'react';
import {
DISPLAY,
BackgroundColor,
BorderColor,
FONT_WEIGHT,
FONT_STYLE,
TextColor,
TEXT_ALIGN,
OVERFLOW_WRAP,
TEXT_TRANSFORM,
FRACTIONS,
FLEX_DIRECTION,
TextVariant,
Color,
} from '../../../helpers/constants/design-system';
import Box from '../../ui/box';
import { ValidTags, Text } from './text';
import { TEXT_DIRECTIONS } from './text.constants';
import README from './README.mdx';
const sizeKnobOptions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
const marginSizeKnobOptions = [...sizeKnobOptions, 'auto'];
export default {
title: 'Components/ComponentLibrary/Text',
parameters: {
docs: {
page: README,
},
},
argTypes: {
variant: {
control: { type: 'select' },
options: Object.values(TextVariant),
},
color: {
control: { type: 'select' },
options: Object.values(TextColor),
},
fontWeight: {
control: { type: 'select' },
options: Object.values(FONT_WEIGHT),
},
fontStyle: {
control: { type: 'select' },
options: Object.values(FONT_STYLE),
},
textTransform: {
control: { type: 'select' },
options: Object.values(TEXT_TRANSFORM),
},
align: {
control: { type: 'select' },
options: Object.values(TEXT_ALIGN),
},
overflowWrap: {
control: { type: 'select' },
options: Object.values(OVERFLOW_WRAP),
},
ellipsis: {
control: { type: 'boolean' },
},
as: {
control: { type: 'select' },
options: ValidTags,
},
textDirection: {
control: { type: 'select' },
options: Object.values(TEXT_DIRECTIONS),
},
className: {
control: { type: 'text' },
},
children: {
control: { type: 'text' },
},
display: {
options: Object.values(DISPLAY),
control: 'select',
table: { category: 'box props' },
},
backgroundColor: {
options: Object.values(BackgroundColor),
control: 'select',
table: { category: 'box props' },
},
borderColor: {
options: Object.values(BorderColor),
control: 'select',
table: { category: 'box props' },
},
padding: {
options: sizeKnobOptions,
control: 'select',
table: { category: 'box props' },
},
margin: {
options: marginSizeKnobOptions,
control: 'select',
table: { category: 'box props' },
},
marginTop: {
options: marginSizeKnobOptions,
control: 'select',
table: { category: 'box props' },
},
marginRight: {
options: marginSizeKnobOptions,
control: 'select',
table: { category: 'box props' },
},
marginBottom: {
options: marginSizeKnobOptions,
control: 'select',
table: { category: 'box props' },
},
marginLeft: {
options: marginSizeKnobOptions,
control: 'select',
table: { category: 'box props' },
},
},
};
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;
default:
bgColor = null;
break;
}
return bgColor;
}
export const DefaultStory = (args) =>