css-preflight 0.2.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE_TAILWIND.md +3 -0
- package/README.md +67 -21
- package/package.json +32 -20
- package/styles/enhancements.css +29 -0
- package/{dist/core.css → styles/preflight.css} +19 -73
- /package/{dist → styles}/rem-same-px.css +0 -0
package/LICENSE_TAILWIND.md
CHANGED
package/README.md
CHANGED
|
@@ -1,41 +1,87 @@
|
|
|
1
1
|
# CSS Preflight
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/css-preflight)
|
|
3
|
+
[](https://www.npmjs.com/package/css-preflight)
|
|
4
4
|
[](https://github.com/woodbrettm/css-preflight/blob/main/LICENSE.md)
|
|
5
5
|
|
|
6
|
-
This is a CSS browser
|
|
7
|
-
with additional enhancements like smooth scrolling. The original
|
|
8
|
-
preflight has several Tailwind-isms like tailwind-specific css variables,
|
|
9
|
-
and usage of the tailwind `theme()` function, which have been removed.
|
|
6
|
+
This is a CSS browser reset based on Tailwind's preflight, optimized for non-Tailwind projects. **Optional** enhancements like smooth scrolling and other utilities are also provided (see usage).
|
|
10
7
|
|
|
11
|
-
##
|
|
8
|
+
## Preflight
|
|
12
9
|
|
|
13
|
-
The
|
|
14
|
-
the root project layout file, such as into `Layout.astro` for example. The core contains
|
|
15
|
-
tailwind's preflight with additional enhancements.
|
|
10
|
+
The following adjustments have been made to Tailwind's preflight, located in `styles/preflight.css`:
|
|
16
11
|
|
|
17
|
-
|
|
12
|
+
1. Tailwind-specific CSS variables removed.
|
|
13
|
+
2. Tailwind postcss functions like `theme()` removed.
|
|
14
|
+
3. Properties with vendor prefixes (e.g. `-webkit-`, `-moz-`) have been removed, to avoid duplication
|
|
15
|
+
from autoprefixer when used. Inline comments in the `preflight.css` source code indicate which of
|
|
16
|
+
these have been adjusted and note the original existing prefix.
|
|
17
|
+
4. system-ui fonts have been removed completely from `font-family` properties in exchange for
|
|
18
|
+
either websafe fonts (e.g. Courier New for monospace elements), or removed completely (in the case
|
|
19
|
+
of the original preflight's font-family on `:root`).
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
#### Removing System UI Fonts
|
|
22
|
+
|
|
23
|
+
system-ui fonts can be problematic as they not only depend on the OS version, but on the language
|
|
24
|
+
settings of the OS as well. These have been removed as it's felt they're too unpredictable to be
|
|
25
|
+
left in as a preflight, and better left for a dev to intentionally specify them.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
#pnpm
|
|
31
|
+
pnpm add css-preflight
|
|
32
|
+
|
|
33
|
+
#npm
|
|
34
|
+
npm install css-preflight
|
|
21
35
|
```
|
|
22
36
|
|
|
23
|
-
##
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
The exports are broken down into 3 main CSS files. Completely
|
|
40
|
+
unprocessed so it's up to the dev to pass them through optimizations like
|
|
41
|
+
Autoprefixer and minification.
|
|
42
|
+
|
|
43
|
+
Simply import these into the root layout file (like `Layout.astro` for example).
|
|
44
|
+
They should be imported first before any other CSS imports.
|
|
45
|
+
|
|
46
|
+
#### Possible Imports
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import 'css-preflight'; // styles/preflight.css
|
|
50
|
+
import 'css-preflight/preflight'; // ALIAS: styles/preflight.css
|
|
24
51
|
|
|
25
|
-
|
|
52
|
+
import 'css-preflight/enhancements'; // styles/enhancements.css
|
|
26
53
|
|
|
27
|
-
|
|
54
|
+
import 'css-preflight/rem-same-px'; // styles/rem-same-px
|
|
55
|
+
```
|
|
28
56
|
|
|
29
|
-
|
|
30
|
-
This calculation is done using `%`, so the browser root font size
|
|
31
|
-
will still affect using `rem` for accessibility purposes.
|
|
57
|
+
#### Typical Setup
|
|
32
58
|
|
|
33
59
|
```javascript
|
|
34
|
-
import 'css-preflight/
|
|
60
|
+
import 'css-preflight/preflight';
|
|
61
|
+
import 'css-preflight/enhancements';
|
|
35
62
|
```
|
|
36
63
|
|
|
64
|
+
### Preflight
|
|
65
|
+
|
|
66
|
+
Tailwind preflight (with adjustments mentioned previously). Can either do a bare
|
|
67
|
+
`css-preflight` import, or use the more verbose option of `css-preflight/preflight`.
|
|
68
|
+
Both are exactly the same.
|
|
69
|
+
|
|
70
|
+
### Enhancements
|
|
71
|
+
|
|
72
|
+
These are small enhancements added to the main preflight:
|
|
73
|
+
|
|
74
|
+
- Enables smooth scrolling to anchor points (e.g. #about). Disabled for `prefers-reduced-motion`.
|
|
75
|
+
- Adds `text-wrap: balance` on h1-h6 and blockquote. Helps prevent hanging words on newlines.
|
|
76
|
+
|
|
77
|
+
### Rem Same Px
|
|
78
|
+
|
|
79
|
+
Sets rem equal to 1px at the root for easier design-dev handoff. This calculation is done
|
|
80
|
+
using `%`, so the browser root font size will still affect fonts using `rem` for
|
|
81
|
+
accessibility purposes.
|
|
82
|
+
|
|
37
83
|
### License
|
|
38
84
|
|
|
39
85
|
The repo falls under MIT licensing, contained in the LICENSE.md file.
|
|
40
|
-
Usage is also subject to Tailwind's licensing (MIT), which is included
|
|
41
|
-
in the repo for reference
|
|
86
|
+
Usage of the `preflight.css` file is also subject to Tailwind's licensing (MIT), which is included
|
|
87
|
+
in the repo for reference.
|
package/package.json
CHANGED
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package",
|
|
2
3
|
"name": "css-preflight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Tailwind preflight with some added enhancements.",
|
|
5
|
-
"main": "./dist/core.css",
|
|
6
|
-
"style": "./dist/core.css",
|
|
4
|
+
"version": "1.0.0",
|
|
7
5
|
"type": "module",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"description": "CSS browser reset based on Tailwind's preflight, with optional enhancements.",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Brett Wood",
|
|
10
|
+
"url": "https://github.com/woodbrettm"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/woodbrettm/css-preflight/issues",
|
|
13
|
+
"homepage": "https://github.com/woodbrettm/css-preflight",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/woodbrettm/css-preflight"
|
|
11
17
|
},
|
|
12
18
|
"keywords": [
|
|
13
19
|
"css",
|
|
14
20
|
"preflight",
|
|
15
21
|
"normalize",
|
|
16
|
-
"
|
|
22
|
+
"reset",
|
|
23
|
+
"normalizer",
|
|
24
|
+
"browser"
|
|
17
25
|
],
|
|
18
|
-
"
|
|
26
|
+
"main": "./styles/preflight.css",
|
|
27
|
+
"style": "./styles/preflight.css",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./styles/preflight.css",
|
|
30
|
+
"./preflight": "./styles/preflight.css",
|
|
31
|
+
"./enhancements": "./styles/enhancements.css",
|
|
32
|
+
"./rem-same-px": "./styles/rem-same-px.css"
|
|
33
|
+
},
|
|
19
34
|
"files": [
|
|
20
35
|
"LICENSE.md",
|
|
21
36
|
"LICENSE_TAILWIND.md",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
37
|
+
"styles",
|
|
38
|
+
"package.json",
|
|
39
|
+
"README.md"
|
|
24
40
|
],
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "https://github.com/woodbrettm/css-preflight"
|
|
28
|
-
},
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"bugs": "https://github.com/woodbrettm/css-preflight/issues",
|
|
31
|
-
"homepage": "https://github.com/woodbrettm/css-preflight",
|
|
32
41
|
"devDependencies": {
|
|
33
|
-
"
|
|
42
|
+
"@changesets/cli": "2.27.1",
|
|
43
|
+
"stylelint": "15.11.0",
|
|
44
|
+
"stylelint-config-standard": "34.0.0"
|
|
34
45
|
},
|
|
35
46
|
"scripts": {
|
|
36
|
-
"
|
|
47
|
+
"lint": "stylelint \"./styles/*.css\"",
|
|
48
|
+
"release": "changeset publish"
|
|
37
49
|
}
|
|
38
50
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Adds smooth scrolling when a user is navigated to an
|
|
3
|
+
anchor on a page.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
scroll-behavior: smooth;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@media (prefers-reduced-motion) {
|
|
11
|
+
:root {
|
|
12
|
+
scroll-behavior: auto;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
Helps prevent single words on a newline,
|
|
18
|
+
which can make a title seem unbalanced.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
h1,
|
|
22
|
+
h2,
|
|
23
|
+
h3,
|
|
24
|
+
h4,
|
|
25
|
+
h5,
|
|
26
|
+
h6,
|
|
27
|
+
blockquote {
|
|
28
|
+
text-wrap: balance;
|
|
29
|
+
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
This is a slightly modified version of Tailwind's preflight.css file.
|
|
3
|
-
* CSS variables removed.
|
|
4
|
-
* Functions like theme() are removed.
|
|
5
|
-
|
|
6
|
-
See LICENSE_TAILWIND.md., pulled from:
|
|
7
|
-
https://github.com/tailwindlabs/tailwindcss/tree/master
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
*,
|
|
11
2
|
::before,
|
|
12
3
|
::after {
|
|
@@ -17,33 +8,15 @@
|
|
|
17
8
|
1. Use a consistent sensible line-height in all browsers.
|
|
18
9
|
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
19
10
|
3. Use a more readable tab size.
|
|
20
|
-
4.
|
|
21
|
-
5. Use the user's configured `sans` font-feature-settings by default.
|
|
22
|
-
6. Use the user's configured `sans` font-variation-settings by default.
|
|
11
|
+
4. Normalize font features
|
|
23
12
|
*/
|
|
24
13
|
|
|
25
14
|
:root {
|
|
26
15
|
line-height: 1.5; /* 1 */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
font-
|
|
31
|
-
ui-sans-serif,
|
|
32
|
-
system-ui,
|
|
33
|
-
-apple-system,
|
|
34
|
-
BlinkMacSystemFont,
|
|
35
|
-
'Segoe UI',
|
|
36
|
-
Roboto,
|
|
37
|
-
'Helvetica Neue',
|
|
38
|
-
Arial,
|
|
39
|
-
'Noto Sans',
|
|
40
|
-
sans-serif,
|
|
41
|
-
'Apple Color Emoji',
|
|
42
|
-
'Segoe UI Emoji',
|
|
43
|
-
'Segoe UI Symbol',
|
|
44
|
-
'Noto Color Emoji'; /* 4 */
|
|
45
|
-
font-feature-settings: normal; /* 5 */
|
|
46
|
-
font-variation-settings: normal; /* 6 */
|
|
16
|
+
text-size-adjust: 100%; /* 2: -webkit-text-size-adjust */
|
|
17
|
+
tab-size: 4; /* 3: -moz-tab-size */
|
|
18
|
+
font-feature-settings: normal; /* 4 */
|
|
19
|
+
font-variation-settings: normal; /* 4 */
|
|
47
20
|
}
|
|
48
21
|
|
|
49
22
|
/*
|
|
@@ -109,17 +82,16 @@ strong {
|
|
|
109
82
|
}
|
|
110
83
|
|
|
111
84
|
/*
|
|
112
|
-
1.
|
|
113
|
-
2.
|
|
85
|
+
1. Correct the odd `em` font sizing in all browsers.
|
|
86
|
+
2. Use a web-safe monospace font.
|
|
114
87
|
*/
|
|
115
88
|
|
|
116
89
|
code,
|
|
117
90
|
kbd,
|
|
118
91
|
samp,
|
|
119
92
|
pre {
|
|
120
|
-
font-
|
|
121
|
-
|
|
122
|
-
font-size: 1em; /* 2 */
|
|
93
|
+
font-size: 1em; /* 1 */
|
|
94
|
+
font-family: 'Courier New', Courier, monospace; /* 2 */
|
|
123
95
|
}
|
|
124
96
|
|
|
125
97
|
/*
|
|
@@ -202,7 +174,7 @@ button,
|
|
|
202
174
|
[type='button'],
|
|
203
175
|
[type='reset'],
|
|
204
176
|
[type='submit'] {
|
|
205
|
-
|
|
177
|
+
appearance: button; /* -webkit-appearance */
|
|
206
178
|
background-color: transparent; /* 2 */
|
|
207
179
|
background-image: none; /* 2 */
|
|
208
180
|
}
|
|
@@ -246,7 +218,7 @@ Correct the cursor style of increment and decrement buttons in Safari.
|
|
|
246
218
|
*/
|
|
247
219
|
|
|
248
220
|
[type='search'] {
|
|
249
|
-
|
|
221
|
+
appearance: textfield; /* -webkit-appearance */
|
|
250
222
|
outline-offset: -2px; /* 2 */
|
|
251
223
|
}
|
|
252
224
|
|
|
@@ -255,7 +227,7 @@ Remove the inner padding in Chrome and Safari on macOS.
|
|
|
255
227
|
*/
|
|
256
228
|
|
|
257
229
|
::-webkit-search-decoration {
|
|
258
|
-
|
|
230
|
+
appearance: none; /* -webkit-appeaance */
|
|
259
231
|
}
|
|
260
232
|
|
|
261
233
|
/*
|
|
@@ -264,7 +236,7 @@ Remove the inner padding in Chrome and Safari on macOS.
|
|
|
264
236
|
*/
|
|
265
237
|
|
|
266
238
|
::-webkit-file-upload-button {
|
|
267
|
-
|
|
239
|
+
appearance: button; /* -webkit-appearance */
|
|
268
240
|
font: inherit; /* 2 */
|
|
269
241
|
}
|
|
270
242
|
|
|
@@ -356,8 +328,10 @@ Make sure disabled buttons don't get the pointer cursor.
|
|
|
356
328
|
}
|
|
357
329
|
|
|
358
330
|
/*
|
|
359
|
-
1. Make replaced elements `display: block` by default.
|
|
360
|
-
|
|
331
|
+
1. Make replaced elements `display: block` by default.
|
|
332
|
+
(https://github.com/mozdevs/cssremedy/issues/14)
|
|
333
|
+
2. Add `vertical-align: middle` to align replaced elements more sensibly by default.
|
|
334
|
+
(https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
|
361
335
|
This can trigger a poorly considered lint error in some tools but is included by design.
|
|
362
336
|
*/
|
|
363
337
|
|
|
@@ -374,7 +348,8 @@ object {
|
|
|
374
348
|
}
|
|
375
349
|
|
|
376
350
|
/*
|
|
377
|
-
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio.
|
|
351
|
+
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio.
|
|
352
|
+
(https://github.com/mozdevs/cssremedy/issues/14)
|
|
378
353
|
*/
|
|
379
354
|
|
|
380
355
|
img,
|
|
@@ -387,32 +362,3 @@ video {
|
|
|
387
362
|
[hidden] {
|
|
388
363
|
display: none;
|
|
389
364
|
}
|
|
390
|
-
/*
|
|
391
|
-
Adds smooth scrolling when a user is navigated to an
|
|
392
|
-
anchor on a page.
|
|
393
|
-
*/
|
|
394
|
-
|
|
395
|
-
:root {
|
|
396
|
-
scroll-behavior: smooth;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
@media (prefers-reduced-motion) {
|
|
400
|
-
:root {
|
|
401
|
-
scroll-behavior: auto;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/*
|
|
406
|
-
Helps prevent single words on a newline,
|
|
407
|
-
which can make a title seem unbalanced.
|
|
408
|
-
*/
|
|
409
|
-
|
|
410
|
-
h1,
|
|
411
|
-
h2,
|
|
412
|
-
h3,
|
|
413
|
-
h4,
|
|
414
|
-
h5,
|
|
415
|
-
h6,
|
|
416
|
-
blockquote {
|
|
417
|
-
text-wrap: balance;
|
|
418
|
-
}
|
|
File without changes
|