Skip to content

Commit 85fcafa

Browse files
author
Corey Lafferty
committed
implemented KJs suggestions
1 parent 4759793 commit 85fcafa

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

services/app/source/01-global/duration/duration.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const duration = allVars.reduce((allDurations, [key, value]) => {
2222

2323
const Duration: Story = args => {
2424
return (
25-
<div className={styles['duration']}>
25+
<div className={styles.duration}>
2626
<div className={styles.helptext}>(Hover to demo duration)</div>
2727
<div className={styles.group}>
2828
{Object.entries(args.duration as DurationOptions).map(

services/app/source/01-global/spacing/space.stories.tsx

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ const settings: Meta = {
77

88
const allVars = getCssVariables();
99

10-
const basefontsize = allVars.reduce((BaseFontSize, [key, value]) => {
11-
if (key.indexOf('--base-font-size') === 0) {
12-
BaseFontSize = value;
13-
}
14-
return BaseFontSize;
15-
}, {} as string);
10+
const baseFontVar = allVars.find(
11+
([key]) => key.indexOf('--base-font-size') === 0,
12+
);
13+
const baseFontSize = baseFontVar ? parseInt(baseFontVar[1]) : 16;
1614

1715
interface SpacingOptions {
1816
[space: string]: string;
@@ -23,8 +21,6 @@ const spacing = allVars.reduce((allSpacing, [key, value]) => {
2321
let space = key.substring(10);
2422
if (space.includes('-')) {
2523
space = space.replace('-', '.');
26-
} else {
27-
space = space + '.0';
2824
}
2925
allSpacing[space] = value;
3026
}
@@ -43,26 +39,27 @@ const Spacing: Story = args => {
4339
</tr>
4440
</thead>
4541
<tbody>
46-
{Object.entries(args.spacing as SpacingOptions).map(([name, unit]) => (
47-
<tr key={`spacing-${name}`}>
48-
<td>{name.replace('.0', '')}</td>
49-
<td>
50-
{Number(unit.replace('px', '')) /
51-
Number(basefontsize.replace('px', ''))}
52-
rem
53-
</td>
54-
<td>{unit}</td>
55-
<td>
56-
<div
57-
style={{
58-
height: unit,
59-
width: unit,
60-
backgroundColor: '#ccc',
61-
}}
62-
></div>
63-
</td>
64-
</tr>
65-
))}
42+
{Object.entries(args.spacing as SpacingOptions)
43+
.sort(([keyA], [keyB]) => Number(keyA) - Number(keyB))
44+
.map(([name, unit]) => (
45+
<tr key={`spacing-${name}`}>
46+
<td>{name}</td>
47+
<td>
48+
{parseInt(unit) / baseFontSize}
49+
rem
50+
</td>
51+
<td>{unit}</td>
52+
<td>
53+
<div
54+
style={{
55+
height: unit,
56+
width: unit,
57+
backgroundColor: '#ccc',
58+
}}
59+
></div>
60+
</td>
61+
</tr>
62+
))}
6663
</tbody>
6764
</table>
6865
);

0 commit comments

Comments
 (0)