Skip to content

Commit 28ce841

Browse files
authored
normalize light and dark imports (#285)
* adds new exports * adds light and dark normalize src files * removes stray prop * adds a normalize build file test * adds postcss build commands * fixes export alias * fixes bugs in output * adds defenses against competing themes, adds data attribute versions * more defense * updates light theme hd colors to latest * fixes normalize cascade issues * fixes shadows when flipping preference * use :where() in switch files too * update docsite a little * adds 2 more ways to toggle the theme * use the new switch imports
1 parent 5b101bb commit 28ce841

14 files changed

+551
-381
lines changed

docsite/index.css

+2-41
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@import "../src/index.css";
22
@import "../src/extra/normalize.css";
3+
@import "../src/extra/theme.light.switch.css";
4+
@import "../src/extra/theme.dark.switch.css";
35
@import "../src/props.gray-hsl.css";
46
@import "../src/props.masks.edges.css";
57
@import "../src/props.masks.corner-cuts.css";
@@ -1390,54 +1392,13 @@ input[type="range"] {
13901392

13911393
/* no way out of this duplication afaik */
13921394
[data-theme="light"] {
1393-
color-scheme: light;
1394-
1395-
--brand: var(--pink-6);
1396-
1397-
--link: var(--indigo-7);
1398-
--link-visited: var(--grape-7);
1399-
1400-
--text-1: var(--gray-9);
1401-
--text-2: var(--gray-7);
1402-
1403-
--surface-1: var(--gray-0);
1404-
--surface-2: var(--gray-2);
1405-
--surface-3: var(--gray-3);
1406-
--surface-4: var(--gray-4);
1407-
14081395
--nav-icon: var(--gray-7);
14091396
--nav-icon-hover: var(--gray-9);
1410-
1411-
--shadow-color: 220 3% 15%;
1412-
--shadow-strength: 1%;
1413-
1414-
@media (--HDcolor) {
1415-
--link: color(display-p3 0 .5 1);
1416-
--link-visited: color(display-p3 .6 .2 1);
1417-
}
14181397
}
14191398

14201399
[data-theme="dark"] {
1421-
color-scheme: dark;
1422-
1423-
--brand: var(--pink-4);
1424-
1425-
--link: var(--indigo-3);
1426-
--link-visited: var(--grape-3);
1427-
1428-
--text-1: var(--gray-1);
1429-
--text-2: var(--gray-2);
1430-
1431-
--surface-1: var(--gray-9);
1432-
--surface-2: var(--gray-8);
1433-
--surface-3: var(--gray-7);
1434-
--surface-4: var(--gray-6);
1435-
14361400
--nav-icon: var(--gray-5);
14371401
--nav-icon-hover: var(--gray-2);
1438-
1439-
--shadow-strength: 10%;
1440-
--shadow-color: 220 40% 2%;
14411402
}
14421403

14431404
.theme-toggle {

docsite/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,13 @@ <h4>File Sizes</h4>
365365
<svg viewBox="0 0 24 24">
366366
<use href="#bent-arrow" />
367367
</svg>
368-
<a href="https://github.com/argyleink/open-props/blob/main/src/extra/brand.css">brand.css</a>
368+
<a href="https://github.com/argyleink/open-props/blob/main/src/extra/normalize.light.css">normalize.light.css</a>
369369
</div>
370370
<div class="child-ref">
371371
<svg viewBox="0 0 24 24">
372372
<use href="#bent-arrow" />
373373
</svg>
374-
<a href="https://github.com/argyleink/open-props/blob/main/src/extra/theme.css">theme.css</a>
374+
<a href="https://github.com/argyleink/open-props/blob/main/src/extra/normalize.dark.css">normalize.dark.css</a>
375375
</div>
376376
<div class="child-ref">
377377
<svg viewBox="0 0 24 24">

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
"./style": "./open-props.min.css",
4343
"./postcss/style": "./src/index.css",
4444
"./normalize": "./normalize.min.css",
45+
"./normalize/light": "./normalize.light.min.css",
46+
"./normalize/dark": "./normalize.dark.min.css",
47+
"./switch/light": "./theme.light.switch.min.css",
48+
"./switch/dark": "./theme.dark.switch.min.css",
4549
"./postcss/normalize": "./src/extra/normalize.css",
50+
"./postcss/normalize/light": "./src/extra/normalize.light.css",
51+
"./postcss/normalize/dark": "./src/extra/normalize.dark.css",
4652
"./buttons": "./buttons.min.css",
4753
"./postcss/buttons": "./src/extra/buttons.css",
4854
"./animations": "./animations.min.css",
@@ -150,6 +156,10 @@
150156
"module:js": "npm run bundle:pre-edit && microbundle --no-sourcemap && npm run bundle:post-edit",
151157
"lib:all": "postcss src/index.css -o open-props.min.css",
152158
"lib:normalize": "postcss src/extra/normalize.css -o normalize.min.css && node ./build/extras.js",
159+
"lib:normalize:light": "postcss src/extra/normalize.light.css -o normalize.light.min.css",
160+
"lib:normalize:dark": "postcss src/extra/normalize.dark.css -o normalize.dark.min.css",
161+
"lib:switch:light": "postcss src/extra/theme.light.switch.css -o theme.light.switch.min.css",
162+
"lib:switch:dark": "postcss src/extra/theme.dark.switch.css -o theme.dark.switch.min.css",
153163
"lib:buttons": "postcss src/extra/buttons.css -o buttons.min.css",
154164
"lib:animations": "postcss src/props.animations.css -o animations.min.css",
155165
"lib:aspects": "postcss src/props.aspects.css -o aspects.min.css",

src/extra/brand.css

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
@import "theme.css";
2-
31
:where(html) {
4-
--scrollthumb-color: var(--gray-6);
5-
2+
/* --brand: your-brand-color-here; */
3+
64
scrollbar-color: var(--scrollthumb-color) transparent;
7-
accent-color: var(--link);
8-
caret-color: var(--link);
5+
accent-color: var(--brand, var(--link));
6+
caret-color: var(--brand, var(--link));
7+
color: var(--text-2);
8+
background-color: var(--surface-1);
9+
}
910

10-
@media (--OSlight) {
11-
--scrollthumb-color: var(--gray-7);
11+
:where(h1, h2, h3, h4, h5, h6, dt) {
12+
color: var(--text-1);
13+
}
14+
15+
:where(a[href]) {
16+
color: var(--brand, var(--link));
17+
18+
&:visited {
19+
color: var(--link-visited);
1220
}
1321
}
22+
23+
:focus-visible {
24+
outline-color: var(--brand, var(--link));
25+
}

0 commit comments

Comments
 (0)