import * as React from "react"; import { greyLight, themeBrandPrimary } from "../../../design-tokens/build/js/designTokens"; import Box, { BoxProps } from "../components/Box"; import { css } from "@emotion/css"; import { Story, Meta } from "@storybook/react"; import { cssDisplayPropertyValues, textAlignValues, vertAlignValues } from "../../../storybookHelpers/controlConstants"; export default { title: "Style Utilities/Box", component: Box, argTypes: { bgColor: { control: { type: "color" } }, bgImageUrl: { control: { type: "text" } }, display: { options: cssDisplayPropertyValues, control: { type: "select" } }, textAlign: { options: textAlignValues, control: { type: "select" } }, vertAlignChildren: { options: vertAlignValues, control: { type: "radio" } }, isVisuallyHidden: { options: [true, false], control: { type: "boolean" } }, className: { control: { disable: true } }, "data-cy": { control: { disable: true } } }, args: { bgImageUrl: "", bgImageOptions: {}, isVisuallyHidden: false } } as Meta; const setHeight = css` > * { height: 200px; } `; const Template: Story = args => { const setBorder = css` border: 2px solid ${themeBrandPrimary}; `; return (
Child 1
Child 2
Child 3
); }; export const Default = Template.bind({}); Default.args = { bgColor: greyLight, textAlign: "center" }; export const BackgroundImage = Template.bind({}); BackgroundImage.args = { bgImageUrl: "https://via.placeholder.com/150" }; export const BackgroundImageWithOptions: Story = args => { const bgOptions = `{\n\t"position": "top-left",\n\t"repeat": "repeat-x",\n\t"size": "contain"\n}`; return (

Options:

{bgOptions}
); }; BackgroundImageWithOptions.args = { bgImageUrl: "https://via.placeholder.com/150", bgImageOptions: { size: "contain", repeat: "repeat-x", position: "top-left" } }; BackgroundImageWithOptions.parameters = { controls: { exclude: ["vertAlignChildren", "textAlign", "bgColor", "display"] } }; export const DisplayInline: Story = args => ( <> Box 1 Box 2 Box 3 ); DisplayInline.args = { display: "inline" }; DisplayInline.parameters = { controls: { exclude: ["vertAlignChildren", "textAlign"] } }; export const VerticalAlignChildren: Story = args => (

Use the Control panel to try other alignments.

Child 1
Child 2
Child 3
); VerticalAlignChildren.parameters = { controls: { exclude: ["display"] } }; export const CustomTag = args => (
{`This is rendered using a
tag`}
);