Skip to content

Commit 17ecfde

Browse files
committed
feat: [Icons] Display a Story with a table for "Icons with text"
1 parent d6346eb commit 17ecfde

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

src/components/Headings/Heading.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export type HeadingType =
1515
interface HeadingProperties extends React.HTMLProps<HTMLHeadingElement> {
1616
/** Heading type (1-6, display, eyebrow, slug) */
1717
type?: HeadingType;
18-
/** Heading content */
19-
children: JSXElement | string;
2018
}
2119

2220
export const Heading = ({

src/components/Icon/Icon.stories.tsx

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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';
34
import {
45
communicationIcons,
56
documentIcons,
@@ -29,6 +30,8 @@ Source: https://cfpb.github.io/design-system/foundation/iconography
2930

3031
export default meta;
3132

33+
type Story = StoryObj<typeof meta>;
34+
3235
const biggerIcon = { fontSize: '2em' };
3336

3437
const makeRows = (names: string[]): JSX.Element[] =>
@@ -105,3 +108,60 @@ export const ExpenseIcons = (): React.ReactElement => (
105108
export const WebApplicationIcons = (): React.ReactElement => (
106109
<IconTable>{makeRows(webIcons)}</IconTable>
107110
);
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

Comments
 (0)