Skip to content

Commit f7d4553

Browse files
connor-baerGuyLivni
authored andcommitted
Make font sizes responsive (#235)
* Add responsive font sizes for Text * Use knobs for Heading, SubHeading and Text * Update snapshots * Add responsive styles for Text and Heading * Change responsiveMap name to mobileSizeMap
1 parent 0a7dfb3 commit f7d4553

File tree

11 files changed

+326
-98
lines changed

11 files changed

+326
-98
lines changed

src/components/Blockquote/__snapshots__/Blockquote.spec.js.snap

+23-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ exports[`Blockquote should render with default styles 1`] = `
1111
border-left: 2px solid #3388FF;
1212
}
1313
14+
@media (min-width:480px) {
15+
.circuit-1 {
16+
font-size: 13px;
17+
line-height: 20px;
18+
}
19+
}
20+
1421
<blockquote
1522
className="circuit-0 circuit-1 circuit-2"
1623
>
@@ -26,15 +33,22 @@ exports[`Blockquote should render with giga styles 1`] = `
2633
.circuit-1 {
2734
font-weight: 400;
2835
margin-bottom: 16px;
29-
font-size: 18px;
30-
line-height: 28px;
36+
font-size: 15px;
37+
line-height: 24px;
3138
font-style: italic;
3239
padding-left: 12px;
3340
border-left: 2px solid #3388FF;
3441
padding-left: 16px;
3542
border-left: 3px solid #3388FF;
3643
}
3744
45+
@media (min-width:480px) {
46+
.circuit-1 {
47+
font-size: 18px;
48+
line-height: 28px;
49+
}
50+
}
51+
3852
<blockquote
3953
className="circuit-0 circuit-1 circuit-2"
4054
>
@@ -57,6 +71,13 @@ exports[`Blockquote should render with mega styles 1`] = `
5771
border-left: 2px solid #3388FF;
5872
}
5973
74+
@media (min-width:480px) {
75+
.circuit-1 {
76+
font-size: 15px;
77+
line-height: 24px;
78+
}
79+
}
80+
6081
<blockquote
6182
className="circuit-0 circuit-1 circuit-2"
6283
>

src/components/Button/components/PlainButton/__snapshots__/PlainButton.spec.js.snap

+44-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ exports[`PlainButton should have giga link styles 1`] = `
44
.circuit-0 {
55
font-weight: 400;
66
margin-bottom: 16px;
7-
font-size: 18px;
8-
line-height: 28px;
7+
font-size: 15px;
8+
line-height: 24px;
99
margin-bottom: 0;
1010
box-shadow: none;
1111
border: none;
@@ -17,6 +17,13 @@ exports[`PlainButton should have giga link styles 1`] = `
1717
outline: none;
1818
}
1919
20+
@media (min-width:480px) {
21+
.circuit-0 {
22+
font-size: 18px;
23+
line-height: 28px;
24+
}
25+
}
26+
2027
.circuit-0:hover {
2128
-webkit-text-decoration: underline;
2229
text-decoration: underline;
@@ -53,6 +60,13 @@ exports[`PlainButton should have kilo link styles 1`] = `
5360
outline: none;
5461
}
5562
63+
@media (min-width:480px) {
64+
.circuit-0 {
65+
font-size: 13px;
66+
line-height: 20px;
67+
}
68+
}
69+
5670
.circuit-0:hover {
5771
-webkit-text-decoration: underline;
5872
text-decoration: underline;
@@ -89,6 +103,13 @@ exports[`PlainButton should have mega link styles 1`] = `
89103
outline: none;
90104
}
91105
106+
@media (min-width:480px) {
107+
.circuit-0 {
108+
font-size: 15px;
109+
line-height: 24px;
110+
}
111+
}
112+
92113
.circuit-0:hover {
93114
-webkit-text-decoration: underline;
94115
text-decoration: underline;
@@ -126,6 +147,13 @@ exports[`PlainButton should have primary styles 1`] = `
126147
color: #3388FF;
127148
}
128149
150+
@media (min-width:480px) {
151+
.circuit-0 {
152+
font-size: 15px;
153+
line-height: 24px;
154+
}
155+
}
156+
129157
.circuit-0:hover {
130158
-webkit-text-decoration: underline;
131159
text-decoration: underline;
@@ -166,6 +194,13 @@ exports[`PlainButton should render with default styles 1`] = `
166194
outline: none;
167195
}
168196
197+
@media (min-width:480px) {
198+
.circuit-0 {
199+
font-size: 15px;
200+
line-height: 24px;
201+
}
202+
}
203+
169204
.circuit-0:hover {
170205
-webkit-text-decoration: underline;
171206
text-decoration: underline;
@@ -202,6 +237,13 @@ exports[`PlainButton should render with href 1`] = `
202237
outline: none;
203238
}
204239
240+
@media (min-width:480px) {
241+
.circuit-0 {
242+
font-size: 15px;
243+
line-height: 24px;
244+
}
245+
}
246+
205247
.circuit-0:hover {
206248
-webkit-text-decoration: underline;
207249
text-decoration: underline;

src/components/Heading/Heading.js

+22-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,33 @@ import { sizes } from '../../styles/constants';
88

99
const { KILO, MEGA, GIGA, TERA, PETA, EXA, ZETTA } = sizes;
1010

11+
const mobileSizeMap = {
12+
[KILO]: KILO,
13+
[MEGA]: MEGA,
14+
[GIGA]: MEGA,
15+
[TERA]: GIGA,
16+
[PETA]: TERA,
17+
[EXA]: PETA,
18+
[ZETTA]: PETA
19+
};
20+
1121
const baseStyles = ({ theme }) => css`
1222
label: heading;
1323
font-weight: ${theme.fontWeight.bold};
1424
margin-bottom: ${theme.spacings.giga};
1525
`;
1626

17-
const sizeStyles = ({ theme, size }) => css`
18-
label: heading--${size};
19-
font-size: ${theme.typography.headings[size].fontSize};
20-
line-height: ${theme.typography.headings[size].lineHeight};
21-
`;
27+
const sizeStyles = ({ theme, size }) =>
28+
css`
29+
label: heading--${size};
30+
font-size: ${theme.typography.headings[mobileSizeMap[size]].fontSize};
31+
line-height: ${theme.typography.headings[mobileSizeMap[size]].lineHeight};
32+
33+
${theme.mq.kilo`
34+
font-size: ${theme.typography.headings[size].fontSize};
35+
line-height: ${theme.typography.headings[size].lineHeight};
36+
`};
37+
`;
2238

2339
const noMarginStyles = ({ noMargin }) =>
2440
noMargin &&
@@ -34,8 +50,7 @@ const HeadingElement = styled(HtmlElement)`
3450
`;
3551

3652
/**
37-
* A heading flexible heading component capable of rendering using
38-
* different HTML tags.
53+
* A flexible heading component capable of rendering using any HTML heading tag.
3954
*/
4055
const Heading = props => (
4156
<HeadingElement {...props} blacklist={{ size: true, noMargin: true }} />
+20-51
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,35 @@
11
import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { withInfo } from '@storybook/addon-info';
4+
import { select, boolean, text } from '@storybook/addon-knobs/react';
5+
46
import { GROUPS } from '../../../.storybook/hierarchySeparators';
57

68
import withTests from '../../util/withTests';
79
import Heading from '.';
810

11+
const elements = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
12+
const sizes = [
13+
Heading.ZETTA,
14+
Heading.EXA,
15+
Heading.PETA,
16+
Heading.TERA,
17+
Heading.GIGA,
18+
Heading.MEGA,
19+
Heading.KILO
20+
];
21+
922
storiesOf(`${GROUPS.TYPOGRAPHY}|Heading`, module)
1023
.addDecorator(withTests('Heading'))
1124
.add(
12-
'Zetta Heading with h1',
13-
withInfo()(() => (
14-
<Heading element="h1" size={Heading.ZETTA}>
15-
This is a zetta heading with an h1 element
16-
</Heading>
17-
))
18-
)
19-
.add(
20-
'Exa Heading with h2',
21-
withInfo()(() => (
22-
<Heading element="h2" size={Heading.EXA}>
23-
This is an exa heading with an h2 element
24-
</Heading>
25-
))
26-
)
27-
.add(
28-
'Peta Heading with h3',
29-
withInfo()(() => (
30-
<Heading element="h3" size={Heading.PETA}>
31-
This is a peta heading with an h3 element
32-
</Heading>
33-
))
34-
)
35-
.add(
36-
'Tera Heading with h4',
37-
withInfo()(() => (
38-
<Heading element="h4" size={Heading.TERA}>
39-
This is a tera heading with an h4 element
40-
</Heading>
41-
))
42-
)
43-
.add(
44-
'Giga Heading with h5',
45-
withInfo()(() => (
46-
<Heading element="h5" size={Heading.GIGA}>
47-
This is a giga heading with an h5 element
48-
</Heading>
49-
))
50-
)
51-
.add(
52-
'Mega Heading with h6',
53-
withInfo()(() => (
54-
<Heading element="h6" size={Heading.MEGA}>
55-
This is a mega heading with an h6 element
56-
</Heading>
57-
))
58-
)
59-
.add(
60-
'Kilo Heading with h6',
25+
'Heading',
6126
withInfo()(() => (
62-
<Heading element="h6" size={Heading.KILO}>
63-
This is a kilo heading with an h6 element
27+
<Heading
28+
element={select('Element', elements, elements[0])}
29+
size={select('Size', sizes, sizes[0])}
30+
noMargin={boolean('No margin', false)}
31+
>
32+
{text('Text', 'This is a heading')}
6433
</Heading>
6534
))
6635
);

0 commit comments

Comments
 (0)