Skip to content

Commit b3225ad

Browse files
committed
fix: Apply 1   worth of margin between icon/text
1 parent f079d10 commit b3225ad

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

src/components/Icon/Icon.less

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Calculation methodology
2+
// https://github.com/cfpb/design-stories/issues/130#issuecomment-1670396537
3+
@width-of-1-nbsp: 0.3098125em;
4+
5+
.u-icon-before-text .cf-icon-svg-wrapper {
6+
margin-right: @width-of-1-nbsp;
7+
}
8+
9+
.u-icon-after-text .cf-icon-svg-wrapper {
10+
margin-left: @width-of-1-nbsp;
11+
}
12+
13+
.t-icon-with-text {
14+
width: 100%;
15+
}

src/components/Icon/Icon.stories.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ export const IconWithText = (): React.ReactElement => {
7575
const elements = ['h1', 'h2', 'h3', 'h4', 'h5', 'p', 'a'];
7676

7777
return (
78-
<table>
78+
<table className='t-icon-with-text'>
7979
<thead>
8080
<tr>
8181
<th>Element</th>
8282
<th>Plain Icon</th>
83-
<th>Plain Icon Left</th>
8483
<th>Round Icon</th>
85-
<th>Round Icon Left</th>
8684
<th>Square Icon</th>
85+
<th>Plain Icon Left</th>
86+
<th>Round Icon Left</th>
8787
<th>Square Icon Left</th>
8888
</tr>
8989
</thead>
@@ -95,44 +95,49 @@ export const IconWithText = (): React.ReactElement => {
9595
<tr key={element}>
9696
<td>{element}</td>
9797
<td>
98-
<DynamicTag>
98+
<DynamicTag className='u-icon-after-text'>
9999
{element} text
100100
<Icon name='email' />
101101
</DynamicTag>
102102
</td>
103+
103104
<td>
104-
<DynamicTag>
105-
<Icon name='email' />
105+
<DynamicTag className='u-icon-after-text'>
106106
{element} text
107+
<Icon name='zero' withBg />
107108
</DynamicTag>
108109
</td>
110+
109111
<td>
110-
<DynamicTag>
112+
<DynamicTag className='u-icon-after-text'>
111113
{element} text
112-
<Icon name='zero' withBg />
114+
<Icon name='facebook' withBg />
113115
</DynamicTag>
114116
</td>
115117
<td>
116-
<DynamicTag>
117-
<Icon name='zero' withBg />
118+
<DynamicTag className='u-icon-before-text'>
119+
<Icon name='email' />
118120
{element} text
119121
</DynamicTag>
120122
</td>
121123
<td>
122-
<DynamicTag>
123-
<Icon name='facebook' withBg />
124+
<DynamicTag className='u-icon-before-text'>
125+
<Icon name='zero' withBg />
124126
{element} text
125127
</DynamicTag>
126128
</td>
127129
<td>
128-
<DynamicTag>
129-
{element} text
130+
<DynamicTag className='u-icon-before-text'>
130131
<Icon name='facebook' withBg />
132+
{element} text
131133
</DynamicTag>
132134
</td>
133135
</tr>
134136
);
135137
})}
138+
<tr>
139+
<td>test space</td>
140+
</tr>
136141
</tbody>
137142
</table>
138143
);

src/components/Icon/Icon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import classNames from 'classnames';
22
import { useIconSvg } from '../../hooks/useIconSvg';
33
import { numberIcons } from './iconLists';
44

5+
import './Icon.less';
6+
57
// Design System font sizes for HTML elements
68
const sizeMap: Record<string, string> = {
79
h1: '34px',

0 commit comments

Comments
 (0)