@nu-appdev/northwestern-starlight-theme 1.0.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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/expressive-code.mjs +18 -0
- package/index.ts +170 -0
- package/mermaid.ts +376 -0
- package/package.json +63 -0
- package/src/components/ConditionalEditLink.astro +7 -0
- package/src/components/Hero.astro +252 -0
- package/src/components/ThemeToggle.astro +199 -0
- package/src/scripts/mermaid-toolbar.ts +503 -0
- package/src/styles/components/cards.css +31 -0
- package/src/styles/components/code.css +168 -0
- package/src/styles/components/mermaid.css +86 -0
- package/src/styles/components/steps.css +28 -0
- package/src/styles/components/tabs.css +103 -0
- package/src/styles/components/utility-surfaces.css +41 -0
- package/src/styles/content.css +386 -0
- package/src/styles/layers.css +8 -0
- package/src/styles/mermaid-toolbar.css +163 -0
- package/src/styles/navigation.css +201 -0
- package/src/styles/openapi.css +119 -0
- package/src/styles/theme.css +114 -0
- package/src/styles/typography.css +170 -0
- package/src/styles/variables.css +121 -0
- package/src/virtual.d.ts +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2025-06-01
|
|
11
|
+
|
|
12
|
+
- Initial public release
|
|
13
|
+
- Northwestern Purple color palette mapped to Starlight's accent system
|
|
14
|
+
- Akkurat Pro (body) and Poppins (headings) loaded from Northwestern CDN
|
|
15
|
+
- Styled tables, badges, asides, cards, tabs, and code blocks
|
|
16
|
+
- Mermaid diagram support with Northwestern colors and fullscreen viewer
|
|
17
|
+
- OpenAPI plugin compatibility with method badge preservation
|
|
18
|
+
- Reduced motion support for transitions
|
|
19
|
+
|
|
20
|
+
[Unreleased]: https://github.com/NIT-Administrative-Systems/northwestern-starlight-theme/compare/v1.0.0...HEAD
|
|
21
|
+
[1.0.0]: https://github.com/NIT-Administrative-Systems/northwestern-starlight-theme/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Northwestern University
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img src="/art/logo.svg" width="80" alt="Northwestern Starlight Theme"><br/>
|
|
3
|
+
Northwestern Starlight Theme
|
|
4
|
+
</h1>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-22+-339933?style=flat&logo=node.js&logoColor=white" alt="Node Version"></a>
|
|
8
|
+
<a href="https://astro.build"><img src="https://img.shields.io/badge/Astro-5.x+-BC52EE?style=flat&logo=astro&logoColor=white" alt="Astro Version"></a>
|
|
9
|
+
<a href="https://starlight.astro.build"><img src="https://img.shields.io/badge/Starlight-0.32+-FF5D01?style=flat&logo=astro&logoColor=white" alt="Starlight Version"></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
A branded <a href="https://starlight.astro.build">Starlight</a> theme plugin for <a href="https://www.northwestern.edu">Northwestern University</a> documentation sites.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @nu-appdev/northwestern-starlight-theme
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import starlight from "@astrojs/starlight";
|
|
24
|
+
import { defineConfig } from "astro/config";
|
|
25
|
+
import northwesternTheme from "@nu-appdev/northwestern-starlight-theme";
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
integrations: [
|
|
29
|
+
starlight({
|
|
30
|
+
plugins: [northwesternTheme()],
|
|
31
|
+
title: "My Docs",
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The plugin applies Northwestern's purple palette, Akkurat Pro + Poppins typography, branded navigation, styled components, and full dark mode support. No additional CSS or configuration required.
|
|
38
|
+
|
|
39
|
+
See the **[documentation](https://starlight-theme.entapp.northwestern.edu)** for setup options, customization, and component examples.
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm install
|
|
45
|
+
pnpm docs:dev # Start docs dev server
|
|
46
|
+
pnpm verify # Lint, fix, and build
|
|
47
|
+
pnpm verify:full # Above + accessibility tests
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { pluginLineNumbers } from "@expressive-code/plugin-line-numbers";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import("@astrojs/starlight/expressive-code").StarlightExpressiveCodeOptions} [config]
|
|
5
|
+
* @returns {import("@astrojs/starlight/expressive-code").StarlightExpressiveCodeOptions}
|
|
6
|
+
*/
|
|
7
|
+
export function northwesternExpressiveCode(config = {}) {
|
|
8
|
+
const { defaultProps, plugins, ...rest } = config;
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
...rest,
|
|
12
|
+
plugins: [pluginLineNumbers(), ...(plugins ?? [])],
|
|
13
|
+
defaultProps: {
|
|
14
|
+
showLineNumbers: false,
|
|
15
|
+
...(defaultProps ?? {}),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { StarlightPlugin } from "@astrojs/starlight/types";
|
|
2
|
+
|
|
3
|
+
export interface NorthwesternHomepageConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Hero layout style.
|
|
6
|
+
*
|
|
7
|
+
* - `"centered"` (default) — image above title, everything centered
|
|
8
|
+
* - `"split"` — text + buttons on the left, image on the right (60/40 split)
|
|
9
|
+
*/
|
|
10
|
+
layout?: "centered" | "split";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Whether to display the page title in the hero.
|
|
14
|
+
*
|
|
15
|
+
* Set to `false` when the hero image is a lockup that already contains the title.
|
|
16
|
+
*
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
showTitle?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface NorthwesternThemeConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Homepage hero layout configuration.
|
|
25
|
+
*/
|
|
26
|
+
homepage?: NorthwesternHomepageConfig;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Mermaid diagram support.
|
|
30
|
+
*
|
|
31
|
+
* - `true` (default) — auto-detect: enables mermaid if `astro-mermaid` and `mermaid`
|
|
32
|
+
* are installed, skips silently if they are not
|
|
33
|
+
* - `false` — disables mermaid entirely
|
|
34
|
+
* - `object` — enables mermaid with custom config (merged with Northwestern defaults)
|
|
35
|
+
*/
|
|
36
|
+
mermaid?: boolean | Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Try to resolve a module. Returns true if it can be imported.
|
|
41
|
+
*/
|
|
42
|
+
async function canResolve(id: string): Promise<boolean> {
|
|
43
|
+
try {
|
|
44
|
+
await import(/* @vite-ignore */ id);
|
|
45
|
+
return true;
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const VIRTUAL_MODULE_ID = "virtual:northwestern-theme/config";
|
|
52
|
+
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
53
|
+
|
|
54
|
+
export default function northwesternTheme(config: NorthwesternThemeConfig = {}): StarlightPlugin {
|
|
55
|
+
const { homepage = {}, mermaid = true } = config;
|
|
56
|
+
const themeConfig = { homepage: { layout: homepage.layout ?? "centered", showTitle: homepage.showTitle ?? true } };
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
name: "northwestern-starlight-theme",
|
|
60
|
+
hooks: {
|
|
61
|
+
async "config:setup"({ config: starlightConfig, updateConfig, addIntegration, logger }) {
|
|
62
|
+
addIntegration({
|
|
63
|
+
name: "northwestern-theme-config",
|
|
64
|
+
hooks: {
|
|
65
|
+
"astro:config:setup": ({ updateConfig: updateAstroConfig }) => {
|
|
66
|
+
updateAstroConfig({
|
|
67
|
+
vite: {
|
|
68
|
+
plugins: [
|
|
69
|
+
{
|
|
70
|
+
name: "northwestern-theme-virtual-config",
|
|
71
|
+
resolveId(id: string) {
|
|
72
|
+
if (id === VIRTUAL_MODULE_ID) return RESOLVED_VIRTUAL_MODULE_ID;
|
|
73
|
+
},
|
|
74
|
+
load(id: string) {
|
|
75
|
+
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
76
|
+
return `export default ${JSON.stringify(themeConfig)};`;
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
// Detect mermaid availability
|
|
87
|
+
let mermaidEnabled = mermaid !== false;
|
|
88
|
+
|
|
89
|
+
if (mermaidEnabled) {
|
|
90
|
+
const hasMermaid = await canResolve("astro-mermaid");
|
|
91
|
+
|
|
92
|
+
if (!hasMermaid) {
|
|
93
|
+
if (typeof mermaid === "object") {
|
|
94
|
+
// User explicitly configured mermaid but it's not installed
|
|
95
|
+
logger.warn(
|
|
96
|
+
'Mermaid config was provided but "astro-mermaid" and "mermaid" are not installed.\n' +
|
|
97
|
+
" Run: pnpm add astro-mermaid mermaid",
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
mermaidEnabled = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
updateConfig({
|
|
105
|
+
components: {
|
|
106
|
+
...(starlightConfig.components ?? {}),
|
|
107
|
+
Hero:
|
|
108
|
+
starlightConfig.components?.Hero ??
|
|
109
|
+
"@nu-appdev/northwestern-starlight-theme/src/components/Hero.astro",
|
|
110
|
+
EditLink:
|
|
111
|
+
starlightConfig.components?.EditLink ??
|
|
112
|
+
"@nu-appdev/northwestern-starlight-theme/src/components/ConditionalEditLink.astro",
|
|
113
|
+
ThemeSelect:
|
|
114
|
+
starlightConfig.components?.ThemeSelect ??
|
|
115
|
+
"@nu-appdev/northwestern-starlight-theme/src/components/ThemeToggle.astro",
|
|
116
|
+
},
|
|
117
|
+
customCss: [
|
|
118
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/layers.css",
|
|
119
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/variables.css",
|
|
120
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/typography.css",
|
|
121
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/theme.css",
|
|
122
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/navigation.css",
|
|
123
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/content.css",
|
|
124
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/components/cards.css",
|
|
125
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/components/utility-surfaces.css",
|
|
126
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/components/steps.css",
|
|
127
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/components/code.css",
|
|
128
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/components/tabs.css",
|
|
129
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/components/mermaid.css",
|
|
130
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/mermaid-toolbar.css",
|
|
131
|
+
"@nu-appdev/northwestern-starlight-theme/src/styles/openapi.css",
|
|
132
|
+
...(starlightConfig.customCss ?? []),
|
|
133
|
+
],
|
|
134
|
+
expressiveCode: {
|
|
135
|
+
themes: ["github-dark", "github-light"],
|
|
136
|
+
useStarlightUiThemeColors: true,
|
|
137
|
+
...(typeof starlightConfig.expressiveCode === "object" ? starlightConfig.expressiveCode : {}),
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (mermaidEnabled) {
|
|
142
|
+
const { default: mermaidIntegration } = await import("astro-mermaid");
|
|
143
|
+
const { defaultMermaidConfig } = await import("./mermaid.ts");
|
|
144
|
+
|
|
145
|
+
const userOverrides = typeof mermaid === "object" ? (mermaid as Record<string, unknown>) : {};
|
|
146
|
+
const mergedConfig = {
|
|
147
|
+
...defaultMermaidConfig,
|
|
148
|
+
...userOverrides,
|
|
149
|
+
enableLog: false,
|
|
150
|
+
mermaidConfig: {
|
|
151
|
+
...(defaultMermaidConfig.mermaidConfig ?? {}),
|
|
152
|
+
...((userOverrides.mermaidConfig as Record<string, unknown>) ?? {}),
|
|
153
|
+
themeVariables: {
|
|
154
|
+
...((defaultMermaidConfig.mermaidConfig as Record<string, unknown>)?.themeVariables ??
|
|
155
|
+
{}),
|
|
156
|
+
...(((userOverrides.mermaidConfig as Record<string, unknown>)?.themeVariables as Record<
|
|
157
|
+
string,
|
|
158
|
+
unknown
|
|
159
|
+
>) ?? {}),
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
addIntegration(mermaidIntegration(mergedConfig));
|
|
165
|
+
logger.info("Mermaid support enabled");
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
package/mermaid.ts
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import type { AstroIntegration } from "astro";
|
|
2
|
+
import mermaid, { type AstroMermaidOptions } from "astro-mermaid";
|
|
3
|
+
import { darken, isDark, lighten, mix, transparentize } from "khroma";
|
|
4
|
+
|
|
5
|
+
export interface NorthwesternMermaidOptions extends AstroMermaidOptions {
|
|
6
|
+
toolbar?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type NorthwesternMermaidMode = "light" | "dark";
|
|
10
|
+
|
|
11
|
+
type ThemeVariables = Record<string, unknown>;
|
|
12
|
+
|
|
13
|
+
type BrandPalette = {
|
|
14
|
+
purple: string;
|
|
15
|
+
blue: string;
|
|
16
|
+
green: string;
|
|
17
|
+
yellow: string;
|
|
18
|
+
red: string;
|
|
19
|
+
teal: string;
|
|
20
|
+
orange: string;
|
|
21
|
+
white: string;
|
|
22
|
+
black: string;
|
|
23
|
+
canvas: string;
|
|
24
|
+
text: string;
|
|
25
|
+
textMuted: string;
|
|
26
|
+
surface: string;
|
|
27
|
+
surfaceAlt: string;
|
|
28
|
+
border: string;
|
|
29
|
+
edgeLabel: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const chartPalette = ["#4e2a84", "#836eaa", "#5091cd", "#008656", "#ffc520", "#ef553f", "#7fcecd", "#d85820"];
|
|
33
|
+
|
|
34
|
+
function onColor(color: string, darkText = "#342f2e", lightText = "#fff") {
|
|
35
|
+
return isDark(color) ? lightText : darkText;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createPalette(mode: NorthwesternMermaidMode): BrandPalette {
|
|
39
|
+
if (mode === "dark") {
|
|
40
|
+
const canvas = "#1c1c1f";
|
|
41
|
+
const purple = lighten("#4e2a84", 8);
|
|
42
|
+
const blue = lighten("#1168bd", 6);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
purple,
|
|
46
|
+
blue,
|
|
47
|
+
green: "#008656",
|
|
48
|
+
yellow: "#ffc520",
|
|
49
|
+
red: "#ef553f",
|
|
50
|
+
teal: "#7fcecd",
|
|
51
|
+
orange: "#d85820",
|
|
52
|
+
white: "#fff",
|
|
53
|
+
black: "#342f2e",
|
|
54
|
+
canvas,
|
|
55
|
+
text: "#f0f0f0",
|
|
56
|
+
textMuted: mix("#f0f0f0", canvas, 60),
|
|
57
|
+
surface: mix("#4e2a84", canvas, 18),
|
|
58
|
+
surfaceAlt: mix("#fff", canvas, 8),
|
|
59
|
+
border: mix("#b6acd1", canvas, 18),
|
|
60
|
+
edgeLabel: "#fff",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
purple: "#4e2a84",
|
|
66
|
+
blue: "#1168bd",
|
|
67
|
+
green: "#008656",
|
|
68
|
+
yellow: "#ffc520",
|
|
69
|
+
red: "#ef553f",
|
|
70
|
+
teal: "#7fcecd",
|
|
71
|
+
orange: "#d85820",
|
|
72
|
+
white: "#fff",
|
|
73
|
+
black: "#342f2e",
|
|
74
|
+
canvas: "#fff",
|
|
75
|
+
text: "#342f2e",
|
|
76
|
+
textMuted: mix("#342f2e", "#fff", 45),
|
|
77
|
+
surface: "#f3f0f7",
|
|
78
|
+
surfaceAlt: "#e4e0ee",
|
|
79
|
+
border: "#b6acd1",
|
|
80
|
+
edgeLabel: "#fff",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function createThemeVariables(mode: NorthwesternMermaidMode): ThemeVariables {
|
|
85
|
+
const palette = createPalette(mode);
|
|
86
|
+
const dark = mode === "dark";
|
|
87
|
+
const primary = palette.purple;
|
|
88
|
+
const primaryBorder = dark ? lighten(primary, 24) : darken(primary, 10);
|
|
89
|
+
const secondary = dark ? palette.surface : palette.surfaceAlt;
|
|
90
|
+
const tertiary = dark ? mix(palette.white, palette.canvas, 6) : palette.surface;
|
|
91
|
+
const noteBackground = dark ? mix(primary, palette.canvas, 16) : palette.surface;
|
|
92
|
+
const actorLine = dark ? primary : primary;
|
|
93
|
+
const activation = dark ? mix(primary, palette.canvas, 28) : palette.surfaceAlt;
|
|
94
|
+
const cluster = dark ? mix(primary, palette.canvas, 10) : lighten(palette.surface, 2);
|
|
95
|
+
const _externalSystem = dark ? mix(palette.white, palette.canvas, 38) : "#999";
|
|
96
|
+
const stateBackground = dark ? mix(palette.white, palette.canvas, 8) : tertiary;
|
|
97
|
+
const compositeBackground = dark ? mix(palette.white, palette.canvas, 5) : palette.white;
|
|
98
|
+
const compositeAltBackground = dark ? mix(palette.purple, palette.canvas, 22) : palette.surfaceAlt;
|
|
99
|
+
const stateTitleBackground = dark ? mix(primary, palette.canvas, 14) : tertiary;
|
|
100
|
+
const stateLabelColor = dark ? palette.white : palette.black;
|
|
101
|
+
const rowOdd = dark ? mix(primary, palette.canvas, 26) : palette.surface;
|
|
102
|
+
const rowEven = dark ? mix(palette.white, palette.canvas, 8) : palette.white;
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
primaryColor: primary,
|
|
106
|
+
primaryTextColor: onColor(primary),
|
|
107
|
+
primaryBorderColor: primaryBorder,
|
|
108
|
+
|
|
109
|
+
secondaryColor: secondary,
|
|
110
|
+
secondaryTextColor: onColor(secondary),
|
|
111
|
+
secondaryBorderColor: palette.border,
|
|
112
|
+
|
|
113
|
+
tertiaryColor: tertiary,
|
|
114
|
+
tertiaryTextColor: onColor(tertiary),
|
|
115
|
+
tertiaryBorderColor: dark ? mix(palette.border, palette.canvas, 24) : lighten(palette.border, 8),
|
|
116
|
+
|
|
117
|
+
background: palette.canvas,
|
|
118
|
+
mainBkg: primary,
|
|
119
|
+
secondBkg: secondary,
|
|
120
|
+
tertiaryBkg: tertiary,
|
|
121
|
+
|
|
122
|
+
textColor: palette.text,
|
|
123
|
+
taskTextColor: palette.text,
|
|
124
|
+
taskTextLightColor: palette.white,
|
|
125
|
+
nodeTextColor: onColor(primary),
|
|
126
|
+
textColorStrong: palette.text,
|
|
127
|
+
mainContrastColor: palette.text,
|
|
128
|
+
darkTextColor: palette.black,
|
|
129
|
+
lineColor: dark ? lighten(primary, 28) : primary,
|
|
130
|
+
arrowheadColor: dark ? lighten(primary, 28) : primary,
|
|
131
|
+
defaultLinkColor: dark ? lighten(primary, 28) : primary,
|
|
132
|
+
fontFamily: '"Akkurat Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
133
|
+
fontSize: "14px",
|
|
134
|
+
|
|
135
|
+
nodeBkg: primary,
|
|
136
|
+
nodeBorder: primaryBorder,
|
|
137
|
+
border1: palette.border,
|
|
138
|
+
border2: primaryBorder,
|
|
139
|
+
clusterBkg: cluster,
|
|
140
|
+
clusterBorder: palette.border,
|
|
141
|
+
edgeLabelBackground: palette.edgeLabel,
|
|
142
|
+
labelBackground: palette.edgeLabel,
|
|
143
|
+
|
|
144
|
+
titleColor: palette.text,
|
|
145
|
+
labelColor: palette.text,
|
|
146
|
+
labelTextColor: palette.text,
|
|
147
|
+
loopTextColor: palette.text,
|
|
148
|
+
transitionColor: dark ? lighten(primary, 28) : primary,
|
|
149
|
+
transitionLabelColor: palette.black,
|
|
150
|
+
stateLabelColor,
|
|
151
|
+
stateBkg: stateBackground,
|
|
152
|
+
labelBackgroundColor: palette.edgeLabel,
|
|
153
|
+
compositeBackground,
|
|
154
|
+
compositeTitleBackground: stateTitleBackground,
|
|
155
|
+
compositeBorder: palette.border,
|
|
156
|
+
innerEndBackground: compositeBackground,
|
|
157
|
+
specialStateColor: primary,
|
|
158
|
+
|
|
159
|
+
noteBkgColor: noteBackground,
|
|
160
|
+
noteBorderColor: palette.border,
|
|
161
|
+
noteTextColor: palette.text,
|
|
162
|
+
|
|
163
|
+
actorBkg: primary,
|
|
164
|
+
actorBorder: primaryBorder,
|
|
165
|
+
actorTextColor: onColor(primary),
|
|
166
|
+
actorLineColor: actorLine,
|
|
167
|
+
signalColor: palette.text,
|
|
168
|
+
signalTextColor: palette.text,
|
|
169
|
+
labelBoxBkgColor: noteBackground,
|
|
170
|
+
labelBoxBorderColor: palette.border,
|
|
171
|
+
activationBkgColor: activation,
|
|
172
|
+
activationBorderColor: actorLine,
|
|
173
|
+
sequenceNumberColor: dark ? palette.black : palette.white,
|
|
174
|
+
|
|
175
|
+
taskBorderColor: primaryBorder,
|
|
176
|
+
taskBkgColor: primary,
|
|
177
|
+
taskTextOutsideColor: palette.text,
|
|
178
|
+
taskTextClickableColor: dark ? lighten(primary, 32) : primary,
|
|
179
|
+
activeTaskBorderColor: dark ? lighten(primary, 20) : darken(primary, 10),
|
|
180
|
+
activeTaskBkgColor: dark ? lighten(primary, 12) : lighten(primary, 8),
|
|
181
|
+
gridColor: dark ? mix(palette.white, palette.canvas, 15) : "#ddd",
|
|
182
|
+
doneTaskBkgColor: dark ? mix(palette.green, palette.canvas, 30) : lighten(palette.green, 30),
|
|
183
|
+
doneTaskBorderColor: palette.green,
|
|
184
|
+
critBorderColor: palette.red,
|
|
185
|
+
critBkgColor: dark ? mix(palette.red, palette.canvas, 30) : lighten(palette.red, 30),
|
|
186
|
+
taskTextDarkColor: palette.text,
|
|
187
|
+
todayLineColor: palette.red,
|
|
188
|
+
|
|
189
|
+
errorBkgColor: dark ? mix(palette.red, palette.canvas, 30) : lighten(palette.red, 36),
|
|
190
|
+
errorTextColor: dark ? lighten(palette.red, 20) : palette.red,
|
|
191
|
+
|
|
192
|
+
requirementBackground: dark ? mix(primary, palette.canvas, 20) : palette.surface,
|
|
193
|
+
requirementBorderColor: palette.border,
|
|
194
|
+
requirementBorderSize: "1",
|
|
195
|
+
requirementTextColor: palette.text,
|
|
196
|
+
relationColor: dark ? lighten(primary, 28) : primary,
|
|
197
|
+
relationLabelBackground: palette.edgeLabel,
|
|
198
|
+
relationLabelColor: palette.text,
|
|
199
|
+
|
|
200
|
+
altBackground: secondary,
|
|
201
|
+
classText: palette.white,
|
|
202
|
+
fillType0: primary,
|
|
203
|
+
fillType1: secondary,
|
|
204
|
+
fillType2: mix("#8b1e5a", palette.canvas, dark ? 20 : 0),
|
|
205
|
+
fillType3: mix("#f1dfe8", palette.canvas, dark ? 65 : 0),
|
|
206
|
+
fillType4: mix("#0d5f90", palette.canvas, dark ? 10 : 0),
|
|
207
|
+
fillType5: mix("#d9eef6", palette.canvas, dark ? 65 : 0),
|
|
208
|
+
fillType6: mix("#8d4a00", palette.canvas, dark ? 10 : 0),
|
|
209
|
+
fillType7: mix("#f8e9d7", palette.canvas, dark ? 68 : 0),
|
|
210
|
+
|
|
211
|
+
rowOdd,
|
|
212
|
+
rowEven,
|
|
213
|
+
attributeBackgroundColorOdd: dark ? transparentize(primary, 0.76) : palette.surface,
|
|
214
|
+
attributeBackgroundColorEven: dark ? "#1f1f23" : palette.white,
|
|
215
|
+
sectionBkgColor: rowOdd,
|
|
216
|
+
altSectionBkgColor: rowEven,
|
|
217
|
+
sectionBkgColor2: compositeAltBackground,
|
|
218
|
+
|
|
219
|
+
git0: chartPalette[0],
|
|
220
|
+
git1: chartPalette[1],
|
|
221
|
+
git2: chartPalette[2],
|
|
222
|
+
git3: chartPalette[3],
|
|
223
|
+
git4: chartPalette[4],
|
|
224
|
+
git5: chartPalette[5],
|
|
225
|
+
git6: chartPalette[6],
|
|
226
|
+
git7: chartPalette[7],
|
|
227
|
+
gitBranchLabel0: onColor(chartPalette[0]),
|
|
228
|
+
gitBranchLabel1: onColor(chartPalette[1]),
|
|
229
|
+
gitBranchLabel2: onColor(chartPalette[2]),
|
|
230
|
+
gitBranchLabel3: onColor(chartPalette[3]),
|
|
231
|
+
gitBranchLabel4: onColor(chartPalette[4]),
|
|
232
|
+
gitBranchLabel5: onColor(chartPalette[5]),
|
|
233
|
+
gitBranchLabel6: onColor(chartPalette[6]),
|
|
234
|
+
gitBranchLabel7: onColor(chartPalette[7]),
|
|
235
|
+
gitInv0: palette.white,
|
|
236
|
+
|
|
237
|
+
pie1: chartPalette[0],
|
|
238
|
+
pie2: chartPalette[1],
|
|
239
|
+
pie3: chartPalette[2],
|
|
240
|
+
pie4: chartPalette[3],
|
|
241
|
+
pie5: chartPalette[4],
|
|
242
|
+
pie6: chartPalette[5],
|
|
243
|
+
pie7: chartPalette[6],
|
|
244
|
+
pie8: chartPalette[7],
|
|
245
|
+
pie9: dark ? lighten(chartPalette[0], 16) : darken(chartPalette[0], 10),
|
|
246
|
+
pie10: dark ? lighten(chartPalette[2], 16) : darken(chartPalette[2], 10),
|
|
247
|
+
pie11: dark ? lighten(chartPalette[3], 16) : darken(chartPalette[3], 10),
|
|
248
|
+
pie12: dark ? lighten(chartPalette[4], 10) : darken(chartPalette[4], 10),
|
|
249
|
+
pieStrokeColor: dark ? palette.canvas : palette.white,
|
|
250
|
+
pieSectionTextColor: palette.white,
|
|
251
|
+
pieSectionTextSize: "14px",
|
|
252
|
+
pieTitleTextColor: palette.text,
|
|
253
|
+
pieTitleTextSize: "16px",
|
|
254
|
+
pieLegendTextColor: palette.text,
|
|
255
|
+
pieLegendTextSize: "14px",
|
|
256
|
+
pieStrokeWidth: "2px",
|
|
257
|
+
pieOuterStrokeWidth: "1px",
|
|
258
|
+
pieOuterStrokeColor: dark ? palette.border : palette.border,
|
|
259
|
+
pieOpacity: "0.85",
|
|
260
|
+
|
|
261
|
+
cScale0: dark ? mix(primary, palette.canvas, 40) : primary,
|
|
262
|
+
cScale1: dark ? mix(palette.blue, palette.canvas, 40) : palette.blue,
|
|
263
|
+
cScale2: dark ? mix(palette.green, palette.canvas, 40) : palette.green,
|
|
264
|
+
cScale3: dark ? mix(palette.orange, palette.canvas, 35) : palette.orange,
|
|
265
|
+
cScale4: dark ? mix(palette.teal, palette.canvas, 35) : darken(palette.teal, 15),
|
|
266
|
+
cScale5: dark ? mix(palette.yellow, palette.canvas, 30) : darken(palette.yellow, 20),
|
|
267
|
+
cScale6: dark ? mix(palette.red, palette.canvas, 35) : palette.red,
|
|
268
|
+
cScale7: dark ? mix(primary, palette.canvas, 30) : lighten(primary, 10),
|
|
269
|
+
|
|
270
|
+
cScaleLabel0: palette.white,
|
|
271
|
+
cScaleLabel1: palette.white,
|
|
272
|
+
cScaleLabel2: palette.white,
|
|
273
|
+
cScaleLabel3: palette.white,
|
|
274
|
+
cScaleLabel4: dark ? palette.white : palette.black,
|
|
275
|
+
cScaleLabel5: palette.black,
|
|
276
|
+
cScaleLabel6: palette.white,
|
|
277
|
+
cScaleLabel7: palette.white,
|
|
278
|
+
|
|
279
|
+
quadrant1Fill: dark ? mix(primary, palette.canvas, 35) : mix(primary, palette.white, 25),
|
|
280
|
+
quadrant2Fill: dark ? mix(primary, palette.canvas, 28) : mix(primary, palette.white, 18),
|
|
281
|
+
quadrant3Fill: dark ? mix(primary, palette.canvas, 22) : mix(primary, palette.white, 12),
|
|
282
|
+
quadrant4Fill: dark ? mix(primary, palette.canvas, 15) : mix(primary, palette.white, 8),
|
|
283
|
+
quadrant1TextFill: onColor(dark ? mix(primary, palette.canvas, 35) : mix(primary, palette.white, 25)),
|
|
284
|
+
quadrant2TextFill: onColor(dark ? mix(primary, palette.canvas, 28) : mix(primary, palette.white, 18)),
|
|
285
|
+
quadrant3TextFill: onColor(dark ? mix(primary, palette.canvas, 22) : mix(primary, palette.white, 12)),
|
|
286
|
+
quadrant4TextFill: onColor(dark ? mix(primary, palette.canvas, 15) : mix(primary, palette.white, 8)),
|
|
287
|
+
quadrantPointFill: primary,
|
|
288
|
+
quadrantPointTextFill: dark ? palette.white : palette.black,
|
|
289
|
+
quadrantXAxisTextFill: palette.text,
|
|
290
|
+
quadrantYAxisTextFill: palette.text,
|
|
291
|
+
quadrantTitleFill: palette.text,
|
|
292
|
+
quadrantInternalBorderStrokeFill: dark ? palette.border : lighten(palette.border, 10),
|
|
293
|
+
quadrantExternalBorderStrokeFill: palette.border,
|
|
294
|
+
|
|
295
|
+
xyChart: {
|
|
296
|
+
plotColorPalette: chartPalette.join(","),
|
|
297
|
+
titleColor: dark ? "#342f2e" : palette.text,
|
|
298
|
+
xAxisLabelColor: dark ? "#342f2e" : palette.text,
|
|
299
|
+
yAxisLabelColor: dark ? "#342f2e" : palette.text,
|
|
300
|
+
xAxisTitleColor: dark ? "#342f2e" : palette.text,
|
|
301
|
+
yAxisTitleColor: dark ? "#342f2e" : palette.text,
|
|
302
|
+
xAxisLineColor: "#ccc",
|
|
303
|
+
yAxisLineColor: "#ccc",
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function createNorthwesternMermaidConfig(mode: NorthwesternMermaidMode): AstroMermaidOptions {
|
|
309
|
+
const palette = createPalette(mode);
|
|
310
|
+
return {
|
|
311
|
+
theme: "base",
|
|
312
|
+
autoTheme: false,
|
|
313
|
+
mermaidConfig: {
|
|
314
|
+
themeVariables: createThemeVariables(mode),
|
|
315
|
+
xyChart: {
|
|
316
|
+
plotColorPalette: chartPalette.join(","),
|
|
317
|
+
titleColor: mode === "dark" ? "#342f2e" : palette.text,
|
|
318
|
+
xAxisLabelColor: mode === "dark" ? "#342f2e" : palette.text,
|
|
319
|
+
yAxisLabelColor: mode === "dark" ? "#342f2e" : palette.text,
|
|
320
|
+
xAxisTitleColor: mode === "dark" ? "#342f2e" : palette.text,
|
|
321
|
+
yAxisTitleColor: mode === "dark" ? "#342f2e" : palette.text,
|
|
322
|
+
xAxisLineColor: "#ccc",
|
|
323
|
+
yAxisLineColor: "#ccc",
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Northwestern-branded Mermaid configuration.
|
|
331
|
+
*
|
|
332
|
+
* The theme is derived from a small brand palette per mode instead of a large
|
|
333
|
+
* hand-authored variable table. Mermaid renders with a dedicated light or dark
|
|
334
|
+
* config, while CSS remains limited to structural SVG tweaks.
|
|
335
|
+
*/
|
|
336
|
+
export const defaultMermaidConfig: AstroMermaidOptions = createNorthwesternMermaidConfig("light");
|
|
337
|
+
export const darkMermaidConfig: AstroMermaidOptions = createNorthwesternMermaidConfig("dark");
|
|
338
|
+
|
|
339
|
+
export function northwesternMermaid(options: NorthwesternMermaidOptions = {}): AstroIntegration {
|
|
340
|
+
const { toolbar = true, ...overrides } = options;
|
|
341
|
+
const lightConfig = createNorthwesternMermaidConfig("light");
|
|
342
|
+
const darkConfig = createNorthwesternMermaidConfig("dark");
|
|
343
|
+
|
|
344
|
+
const mermaidIntegration = mermaid({
|
|
345
|
+
...lightConfig,
|
|
346
|
+
...overrides,
|
|
347
|
+
enableLog: false,
|
|
348
|
+
mermaidConfig: {
|
|
349
|
+
...(lightConfig.mermaidConfig ?? {}),
|
|
350
|
+
...(overrides.mermaidConfig ?? {}),
|
|
351
|
+
themeVariables: {
|
|
352
|
+
...((lightConfig.mermaidConfig as Record<string, unknown>)?.themeVariables ?? {}),
|
|
353
|
+
...((overrides.mermaidConfig as Record<string, unknown>)?.themeVariables ?? {}),
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
return {
|
|
359
|
+
name: "northwestern-mermaid",
|
|
360
|
+
hooks: {
|
|
361
|
+
"astro:config:setup"(params) {
|
|
362
|
+
mermaidIntegration.hooks["astro:config:setup"]?.(params);
|
|
363
|
+
|
|
364
|
+
params.injectScript(
|
|
365
|
+
"page",
|
|
366
|
+
`window.__NU_MERMAID_TOOLBAR__ = ${toolbar ? "true" : "false"}; window.__NU_MERMAID_CONFIGS__ = ${JSON.stringify(
|
|
367
|
+
{
|
|
368
|
+
light: lightConfig.mermaidConfig,
|
|
369
|
+
dark: darkConfig.mermaidConfig,
|
|
370
|
+
},
|
|
371
|
+
)}; import "@nu-appdev/northwestern-starlight-theme/src/scripts/mermaid-toolbar.ts";`,
|
|
372
|
+
);
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|