|
1 |
| -import type { Meta } from '@storybook/react'; |
2 |
| -import { Icon } from '~/src/index'; |
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | +import { Heading, Icon } from '~/src/index'; |
| 3 | +import type { HeadingType } from '../Headings/Heading'; |
3 | 4 | import {
|
4 | 5 | communicationIcons,
|
5 | 6 | documentIcons,
|
@@ -29,6 +30,8 @@ Source: https://cfpb.github.io/design-system/foundation/iconography
|
29 | 30 |
|
30 | 31 | export default meta;
|
31 | 32 |
|
| 33 | +type Story = StoryObj<typeof meta>; |
| 34 | + |
32 | 35 | const biggerIcon = { fontSize: '2em' };
|
33 | 36 |
|
34 | 37 | const makeRows = (names: string[]): JSX.Element[] =>
|
@@ -105,3 +108,60 @@ export const ExpenseIcons = (): React.ReactElement => (
|
105 | 108 | export const WebApplicationIcons = (): React.ReactElement => (
|
106 | 109 | <IconTable>{makeRows(webIcons)}</IconTable>
|
107 | 110 | );
|
| 111 | + |
| 112 | +export const IconWithText: Story = { |
| 113 | + name: 'Icon with text', |
| 114 | + render: () => { |
| 115 | + interface LevelExample { |
| 116 | + type: HeadingType; |
| 117 | + text: string; |
| 118 | + } |
| 119 | + |
| 120 | + const acceptableLevels: LevelExample[] = [ |
| 121 | + { type: '2', text: 'Auto loans' }, |
| 122 | + { type: '3', text: 'Bank accounts' }, |
| 123 | + { type: '4', text: 'Credit cards' }, |
| 124 | + { type: '5', text: 'Submit a complaint' } |
| 125 | + ]; |
| 126 | + |
| 127 | + return ( |
| 128 | + <table> |
| 129 | + <thead> |
| 130 | + <th>Text element</th> |
| 131 | + <th>Icon with background</th> |
| 132 | + <th>Icon without background</th> |
| 133 | + </thead> |
| 134 | + <tbody> |
| 135 | + {acceptableLevels.map(({ type, text }) => ( |
| 136 | + <tr key={type}> |
| 137 | + <td>h{type}</td> |
| 138 | + <td> |
| 139 | + <Heading type={type}> |
| 140 | + <Icon name='credit-card' withBg /> {text} |
| 141 | + </Heading> |
| 142 | + </td> |
| 143 | + <td> |
| 144 | + <Heading type={type}> |
| 145 | + <Icon name='credit-card' /> {text} |
| 146 | + </Heading> |
| 147 | + </td> |
| 148 | + </tr> |
| 149 | + ))} |
| 150 | + <tr> |
| 151 | + <td>p</td> |
| 152 | + <td> |
| 153 | + <p> |
| 154 | + <Icon name='college' withBg /> Student loans |
| 155 | + </p> |
| 156 | + </td> |
| 157 | + <td> |
| 158 | + <p> |
| 159 | + <Icon name='college' /> Student loans |
| 160 | + </p> |
| 161 | + </td> |
| 162 | + </tr> |
| 163 | + </tbody> |
| 164 | + </table> |
| 165 | + ); |
| 166 | + } |
| 167 | +}; |
0 commit comments