|
| 1 | +import { IconButton, Flex, Icon } from "@chakra-ui/react" |
| 2 | +import { Fragment } from 'react'; |
| 3 | +import { Canvas, Meta, Story } from "@storybook/addon-docs" |
| 4 | +import { MagnifyingGlass } from '@phosphor-icons/react' |
| 5 | + |
| 6 | +import { buttonArgTypes } from "./controls" |
| 7 | + |
| 8 | +<Meta title="Atoms/Icon Buttons" component={IconButton} /> |
| 9 | + |
| 10 | +export const Template = (args) => { return (<Flex gap="1rem"> |
| 11 | +<IconButton size="icon-sm" {...args} icon={<Icon width="1.25rem" height="1.25rem" as={MagnifyingGlass} />} /> |
| 12 | +<IconButton size="icon-md" {...args} icon={<Icon width="1.5rem" height="1.5rem" as={MagnifyingGlass} />} /> |
| 13 | +<IconButton size="icon-lg" {...args} icon={<Icon width="2rem" height="2rem" as={MagnifyingGlass} />} /> |
| 14 | +</Flex>)} |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +```ts |
| 19 | +import { IconButton, Icon } from '@chakra-ui/react' |
| 20 | +import { MagnifyingGlass } from '@phosphor-icons/react' |
| 21 | + |
| 22 | +function SomeComponentWithSecondaryActionHandledByIconButton() { |
| 23 | + return ( |
| 24 | + <> |
| 25 | + <IconButton size="icon-sm" variant="primary" icon={<Icon width="1.25rem" height="1.25rem" as={MagnifyingGlass} />} /> |
| 26 | + <IconButton size="icon-md" variant="secondary" icon={<Icon width="1.5rem" height="1.5rem" as={MagnifyingGlass} />} /> |
| 27 | + <IconButton size="icon-lg" variant="tertiary" icon={<Icon width="2rem" height="2rem" as={MagnifyingGlass} />} /> |
| 28 | + </> |
| 29 | + ); |
| 30 | +} |
| 31 | +``` |
| 32 | +
|
| 33 | +
|
| 34 | +
|
| 35 | +## Types of Buttons |
| 36 | +
|
| 37 | +#### Primary |
| 38 | +
|
| 39 | +<ul> |
| 40 | + <li>Used for the most important action on the page.</li> |
| 41 | + <li>Solid color buttons based on the primary brand color. </li> |
| 42 | +</ul> |
| 43 | +
|
| 44 | +<Canvas> |
| 45 | + <Story |
| 46 | + name="PrimaryIconButton" |
| 47 | + argTypes={buttonArgTypes} |
| 48 | + args={{ |
| 49 | + variant: "primary", |
| 50 | + }} |
| 51 | + > |
| 52 | + {Template.bind({})} |
| 53 | + </Story> |
| 54 | +</Canvas> |
| 55 | +
|
| 56 | +#### Secondary |
| 57 | +
|
| 58 | +<ul> |
| 59 | + <li>Used for the second most important action on the page. </li> |
| 60 | + <li> |
| 61 | + These are also solid color buttons however the secondary buttons use a muted color palette. |
| 62 | + </li> |
| 63 | +</ul> |
| 64 | +
|
| 65 | +<Canvas> |
| 66 | + <Story |
| 67 | + name="SecondaryIconButton" |
| 68 | + argTypes={buttonArgTypes} |
| 69 | + args={{ |
| 70 | + variant: "secondary", |
| 71 | + }} |
| 72 | + > |
| 73 | + {Template.bind({})} |
| 74 | + </Story> |
| 75 | +</Canvas> |
| 76 | +
|
| 77 | +#### Tertiary |
| 78 | +
|
| 79 | +<ul> |
| 80 | + <li> |
| 81 | + Tertiary buttons are outlined versions of the Primary buttons and should be used for in page |
| 82 | + actions like filtering.{" "} |
| 83 | + </li> |
| 84 | +</ul> |
| 85 | +
|
| 86 | +<Canvas> |
| 87 | + <Story |
| 88 | + name="TertiaryIconButton" |
| 89 | + argTypes={buttonArgTypes} |
| 90 | + args={{ |
| 91 | + variant: "tertiary", |
| 92 | + }} |
| 93 | + > |
| 94 | + {Template.bind({})} |
| 95 | + </Story> |
| 96 | +</Canvas> |
0 commit comments