You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before you start the layout of a web site or web application, and before you dive into applying to brand, you need something to which you should apply your brand. This is that thing.
17
19
18
-
The easiest place to start in a design is with the typography. This makes it easy to do that.
20
+
Before you start the layout of a web site or web application, and before you dive into applying to brand, you need something to which you should apply your brand. This is that thing.
21
+
22
+
The easiest place to start in a design is with the typography.
23
+
24
+
This makes it easy to do that.
19
25
20
26
### It covers all your semantic markup
21
-
Driven by the [W3C spec](https://www.w3.org/TR/html5/) this addresses almost every semantic element that will wrap text and makes sure that everything looks like _something_.
27
+
28
+
Driven by the [W3C spec](https://www.w3.org/TR/html5/) this addresses almost every semantic element that will wrap text and makes sure that everything looks like _something_.
22
29
23
30
The <samp>test.html</samp> file uses each and every element according to its semantic definition, too. So you have a miniature guide to semantics built in.
24
31
25
32
This saves you from a scare down the road when someone wants to output the `<kbd>` element, use `<dfn>`, or try some other obscure element.
26
33
27
34
### Gives you a "no-design" design
28
-
For those times where you need just a bit more than a [Normalize](http://necolas.github.io/normalize.css/), but way less than [Bootstrap](https://getbootstrap.com/), this gets you there.
29
35
30
-
This is a fairly unopinionated approach to making sure that the text has a decent font family, decent spacing, and decent visual appeal.
36
+
For those times where you need just a bit more than a [Normalize](http://necolas.github.io/normalize.css/), but way less than [Bootstrap](https://getbootstrap.com/), this gets you there.
37
+
38
+
This is a fairly unopinionated approach to making sure that the text has a decent font family, decent spacing, and decent visual appeal.
31
39
32
40
## Browser Support
41
+
33
42
* Firefox
34
43
* Chrome
35
44
* Edge
@@ -38,6 +47,7 @@ This is a fairly unopinionated approach to making sure that the text has a decen
38
47
39
48
40
49
## Usage
50
+
41
51
While this is relatively unopinionated, there are a few "opinions" to consider:
42
52
43
53
*[`em` for for `font-size`](https://css-tricks.com/rems-ems/)
@@ -46,68 +56,76 @@ While this is relatively unopinionated, there are a few "opinions" to consider:
46
56
*[text-spacing based on the golden ratio ](https://pearsonified.com/golden-ratio-typography-intro/)(.618 / 1.618)
47
57
48
58
### Fitting it into a CSS architecture
59
+
49
60
This would come after a reset / [normalize](https://necolas.github.io/normalize.css/) and before you set baseline styles for forms or tables. If you're a fan of [ITCSS](https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/), this is in the Elements layer.
50
61
51
-
If you were to load this into a [CSS Layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer), you would want it to come very early so that you could over ride it.
62
+
If you were to load this into a [CSS Layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer), you would want it to come very early so that you could over ride it.
52
63
53
-
Wherever you place it, place it _early_ in the cascade so that other things can use and/or re-declare the variables.
64
+
Wherever you place it, place it _early_ in the cascade so that other things can use and/or re-declare the variables.
54
65
55
66
#### Using it in a project
67
+
56
68
1. Add the baseline
57
-
- import into your project with NPM `@import typography-baseline.css`
58
-
- <kbd>copy</kbd> + <kbd>paste</kbd> this project's `baseline.css`
69
+
* import into your project with NPM `@import typography-baseline.css`
70
+
* <kbd>copy</kbd> + <kbd>paste</kbd> this project's `src/baseline.css`
59
71
2. Add your own `typography.css` file that comes after the baseline, but before you style anything else.
60
72
3. Add something like `html {}` or `body {}`.
61
73
4. Modify the variables _in those rulesets_.
62
-
5. Then add your own element styles.
74
+
5. Then add your own element styles.
63
75
64
76
**Don't modify the typography-baseline directly. Modify the variables it sets with new rulesets.**
65
77
66
78
### Modifying without Swearing or Heavy Drinking
79
+
67
80
One of the really annoying things about other CSS frameworks (cough cough <small>Bootstrap</small>) is that you mostly have to write new CSS to overwrite the existing styles. Often that means raising specificity, which is really stinking annoying. This is designed to avoid that by using [CSS Variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
68
81
82
+
See [Standards and Conventions](#standards-and-conventions) for understanding why variables are named the way they are.
83
+
84
+
#### Override close to (or at) the root
69
85
70
86
The typography baseline sets all of the CSS variables on the `:root`. As CSS variables are subject to the cascade, you can override _any_ variable at any time by changing its value — on the same selector *or* a more specific one.
71
87
72
-
You can import this into your current CSS setup, and overwrite all the variables by setting new ones on the `html` element.
88
+
You can import this into your current CSS setup, and overwrite all the variables by setting new ones on the `html` element.
73
89
74
90
So if you want the `--baseLinkColor` to be different, you can write the following in your own stylesheet:
75
91
76
-
```
92
+
```css
77
93
html {
78
94
--baseLinkColor: #c0ffee
79
95
}
80
96
```
81
97
82
-
**No raising specificity. Just changing a variable.**
98
+
#### No raising specificity; just changing a variable
83
99
84
100
If you want to theme a special area of the site, or even a particular widget, it's just:
85
101
86
-
```
102
+
```css
87
103
.theme {
88
104
--baseLinkColor: #c0ffee
89
105
}
90
106
```
91
107
108
+
#### Color Palette(s)
92
109
93
-
#### Color Palette
94
-
Colors are derivatives of a base value of 55. All of the neutral colors are multipliers of rgb(55,55,55). Even the non-neutral colors are close-ish to that.
110
+
The color palette contains predominantly neutral colors.
95
111
112
+
Neutral colors are derivatives of a base value of 31. All of the neutral colors are multipliers of rgb(31,31,31).
113
+
114
+
```css
115
+
--colorNeutralDarker: rgb(31,31,31); /* base */
116
+
--colorNeutralDark: rgb(62,62,62); /* base * 2 */
117
+
--colorNeutral: rgb(155,155,155); /* base * 5 */
118
+
--colorNeutralLight: rgb(186,186,186); /* base * 6 */
119
+
--colorNeutralLighter: rgb(217,217,217); /* base * 7 */
96
120
```
97
-
--colorNeutralDarker: rgb(55,55,55); /* base */
98
-
--colorNeutralDark: rgb(110,110,110); /* base * 2: */
99
-
--colorNeutral: rgb(165,165,165); /* base * 3: */
100
-
--colorNeutralLight: rgb(192.5,192.5,192.5); /* base * 3.5 */
101
-
--colorNeutralLighter: rgb(220,220,220); /* base * 4: */
102
-
```
103
-
Color-naming convention follows a pattern established [here](https://codepen.io/paceaux/pen/XdxQza). A big huge and heavy thanks to Sarah Braumiller for suggesting that convention years ago.
104
121
105
-
[The great big idea](https://blog.frankmtaylor.com/2021/10/21/a-small-guide-for-naming-stuff-in-front-end-code/#css-pre-processor-naming-scss-sass-less-stylus) is that these color name tells you a meaningful aspect of the value, not the value itself. That way it feels safer changing it.
122
+
The color-naming convention follows a pattern established [here](https://codepen.io/paceaux/pen/XdxQza). A big huge and heavy thanks to Sarah Braumiller for suggesting that convention years ago.
106
123
107
-
#### Colors
108
-
All of the color variables are abstractions from the color palette. This is so you can change these colors without having to touch your neutral palette.
124
+
#### Applying Colors
109
125
110
-
```
126
+
All of the color variables are abstractions from the color palette. This is so you can change these colors without having to touch your neutral palette — and you can add new palettes if you want.
@@ -116,18 +134,19 @@ All of the color variables are abstractions from the color palette. This is so y
116
134
```
117
135
118
136
#### Line Heights
137
+
119
138
The `--baseLineHeight` is applied to body copy, and the `--smallLineHeight` is used on titles:
120
139
121
-
```
140
+
```css
122
141
--baseLineHeight: 1.618;
123
142
--smallLineHeight: 1.2;
124
143
```
125
144
126
-
#### Text Sizes
127
-
You have a minimum of 6 text sizes in two categories: `--<n>TextSize` and `--<n>TitleSize`. You have a "base" and then superlatives or diminutives to describe the deviation from that base. e.g.:
145
+
#### Text and Title Sizes
128
146
147
+
You have a minimum of 6 text sizes in two categories: `--<n>TextSize` and `--<n>TitleSize`. You have a "base" and then superlatives or diminutives to describe the deviation from that base. e.g.:
129
148
130
-
```
149
+
```css
131
150
--biggestTextSize: 1.3em;
132
151
--biggerTextSize: 1.2em;
133
152
--bigTextSize: 1.1em;
@@ -137,12 +156,11 @@ You have a minimum of 6 text sizes in two categories: `--<n>TextSize` and `--<n>
137
156
--smallestTextSize: .618em;
138
157
```
139
158
140
-
For _titles_ you have only _six_ sizes, instead of seven. That's because each title size corresponds to an `<h/>` element.
159
+
For _titles_ you have only _six_ sizes, instead of seven. That's because each title size corresponds to an `<h/>` element.
141
160
142
-
You may also notice that title sizes overlap with base text sizes. This is intentional! You have the flexibility to have your smaller headings be the same as larger text, or to create new title sizes for your headings that won't overlap with the text.
161
+
You may also notice that title sizes overlap with basetext sizes. This is intentional! You have the flexibility to have your smaller headings be the same as larger text, or to create new title sizes for your headings that won't overlap with the text.
143
162
144
-
145
-
```
163
+
```css
146
164
--biggestTitleSize: 2.617924em; /* (16 x 1.618) x 1.618 */
147
165
--bigTitleSize: 1.618em;
148
166
--baseTitleSize: 1.5em;
@@ -151,16 +169,18 @@ You may also notice that title sizes overlap with base text sizes. This is inten
151
169
--smallestTitleSize: var(--bigTextSize);
152
170
```
153
171
154
-
You may notice that all of the font-sizes are in `em`. This is _intentional_ so that your headlines can scale easily relative to the font-size of their containers. That means **you should be careful about how many times you change `font-size`**.
172
+
You may notice that all of the font-sizes are in `em`. This is _intentional_ so that your headlines can scale easily relative to the font-size of their containers. That means **you should be careful about how many times you change `font-size`**.
155
173
156
-
If you think you'll be changing `font-size`_a lot_, you may want to set these in `rem` instead, to avoid FOUC (Flash Of Unstyled Content).
174
+
If you think you'll be changing `font-size`_a lot_, you may want to set these in `rem` instead, to avoid FOUC (Flash Of Unstyled Content).
157
175
158
176
#### Spacing
177
+
159
178
Spacing is done with the golden ratio (.618 / 1.618)
160
-
`rem` is used for horizontal spacing so that text remains aligned, regardless of size. `em` is used for vertical spacing so that bigger text gets more room to breathe.
161
-
You have two spacings to start with.
179
+
`rem` is used for horizontal spacing so that text remains aligned, regardless of size. `em` is used for vertical spacing so that bigger text gets more room to breathe.
162
180
163
-
```
181
+
You have two spacings to start with.
182
+
183
+
```css
164
184
--bigSpacingHorizontal: 1.618rem;
165
185
--baseSpacingHorizontal: .618rem;
166
186
@@ -171,28 +191,30 @@ You have two spacings to start with.
171
191
#### Font Modifications
172
192
173
193
##### Font families
174
-
You have three font families to choose from. `--baseFontFamily` is applied to the html element.
175
194
176
-
```
195
+
You have three font families to choose from. `--baseFontFamily` is applied to the htmlelement.
196
+
197
+
```css
177
198
--baseFontFamily: Georgia, 'Times New Roman', serif;
178
199
--titleFontFamily: Helvetica, Arial, sans-serif;
179
200
--codeFontFamily: monospace;
180
201
```
181
202
182
203
##### Font Weights
204
+
183
205
You have three font weights to choose from.
184
206
185
-
```
207
+
```css
186
208
--lightestFontWeight: 100;
187
209
--baseFontWeight: 400;
188
210
--heaviestFontWeight: 700;
189
211
```
190
212
191
-
While the browser technically has nine font-weights, you're only able to add another four (for a total of seven) by following the pattern of adding "er" or "est". If you *really* need nine font-weights, consider naming the ones at the heavy end `--ultraHeavy` and `--ultraHeaviest`.
192
-
213
+
While the browser technically has nine font-weights, you're only able to add another four (for a total of seven) by following the pattern of adding "er" or "est". If you *really* need nine font-weights, consider naming the ones at the heavy end `--ultraHeavy` and `--ultraHeaviest`.
214
+
193
215
*Just make sure you've added those typefaces!*
194
216
195
-
```
217
+
```css
196
218
--lightFontWeight: 300;
197
219
--lighterFontWeight: 200;
198
220
--heavyFontWeight: 500;
@@ -202,41 +224,93 @@ You have three font weights to choose from.
202
224
If you add more font-weights, remember that [the browser will synthesize the font weights unless proper font-families with those weights are provided](https://w3c.github.io/csswg-drafts/css-fonts-4/#missing-weights)— unless you are using a [variable font ](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#variable_fonts). **Add more font-weights carefully**.
203
225
204
226
##### Font Styles
205
-
You have three font styles to use. These are called `fontVoice` because it's important for you to imagine how a person might read the text _out loud_. If you think someone might enunciate or pronounce it differently, that's "italic" (what you might use for `<em>` or `<i>`). The browser will actually look for an italic font.
227
+
228
+
You have three font styles to use. These are called `fontVoice` because it's important for you to imagine how a person might read the text _out loud_. If you think someone might enunciate or pronounce it differently, that's "italic" (what you might use for `<em>` or `<i>`). The browser will actually look for an italic font.
206
229
207
230
If you just want to show slanted text, that's "oblique". The browser is just going to angle the font.
208
231
209
-
```
232
+
```css
210
233
--shiftedFontVoice: oblique 15deg;
211
234
--baseFontVoice: normal;
212
235
--alternateFontVoice: italic;
213
236
```
214
237
215
238
#### Quote Styles
239
+
216
240
One of the very few strong opinions in this baseline is the look and feel of ablockquote. However, you can set the quotes that come before and after the `<blockquote>` and `<q>` elements. This is useful for internationalization; you have one place to make sure all quote symbols are updated!
217
241
218
-
```
242
+
```css
219
243
--baseTextQuotes: "\201C""\201D""\2018""\2019";
220
244
```
221
245
222
246
`<blockquote>` and `<samp>` both share a thick left "quote border":
One of the only strong opinions here is how links are presented. Instead of using using `text-decoration`, they use a bottom border. This is because I like just a little more space between text and line than what `text-decoration` offers.
256
+
257
+
Your core link-related styles are:
258
+
259
+
```css
260
+
--baseLinkColor: var(--colorCool);
261
+
--baseLinkColorHover: var(--colorCoolDarker);
262
+
263
+
--idleTextLineStyle: dotted; /* default */
264
+
--interestTextLineStyle: solid; /* :hover and :focus*/
Since we indicate interaction with color and border, if you wanted to change how links behave, you would need to target `:hover`, `:focus`, and `:active` states. e.g.:
The <samp>test.html</samp> file passes [WCAG 2.1](https://www.w3.org/TR/WCAG21/) level AA guidelines. It is tested _manually_ using the [Axe dev tools](https://chrome.google.com/webstore/detail/axe-devtools-web-accessib/lhdoppojpmngadmnindnejefpokejbdd) Chrome extension.
291
+
292
+
The text and link colors were determined by testing how they contrast each other and a white background using [WebAIM's Contrast Checker](https://webaim.org/resources/contrastchecker/).
230
293
231
294
### Style guide
232
-
The CSS follows the guidelines established [here](https://gist.github.com/paceaux/f31e278613ab29b74a412a7eb5046422).
295
+
296
+
The CSS is linted against [stylelint](https://stylelint.io/). The rules are in the `.stylelintrc` file. There is a specific order for CSS properties (content, position, font, inside-out box sizing, effects).
233
297
234
298
### Naming Conventions
299
+
235
300
CSS Variable names follow a convention established [here](https://blog.frankmtaylor.com/2021/10/21/a-small-guide-for-naming-stuff-in-front-end-code/).
236
301
302
+
The guiding principles for the variable names are:
303
+
304
+
* camelCased
305
+
* Describe usage or purpose
306
+
* Favor descriptors (adjectives) that can use common comparatives and superlatives (e.g <samp>er</samp> and <samp>est</samp>) to indicate how variations of a common value are related.
307
+
* Start by indicating if it's a base or a derivative with a modifier(adjective): <samp>base</samp>, <samp>small</samp>, <samp>big</samp>, <samp>shifted</samp>, <samp>alternate</samp>
308
+
* Then indicate the domain of the user experience the variable affects with a noun: <samp>color</samp>, <samp>font</samp>, <samp>lineHeight</samp>, <samp>spacing</samp>, <samp>text</samp>, <samp>title</samp>, <samp>voice</samp>
309
+
* If necessary, narrow the domain with another noun:
310
+
* Subdomain of the affected value: <samp>LineStyle</samp>, <samp>Size</samp>, <samp>Weight</samp>
311
+
* A specific state where the value might change: <samp>Hover</samp>, <samp>interest</samp>
0 commit comments