-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor theme.html
More file actions
221 lines (189 loc) · 5.81 KB
/
Copy pathColor theme.html
File metadata and controls
221 lines (189 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
/* Modern CSS Theming Demo */
@property --contrast-color {
syntax: "<color>";
initial-value: white;
inherits: true;
}
@property --bg {
syntax: "<color>";
initial-value: #6c1afb;
inherits: true;
}
/* Demo wrapper */
.theming-demo {
color-scheme: light dark;
padding: 1.5rem 1.5rem 0;
background: light-dark(oklch(0.965 0.003 265), oklch(0.14 0.008 265));
font-family: system-ui, -apple-system, sans-serif;
-webkit-font-smoothing: antialiased;
transition: background 0.3s, border-color 0.3s;
height: 100dvh;
}
.theming-demo small {
display: block;
margin-block-end: 1rem;
font-size: 0.75rem;
}
/* Toggle row */
.theming-demo-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-block-end: 1.25rem;
}
.theming-demo-header span {
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
color: contrast-color(var(--bg));
}
.theming-demo-toggle {
appearance: none;
width: 40px;
height: 22px;
border-radius: 999px;
background: light-dark(oklch(0.88 0.01 265), oklch(0.28 0.015 265));
border: 1.5px solid light-dark(oklch(0.82 0.012 265), oklch(0.35 0.015 265));
cursor: pointer;
position: relative;
transition: background 0.25s, border-color 0.25s;
}
.theming-demo-toggle::after {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 14px;
height: 14px;
border-radius: 50%;
background: light-dark(white, oklch(0.82 0.02 265));
transition: transform 0.25s ease, background 0.25s;
box-shadow: 0 1px 2px oklch(0 0 0 / 0.15);
}
.theming-demo-toggle:checked::after {
transform: translateX(18px);
}
.theming-demo-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.75rem;
}
.theming-card {
--bg: var(--brand-color, oklch(0.55 0.08 265));
--contrast-color: contrast-color(var(--bg));
background: var(--bg);
color: contrast-color(var(--bg));
border-radius: 10px;
padding: 1.25rem;
transition: box-shadow 0.3s ease, transform 0.2s ease;
box-shadow:
/* Subtle shadow--visible in light, transparent in dark */
0 1px 2px light-dark(lightgray, transparent),
0 4px 12px light-dark(lightgray, transparent),
0 12px 32px light-dark(lightgray, transparent),
/* Glowy border--transparent in light, visible in dark */
inset 0 0 0 1px light-dark(transparent, oklch(from var(--bg) calc(l + 0.5) c h / 0.5)),
0 0 16px light-dark(transparent, oklch(from var(--bg) calc(l + 0.5) c h / 0.3)),
0 0 3px light-dark(transparent, oklch(from var(--bg) calc(l + 0.5) c h / 0.5))
}
.theming-card:hover {
transform: translateY(-1px);
}
.theming-card-label {
font-size: 0.62rem;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
margin-block-end: 0.4rem;
}
.theming-card-title {
font-size: 0.9rem;
font-weight: 600;
letter-spacing: -0.015em;
margin-block-end: 0.35rem;
line-height: 1.35;
}
.theming-card-body {
font-size: 0.8rem;
line-height: 1.5;
}
/* Style query palette customization */
@container style(--contrast-color: white) {
.theming-card-label,
.theming-card-body {
color: oklch(from var(--bg) 0.9 0.1 h);
}
.theming-card-title {
color: contrast-color(var(--bg));
}
}
@container style(--contrast-color: black) {
.theming-card-label,
.theming-card-body {
color: oklch(from var(--bg) 0.3 0.1 h);
}
.theming-card-title {
color: contrast-color(var(--bg));
}
}
body {
font-family: system-ui;
margin: 0;
}
</style>
<body>
<div class="theming-demo">
<div class="theming-demo-header">
<input type="checkbox" class="theming-demo-toggle" aria-label="Toggle dark mode">
</div>
<div class="theming-demo-grid">
<div class="theming-card" style="--brand-color: light-dark(oklch(0.53 0.28 266.94), oklch(0.77 0.13 285.18))">
<div class="theming-card-label">Micro Theming</div>
<div class="theming-card-title">Local Theming</div>
<div class="theming-card-body">Theming based on element, based on system (micro theme).</div>
</div>
<div class="theming-card" style="--brand-color: light-dark(oklch(0.89 0.11 163.4), oklch(0.39 0.08 167.68))">
<div class="theming-card-label">Contrast</div>
<div class="theming-card-title">Auto Text Color</div>
<div class="theming-card-body">Readable text on any background, according to WCAG 2.</div>
</div>
<div class="theming-card" style="--brand-color: light-dark(oklch(0.9 0.09 60.77), oklch(0.38 0.09 53.69))">
<div class="theming-card-label">Macro themeing</div>
<div class="theming-card-title">Elevation</div>
<div class="theming-card-body">Shadows in light, neon glow in dark (macro theme).</div>
</div>
<div class="theming-card" style="--brand-color: light-dark(oklch(0.85 0.13 347.79), oklch(0.42 0.1 338.12))">
<div class="theming-card-label">Style Queries</div>
<div class="theming-card-title">Style Branching</div>
<div class="theming-card-body">Custom palettes via container style queries.</div>
</div>
</div>
</div>
<script>
// Theme toggle for embedded demo
document.querySelectorAll('.theming-demo').forEach((demo) => {
const toggle = demo.querySelector('.theming-demo-toggle');
if (!toggle) return;
const darkMQ = matchMedia('(prefers-color-scheme: dark)');
function apply(dark) {
toggle.checked = dark;
demo.style.colorScheme = dark ? 'dark' : 'light';
}
apply(darkMQ.matches);
darkMQ.addEventListener('change', (e) => apply(e.matches));
toggle.addEventListener('change', () => {
demo.style.colorScheme = toggle.checked ? 'dark' : 'light';
});
});
</script>
<!-- Lenis CDN -->
<script src="https://unpkg.com/@studio-freight/lenis@1.0.33/dist/lenis.min.js"></script>
</body>
</html>