@nyxwire/starlight 0.0.0-stage → 0.1.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +221 -2
  3. package/dist/config.d.ts +9 -0
  4. package/dist/config.js +32 -0
  5. package/dist/docs/foundations/accessibility.md +71 -0
  6. package/dist/docs/foundations/color-roles.md +114 -0
  7. package/dist/docs/foundations/effects-motion.md +150 -0
  8. package/dist/docs/foundations/flavors.md +156 -0
  9. package/dist/docs/foundations/icons.md +45 -0
  10. package/dist/docs/foundations/palette.md +180 -0
  11. package/dist/docs/foundations/spacing-elevation.md +168 -0
  12. package/dist/docs/foundations/typography.md +80 -0
  13. package/dist/docs/index.md +51 -0
  14. package/dist/docs/kitchen-sink.md +283 -0
  15. package/dist/docs/manifest.json +61 -0
  16. package/dist/docs/setup.md +190 -0
  17. package/dist/ec-themes.d.ts +443 -0
  18. package/dist/ec-themes.js +217 -0
  19. package/dist/expressive-code.d.ts +75 -0
  20. package/dist/expressive-code.js +101 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.js +25 -0
  23. package/dist/options.d.ts +29 -0
  24. package/dist/options.js +56 -0
  25. package/dist/runtime.d.ts +16 -0
  26. package/dist/runtime.js +52 -0
  27. package/dist/theme-bridge.d.ts +27 -0
  28. package/dist/theme-bridge.js +73 -0
  29. package/package.json +67 -3
  30. package/src/chrome.css +191 -0
  31. package/src/components/ThemeProvider.astro +15 -0
  32. package/src/components/ThemeSelect.astro +51 -0
  33. package/src/components/env.d.ts +5 -0
  34. package/src/config.ts +53 -0
  35. package/src/content-components.css +154 -0
  36. package/src/ec-themes.ts +246 -0
  37. package/src/expressive-code.ts +115 -0
  38. package/src/index.ts +32 -0
  39. package/src/options.ts +80 -0
  40. package/src/prose.css +108 -0
  41. package/src/runtime.ts +67 -0
  42. package/src/theme-bridge.css +130 -0
  43. package/src/theme-bridge.ts +89 -0
  44. package/styles.css +299 -0
package/src/chrome.css ADDED
@@ -0,0 +1,191 @@
1
+ .sl-skip-link:focus {
2
+ border-radius: var(--nw-radius-sm);
3
+ }
4
+
5
+ .page > header.header {
6
+ background-color: var(--nw-glass);
7
+ backdrop-filter: blur(var(--nw-blur-md)) saturate(1.25);
8
+ }
9
+
10
+ .page > header.header::after {
11
+ content: '';
12
+ position: absolute;
13
+ inset: auto 0 calc(-1 * var(--nw-space-px));
14
+ block-size: var(--nw-space-px);
15
+ pointer-events: none;
16
+ background: var(--nw-gradient-wire);
17
+ opacity: var(--nw-glow-strength);
18
+ }
19
+
20
+ .site-title {
21
+ font-weight: 650;
22
+ letter-spacing: var(--nw-tracking-tight);
23
+ transition: color var(--nw-duration-fast) var(--nw-ease-standard);
24
+ }
25
+
26
+ .site-title:hover {
27
+ color: var(--nw-link);
28
+ }
29
+
30
+ @media (min-width: 50rem) {
31
+ site-search button[data-open-modal] {
32
+ border-radius: var(--nw-radius-sm);
33
+ background: var(--nw-canvas-subtle);
34
+ color: var(--nw-fg-muted);
35
+ }
36
+
37
+ site-search button[data-open-modal]:hover {
38
+ background: var(--nw-panel);
39
+ color: var(--nw-fg);
40
+ }
41
+
42
+ site-search dialog {
43
+ border-radius: var(--nw-radius-lg);
44
+ box-shadow: var(--nw-shadow-lg);
45
+ }
46
+ }
47
+
48
+ site-search button[data-open-modal] kbd {
49
+ border: var(--nw-space-px) solid var(--nw-line-strong);
50
+ border-radius: var(--nw-radius-sm);
51
+ background: var(--nw-panel);
52
+ color: var(--nw-fg-muted);
53
+ font-family: var(--nw-font-mono);
54
+ }
55
+
56
+ site-search dialog::before {
57
+ content: '';
58
+ position: absolute;
59
+ inset: 0 var(--nw-space-4) auto;
60
+ block-size: var(--nw-space-px);
61
+ background: var(--nw-gradient-wire);
62
+ pointer-events: none;
63
+ }
64
+
65
+ #starlight__search {
66
+ --pagefind-ui-font: var(--nw-font-sans);
67
+ --sl-search-corners: var(--nw-radius-sm);
68
+ }
69
+
70
+ #starlight__search .pagefind-ui__search-input {
71
+ color: var(--nw-fg);
72
+ }
73
+
74
+ #starlight__search .pagefind-ui__search-input:focus-visible {
75
+ box-shadow: var(--nw-glow-sm);
76
+ }
77
+
78
+ #starlight__search .pagefind-ui__message,
79
+ .sidebar-content summary .group-label > .large,
80
+ .right-sidebar-panel h2 {
81
+ color: var(--nw-fg-muted);
82
+ font-family: var(--nw-font-mono);
83
+ font-size: var(--nw-text-xs);
84
+ font-weight: 500;
85
+ letter-spacing: var(--nw-tracking-wide);
86
+ }
87
+
88
+ #starlight__search
89
+ :is(
90
+ .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)),
91
+ .pagefind-ui__result-nested,
92
+ .pagefind-ui__result-tags
93
+ ) {
94
+ background: var(--nw-panel);
95
+ }
96
+
97
+ #starlight__search
98
+ :is(
99
+ .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)),
100
+ .pagefind-ui__result-nested
101
+ )
102
+ :is(a:hover, a:focus-visible) {
103
+ color: var(--nw-link);
104
+ }
105
+
106
+ #starlight__search
107
+ :is(
108
+ .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)),
109
+ .pagefind-ui__result-nested
110
+ ):hover {
111
+ background: var(--nw-panel-hover);
112
+ }
113
+
114
+ #starlight__search
115
+ :is(
116
+ .pagefind-ui__result-title:not(:where(.pagefind-ui__result-nested *)),
117
+ .pagefind-ui__result-nested
118
+ ):focus-within {
119
+ background: color-mix(in oklab, var(--nw-primary-soft), var(--nw-panel));
120
+ outline-color: var(--nw-ring);
121
+ }
122
+
123
+ #starlight__search .pagefind-ui__result-link {
124
+ font-family: var(--nw-font-display);
125
+ }
126
+
127
+ #starlight__search .pagefind-ui__result-nested .pagefind-ui__result-link {
128
+ font-family: var(--nw-font-sans);
129
+ }
130
+
131
+ #starlight__search .pagefind-ui__button {
132
+ border-radius: var(--nw-radius-sm);
133
+ color: var(--nw-fg);
134
+ font-weight: 600;
135
+ }
136
+
137
+ #starlight__search .pagefind-ui__button:hover {
138
+ background: var(--nw-panel-hover);
139
+ }
140
+
141
+ .sidebar-content :is(a, summary) {
142
+ border-radius: var(--nw-radius-sm);
143
+ }
144
+
145
+ .sidebar-content a[aria-current='page'] {
146
+ box-shadow: inset 0 0 0 var(--nw-space-px) var(--nw-primary);
147
+ }
148
+
149
+ .sidebar-content summary .caret {
150
+ color: var(--nw-fg-subtle);
151
+ }
152
+
153
+ .sl-menu-button {
154
+ border: var(--nw-space-px) solid var(--nw-line-strong);
155
+ background: var(--nw-panel);
156
+ color: var(--nw-fg);
157
+ }
158
+
159
+ .sl-menu-button:has(~ :popover-open) {
160
+ border-color: var(--nw-primary);
161
+ background: var(--nw-primary);
162
+ color: var(--nw-on-primary);
163
+ }
164
+
165
+ .mobile-preferences {
166
+ border-block-start-color: var(--nw-line);
167
+ }
168
+
169
+ mobile-starlight-toc .toggle {
170
+ border-radius: var(--nw-radius-sm);
171
+ }
172
+
173
+ mobile-starlight-toc .display-current {
174
+ color: var(--nw-fg-muted);
175
+ }
176
+
177
+ :is(nw-starlight-flavor-select, starlight-theme-select, starlight-lang-select) select {
178
+ min-block-size: calc(var(--nw-control-md) + var(--nw-space-1));
179
+ border-radius: var(--nw-radius-sm);
180
+ }
181
+
182
+ nw-starlight-flavor-select select:hover {
183
+ background-color: var(--nw-panel);
184
+ }
185
+
186
+ @media (forced-colors: active) {
187
+ .page > header.header::after,
188
+ site-search dialog::before {
189
+ display: none;
190
+ }
191
+ }
@@ -0,0 +1,15 @@
1
+ ---
2
+ import { Icon } from '@astrojs/starlight/components'
3
+ import runtime from 'virtual:nyxwire/starlight-runtime'
4
+ ---
5
+
6
+ <meta name="theme-color" content={runtime.themeColor} data-nyxwire-theme-color />
7
+ {/* Intentionally inline to avoid a flash of the wrong flavor. */}
8
+ <script is:inline set:html={runtime.script}></script>
9
+
10
+ {/* Label icons for theme pickers (Starlight's ThemeSelect and the Nyxwire flavor select). */}
11
+ <template id="theme-icons">
12
+ <Icon name="sun" class="light" />
13
+ <Icon name="moon" class="dark" />
14
+ <Icon name="laptop" class="auto" />
15
+ </template>
@@ -0,0 +1,51 @@
1
+ ---
2
+ import Select from '@astrojs/starlight/components/Select.astro'
3
+ import { flavorMeta, flavorNames } from '@nyxwire/palette'
4
+
5
+ const options = [
6
+ { label: Astro.locals.t('themeSelect.auto'), value: 'auto', selected: true },
7
+ ...flavorNames.map((id) => ({ label: flavorMeta[id].label, value: id, selected: false })),
8
+ ]
9
+ // Select.astro sizes its text box from `width`; grow it for long localized "Auto" labels.
10
+ const longestLabel = Math.max(...options.map((option) => option.label.length))
11
+ const width = `${Math.max(7.75, 0.56 * longestLabel + 3.2).toFixed(2)}em`
12
+ ---
13
+
14
+ <nw-starlight-flavor-select>
15
+ <Select
16
+ icon="laptop"
17
+ label={Astro.locals.t('themeSelect.accessibleLabel')}
18
+ options={options}
19
+ width={width}
20
+ />
21
+ </nw-starlight-flavor-select>
22
+
23
+ {/* Inlined to show the stored flavor before first paint (runtime from ThemeProvider). */}
24
+ <script is:inline>
25
+ window.StarlightThemeProvider?.updatePickers()
26
+ </script>
27
+
28
+ <script>
29
+ import { isFlavorPreference } from '@nyxwire/astro'
30
+ import type {} from '../theme-bridge.ts'
31
+
32
+ class NwStarlightFlavorSelect extends HTMLElement {
33
+ private readonly change = (event: Event) => {
34
+ const value = event.target instanceof HTMLSelectElement ? event.target.value : undefined
35
+ if (isFlavorPreference(value)) window.nyxwire?.setFlavor(value)
36
+ }
37
+
38
+ connectedCallback() {
39
+ this.addEventListener('change', this.change)
40
+ window.StarlightThemeProvider?.updatePickers()
41
+ }
42
+
43
+ disconnectedCallback() {
44
+ this.removeEventListener('change', this.change)
45
+ }
46
+ }
47
+
48
+ if (!customElements.get('nw-starlight-flavor-select')) {
49
+ customElements.define('nw-starlight-flavor-select', NwStarlightFlavorSelect)
50
+ }
51
+ </script>
@@ -0,0 +1,5 @@
1
+ /** Provided by the `@nyxwire/starlight` plugin (see `createRuntimeIntegration`). */
2
+ declare module 'virtual:nyxwire/starlight-runtime' {
3
+ const runtime: { readonly script: string; readonly themeColor: string }
4
+ export default runtime
5
+ }
package/src/config.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { StarlightUserConfig } from '@astrojs/starlight/types'
2
+ import { createExpressiveCodeOptions } from './expressive-code.js'
3
+ import type { NyxwireStarlightConfig } from './options.js'
4
+
5
+ export const PACKAGE_NAME = '@nyxwire/starlight'
6
+ export const STYLES_ENTRY = `${PACKAGE_NAME}/styles.css`
7
+ export const THEME_PROVIDER_COMPONENT = `${PACKAGE_NAME}/components/ThemeProvider.astro`
8
+ export const THEME_SELECT_COMPONENT = `${PACKAGE_NAME}/components/ThemeSelect.astro`
9
+
10
+ type ComponentOverrides = NonNullable<StarlightUserConfig['components']>
11
+ export type StarlightConfigUpdate = Pick<
12
+ StarlightUserConfig,
13
+ 'customCss' | 'components' | 'expressiveCode'
14
+ >
15
+
16
+ const OVERRIDES = {
17
+ ThemeProvider: THEME_PROVIDER_COMPONENT,
18
+ ThemeSelect: THEME_SELECT_COMPONENT,
19
+ } as const
20
+
21
+ function override(
22
+ name: keyof typeof OVERRIDES,
23
+ current: string | undefined,
24
+ warn: (message: string) => void,
25
+ ): string {
26
+ const ours = OVERRIDES[name]
27
+ if (current === undefined || current === ours) return ours
28
+ warn(
29
+ `Keeping your ${name} override (${current}). Nyxwire's ${name} (${ours}) is skipped, so ` +
30
+ 'custom theme components must retain the Nyxwire ThemeProvider runtime if they replace it.',
31
+ )
32
+ return current
33
+ }
34
+
35
+ /** The Starlight config update applied by the plugin's `config:setup` hook. */
36
+ export function createConfigUpdate(
37
+ user: StarlightUserConfig,
38
+ config: NyxwireStarlightConfig,
39
+ warn: (message: string) => void,
40
+ ): StarlightConfigUpdate {
41
+ const components: ComponentOverrides = {
42
+ ...user.components,
43
+ ThemeProvider: override('ThemeProvider', user.components?.ThemeProvider, warn),
44
+ }
45
+ if (config.flavorSelect) {
46
+ components.ThemeSelect = override('ThemeSelect', user.components?.ThemeSelect, warn)
47
+ }
48
+ const customCss = [STYLES_ENTRY, ...(user.customCss ?? []).filter((id) => id !== STYLES_ENTRY)]
49
+ const expressiveCode = createExpressiveCodeOptions(user.expressiveCode, config)
50
+ return expressiveCode === undefined
51
+ ? { customCss, components }
52
+ : { customCss, components, expressiveCode }
53
+ }
@@ -0,0 +1,154 @@
1
+ .starlight-aside__title,
2
+ .sl-markdown-content :is(article.card, .sl-link-card) .title {
3
+ font-family: var(--nw-font-display);
4
+ letter-spacing: var(--nw-tracking-tight);
5
+ }
6
+
7
+ .starlight-aside__icon {
8
+ --nw-glow-color: var(--sl-color-asides-border);
9
+ filter: var(--nw-glow-drop-sm);
10
+ }
11
+
12
+ .starlight-aside__content a {
13
+ text-decoration-color: color-mix(in oklab, currentColor 60%, transparent);
14
+ }
15
+
16
+ .sl-markdown-content .starlight-aside :not(pre) > code:not(:where(.not-content *)) {
17
+ border-color: color-mix(in oklab, var(--sl-color-asides-border) 50%, transparent);
18
+ color: var(--nw-fg);
19
+ }
20
+
21
+ .sl-badge {
22
+ border-radius: var(--nw-radius-sm);
23
+ font-weight: 600;
24
+ letter-spacing: var(--nw-tracking-wide);
25
+ }
26
+
27
+ .sl-badge.small,
28
+ .sidebar-content .sl-badge {
29
+ padding: var(--nw-space-0-5) var(--nw-space-1-5);
30
+ }
31
+
32
+ .sidebar-content .sl-badge {
33
+ font-size: var(--nw-text-2xs);
34
+ }
35
+
36
+ .sl-badge.medium {
37
+ padding: var(--nw-space-0-5) var(--nw-space-2);
38
+ }
39
+
40
+ .sl-badge.large {
41
+ padding: var(--nw-space-1) var(--nw-space-2-5);
42
+ }
43
+
44
+ .sl-markdown-content :is(article.card, .sl-link-card) {
45
+ box-shadow: var(--nw-shadow-sm);
46
+ }
47
+
48
+ .sl-markdown-content .sl-link-card:is(:hover, :focus-within) .icon {
49
+ color: var(--nw-primary);
50
+ }
51
+
52
+ :is(.hero .action, .sl-link-button) {
53
+ font-weight: 600;
54
+ letter-spacing: var(--nw-tracking-tight);
55
+ }
56
+
57
+ :is(.hero .action, .sl-link-button).minimal:hover {
58
+ color: var(--nw-link);
59
+ }
60
+
61
+ starlight-tabs .tab > [role='tab'] {
62
+ border-block-end: 2px solid transparent;
63
+ font-family: var(--nw-font-display);
64
+ font-weight: 600;
65
+ }
66
+
67
+ starlight-tabs .tab > [role='tab']:hover {
68
+ background: var(--nw-panel-hover);
69
+ color: var(--nw-fg);
70
+ }
71
+
72
+ starlight-tabs .tab > [role='tab'][aria-selected='true'] {
73
+ border-block-end-color: var(--nw-primary);
74
+ }
75
+
76
+ .sl-steps > li::before {
77
+ background: var(--nw-canvas-sunken);
78
+ box-shadow: inset 0 0 0 var(--nw-space-px) var(--nw-line-strong);
79
+ color: var(--nw-link);
80
+ font-family: var(--nw-font-mono);
81
+ }
82
+
83
+ starlight-file-tree {
84
+ border-color: var(--nw-line-strong);
85
+ border-radius: var(--nw-radius-md);
86
+ background: var(--nw-canvas-sunken);
87
+ scrollbar-width: thin;
88
+ }
89
+
90
+ starlight-file-tree .file {
91
+ color: var(--nw-fg-muted);
92
+ }
93
+
94
+ starlight-file-tree .highlight {
95
+ border-radius: var(--nw-radius-sm);
96
+ }
97
+
98
+ .expressive-code .frame.has-title:not(.is-terminal) .title::after {
99
+ filter: var(--nw-glow-drop-sm);
100
+ }
101
+
102
+ .expressive-code .frame.is-terminal .header::before {
103
+ background-color: transparent;
104
+ background-image: linear-gradient(
105
+ 90deg,
106
+ var(--nw-danger) 0 30%,
107
+ var(--nw-warning) 30% 70%,
108
+ var(--nw-success) 70%
109
+ );
110
+ }
111
+
112
+ .pagination-links a > span {
113
+ color: var(--nw-fg-muted);
114
+ font-family: var(--nw-font-mono);
115
+ font-size: var(--nw-text-xs);
116
+ letter-spacing: var(--nw-tracking-wide);
117
+ }
118
+
119
+ .pagination-links .link-title {
120
+ color: var(--nw-fg);
121
+ font-family: var(--nw-font-display);
122
+ font-size: var(--nw-text-xl);
123
+ font-weight: 600;
124
+ }
125
+
126
+ .pagination-links a:hover svg {
127
+ color: var(--nw-link);
128
+ }
129
+
130
+ .hero h1 {
131
+ inline-size: fit-content;
132
+ max-inline-size: 100%;
133
+ font-weight: 700;
134
+ text-wrap: balance;
135
+ }
136
+
137
+ @media (forced-colors: none) {
138
+ .hero h1 {
139
+ background-image: var(--nw-gradient-wire);
140
+ background-clip: text;
141
+ color: transparent;
142
+ }
143
+ }
144
+
145
+ .sl-banner {
146
+ background: var(--sl-color-banner-bg);
147
+ color: var(--sl-color-banner-text);
148
+ font-weight: 600;
149
+ }
150
+
151
+ .sl-banner a {
152
+ text-decoration-thickness: var(--nw-space-px);
153
+ text-underline-offset: 0.2em;
154
+ }