Skip to content

Commit 9b8a018

Browse files
committed
Update CSS mapping to reduce chance of future breakage
1 parent 1fb2704 commit 9b8a018

File tree

3 files changed

+23
-83
lines changed

3 files changed

+23
-83
lines changed

src/lib/cssMap.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,32 @@ const currentURL = import.meta.url
88
const currentFilename = new URL(currentURL).pathname
99
const currentDirname = path.dirname(currentFilename)
1010

11-
// get resolved filenames for css libraries
11+
// get resolved filenames for normalize.css
1212
const normalizeCSS = resolve('@csstools/normalize.css')
13-
const normalizeOpinionatedCSS = resolve('@csstools/normalize.css/opinionated.css')
13+
const normalizeDir = path.dirname(normalizeCSS)
14+
const normalizeOpinionatedCSS = path.join(normalizeDir, 'opinionated.css')
15+
16+
// get resolved filenames for sanitize.css
1417
const sanitizeCSS = resolve('sanitize.css')
15-
const sanitizeFormsCSS = resolve('sanitize.css/forms.css')
16-
const sanitizeTypographyCSS = resolve('sanitize.css/typography.css')
18+
const sanitizeDir = path.dirname(sanitizeCSS)
19+
const sanitizeAssetsCSS = path.join(sanitizeDir, 'assets.css')
20+
const sanitizeFormsCSS = path.join(sanitizeDir, 'forms.css')
21+
const sanitizeReduceMotionCSS = path.join(sanitizeDir, 'reduce-motion.css')
22+
const sanitizeTypographyCSS = path.join(sanitizeDir, 'typography.css')
23+
const sanitizeSystemUiCSS = path.join(sanitizeDir, 'system-ui.css')
24+
const sanitizeUiMonospace = path.join(sanitizeDir, 'ui-monospace.css')
1725

1826
// export a hashmap of css library filenames
1927
export const parsableFilenames = create({
2028
[normalizeCSS]: true,
2129
[normalizeOpinionatedCSS]: true,
2230
[sanitizeCSS]: true,
31+
[sanitizeAssetsCSS]: true,
2332
[sanitizeFormsCSS]: true,
24-
[sanitizeTypographyCSS]: true
33+
[sanitizeReduceMotionCSS]: true,
34+
[sanitizeTypographyCSS]: true,
35+
[sanitizeSystemUiCSS]: true,
36+
[sanitizeUiMonospace]: true,
2537
})
2638

2739
// export a hashmap of css library filenames by id
@@ -30,10 +42,14 @@ export const resolvedFilenamesById = create({
3042
'normalize/opinionated': [normalizeOpinionatedCSS],
3143
'normalize/*': [normalizeOpinionatedCSS],
3244
'sanitize': [sanitizeCSS],
45+
'sanitize/assets': [sanitizeAssetsCSS],
3346
'sanitize/forms': [sanitizeCSS, sanitizeFormsCSS],
34-
'sanitize/page': [sanitizeCSS],
47+
'sanitize/page': [sanitizeAssetsCSS], // deprecated; remaining for v10.0.0 compatibility
48+
'sanitize/reduce-motion': [sanitizeCSS, sanitizeReduceMotionCSS],
49+
'sanitize/system-ui': [sanitizeCSS, sanitizeSystemUiCSS],
3550
'sanitize/typography': [sanitizeCSS, sanitizeTypographyCSS],
36-
'sanitize/*': [sanitizeCSS, sanitizeFormsCSS, sanitizeTypographyCSS]
51+
'sanitize/ui-monospace': [sanitizeCSS, sanitizeUiMonospace],
52+
'sanitize/*': [sanitizeCSS, sanitizeFormsCSS],
3753
})
3854

3955
// get the resolved filename of a package/module

test/force-sanitize-all.expect.css

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -264,42 +264,4 @@
264264
:where([type="color" i], [type="range" i]) {
265265
border-width: 0;
266266
padding: 0;
267-
}/**
268-
* Use the default user interface font in all browsers (opinionated).
269-
*/
270-
html {
271-
font-family:
272-
system-ui,
273-
/* macOS 10.11-10.12 */ -apple-system,
274-
/* Windows 6+ */ "Segoe UI",
275-
/* Android 4+ */ "Roboto",
276-
/* Ubuntu 10.10+ */ "Ubuntu",
277-
/* Gnome 3+ */ "Cantarell",
278-
/* KDE Plasma 5+ */ "Noto Sans",
279-
/* fallback */ sans-serif,
280-
/* macOS emoji */ "Apple Color Emoji",
281-
/* Windows emoji */ "Segoe UI Emoji",
282-
/* Windows emoji */ "Segoe UI Symbol",
283-
/* Linux emoji */ "Noto Color Emoji";
284-
}/**
285-
* Use the default monospace user interface font in all browsers (opinionated).
286-
*/
287-
code,
288-
kbd,
289-
samp,
290-
pre {
291-
font-family:
292-
ui-monospace,
293-
/* macOS 10.10+ */ "Menlo",
294-
/* Windows 6+ */ "Consolas",
295-
/* Android 4+ */ "Roboto Mono",
296-
/* Ubuntu 10.10+ */ "Ubuntu Monospace",
297-
/* KDE Plasma 5+ */ "Noto Mono",
298-
/* KDE Plasma 4+ */ "Oxygen Mono",
299-
/* Linux/OpenOffice fallback */ "Liberation Mono",
300-
/* fallback */ monospace,
301-
/* macOS emoji */ "Apple Color Emoji",
302-
/* Windows emoji */ "Segoe UI Emoji",
303-
/* Windows emoji */ "Segoe UI Symbol",
304-
/* Linux emoji */ "Noto Color Emoji";
305267
}

test/import-sanitize-all.expect.css

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -264,42 +264,4 @@
264264
:where([type="color" i], [type="range" i]) {
265265
border-width: 0;
266266
padding: 0;
267-
}/**
268-
* Use the default user interface font in all browsers (opinionated).
269-
*/
270-
html {
271-
font-family:
272-
system-ui,
273-
/* macOS 10.11-10.12 */ -apple-system,
274-
/* Windows 6+ */ "Segoe UI",
275-
/* Android 4+ */ "Roboto",
276-
/* Ubuntu 10.10+ */ "Ubuntu",
277-
/* Gnome 3+ */ "Cantarell",
278-
/* KDE Plasma 5+ */ "Noto Sans",
279-
/* fallback */ sans-serif,
280-
/* macOS emoji */ "Apple Color Emoji",
281-
/* Windows emoji */ "Segoe UI Emoji",
282-
/* Windows emoji */ "Segoe UI Symbol",
283-
/* Linux emoji */ "Noto Color Emoji";
284-
}/**
285-
* Use the default monospace user interface font in all browsers (opinionated).
286-
*/
287-
code,
288-
kbd,
289-
samp,
290-
pre {
291-
font-family:
292-
ui-monospace,
293-
/* macOS 10.10+ */ "Menlo",
294-
/* Windows 6+ */ "Consolas",
295-
/* Android 4+ */ "Roboto Mono",
296-
/* Ubuntu 10.10+ */ "Ubuntu Monospace",
297-
/* KDE Plasma 5+ */ "Noto Mono",
298-
/* KDE Plasma 4+ */ "Oxygen Mono",
299-
/* Linux/OpenOffice fallback */ "Liberation Mono",
300-
/* fallback */ monospace,
301-
/* macOS emoji */ "Apple Color Emoji",
302-
/* Windows emoji */ "Segoe UI Emoji",
303-
/* Windows emoji */ "Segoe UI Symbol",
304-
/* Linux emoji */ "Noto Color Emoji";
305267
}

0 commit comments

Comments
 (0)