@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.
Files changed (141) hide show
  1. package/bin/canopy.js +16 -0
  2. package/lib/AGENTS.md +107 -0
  3. package/lib/base-path.js +67 -0
  4. package/lib/build/appearance.js +76 -0
  5. package/lib/build/assets.js +30 -0
  6. package/lib/build/build.js +350 -0
  7. package/lib/build/dev.js +1355 -0
  8. package/lib/build/devtoast.config.json +6 -0
  9. package/lib/build/devtoast.css +14 -0
  10. package/lib/build/facets.js +19 -0
  11. package/lib/build/fonts.js +105 -0
  12. package/lib/build/iiif.js +2990 -0
  13. package/lib/build/log.js +31 -0
  14. package/lib/build/mdx.js +1967 -0
  15. package/lib/build/package-names.js +111 -0
  16. package/lib/build/pages.js +420 -0
  17. package/lib/build/rehype-task-list-labels.js +54 -0
  18. package/lib/build/runtimes.js +141 -0
  19. package/lib/build/search-index.js +55 -0
  20. package/lib/build/search-text.js +160 -0
  21. package/lib/build/search-workflow.js +72 -0
  22. package/lib/build/search.js +302 -0
  23. package/lib/build/sitemap.js +197 -0
  24. package/lib/build/styles.js +140 -0
  25. package/lib/build/theme-tokens.js +78 -0
  26. package/lib/build/ui-styles.js +25 -0
  27. package/lib/build/upgrade-notices.js +121 -0
  28. package/lib/cli.js +64 -0
  29. package/lib/common.js +580 -0
  30. package/lib/components/bibliography.js +197 -0
  31. package/lib/components/featured.js +237 -0
  32. package/lib/components/hero-slider-runtime.js +215 -0
  33. package/lib/components/image-story-runtime-entry.js +249 -0
  34. package/lib/components/map-runtime.js +114 -0
  35. package/lib/components/metadata-index.js +32 -0
  36. package/lib/components/nav-place.js +227 -0
  37. package/lib/components/navigation.js +381 -0
  38. package/lib/components/referenced.js +217 -0
  39. package/lib/components/slider-runtime-entry.js +106 -0
  40. package/lib/components/timeline-runtime.js +80 -0
  41. package/lib/components/viewer-runtime-entry.js +88 -0
  42. package/lib/config-path.js +78 -0
  43. package/lib/default-locale.js +113 -0
  44. package/lib/discovery/browser-loader.js +107 -0
  45. package/lib/discovery/browser.js +115 -0
  46. package/lib/discovery/config.js +25 -0
  47. package/lib/discovery/envelope.js +124 -0
  48. package/lib/discovery/export.js +226 -0
  49. package/lib/discovery/ingestion.js +62 -0
  50. package/lib/discovery/pagination.js +66 -0
  51. package/lib/discovery/provenance.js +79 -0
  52. package/lib/discovery/search.js +81 -0
  53. package/lib/discovery/tools.js +155 -0
  54. package/lib/discovery/validation.js +121 -0
  55. package/lib/head.js +154 -0
  56. package/lib/iiif/thumbnail.js +402 -0
  57. package/lib/index.js +9 -0
  58. package/lib/locale-runtime.js +69 -0
  59. package/lib/locales.js +203 -0
  60. package/lib/orchestrator.js +231 -0
  61. package/lib/page-context.js +24 -0
  62. package/lib/search/bundle.js +25 -0
  63. package/lib/search/data.js +202 -0
  64. package/lib/search/engine.js +86 -0
  65. package/lib/search/index-cache.js +95 -0
  66. package/lib/search/search-app.jsx +835 -0
  67. package/lib/search/search-engine-runtime.js +44 -0
  68. package/lib/search/search-form-runtime.js +462 -0
  69. package/lib/search/search.js +676 -0
  70. package/package.json +109 -3
  71. package/types/base-path.d.ts +4 -0
  72. package/types/orchestrator.d.ts +17 -0
  73. package/ui/dist/index.mjs +7358 -0
  74. package/ui/dist/index.mjs.map +7 -0
  75. package/ui/dist/server.mjs +12731 -0
  76. package/ui/dist/server.mjs.map +7 -0
  77. package/ui/fonts/OFL.txt +98 -0
  78. package/ui/fonts/google-sans-flex-latin-ext.woff2 +0 -0
  79. package/ui/fonts/google-sans-flex-latin.woff2 +0 -0
  80. package/ui/fonts/source-serif-4-italic-latin-ext.woff2 +0 -0
  81. package/ui/fonts/source-serif-4-italic-latin.woff2 +0 -0
  82. package/ui/fonts/source-serif-4-latin-ext.woff2 +0 -0
  83. package/ui/fonts/source-serif-4-latin.woff2 +0 -0
  84. package/ui/styles/base/_common.scss +97 -0
  85. package/ui/styles/base/_heading.scss +61 -0
  86. package/ui/styles/base/_markdown.scss +188 -0
  87. package/ui/styles/base/_type.scss +51 -0
  88. package/ui/styles/base/_utilities.scss +7 -0
  89. package/ui/styles/base/index.scss +5 -0
  90. package/ui/styles/components/_article-card.scss +108 -0
  91. package/ui/styles/components/_band.scss +104 -0
  92. package/ui/styles/components/_bibliography.scss +88 -0
  93. package/ui/styles/components/_buttons.scss +143 -0
  94. package/ui/styles/components/_card.scss +109 -0
  95. package/ui/styles/components/_diagram.scss +76 -0
  96. package/ui/styles/components/_feature.scss +66 -0
  97. package/ui/styles/components/_footer.scss +136 -0
  98. package/ui/styles/components/_gallery.scss +476 -0
  99. package/ui/styles/components/_image-story.scss +56 -0
  100. package/ui/styles/components/_interstitial-hero.scss +625 -0
  101. package/ui/styles/components/_layout.scss +83 -0
  102. package/ui/styles/components/_map.scss +296 -0
  103. package/ui/styles/components/_metadata-index.scss +68 -0
  104. package/ui/styles/components/_nav-tree.scss +80 -0
  105. package/ui/styles/components/_referenced-items.scss +69 -0
  106. package/ui/styles/components/_sub-navigation.scss +208 -0
  107. package/ui/styles/components/_swoosh.scss +50 -0
  108. package/ui/styles/components/_timeline.scss +350 -0
  109. package/ui/styles/components/_work.scss +71 -0
  110. package/ui/styles/components/header/_header.scss +294 -0
  111. package/ui/styles/components/header/_logo.scss +99 -0
  112. package/ui/styles/components/header/_navbar.scss +143 -0
  113. package/ui/styles/components/header/index.scss +3 -0
  114. package/ui/styles/components/iiif/_image.scss +32 -0
  115. package/ui/styles/components/iiif/_slider.scss +5 -0
  116. package/ui/styles/components/iiif/index.scss +2 -0
  117. package/ui/styles/components/index.scss +25 -0
  118. package/ui/styles/components/modal/_modal.scss +130 -0
  119. package/ui/styles/components/modal/index.scss +1 -0
  120. package/ui/styles/components/search/_filters.scss +259 -0
  121. package/ui/styles/components/search/_form.scss +187 -0
  122. package/ui/styles/components/search/_panel.scss +7 -0
  123. package/ui/styles/components/search/_results.scss +241 -0
  124. package/ui/styles/components/search/_tabs.scss +60 -0
  125. package/ui/styles/components/search/index.scss +4 -0
  126. package/ui/styles/index.css +5007 -0
  127. package/ui/styles/index.scss +11 -0
  128. package/ui/styles/settings/_breakpoints.scss +7 -0
  129. package/ui/styles/settings/_focus.scss +15 -0
  130. package/ui/styles/settings/_tokens.scss +170 -0
  131. package/ui/styles/settings/_type.scss +126 -0
  132. package/ui/styles/version-parity.css +116 -0
  133. package/ui/tailwind-canopy-iiif-plugin.js +39 -0
  134. package/ui/tailwind-canopy-iiif-preset.js +32 -0
  135. package/ui/tailwind-config.d.ts +29 -0
  136. package/ui/tailwind-config.js +159 -0
  137. package/ui/tailwind-default.config.mjs +4 -0
  138. package/ui/theme-color.js +130 -0
  139. package/ui/theme-palette.js +337 -0
  140. package/ui/theme.js +153 -0
  141. 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
@@ -1,3 +0,0 @@
1
- # @nulib/canopy
2
-
3
- A placeholder, published to create the package. Canopy is published here from 2.0.0: https://nulib-ds.github.io/canopy/