Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/components/Icon/Icon.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Calculation methodology
// https://github.com/cfpb/design-stories/issues/130#issuecomment-1670396537
@width-of-1-nbsp: 0.3098125em;

.u-icon-before-text .cf-icon-svg-wrapper {
margin-right: @width-of-1-nbsp;
}

.u-icon-after-text .cf-icon-svg-wrapper {
margin-left: @width-of-1-nbsp;
}

.t-icon-with-text {
width: 100%;
}
50 changes: 50 additions & 0 deletions src/components/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,56 @@ export const IconWithBackground = (): React.ReactElement => (
</span>
);

export const IconWithText = (): React.ReactElement => {
const elements = ['h1', 'h2', 'h3', 'h4', 'h5', 'p', 'a'];

return (
<table className='t-icon-with-text'>
<thead>
<tr>
<th>Element</th>
<th>Text + Icon</th>
<th>Icon + Text</th>
<th>Round Icon + Text</th>
</tr>
</thead>
<tbody>
{elements.map(element => {
const DynamicTag = element;

return (
<tr key={element}>
<td>{element}</td>
<td>
<DynamicTag className='u-icon-after-text'>
{element} text
<Icon name='email' />
</DynamicTag>
</td>

<td>
<DynamicTag className='u-icon-before-text'>
<Icon name='email' />
{element} text
</DynamicTag>
</td>
<td>
<DynamicTag className='u-icon-before-text'>
<Icon name='zero' withBg />
{element} text
</DynamicTag>
</td>
</tr>
);
})}
<tr>
<td>test space</td>
</tr>
</tbody>
</table>
);
};

export const NavigationIcons = (): React.ReactElement => (
<IconTable>{makeRows(navigationIcons)}</IconTable>
);
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import classNames from 'classnames';
import { useIconSvg } from '../../hooks/useIconSvg';
import { numberIcons } from './iconLists';

import './Icon.less';

// Design System font sizes for HTML elements
const sizeMap: Record<string, string> = {
h1: '34px',
Expand Down