@chassis-ui/docs 0.1.10 → 0.3.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/README.md +16 -16
- package/index.ts +6 -1
- package/package.json +20 -8
- package/src/components/DocsSidebar.astro +63 -23
- package/src/components/FeatureCard.astro +8 -8
- package/src/components/NavLink.astro +1 -1
- package/src/components/TableOfContents.astro +8 -7
- package/src/components/ThemeToggler.astro +16 -37
- package/src/components/shortcodes/Blockquote.astro +31 -0
- package/src/components/shortcodes/CSSOnly.astro +22 -0
- package/src/components/shortcodes/Callout.astro +6 -2
- package/src/components/shortcodes/Code.astro +289 -0
- package/src/components/shortcodes/DeprecatedIn.astro +18 -0
- package/src/components/shortcodes/Example.astro +132 -0
- package/src/components/shortcodes/Icon.astro +57 -0
- package/src/components/shortcodes/InFigma.astro +26 -0
- package/src/components/shortcodes/JsDocs.astro +64 -0
- package/src/components/shortcodes/Placeholder.astro +28 -0
- package/src/components/shortcodes/ResizableExample.astro +126 -0
- package/src/components/shortcodes/ScssDocs.astro +108 -0
- package/src/components/shortcodes/ScssDocsSimple.astro +66 -0
- package/src/js/color-modes.js +3 -3
- package/src/js/example-mode.js +75 -0
- package/src/js/search.js +501 -39
- package/src/js/theme-color.js +1 -1
- package/src/layouts/DocsLayout.astro +18 -21
- package/src/layouts/RedirectLayout.astro +1 -0
- package/src/layouts/SingleLayout.astro +3 -3
- package/src/layouts/footer/Footer.astro +5 -5
- package/src/layouts/footer/Scripts.astro +14 -7
- package/src/layouts/head/Analytics.astro +12 -6
- package/src/layouts/head/Favicons.astro +0 -2
- package/src/layouts/head/Head.astro +2 -7
- package/src/layouts/head/Stylesheet.astro +18 -11
- package/src/layouts/header/Header.astro +2 -5
- package/src/layouts/header/Navigation.astro +40 -42
- package/src/layouts/header/SearchDialog.astro +74 -0
- package/src/layouts/header/SearchTrigger.astro +41 -0
- package/src/layouts/header/Skippy.astro +1 -1
- package/src/libs/highlight.ts +91 -0
- package/src/libs/icon.ts +75 -0
- package/src/libs/image.ts +12 -1
- package/src/libs/layout.ts +18 -0
- package/src/libs/markdown.ts +128 -0
- package/src/libs/placeholder.ts +250 -0
- package/src/libs/rehype.ts +0 -17
- package/src/libs/shortcodes.ts +129 -0
- package/src/libs/site.ts +95 -0
- package/src/libs/toc.ts +40 -6
- package/src/libs/utils.ts +34 -82
- package/src/libs/vite.ts +45 -0
- package/src/scss/_anchor.scss +20 -16
- package/src/scss/_callouts.scss +29 -28
- package/src/scss/_content.scss +72 -103
- package/src/scss/_footer.scss +18 -19
- package/src/scss/_layout.scss +56 -61
- package/src/scss/_navbar.scss +19 -126
- package/src/scss/_placeholder-img.scss +11 -7
- package/src/scss/_scrolling.scss +14 -12
- package/src/scss/_search.scss +418 -0
- package/src/scss/_shiki.scss +120 -0
- package/src/scss/_sidebar.scss +137 -132
- package/src/scss/_skippy.scss +6 -4
- package/src/scss/_snippets.scss +181 -0
- package/src/scss/_toc.scss +97 -93
- package/src/scss/_vars.scss +89 -0
- package/src/scss/main.scss +75 -81
- package/src/js/icon-loader.js +0 -229
- package/src/libs/chassis.ts +0 -38
- package/src/scss/_brand.scss +0 -59
- package/src/scss/_buttons.scss +0 -33
- package/src/scss/_clipboard-js.scss +0 -63
- package/src/scss/_code.scss +0 -116
- package/src/scss/_colors.scss +0 -140
- package/src/scss/_docsearch.scss +0 -212
- package/src/scss/_masthead.scss +0 -124
- package/src/scss/_settings.scss +0 -29
- package/src/scss/_syntax.scss +0 -160
- package/src/scss/_variables.scss +0 -78
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
@use "@chassis-ui/css/scss/mixins" as *;
|
|
2
|
+
@use "@chassis-ui/css/scss/placeholders" as *;
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Pagefind search UI
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
.cxd-search {
|
|
9
|
+
position: relative;
|
|
10
|
+
|
|
11
|
+
@include media-breakpoint-up(large) {
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 20%;
|
|
14
|
+
right: 13rem;
|
|
15
|
+
width: 200px;
|
|
16
|
+
|
|
17
|
+
[dir="rtl"] & {
|
|
18
|
+
right: auto;
|
|
19
|
+
left: 13rem;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// Trigger button
|
|
27
|
+
//
|
|
28
|
+
// Mobile (< md): icon-only, no chrome.
|
|
29
|
+
// md+: expands to a faux input with label and ⌘K shortcut hint.
|
|
30
|
+
|
|
31
|
+
.cxd-search-trigger {
|
|
32
|
+
// @extend %form-input;
|
|
33
|
+
--cx-padding-x: var(--cx-space-xsmall);
|
|
34
|
+
--cx-padding-y: .375rem;
|
|
35
|
+
--cx-icon-color: var(--cx-fg-color);
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
gap: .5rem;
|
|
38
|
+
align-items: center;
|
|
39
|
+
margin-block: .125rem;
|
|
40
|
+
// padding-inline-end: .5rem;
|
|
41
|
+
// padding: .25rem .5rem;
|
|
42
|
+
@include exclude-strokes(form-input);
|
|
43
|
+
@include font-size(var(--cx-font-size-small));
|
|
44
|
+
color: var(--cx-fg-subtle);
|
|
45
|
+
text-align: start;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border: 0;
|
|
49
|
+
@include border-radius(var(--cx-border-radius-medium));
|
|
50
|
+
@include transition(color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out);
|
|
51
|
+
|
|
52
|
+
&:focus-visible {
|
|
53
|
+
@include focus-ring(true);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@include media-breakpoint-up(large) {
|
|
57
|
+
--cx-border-color: var(--cx-border-subtle);
|
|
58
|
+
--cx-icon-size: var(--cx-icon-small);
|
|
59
|
+
--cx-icon-color: var(--cx-fg-subtle);
|
|
60
|
+
width: 100%;
|
|
61
|
+
background-color: var(--cx-bg-main);
|
|
62
|
+
@include border();
|
|
63
|
+
|
|
64
|
+
&:hover {
|
|
65
|
+
// --fg-color: var(--cx-fg-main);
|
|
66
|
+
--cx-icon-color: var(--cx-fg-color);
|
|
67
|
+
--cx-border-color: var(--cx-border-main);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.cxd-search-trigger-icon {
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
color: var(--cx-fg-subtle);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.cxd-search-trigger-label,
|
|
78
|
+
.cxd-search-trigger-shortcut {
|
|
79
|
+
display: none;
|
|
80
|
+
|
|
81
|
+
@include media-breakpoint-up(large) {
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.cxd-search-trigger-label {
|
|
87
|
+
flex: 1;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.cxd-search-trigger-shortcut {
|
|
94
|
+
flex-shrink: 0;
|
|
95
|
+
gap: .125rem;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.cxd-search-trigger-key {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
min-width: 1.25rem;
|
|
103
|
+
padding: .125rem .375rem;
|
|
104
|
+
font-family: var(--cx-font-family-code);
|
|
105
|
+
@include font-size(var(--cx-font-size-small));
|
|
106
|
+
@include line-height(var(--cx-line-height-small));
|
|
107
|
+
color: var(--cx-fg-subtle);
|
|
108
|
+
background-color: var(--cx-bg-evident);
|
|
109
|
+
// border: var(--cx-border-width) solid var(--cx-border-color);
|
|
110
|
+
@include border-radius(var(--cx-border-radius-small));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Search dialog shell
|
|
114
|
+
//
|
|
115
|
+
// Top-aligned overlay using the existing `.dialog` surface.
|
|
116
|
+
// Sizing and position make it feel like a command palette.
|
|
117
|
+
|
|
118
|
+
.cxd-search-dialog {
|
|
119
|
+
--cx-dialog-margin: 1.5rem;
|
|
120
|
+
--cx-dialog-padding: .75rem;
|
|
121
|
+
--cx-dialog-header-padding: .75rem;
|
|
122
|
+
--cx-dialog-footer-padding: .5rem .75rem;
|
|
123
|
+
--cx-dialog-border-radius: var(--cx-border-radius-large);
|
|
124
|
+
|
|
125
|
+
align-self: flex-start;
|
|
126
|
+
width: 640px;
|
|
127
|
+
max-height: min(80dvh, 720px);
|
|
128
|
+
margin-block-start: 3rem;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
background-color: var(--cx-bg-even);
|
|
131
|
+
|
|
132
|
+
@include media-breakpoint-down(small) {
|
|
133
|
+
max-height: calc(100dvh - 4rem);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Header / search form
|
|
138
|
+
|
|
139
|
+
.cxd-search-form {
|
|
140
|
+
display: flex;
|
|
141
|
+
flex-wrap: nowrap;
|
|
142
|
+
gap: .75rem;
|
|
143
|
+
align-items: center;
|
|
144
|
+
padding: var(--cx-space-medium);
|
|
145
|
+
border-bottom: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
cxd-search-input {
|
|
149
|
+
width: 100%;
|
|
150
|
+
}
|
|
151
|
+
// .cxd-search-input {
|
|
152
|
+
// flex: 1;
|
|
153
|
+
// width: 100%;
|
|
154
|
+
// min-width: 0;
|
|
155
|
+
// background-color: transparent;
|
|
156
|
+
// border-color: transparent;
|
|
157
|
+
// box-shadow: none;
|
|
158
|
+
|
|
159
|
+
// &:focus {
|
|
160
|
+
// background-color: transparent;
|
|
161
|
+
// border-color: transparent;
|
|
162
|
+
// box-shadow: none;
|
|
163
|
+
// }
|
|
164
|
+
// }
|
|
165
|
+
|
|
166
|
+
// .cxd-search-close {
|
|
167
|
+
// flex-shrink: 0;
|
|
168
|
+
// margin-inline-start: 0;
|
|
169
|
+
// }
|
|
170
|
+
|
|
171
|
+
// Body / results
|
|
172
|
+
|
|
173
|
+
.cxd-search-body {
|
|
174
|
+
padding: 0 var(--cx-space-medium) var(--cx-space-medium);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.cxd-search-results {
|
|
178
|
+
display: block;
|
|
179
|
+
min-height: 6rem;
|
|
180
|
+
border: 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.cxd-search-results-list {
|
|
184
|
+
// --cx-list-border-width: 0;
|
|
185
|
+
// --cx-list-border-radius: 0;
|
|
186
|
+
|
|
187
|
+
gap: var(--cx-space-small);
|
|
188
|
+
padding-block-start: var(--cx-space-xsmall);
|
|
189
|
+
list-style: none;
|
|
190
|
+
.list-item {
|
|
191
|
+
padding: 0;
|
|
192
|
+
border: 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.cxd-search-result {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-direction: column;
|
|
199
|
+
// gap: var(--cx-space-xsmall);
|
|
200
|
+
gap: 0;
|
|
201
|
+
padding: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Default-active state: while focus is in the search input, the first result
|
|
205
|
+
// is highlighted as the Enter target. Once the user arrows into the list,
|
|
206
|
+
// :focus-within takes over.
|
|
207
|
+
.cxd-search-results:not(:focus-within) .cxd-search-result:first-child > .cxd-search-item {
|
|
208
|
+
@include focus-ring(true);
|
|
209
|
+
--cx-focus-ring-offset: -2px;
|
|
210
|
+
background-color: var(--cx-bg-main);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Single row template: top-level results, sub-results, and recent visits.
|
|
214
|
+
.cxd-search-item {
|
|
215
|
+
--cx-icon-size: var(--cx-icon-medium);
|
|
216
|
+
--cx-icon-color: var(--cx-fg-subtle);
|
|
217
|
+
position: relative;
|
|
218
|
+
display: grid;
|
|
219
|
+
grid-template-columns: auto 1fr;
|
|
220
|
+
column-gap: .5rem;
|
|
221
|
+
align-items: center;
|
|
222
|
+
padding: var(--cx-space-xsmall);
|
|
223
|
+
text-decoration: none;
|
|
224
|
+
background-color: var(--cx-bg-main);
|
|
225
|
+
@include border();
|
|
226
|
+
@include border-radius(var(--cx-border-radius-medium));
|
|
227
|
+
|
|
228
|
+
mark {
|
|
229
|
+
background: none;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
&:has(+ .cxd-search-subresults) {
|
|
233
|
+
border-block-end-width: 0;
|
|
234
|
+
@include border-bottom-radius(0);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
&:hover {
|
|
238
|
+
background-color: var(--cx-bg-main);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
&:focus-visible {
|
|
242
|
+
--cx-focus-ring-offset: -2px;
|
|
243
|
+
z-index: 1;
|
|
244
|
+
@include focus-ring(true);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// &:not(.cxd-search-item-sub) {
|
|
248
|
+
// border: var(--cx-border-width) solid var(--cx-border-color);
|
|
249
|
+
// }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.cxd-search-item-icon {
|
|
253
|
+
// margin-block-start: .15rem;
|
|
254
|
+
color: var(--cx-fg-subtle);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.cxd-search-item-body {
|
|
258
|
+
grid-column: 2;
|
|
259
|
+
min-width: 0;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.cxd-search-item-title {
|
|
263
|
+
font-weight: var(--cx-font-weight-strong);
|
|
264
|
+
color: var(--cx-fg-main);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.cxd-search-item-excerpt {
|
|
268
|
+
overflow: hidden;
|
|
269
|
+
color: var(--cx-fg-subtle);
|
|
270
|
+
text-overflow: ellipsis;
|
|
271
|
+
white-space: nowrap;
|
|
272
|
+
@include font-size(var(--cx-font-size-small));
|
|
273
|
+
@include line-height(var(--cx-line-height-small));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.cxd-search-subitem {
|
|
277
|
+
--cx-icon-size: var(--cx-icon-small);
|
|
278
|
+
--cx-icon-color: var(--cx-fg-subtle);
|
|
279
|
+
align-items: center;
|
|
280
|
+
padding-inline-start: var(--cx-space-4xlarge);
|
|
281
|
+
// padding-inline-start: var(--cx-space-medium);
|
|
282
|
+
|
|
283
|
+
&::before {
|
|
284
|
+
position: absolute;
|
|
285
|
+
inset-block: 15%;
|
|
286
|
+
inset-inline: 0;
|
|
287
|
+
width: var(--cx-border-width);
|
|
288
|
+
height: 70%;
|
|
289
|
+
margin-inline-start: 1.25rem;
|
|
290
|
+
content: " ";
|
|
291
|
+
background-color: var(--cx-fg-subtle);
|
|
292
|
+
}
|
|
293
|
+
&::after {
|
|
294
|
+
position: absolute;
|
|
295
|
+
inset: 0;
|
|
296
|
+
width: .75rem;
|
|
297
|
+
height: var(--cx-border-width);
|
|
298
|
+
margin-block: auto;
|
|
299
|
+
margin-inline-start: 1.25rem;
|
|
300
|
+
content: " ";
|
|
301
|
+
background-color: var(--cx-fg-subtle);
|
|
302
|
+
}
|
|
303
|
+
.cxd-search-item-title {
|
|
304
|
+
@include font-size(var(--cx-font-size-small));
|
|
305
|
+
@include line-height(var(--cx-line-height-small));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.cxd-search-subresults {
|
|
311
|
+
display: flex;
|
|
312
|
+
flex-direction: column;
|
|
313
|
+
// gap: var(--cx-space-xsmall);
|
|
314
|
+
gap: 0;
|
|
315
|
+
// padding-inline-start: var(--cx-space-large);
|
|
316
|
+
.cxd-search-subitem {
|
|
317
|
+
border-block-end-width: 0;
|
|
318
|
+
@include border-radius(0);
|
|
319
|
+
&:is(:last-child > .cxd-search-subitem) {
|
|
320
|
+
border-block-end-width: var(--cx-border-width);
|
|
321
|
+
@include border-bottom-radius(var(--cx-border-radius));
|
|
322
|
+
&::before {
|
|
323
|
+
height: 35%;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Recently visited
|
|
331
|
+
|
|
332
|
+
.cxd-search-recent-header {
|
|
333
|
+
display: flex;
|
|
334
|
+
gap: .5rem;
|
|
335
|
+
align-items: center;
|
|
336
|
+
justify-content: space-between;
|
|
337
|
+
padding-block: .5rem;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.cxd-search-recent-label {
|
|
341
|
+
@include font-size(var(--cx-font-size-xsmall));
|
|
342
|
+
font-weight: 600;
|
|
343
|
+
color: var(--cx-fg-subtle);
|
|
344
|
+
text-transform: uppercase;
|
|
345
|
+
letter-spacing: .04em;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.cxd-search-recent-clear {
|
|
349
|
+
padding: .125rem .375rem;
|
|
350
|
+
@include font-size(var(--cx-font-size-xsmall));
|
|
351
|
+
color: var(--cx-fg-subtle);
|
|
352
|
+
cursor: pointer;
|
|
353
|
+
background-color: transparent;
|
|
354
|
+
border: 0;
|
|
355
|
+
@include border-radius(var(--cx-border-radius-medium));
|
|
356
|
+
@include transition(color .15s ease-in-out, background-color .15s ease-in-out);
|
|
357
|
+
|
|
358
|
+
&:hover {
|
|
359
|
+
color: var(--cx-fg-main);
|
|
360
|
+
background-color: var(--cx-bg-main);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
&:focus-visible {
|
|
364
|
+
@include focus-ring(true);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Empty / loading / error states
|
|
369
|
+
|
|
370
|
+
.cxd-search-empty,
|
|
371
|
+
.cxd-search-error {
|
|
372
|
+
padding: 2rem 1rem;
|
|
373
|
+
@include font-size(var(--cx-font-size-small));
|
|
374
|
+
color: var(--cx-fg-subtle);
|
|
375
|
+
text-align: center;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.cxd-search-error {
|
|
379
|
+
color: var(--cx-danger-fg-main);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.cxd-search-loading {
|
|
383
|
+
display: flex;
|
|
384
|
+
flex-direction: column;
|
|
385
|
+
gap: var(--cx-space-small);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
.cxd-search-footer {
|
|
390
|
+
padding-block: var(--cx-space-small);
|
|
391
|
+
background-color: var(--cx-bg-evident);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.cxd-search-shortcuts-list > .list-item {
|
|
395
|
+
display: inline-flex;
|
|
396
|
+
gap: .25rem;
|
|
397
|
+
align-items: center;
|
|
398
|
+
padding: 0 .5rem;
|
|
399
|
+
color: var(--cx-fg-subtle);
|
|
400
|
+
background: none;
|
|
401
|
+
border: 0;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.cxd-search-shortcut-key {
|
|
405
|
+
display: inline-flex;
|
|
406
|
+
align-items: center;
|
|
407
|
+
justify-content: center;
|
|
408
|
+
min-width: 1.25rem;
|
|
409
|
+
min-height: 1.25rem;
|
|
410
|
+
padding: 0 .25rem;
|
|
411
|
+
background-color: var(--cx-bg-main);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.cxd-search-shortcut-label {
|
|
415
|
+
padding-inline-start: .25rem;
|
|
416
|
+
@include font-size(var(--cx-font-size-small));
|
|
417
|
+
@include line-height(var(--cx-line-height-small));
|
|
418
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
@use "@chassis-ui/css/scss/mixins" as *;
|
|
2
|
+
|
|
3
|
+
// Shiki syntax highlighting — CSS variable theme
|
|
4
|
+
// Requires defaultColor: false in codeToHtml so tokens carry
|
|
5
|
+
// --shiki-light / --shiki-dark custom properties instead of inline hex.
|
|
6
|
+
|
|
7
|
+
@layer custom {
|
|
8
|
+
// Explicit dark (data-cx-theme="dark" on root, body, or any ancestor)
|
|
9
|
+
// @media (prefers-color-scheme: dark) {
|
|
10
|
+
[data-cx-theme="dark"] {
|
|
11
|
+
.astro-code,
|
|
12
|
+
.astro-code span {
|
|
13
|
+
font-style: var(--shiki-dark-font-style);
|
|
14
|
+
font-weight: var(--shiki-dark-font-weight);
|
|
15
|
+
color: var(--shiki-dark);
|
|
16
|
+
text-decoration: var(--shiki-dark-text-decoration);
|
|
17
|
+
// background-color: var(--shiki-dark-bg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Explicit light override (e.g. a light example inside a dark page)
|
|
22
|
+
[data-cx-theme="light"] {
|
|
23
|
+
.astro-code,
|
|
24
|
+
.astro-code span {
|
|
25
|
+
font-style: var(--shiki-light-font-style);
|
|
26
|
+
font-weight: var(--shiki-light-font-weight);
|
|
27
|
+
color: var(--shiki-light);
|
|
28
|
+
text-decoration: var(--shiki-light-text-decoration);
|
|
29
|
+
// background-color: var(--shiki-light-bg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.astro-code {
|
|
34
|
+
position: relative;
|
|
35
|
+
display: flex;
|
|
36
|
+
padding: var(--cxd-code-padding);
|
|
37
|
+
@include border-radius(calc(var(--radius-round) - 1px));
|
|
38
|
+
|
|
39
|
+
> code {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
width: max-content;
|
|
44
|
+
min-width: 100%;
|
|
45
|
+
|
|
46
|
+
.line:empty {
|
|
47
|
+
min-height: 1lh;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.line {
|
|
53
|
+
width: 100%;
|
|
54
|
+
&.highlighted {
|
|
55
|
+
width: #{calc(100% + 2 * var(--cxd-code-padding))};
|
|
56
|
+
padding-inline: var(--cxd-code-padding);
|
|
57
|
+
margin-inline: calc(-1 * var(--cxd-code-padding));
|
|
58
|
+
background-color: var(--cx-bg-highlight);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Line numbers
|
|
63
|
+
.line-numbers {
|
|
64
|
+
--cxd-line-number-width: 2.5rem;
|
|
65
|
+
|
|
66
|
+
code {
|
|
67
|
+
counter-reset: line;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.line {
|
|
71
|
+
position: relative;
|
|
72
|
+
padding-inline-start: var(--cxd-line-number-width); // make room for the number
|
|
73
|
+
|
|
74
|
+
&::before {
|
|
75
|
+
position: absolute;
|
|
76
|
+
inset-inline-start: 0;
|
|
77
|
+
width: var(--cxd-line-number-width);
|
|
78
|
+
padding-inline-end: .5rem;
|
|
79
|
+
margin-inline-start: calc(-1 * var(--cxd-code-padding));
|
|
80
|
+
font-variant-numeric: tabular-nums;
|
|
81
|
+
color: var(--cx-fg-subtle);
|
|
82
|
+
text-align: right;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
content: counter(line);
|
|
85
|
+
counter-increment: line;
|
|
86
|
+
user-select: none;
|
|
87
|
+
background-color: var(--cx-dim-slight);
|
|
88
|
+
border-inline-end: var(--cx-border-width) solid var(--cx-border-subtle);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&:first-child::before {
|
|
92
|
+
padding-block-start: var(--cxd-code-padding);
|
|
93
|
+
margin-block-start: calc(-1 * var(--cxd-code-padding));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&:last-child::before {
|
|
97
|
+
padding-block-end: var(--cxd-code-padding);
|
|
98
|
+
margin-block-end: calc(-1 * var(--cxd-code-padding));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// include line numbers in highlight background
|
|
102
|
+
&.highlighted {
|
|
103
|
+
padding-inline-start: calc(var(--cxd-line-number-width) + var(--cxd-code-padding));
|
|
104
|
+
margin-inline-start: calc(-1 * var(--cxd-code-padding));
|
|
105
|
+
&::before {
|
|
106
|
+
margin-inline-start: 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Exclude line numbers from highlight background
|
|
111
|
+
// &.highlighted {
|
|
112
|
+
// padding-inline-start: calc(var(--cxd-line-number-width) - var(--cxd-code-padding));
|
|
113
|
+
// margin-inline-start: var(--cxd-code-padding);
|
|
114
|
+
// &::before {
|
|
115
|
+
// margin-inline-start: calc(-1 * var(--cxd-line-number-width));
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|