@tenphi/starlight 0.5.0 → 0.6.1

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.
Files changed (38) hide show
  1. package/dist/components/Card.astro +5 -3
  2. package/dist/components/GlobalStyles.js +761 -0
  3. package/dist/components/LayoutComponents.js +404 -0
  4. package/dist/components/Logo.astro +39 -0
  5. package/dist/components/MobileNavigationTabs.astro +7 -2
  6. package/dist/components/PackageVersion.astro +22 -0
  7. package/dist/components/Preview.astro +21 -10
  8. package/dist/components/Steps.astro +5 -1
  9. package/dist/components/Tabs.astro +9 -2
  10. package/dist/components/TastyComponents.js +156 -0
  11. package/dist/components/component-styles.test.ts +75 -0
  12. package/dist/components/component-styles.ts +79 -0
  13. package/dist/components/customize-component.js +10 -0
  14. package/dist/components/svg-icon.test.ts +11 -0
  15. package/dist/components/svg-icon.ts +11 -0
  16. package/dist/components/tasty-states.d.ts +2 -0
  17. package/dist/components/tasty-states.js +21 -0
  18. package/dist/components-public.d.ts +1 -0
  19. package/dist/components.d.ts +2 -1
  20. package/dist/components.js +2 -1
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +297 -163
  24. package/dist/index.js.map +1 -1
  25. package/dist/{navigation-CC0dlAL8.js → navigation-CkQXI2Zb.js} +41 -2
  26. package/dist/navigation-CkQXI2Zb.js.map +1 -0
  27. package/dist/navigation.d.ts +11 -2
  28. package/dist/navigation.d.ts.map +1 -1
  29. package/dist/navigation.js +2 -2
  30. package/dist/overrides/Header.astro +28 -5
  31. package/dist/overrides/MobileMenuFooter.astro +15 -0
  32. package/dist/overrides/ThemeSelect.astro +69 -0
  33. package/dist/routes/DocsPage.astro +43 -145
  34. package/package.json +5 -9
  35. package/dist/components/NavigationTree.astro +0 -98
  36. package/dist/navigation-CC0dlAL8.js.map +0 -1
  37. package/dist/styles.css +0 -1346
  38. package/dist/styles.d.ts +0 -1
@@ -0,0 +1,404 @@
1
+ import { tasty } from "@tenphi/tasty";
2
+ import { customizeComponent } from "./customize-component.js";
3
+ import { configureCookbookStates } from "./tasty-states.js";
4
+
5
+ configureCookbookStates();
6
+
7
+ export const LogoRoot = customizeComponent(
8
+ "Logo",
9
+ { as: "span" },
10
+ tasty({
11
+ as: "span",
12
+ styles: {
13
+ display: "inline-grid",
14
+ flexGrow: "0",
15
+ flexShrink: "0",
16
+ flexBasis: "auto",
17
+ inlineSize: "4rem",
18
+ blockSize: "4rem",
19
+ color: "#accent-surface",
20
+ Svg: {
21
+ $: "> svg",
22
+ display: "block",
23
+ inlineSize: "100%",
24
+ blockSize: "100%",
25
+ },
26
+ },
27
+ }),
28
+ );
29
+
30
+ export const PackageVersionRoot = customizeComponent(
31
+ "PackageVersion",
32
+ { as: "span" },
33
+ tasty({
34
+ as: "span",
35
+ styles: {
36
+ display: "inline-flex",
37
+ alignItems: "center",
38
+ flexShrink: "0",
39
+ minBlockSize: "1.5rem",
40
+ paddingInlineStart: "($gap * 0.75)",
41
+ paddingInlineEnd: "($gap * 0.75)",
42
+ color: "#text-soft",
43
+ fill: "#surface-2",
44
+ border: true,
45
+ radius: "999px",
46
+ preset: "small",
47
+ whiteSpace: "nowrap",
48
+ },
49
+ }),
50
+ );
51
+
52
+ export const TopNavigationRoot = customizeComponent(
53
+ "TopNavigation",
54
+ { as: "nav" },
55
+ tasty({
56
+ as: "nav",
57
+ styles: {
58
+ display: "flex",
59
+ hide: { "": false, "@mobile": true },
60
+ alignItems: "stretch",
61
+ gap: "clamp(1.25rem, 2.5vw, 2.5rem)",
62
+ inlineSize: "100%",
63
+ minBlockSize: "2.5rem",
64
+ overflowX: "auto",
65
+ scrollbar: "none",
66
+
67
+ Scrollbar: { $: "&::-webkit-scrollbar", hide: true },
68
+ Link: {
69
+ $: "a",
70
+ position: "relative",
71
+ display: "inline-flex",
72
+ alignItems: "center",
73
+ flexGrow: "0",
74
+ flexShrink: "0",
75
+ flexBasis: "auto",
76
+ paddingBlockStart: "($gap * 0.75)",
77
+ paddingBlockEnd: "$gap",
78
+ color: "#text-soft",
79
+ preset: "navigation",
80
+ textDecoration: "none",
81
+ whiteSpace: "nowrap",
82
+ },
83
+ HoverLink: { $: "a:hover", color: "#text" },
84
+ CurrentLink: { $: 'a[aria-current="page"]', color: "#accent-text" },
85
+ ActiveIndicator: {
86
+ $: 'a[aria-current="page"]::after',
87
+ content: '""',
88
+ position: "absolute",
89
+ inset: "auto 0 0",
90
+ blockSize: "2px",
91
+ radius: "999px",
92
+ fill: "#accent-surface",
93
+ },
94
+ },
95
+ }),
96
+ );
97
+
98
+ export const StarlightHeaderRoot = customizeComponent(
99
+ "StarlightHeader",
100
+ { as: "div" },
101
+ tasty({
102
+ as: "div",
103
+ styles: {
104
+ display: "flex",
105
+ flow: "column",
106
+ inlineSize: "100%",
107
+ maxInlineSize: "($layout-width - ($sl-sidebar-pad-x * 2))",
108
+ blockSize: "100%",
109
+ minInlineSize: "0",
110
+ marginInlineStart: "auto",
111
+ marginInlineEnd: "auto",
112
+
113
+ Primary: {
114
+ $: ".td-header__primary",
115
+ display: {
116
+ "": "grid",
117
+ "@mobile": "flex",
118
+ },
119
+ gridColumns:
120
+ "minmax(9rem, $sidebar-width) minmax(12rem, 28rem) minmax(5rem, 1fr)",
121
+ placeItems: "center stretch",
122
+ justifyContent: {
123
+ "": "normal",
124
+ "@mobile": "space-between",
125
+ },
126
+ flexGrow: "1",
127
+ flexShrink: "1",
128
+ flexBasis: "0%",
129
+ gap: {
130
+ "": "clamp(1rem, 2.5vw, 2.5rem)",
131
+ "@mobile": "$gap",
132
+ },
133
+ minBlockSize: "0",
134
+ },
135
+ TitleAndSearch: {
136
+ $: ".td-header__title, .td-header__search",
137
+ display: "flex",
138
+ alignItems: "center",
139
+ minInlineSize: "0",
140
+ },
141
+ Title: {
142
+ $: ".td-header__title",
143
+ display: "flex",
144
+ flow: "row",
145
+ gap: "$gap",
146
+ overflow: "hidden",
147
+ maxInlineSize: {
148
+ "": "none",
149
+ "@mobile": "(100% - (($sl-menu-button-size + $sl-nav-gap) * 3))",
150
+ },
151
+ },
152
+ SiteTitle: {
153
+ $: ".site-title",
154
+ color: "#text",
155
+ preset: { "": "h4 / strong", "@mobile": "h5 / strong" },
156
+ },
157
+ Search: {
158
+ $: ".td-header__search",
159
+ position: { "": "static", "@mobile": "fixed" },
160
+ zIndex: { "": "auto", "@mobile": "10" },
161
+ inset: {
162
+ "": "auto top",
163
+ "@mobile": "(($sl-nav-height - $sl-menu-button-size) / 2) top",
164
+ },
165
+ insetInlineEnd: {
166
+ "": "auto",
167
+ "@mobile":
168
+ "($sl-nav-pad-x + (($sl-menu-button-size + $sl-nav-gap) * 2))",
169
+ },
170
+ placeItems: { "": "normal", "@mobile": "center" },
171
+ inlineSize: { "": "auto", "@mobile": "$sl-menu-button-size" },
172
+ blockSize: { "": "auto", "@mobile": "$sl-menu-button-size" },
173
+ marginInlineStart: "0",
174
+ },
175
+ SearchElement: {
176
+ $: ".td-header__search site-search",
177
+ inlineSize: "100%",
178
+ blockSize: { "": "auto", "@mobile": "$sl-menu-button-size" },
179
+ },
180
+ Tools: {
181
+ $: ".td-header__tools",
182
+ display: "flex",
183
+ flow: "row",
184
+ alignItems: "center",
185
+ justifyContent: "flex-end",
186
+ gap: "($gap * 1.5)",
187
+ },
188
+ ToolItem: {
189
+ $: ".td-header__tools > *",
190
+ margin: "0",
191
+ },
192
+ Social: {
193
+ $: ".td-header__social",
194
+ display: "flex",
195
+ alignItems: "center",
196
+ },
197
+ MobileTheme: {
198
+ $: ".td-header__mobile-theme",
199
+ display: "grid",
200
+ hide: { "": true, "@mobile": false },
201
+ position: { "": "static", "@mobile": "fixed" },
202
+ zIndex: { "": "auto", "@mobile": "10" },
203
+ inset: {
204
+ "": "auto top",
205
+ "@mobile": "(($sl-nav-height - $sl-menu-button-size) / 2) top",
206
+ },
207
+ insetInlineEnd: {
208
+ "": "auto",
209
+ "@mobile": "($sl-nav-pad-x + $sl-menu-button-size + $sl-nav-gap)",
210
+ },
211
+ placeItems: { "": "normal", "@mobile": "center" },
212
+ inlineSize: { "": "auto", "@mobile": "$sl-menu-button-size" },
213
+ blockSize: { "": "auto", "@mobile": "$sl-menu-button-size" },
214
+ },
215
+ },
216
+ }),
217
+ );
218
+
219
+ export const ThemeSelectRoot = customizeComponent(
220
+ "ThemeSelect",
221
+ { as: "starlight-theme-select" },
222
+ tasty({
223
+ as: "starlight-theme-select",
224
+ styles: {
225
+ display: "grid",
226
+ placeItems: "center",
227
+ margin: "0",
228
+ inlineSize: {
229
+ "": "$control-height",
230
+ "@mobile": "$sl-menu-button-size",
231
+ },
232
+ blockSize: {
233
+ "": "$control-height",
234
+ "@mobile": "$sl-menu-button-size",
235
+ },
236
+
237
+ Label: {
238
+ $: "label",
239
+ boxSizing: "border-box",
240
+ position: "relative",
241
+ display: "inline-flex",
242
+ alignItems: "center",
243
+ inlineSize: "100%",
244
+ blockSize: "100%",
245
+ padding: "0",
246
+ border: "0",
247
+ fill: "#clear",
248
+ },
249
+ Icon: {
250
+ $: ".label-icon",
251
+ position: "absolute",
252
+ zIndex: "1",
253
+ insetInlineStart: "50%",
254
+ inlineSize: "1rem",
255
+ blockSize: "1rem",
256
+ color: "#text-soft",
257
+ translate: "-50% 0",
258
+ pointerEvents: "none",
259
+ },
260
+ Select: {
261
+ $: "select",
262
+ appearance: "base-select",
263
+ position: "static",
264
+ inlineSize: "100%",
265
+ minInlineSize: "0",
266
+ blockSize: "100%",
267
+ minBlockSize: "0",
268
+ padding: "0",
269
+ margin: "0",
270
+ color: "#clear",
271
+ preset: "small / strong",
272
+ border: true,
273
+ radius: "$radius",
274
+ fill: {
275
+ "": "#surface-3",
276
+ ":hover": "#surface-3-hover",
277
+ ":active": "#surface-3-pressed",
278
+ },
279
+ shadow: "none",
280
+ cursor: "pointer",
281
+ transition: "color 120ms ease, fill 120ms ease",
282
+ },
283
+ PickerIcon: { $: "select::picker-icon", hide: true },
284
+ Picker: {
285
+ $: "select::picker(select)",
286
+ appearance: "base-select",
287
+ gap: "1px",
288
+ minInlineSize: "8rem",
289
+ marginBlockStart: "0.5rem",
290
+ padding: "4px",
291
+ color: "#text",
292
+ border: true,
293
+ radius: "$card-radius",
294
+ fill: "#surface-2",
295
+ shadow: "0 0.75rem 2rem #shadow",
296
+ },
297
+ OpenPicker: {
298
+ $: "select::picker(select):popover-open",
299
+ display: "grid",
300
+ },
301
+ Option: {
302
+ $: "option",
303
+ padding: "0.625rem 0.75rem",
304
+ color: "#text",
305
+ preset: "small",
306
+ radius: "$radius",
307
+ fill: "#surface-2",
308
+ },
309
+ HoverOption: {
310
+ $: "option:hover, option:focus",
311
+ fill: "#surface-2-hover",
312
+ },
313
+ CheckedOption: {
314
+ $: "option:checked",
315
+ color: "#accent-text",
316
+ fill: "color-mix(in oklab, #accent-surface 12%, #surface-2)",
317
+ },
318
+ Checkmark: {
319
+ $: "option::checkmark",
320
+ order: "1",
321
+ marginInlineStart: "auto",
322
+ },
323
+ },
324
+ }),
325
+ );
326
+
327
+ export const MobileNavigationTabsRoot = customizeComponent(
328
+ "MobileNavigationTabs",
329
+ { as: "nav" },
330
+ tasty({
331
+ as: "nav",
332
+ styles: {
333
+ display: "grid",
334
+ hide: { "": false, "@desktop": true },
335
+ gap: "$gap",
336
+ marginBlockEnd: "($gap * 2)",
337
+ paddingBlockEnd: "($gap * 2)",
338
+ borderBlockEnd: "$border-width solid #border",
339
+ Label: {
340
+ $: ".td-mobile-tabs__label",
341
+ paddingInline: "($gap * 1.25)",
342
+ color: "#text",
343
+ preset: "navigation",
344
+ },
345
+ List: {
346
+ $: "ul",
347
+ display: "grid",
348
+ gridColumns: "repeat(2, minmax(0, 1fr))",
349
+ gap: "$gap",
350
+ padding: "0",
351
+ margin: "0",
352
+ listStyle: "none",
353
+ },
354
+ Item: { $: "li", margin: "0" },
355
+ Link: {
356
+ $: "a",
357
+ display: "flex",
358
+ alignItems: "center",
359
+ minBlockSize: "2.25rem",
360
+ padding: "($gap * 0.75) ($gap * 1.25)",
361
+ color: "#text-soft",
362
+ preset: "navigation",
363
+ textDecoration: "none",
364
+ radius: "$radius",
365
+ },
366
+ HoverLink: {
367
+ $: "a:hover",
368
+ color: "#text",
369
+ fill: "#surface-2-hover",
370
+ },
371
+ CurrentLink: {
372
+ $: 'a[aria-current="page"]',
373
+ color: "#accent-text",
374
+ fill: "color-mix(in oklab, #accent-surface 12%, #surface)",
375
+ },
376
+ },
377
+ }),
378
+ );
379
+
380
+ export const MobileMenuFooterRoot = customizeComponent(
381
+ "MobileMenuFooter",
382
+ { as: "div" },
383
+ tasty({
384
+ as: "div",
385
+ styles: {
386
+ display: "flex",
387
+ alignItems: "center",
388
+ justifyContent: "space-between",
389
+ flow: "row wrap",
390
+ gap: "($gap * 2)",
391
+ paddingBlock: "$gap",
392
+ borderBlockStart: "$border-width solid #border",
393
+ Social: {
394
+ $: ".td-mobile-preferences__social",
395
+ display: "flex",
396
+ hide: { "": false, ":empty": true },
397
+ alignItems: "center",
398
+ gap: "($gap * 2)",
399
+ marginInlineEnd: "auto",
400
+ paddingBlock: "($gap * 2)",
401
+ },
402
+ },
403
+ }),
404
+ );
@@ -0,0 +1,39 @@
1
+ ---
2
+ import { LogoRoot } from "./LayoutComponents.js";
3
+
4
+ interface Props {
5
+ label?: string;
6
+ decorative?: boolean;
7
+ class?: string;
8
+ }
9
+
10
+ const {
11
+ label = "Cookbook",
12
+ decorative = false,
13
+ class: className,
14
+ } = Astro.props;
15
+ ---
16
+
17
+ <LogoRoot
18
+ className={className}
19
+ aria-hidden={decorative ? "true" : undefined}
20
+ data-tasty-anatomy="Logo"
21
+ >
22
+ <svg
23
+ xmlns="http://www.w3.org/2000/svg"
24
+ viewBox="0 0 64 64"
25
+ role={decorative ? undefined : "img"}
26
+ aria-label={decorative ? undefined : label}
27
+ focusable="false"
28
+ >
29
+ <rect width="64" height="64" rx="14" fill="currentColor"></rect>
30
+ <path
31
+ fill="#fff"
32
+ d="M14.8 16c6.7.2 12.3 2 16.7 5.4v28.4c-4.4-3.1-10-4.7-16.6-4.9a3 3 0 0 1-2.9-3V19a3 3 0 0 1 2.8-3Z"
33
+ ></path>
34
+ <path
35
+ fill="#fff"
36
+ d="M49.2 16c-6.7.2-12.3 2-16.7 5.4v28.4c4.4-3.1 10-4.7 16.6-4.9a3 3 0 0 0 2.9-3V19a3 3 0 0 0-2.8-3Z"
37
+ ></path>
38
+ </svg>
39
+ </LogoRoot>
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import { layout } from "virtual:cookbook/layout";
3
3
  import { activeNavigationTab, navigationPath } from "../navigation.js";
4
+ import { MobileNavigationTabsRoot } from "./LayoutComponents.js";
4
5
 
5
6
  interface Props {
6
7
  base?: string;
@@ -21,7 +22,11 @@ function tabHref(link: string): string {
21
22
 
22
23
  {
23
24
  layout.tabs.length > 0 && (
24
- <nav class="td-mobile-tabs print:hidden" aria-label="Sections">
25
+ <MobileNavigationTabsRoot
26
+ className="td-mobile-tabs print:hidden"
27
+ aria-label="Sections"
28
+ data-tasty-anatomy="MobileNavigationTabs"
29
+ >
25
30
  <span class="td-mobile-tabs__label">Sections</span>
26
31
  <ul>
27
32
  {layout.tabs.map((tab, index) => (
@@ -35,6 +40,6 @@ function tabHref(link: string): string {
35
40
  </li>
36
41
  ))}
37
42
  </ul>
38
- </nav>
43
+ </MobileNavigationTabsRoot>
39
44
  )
40
45
  }
@@ -0,0 +1,22 @@
1
+ ---
2
+ import { PackageVersionRoot } from "./LayoutComponents.js";
3
+
4
+ interface Props {
5
+ version?: string;
6
+ }
7
+
8
+ const version = Astro.props.version?.trim();
9
+ const label = version?.startsWith("v") ? version : version ? `v${version}` : "";
10
+ ---
11
+
12
+ {
13
+ label && (
14
+ <PackageVersionRoot
15
+ className="td-package-version"
16
+ aria-label={`Version ${version}`}
17
+ data-tasty-anatomy="PackageVersion"
18
+ >
19
+ {label}
20
+ </PackageVersionRoot>
21
+ )
22
+ }
@@ -1,4 +1,6 @@
1
1
  ---
2
+ import { PreviewRoot } from "./TastyComponents.js";
3
+
2
4
  interface Props {
3
5
  title: string;
4
6
  html?: string;
@@ -10,22 +12,31 @@ const { title, html = "", css = "", javascript } = Astro.props;
10
12
  const source = `<!doctype html><meta charset="utf-8"><style>${css}</style>${html}${javascript ? `<script>${javascript}<\/script>` : ""}`;
11
13
  ---
12
14
 
13
- <figure class="td-preview" aria-label={title} data-tasty-anatomy="Preview">
14
- <figcaption><strong>{title}</strong></figcaption>
15
+ <PreviewRoot
16
+ className="td-preview"
17
+ aria-label={title}
18
+ data-tasty-anatomy="Preview"
19
+ >
20
+ <PreviewRoot.Caption><strong>{title}</strong></PreviewRoot.Caption>
15
21
  {
16
22
  javascript ? (
17
- <iframe title={title} sandbox="allow-scripts" srcdoc={source} />
23
+ <PreviewRoot.Frame
24
+ className="td-preview__frame"
25
+ title={title}
26
+ sandbox="allow-scripts"
27
+ srcDoc={source}
28
+ />
18
29
  ) : (
19
- <div class="td-preview__stage">
30
+ <PreviewRoot.Stage className="td-preview__stage">
20
31
  <template
21
32
  shadowrootmode="open"
22
33
  set:html={`<style>${css}</style>${html}`}
23
34
  />
24
- </div>
35
+ </PreviewRoot.Stage>
25
36
  )
26
37
  }
27
- <details class="td-preview__code">
28
- <summary>View source</summary>
29
- <pre><code>{source}</code></pre>
30
- </details>
31
- </figure>
38
+ <PreviewRoot.Code className="td-preview__code">
39
+ <PreviewRoot.Summary>View source</PreviewRoot.Summary>
40
+ <PreviewRoot.Pre><code>{source}</code></PreviewRoot.Pre>
41
+ </PreviewRoot.Code>
42
+ </PreviewRoot>
@@ -1 +1,5 @@
1
- <ol class="td-steps" data-tasty-anatomy="Steps"><slot /></ol>
1
+ ---
2
+ import { StepsRoot } from "./TastyComponents.js";
3
+ ---
4
+
5
+ <StepsRoot className="td-steps" data-tasty-anatomy="Steps"><slot /></StepsRoot>
@@ -1,10 +1,17 @@
1
1
  ---
2
+ import { TabsRoot } from "./TastyComponents.js";
3
+
2
4
  interface Props {
3
5
  label?: string;
4
6
  }
5
7
  const { label = "Examples" } = Astro.props;
6
8
  ---
7
9
 
8
- <div class="td-tabs" role="group" aria-label={label} data-tasty-anatomy="Tabs">
10
+ <TabsRoot
11
+ className="td-tabs"
12
+ role="group"
13
+ aria-label={label}
14
+ data-tasty-anatomy="Tabs"
15
+ >
9
16
  <slot />
10
- </div>
17
+ </TabsRoot>