@nulib/canopy 0.0.0 → 2.0.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.
- package/bin/canopy.js +16 -0
- package/lib/AGENTS.md +107 -0
- package/lib/base-path.js +67 -0
- package/lib/build/appearance.js +76 -0
- package/lib/build/assets.js +30 -0
- package/lib/build/build.js +350 -0
- package/lib/build/dev.js +1355 -0
- package/lib/build/devtoast.config.json +6 -0
- package/lib/build/devtoast.css +14 -0
- package/lib/build/facets.js +19 -0
- package/lib/build/fonts.js +105 -0
- package/lib/build/iiif.js +2990 -0
- package/lib/build/log.js +31 -0
- package/lib/build/mdx.js +1967 -0
- package/lib/build/package-names.js +111 -0
- package/lib/build/pages.js +420 -0
- package/lib/build/rehype-task-list-labels.js +54 -0
- package/lib/build/runtimes.js +141 -0
- package/lib/build/search-index.js +55 -0
- package/lib/build/search-text.js +160 -0
- package/lib/build/search-workflow.js +72 -0
- package/lib/build/search.js +302 -0
- package/lib/build/sitemap.js +197 -0
- package/lib/build/styles.js +140 -0
- package/lib/build/theme-tokens.js +78 -0
- package/lib/build/ui-styles.js +25 -0
- package/lib/build/upgrade-notices.js +121 -0
- package/lib/cli.js +64 -0
- package/lib/common.js +580 -0
- package/lib/components/bibliography.js +197 -0
- package/lib/components/featured.js +237 -0
- package/lib/components/hero-slider-runtime.js +215 -0
- package/lib/components/image-story-runtime-entry.js +249 -0
- package/lib/components/map-runtime.js +114 -0
- package/lib/components/metadata-index.js +32 -0
- package/lib/components/nav-place.js +227 -0
- package/lib/components/navigation.js +381 -0
- package/lib/components/referenced.js +217 -0
- package/lib/components/slider-runtime-entry.js +106 -0
- package/lib/components/timeline-runtime.js +80 -0
- package/lib/components/viewer-runtime-entry.js +88 -0
- package/lib/config-path.js +78 -0
- package/lib/default-locale.js +113 -0
- package/lib/discovery/browser-loader.js +107 -0
- package/lib/discovery/browser.js +115 -0
- package/lib/discovery/config.js +25 -0
- package/lib/discovery/envelope.js +124 -0
- package/lib/discovery/export.js +226 -0
- package/lib/discovery/ingestion.js +62 -0
- package/lib/discovery/pagination.js +66 -0
- package/lib/discovery/provenance.js +79 -0
- package/lib/discovery/search.js +81 -0
- package/lib/discovery/tools.js +155 -0
- package/lib/discovery/validation.js +121 -0
- package/lib/head.js +154 -0
- package/lib/iiif/thumbnail.js +402 -0
- package/lib/index.js +9 -0
- package/lib/locale-runtime.js +69 -0
- package/lib/locales.js +203 -0
- package/lib/orchestrator.js +231 -0
- package/lib/page-context.js +24 -0
- package/lib/search/bundle.js +25 -0
- package/lib/search/data.js +202 -0
- package/lib/search/engine.js +86 -0
- package/lib/search/index-cache.js +95 -0
- package/lib/search/search-app.jsx +835 -0
- package/lib/search/search-engine-runtime.js +44 -0
- package/lib/search/search-form-runtime.js +462 -0
- package/lib/search/search.js +676 -0
- package/package.json +109 -3
- package/types/base-path.d.ts +4 -0
- package/types/orchestrator.d.ts +17 -0
- package/ui/dist/index.mjs +7358 -0
- package/ui/dist/index.mjs.map +7 -0
- package/ui/dist/server.mjs +12731 -0
- package/ui/dist/server.mjs.map +7 -0
- package/ui/fonts/OFL.txt +98 -0
- package/ui/fonts/google-sans-flex-latin-ext.woff2 +0 -0
- package/ui/fonts/google-sans-flex-latin.woff2 +0 -0
- package/ui/fonts/source-serif-4-italic-latin-ext.woff2 +0 -0
- package/ui/fonts/source-serif-4-italic-latin.woff2 +0 -0
- package/ui/fonts/source-serif-4-latin-ext.woff2 +0 -0
- package/ui/fonts/source-serif-4-latin.woff2 +0 -0
- package/ui/styles/base/_common.scss +97 -0
- package/ui/styles/base/_heading.scss +61 -0
- package/ui/styles/base/_markdown.scss +188 -0
- package/ui/styles/base/_type.scss +51 -0
- package/ui/styles/base/_utilities.scss +7 -0
- package/ui/styles/base/index.scss +5 -0
- package/ui/styles/components/_article-card.scss +108 -0
- package/ui/styles/components/_band.scss +104 -0
- package/ui/styles/components/_bibliography.scss +88 -0
- package/ui/styles/components/_buttons.scss +143 -0
- package/ui/styles/components/_card.scss +109 -0
- package/ui/styles/components/_diagram.scss +76 -0
- package/ui/styles/components/_feature.scss +66 -0
- package/ui/styles/components/_footer.scss +136 -0
- package/ui/styles/components/_gallery.scss +476 -0
- package/ui/styles/components/_image-story.scss +56 -0
- package/ui/styles/components/_interstitial-hero.scss +625 -0
- package/ui/styles/components/_layout.scss +83 -0
- package/ui/styles/components/_map.scss +296 -0
- package/ui/styles/components/_metadata-index.scss +68 -0
- package/ui/styles/components/_nav-tree.scss +80 -0
- package/ui/styles/components/_referenced-items.scss +69 -0
- package/ui/styles/components/_sub-navigation.scss +208 -0
- package/ui/styles/components/_swoosh.scss +50 -0
- package/ui/styles/components/_timeline.scss +350 -0
- package/ui/styles/components/_work.scss +71 -0
- package/ui/styles/components/header/_header.scss +294 -0
- package/ui/styles/components/header/_logo.scss +99 -0
- package/ui/styles/components/header/_navbar.scss +143 -0
- package/ui/styles/components/header/index.scss +3 -0
- package/ui/styles/components/iiif/_image.scss +32 -0
- package/ui/styles/components/iiif/_slider.scss +5 -0
- package/ui/styles/components/iiif/index.scss +2 -0
- package/ui/styles/components/index.scss +25 -0
- package/ui/styles/components/modal/_modal.scss +130 -0
- package/ui/styles/components/modal/index.scss +1 -0
- package/ui/styles/components/search/_filters.scss +259 -0
- package/ui/styles/components/search/_form.scss +187 -0
- package/ui/styles/components/search/_panel.scss +7 -0
- package/ui/styles/components/search/_results.scss +241 -0
- package/ui/styles/components/search/_tabs.scss +60 -0
- package/ui/styles/components/search/index.scss +4 -0
- package/ui/styles/index.css +5007 -0
- package/ui/styles/index.scss +11 -0
- package/ui/styles/settings/_breakpoints.scss +7 -0
- package/ui/styles/settings/_focus.scss +15 -0
- package/ui/styles/settings/_tokens.scss +170 -0
- package/ui/styles/settings/_type.scss +126 -0
- package/ui/styles/version-parity.css +116 -0
- package/ui/tailwind-canopy-iiif-plugin.js +39 -0
- package/ui/tailwind-canopy-iiif-preset.js +32 -0
- package/ui/tailwind-config.d.ts +29 -0
- package/ui/tailwind-config.js +159 -0
- package/ui/tailwind-default.config.mjs +4 -0
- package/ui/theme-color.js +130 -0
- package/ui/theme-palette.js +337 -0
- package/ui/theme.js +153 -0
- package/README.md +0 -3
package/ui/theme.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const yaml = require("js-yaml");
|
|
3
|
+
const {resolveCanopyConfigPath} = require("../lib/config-path");
|
|
4
|
+
const {
|
|
5
|
+
AVAILABLE_PALETTES,
|
|
6
|
+
appearanceVariablesToCss,
|
|
7
|
+
normalizeAccentName,
|
|
8
|
+
normalizePaletteName,
|
|
9
|
+
normalizeAppearance,
|
|
10
|
+
toTailwindScale,
|
|
11
|
+
buildVariablesMap,
|
|
12
|
+
variablesToCss,
|
|
13
|
+
} = require("./theme-palette");
|
|
14
|
+
|
|
15
|
+
const DEFAULT_ACCENT = "indigo";
|
|
16
|
+
const DEFAULT_GRAY = "slate";
|
|
17
|
+
const DEBUG_FLAG_RAW = String(process.env.CANOPY_DEBUG_THEME || "");
|
|
18
|
+
const DEBUG_ENABLED = /^(1|true|yes|on)$/i.test(DEBUG_FLAG_RAW.trim());
|
|
19
|
+
|
|
20
|
+
function debugLog(...args) {
|
|
21
|
+
if (!DEBUG_ENABLED) return;
|
|
22
|
+
try {
|
|
23
|
+
console.log("[canopy-theme]", ...args);
|
|
24
|
+
} catch (_) {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function readYamlConfig(cfgPath) {
|
|
28
|
+
try {
|
|
29
|
+
if (!cfgPath) return {};
|
|
30
|
+
if (!fs.existsSync(cfgPath)) {
|
|
31
|
+
debugLog("config not found; falling back to defaults", cfgPath);
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
const raw = fs.readFileSync(cfgPath, "utf8");
|
|
35
|
+
const data = yaml.load(raw) || {};
|
|
36
|
+
debugLog("loaded config", cfgPath);
|
|
37
|
+
return data;
|
|
38
|
+
} catch (_) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Always returned "" and is no longer used; removed in the next
|
|
45
|
+
* major release.
|
|
46
|
+
*/
|
|
47
|
+
function buildSassConfig() {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function loadCanopyTheme(options = {}) {
|
|
52
|
+
const cfgPath = resolveCanopyConfigPath(options);
|
|
53
|
+
const cfg = readYamlConfig(cfgPath);
|
|
54
|
+
const theme = (cfg && cfg.theme) || {};
|
|
55
|
+
const accentRequested = theme && theme.accentColor;
|
|
56
|
+
const grayRequested = theme && theme.grayColor;
|
|
57
|
+
const appearanceRequested = theme && theme.appearance;
|
|
58
|
+
const appearance = normalizeAppearance(appearanceRequested);
|
|
59
|
+
// `auto` draws light first; its dark tokens follow under `prefers-color-scheme`.
|
|
60
|
+
const scaleMode = appearance === "dark" ? "dark" : "light";
|
|
61
|
+
|
|
62
|
+
// A palette's name or a hex color (`#0f62fe`).
|
|
63
|
+
let accentName = normalizeAccentName(accentRequested);
|
|
64
|
+
let accentScale = accentName
|
|
65
|
+
? toTailwindScale(accentName, {appearance: scaleMode, role: "accent"})
|
|
66
|
+
: null;
|
|
67
|
+
let accentFallback = false;
|
|
68
|
+
if (!accentScale) {
|
|
69
|
+
accentFallback = true;
|
|
70
|
+
accentName = DEFAULT_ACCENT;
|
|
71
|
+
accentScale = toTailwindScale(DEFAULT_ACCENT, {
|
|
72
|
+
appearance: scaleMode,
|
|
73
|
+
role: "accent",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let grayName = normalizePaletteName(grayRequested);
|
|
78
|
+
let grayScale = grayName
|
|
79
|
+
? toTailwindScale(grayName, {appearance: scaleMode, role: "gray"})
|
|
80
|
+
: null;
|
|
81
|
+
let grayFallback = false;
|
|
82
|
+
if (!grayScale) {
|
|
83
|
+
grayFallback = true;
|
|
84
|
+
grayName = DEFAULT_GRAY;
|
|
85
|
+
grayScale = toTailwindScale(DEFAULT_GRAY, {
|
|
86
|
+
appearance: scaleMode,
|
|
87
|
+
role: "gray",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const variables = buildVariablesMap(accentScale, grayScale, {
|
|
92
|
+
appearance: scaleMode,
|
|
93
|
+
});
|
|
94
|
+
let variablesDark = null;
|
|
95
|
+
let css = variablesToCss(variables);
|
|
96
|
+
if (appearance === "auto") {
|
|
97
|
+
variablesDark = buildVariablesMap(
|
|
98
|
+
toTailwindScale(accentName, {appearance: "dark", role: "accent"}),
|
|
99
|
+
toTailwindScale(grayName, {appearance: "dark", role: "gray"}),
|
|
100
|
+
{appearance: "dark"},
|
|
101
|
+
);
|
|
102
|
+
css = appearanceVariablesToCss(variables, variablesDark);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
debugLog("resolved theme", {
|
|
106
|
+
configPath: cfgPath,
|
|
107
|
+
requested: {
|
|
108
|
+
accent: accentRequested || null,
|
|
109
|
+
gray: grayRequested || null,
|
|
110
|
+
appearance: appearanceRequested || null,
|
|
111
|
+
},
|
|
112
|
+
resolved: {
|
|
113
|
+
appearance,
|
|
114
|
+
accent: accentName,
|
|
115
|
+
gray: grayName,
|
|
116
|
+
accentFallback,
|
|
117
|
+
grayFallback,
|
|
118
|
+
brandSamples: accentScale
|
|
119
|
+
? {
|
|
120
|
+
50: accentScale["50"],
|
|
121
|
+
500: accentScale["500"],
|
|
122
|
+
900: accentScale["900"],
|
|
123
|
+
}
|
|
124
|
+
: null,
|
|
125
|
+
graySamples: grayScale
|
|
126
|
+
? {50: grayScale["50"], 500: grayScale["500"], 900: grayScale["900"]}
|
|
127
|
+
: null,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
appearance,
|
|
133
|
+
accent: {name: accentName, scale: accentScale},
|
|
134
|
+
gray: {name: grayName, scale: grayScale},
|
|
135
|
+
variables,
|
|
136
|
+
// `appearance: auto` only: the dark tokens beside the light `variables`.
|
|
137
|
+
variablesDark,
|
|
138
|
+
css,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
loadCanopyTheme,
|
|
144
|
+
toTailwindScale,
|
|
145
|
+
normalizeAccentName,
|
|
146
|
+
normalizePaletteName,
|
|
147
|
+
normalizeAppearance,
|
|
148
|
+
AVAILABLE_PALETTES,
|
|
149
|
+
__DEBUG_ENABLED: DEBUG_ENABLED,
|
|
150
|
+
variablesToCss,
|
|
151
|
+
buildVariablesMap,
|
|
152
|
+
buildSassConfig,
|
|
153
|
+
};
|
package/README.md
DELETED