@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
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Main stylesheet for the @nulib/canopy/ui package
3
+ */
4
+ @use "./settings/tokens";
5
+ @use "./base";
6
+ @use "./components";
7
+
8
+ /**
9
+ * Define source files for utility classes
10
+ */
11
+ @source "../dist";
@@ -0,0 +1,7 @@
1
+ $canopy-desktop-breakpoint: 70rem !default;
2
+
3
+ @layer base {
4
+ :root {
5
+ --canopy-desktop-breakpoint: #{$canopy-desktop-breakpoint};
6
+ }
7
+ }
@@ -0,0 +1,15 @@
1
+ // The focus indicator every component draws (DESIGN.md §0, "Focus stays visible and in
2
+ // view"): an outline in `--canopy-focus-color`, 2px wide, standing 2px off the element, so
3
+ // the page shows between them as a second tone. An outline, not a shadow: forced-colors
4
+ // mode keeps it, and it follows the element's corners.
5
+ //
6
+ // `$inset: true` draws it inside the element, for one in a container that clips what
7
+ // stands outside it (a slider's track, a hero's stage).
8
+ @mixin focus-ring($inset: false) {
9
+ outline: var(--canopy-focus-width) solid var(--canopy-focus-color);
10
+ @if $inset {
11
+ outline-offset: calc(-1 * (var(--canopy-focus-width) + var(--canopy-focus-offset)));
12
+ } @else {
13
+ outline-offset: var(--canopy-focus-offset);
14
+ }
15
+ }
@@ -0,0 +1,170 @@
1
+ // Canopy's design tokens (packages/app/DESIGN.md §1): what every component draws with, so
2
+ // a theme or a site's own stylesheet restyles them all at once. The 2.x look's values,
3
+ // after Clover's docs tokens (nulib-ds/clover, `docs/styles/tokens.css`), under Canopy's
4
+ // prefix: Tailwind owns the bare `--text-*`, `--radius-*` and `--shadow-*`, which a site's
5
+ // utility classes read.
6
+ //
7
+ // In `@layer properties`, with the color tokens the build writes from canopy.yml, and
8
+ // ahead of a site's own `app/styles`, which come later in the layer and win: a site sets
9
+ // any of these without `!important`. Square corners and no shadows are one line each
10
+ // (`--canopy-radius-sm: 0`, `--canopy-shadow-md: none`, …), as the Northwestern template
11
+ // sets them. Nothing forces a value on every element (ACCESSIBILITY.md, R1).
12
+ //
13
+ // Dark mode: the values that differ are under `:root.dark` (every dark appearance sets the
14
+ // class), and under the system's dark scheme for `appearance: auto` before its script runs.
15
+
16
+ $canopy-swoosh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 24' preserveAspectRatio='none'%3E%3Cpath d='M3 14.5c34-4.2 74-6.1 118-6.6 52-.6 107 .9 175-3.4 2.2-.1 3.6 1.6 3.4 3.4-.2 1.6-1.4 2.7-3 2.9-69 6.3-122 5.3-175 5.9-41 .5-79 2.3-115 6.5-2.4.3-4.5-1.4-4.7-3.8-.2-2.3 1.4-4.5 3.7-4.9z'/%3E%3C/svg%3E");
17
+
18
+ @mixin canopy-dark-tokens {
19
+ // A raised surface is lighter than the page in the dark, where a shadow does not read.
20
+ --canopy-surface-raised: var(--color-gray-300);
21
+ --canopy-surface-sunken: var(--color-gray-100);
22
+ --canopy-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25), 0 1px 3px rgb(0 0 0 / 0.19);
23
+ --canopy-shadow-md: 0 6px 24px rgb(0 0 0 / 0.4);
24
+ --canopy-shadow-lg: 0 8px 24px -8px rgb(0 0 0 / 0.38), 0 2px 6px -2px rgb(0 0 0 / 0.25);
25
+ // Black on a near-black page: a hairline sets it off.
26
+ --canopy-band-edge: var(--canopy-edge);
27
+ }
28
+
29
+ @layer properties {
30
+ :root,
31
+ :host {
32
+ // ── Type ───────────────────────────────────────────────────────────────────────
33
+ // As a magazine sets it: a sans for headlines and the interface, a serif for reading.
34
+ // Both ship with the package and are served from the site itself
35
+ // (`lib/build/fonts.js`), then the system's own. A site that sets these in its own
36
+ // `app/styles` keeps its families.
37
+ //
38
+ // Google Sans Flex: headings, navigation, buttons, cards, labels, metadata, search.
39
+ --font-sans:
40
+ "Google Sans Flex", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
41
+ "Helvetica Neue", Arial, sans-serif;
42
+ // Source Serif 4: a page's prose, its ledes and its quotes, on a marketing page and
43
+ // in a long read alike.
44
+ --font-serif:
45
+ "Source Serif 4", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
46
+ --default-font-family: var(--font-sans);
47
+ // Headings' family, and reading text's (`base/_common.scss`): set
48
+ // `--canopy-font-body: var(--font-sans)` for one family throughout.
49
+ --canopy-font-display: var(--font-sans);
50
+ --canopy-font-body: var(--font-serif);
51
+ // Two weights, and only two: hierarchy comes from size and color.
52
+ --canopy-weight-regular: 400;
53
+ --canopy-weight-bold: 700;
54
+ // The size scale. Each text style (`settings/_type.scss`) takes one step; nothing else
55
+ // sets a size. Nothing in the interface goes below `--canopy-text-sm` but labels,
56
+ // whose uppercase letters carry more width a point.
57
+ --canopy-text-label: 0.875rem;
58
+ --canopy-text-sm: 0.9375rem;
59
+ --canopy-text-md: 1rem;
60
+ // Reading text: a step over the interface, as a serif at the same size reads smaller
61
+ // than the sans beside it.
62
+ --canopy-text-body: 1.0625rem;
63
+ --canopy-text-lg: 1.125rem;
64
+ --canopy-text-xl: 1.382rem;
65
+ --canopy-text-2xl: 1.618rem;
66
+ // By the window's width: words under a title, a page's or section's title, a hero's
67
+ // headline (one line of about ten words from 320px up).
68
+ --canopy-text-lede: clamp(var(--canopy-text-lg), 2vw, 1.375rem);
69
+ --canopy-text-title: clamp(1.875rem, 3.2vw, 2.618rem);
70
+ --canopy-text-display: clamp(2rem, 8vw, 5.236rem);
71
+ --canopy-text-code: 0.875rem;
72
+ // Tracking: tighter as type grows, open for uppercase labels.
73
+ --canopy-tracking-display: -0.04em;
74
+ --canopy-tracking-tight: -0.02em;
75
+ --canopy-tracking-snug: -0.01em;
76
+ --canopy-tracking-label: 0.06em;
77
+ // Reading text's longest line, a magazine column's: about 70 characters (under the
78
+ // 80 WCAG 1.4.8 advises).
79
+ --canopy-measure: 70ch;
80
+
81
+ // ── Shape ──────────────────────────────────────────────────────────────────────
82
+ // What sits inside a rounded thing takes a smaller step, so corners nest.
83
+ --canopy-radius-none: 0;
84
+ --canopy-radius-sm: 4px;
85
+ --canopy-radius-md: 8px;
86
+ --canopy-radius-lg: 12px;
87
+ --canopy-radius-xl: 16px;
88
+ --canopy-radius-pill: 999px;
89
+ --canopy-radius-circle: 50%;
90
+ // Clover reads its own radius tokens; they follow Canopy's.
91
+ --clover-radius: var(--canopy-radius-sm);
92
+ --clover-radius-pill: var(--canopy-radius-pill);
93
+
94
+ // ── Surfaces ───────────────────────────────────────────────────────────────────
95
+ // Solid fills, not outlines: a panel is a block of color, set off by contrast and
96
+ // space. Text tokens hold 4.5:1 on each (tests/unit/a11y/contrast.test.js).
97
+ --canopy-surface: var(--color-gray-200);
98
+ --canopy-surface-raised: var(--color-gray-50);
99
+ --canopy-surface-sunken: var(--color-gray-300);
100
+ // A hairline, between the gray's steps 4 and 7: decoration, never the only thing that
101
+ // marks a control.
102
+ --canopy-edge: color-mix(in oklab, var(--color-gray-300) 50%, var(--color-gray-400));
103
+ // A control's edge (a field, an outline button): the muted text mixed into the page,
104
+ // as light as keeps 3:1 against it (WCAG 1.4.11), as Clover's fields are.
105
+ --canopy-control-edge: color-mix(in srgb, var(--color-gray-muted) 80%, var(--color-gray-50));
106
+
107
+ // ── Shadows ────────────────────────────────────────────────────────────────────
108
+ --canopy-shadow-none: none;
109
+ --canopy-shadow-sm: 0 1px 2px rgb(28 32 36 / 0.03), 0 1px 3px rgb(28 32 36 / 0.06);
110
+ --canopy-shadow-md: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 24px rgb(0 0 0 / 0.06);
111
+ --canopy-shadow-lg: 0 8px 24px -8px rgb(28 32 36 / 0.13), 0 2px 6px -2px rgb(28 32 36 / 0.08);
112
+ // A card lifted off the page: a hairline edge, then a close, soft shadow.
113
+ --canopy-card-shadow: 0 0 0 1px var(--canopy-edge), var(--canopy-shadow-md);
114
+
115
+ // ── Focus ──────────────────────────────────────────────────────────────────────
116
+ // The text accent, 4.5:1 on the page, so the ring holds 3:1 under every palette.
117
+ // Components draw it as an outline (`focus-ring` in `settings/_focus.scss`), which
118
+ // forced-colors mode keeps; `--canopy-focus-ring` is the same ring as a shadow.
119
+ --canopy-focus-color: var(--color-accent-default);
120
+ --canopy-focus-width: 2px;
121
+ --canopy-focus-offset: 2px;
122
+ --canopy-focus-ring:
123
+ 0 0 0 var(--canopy-focus-offset) var(--color-gray-50),
124
+ 0 0 0 calc(var(--canopy-focus-offset) + var(--canopy-focus-width)) var(--canopy-focus-color);
125
+
126
+ // ── Bands ──────────────────────────────────────────────────────────────────────
127
+ // Black in both appearances, its words white (`<Band>`): 21:1, and its muted words
128
+ // 9:1 or more.
129
+ --canopy-band-background: #000;
130
+ --canopy-band-text: #fff;
131
+ --canopy-band-muted: color-mix(in srgb, #fff 72%, #000);
132
+ --canopy-band-edge: transparent;
133
+
134
+ // ── The brush stroke ───────────────────────────────────────────────────────────
135
+ // A hand-drawn swoosh, used as a mask over the accent (`<Swoosh>`, the wordmark), so
136
+ // it takes the site's accent whatever it is.
137
+ --canopy-swoosh: #{$canopy-swoosh};
138
+
139
+ // ── Motion ─────────────────────────────────────────────────────────────────────
140
+ --canopy-ease: cubic-bezier(0.65, 0, 0.35, 1);
141
+
142
+ // ── Space ──────────────────────────────────────────────────────────────────────
143
+ // The golden steps from the page's 1rem, as Clover's (`--clover-space-*`): the more
144
+ // closely two things belong together, the smaller the step between them; a container's
145
+ // inset is a step larger than the gap between what it holds.
146
+ --canopy-space-3xs: 0.146rem;
147
+ --canopy-space-2xs: 0.236rem;
148
+ --canopy-space-xs: 0.382rem;
149
+ --canopy-space-s: 0.618rem;
150
+ --canopy-space-m: 1rem;
151
+ --canopy-space-l: 1.618rem;
152
+ --canopy-space-xl: 2.618rem;
153
+ --canopy-space-2xl: 4.236rem;
154
+
155
+ // ── Layout ─────────────────────────────────────────────────────────────────────
156
+ // How far down the window what sticks must stand to clear the sticky header: 4rem
157
+ // while the header sticks (`header/_header.scss`), none otherwise.
158
+ --canopy-sticky-top: 0px;
159
+ }
160
+
161
+ :root.dark {
162
+ @include canopy-dark-tokens;
163
+ }
164
+
165
+ @media (prefers-color-scheme: dark) {
166
+ :root[data-appearance="auto"]:not(.light) {
167
+ @include canopy-dark-tokens;
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,126 @@
1
+ // Canopy's text styles (DESIGN.md §1, "Type"; the docs' Style guide page shows each): a
2
+ // closed set, so every piece of text on a page is one of them, and the page reads as one.
3
+ // Components take a style with `@include type.<style>` and never write a size, weight,
4
+ // line height or tracking of their own (`tests/unit/ui/type-scale.test.js` holds them to
5
+ // it). Each style is also a class (`.canopy-type-<style>`, `base/_type.scss`) for authors.
6
+ //
7
+ // Two families: the interface's sans (`--default-font-family`, Google Sans Flex) and the
8
+ // reading serif (`--canopy-font-body`, Source Serif 4). Two weights. Sizes from the scale
9
+ // in `settings/_tokens.scss`; colors are the context's, but a lede's and a label's.
10
+
11
+ @mixin -family($family) {
12
+ @if $family == "display" {
13
+ font-family: var(--canopy-font-display);
14
+ } @else if $family == "body" {
15
+ font-family: var(--canopy-font-body);
16
+ } @else {
17
+ font-family: var(--default-font-family);
18
+ }
19
+ }
20
+
21
+ // A hero's headline: the largest words on a site, once a page.
22
+ @mixin display {
23
+ @include -family("display");
24
+ font-size: var(--canopy-text-display);
25
+ font-weight: var(--canopy-weight-bold);
26
+ line-height: 1.06;
27
+ letter-spacing: var(--canopy-tracking-display);
28
+ }
29
+
30
+ // A page's title (its `h1`) and a section's (`<Feature>`, `<Band>`), by the window's width.
31
+ @mixin title {
32
+ @include -family("display");
33
+ font-size: var(--canopy-text-title);
34
+ font-weight: var(--canopy-weight-bold);
35
+ line-height: 1.1;
36
+ letter-spacing: var(--canopy-tracking-tight);
37
+ }
38
+
39
+ // Headings within a page: `h2`, `h3`, and `h4` to `h6`, which share a size and are told
40
+ // apart by their place.
41
+ @mixin h2 {
42
+ @include -family("display");
43
+ font-size: var(--canopy-text-2xl);
44
+ font-weight: var(--canopy-weight-bold);
45
+ line-height: 1.2;
46
+ letter-spacing: var(--canopy-tracking-tight);
47
+ }
48
+
49
+ @mixin h3 {
50
+ @include -family("display");
51
+ font-size: var(--canopy-text-xl);
52
+ font-weight: var(--canopy-weight-bold);
53
+ line-height: 1.25;
54
+ letter-spacing: var(--canopy-tracking-tight);
55
+ }
56
+
57
+ @mixin h4 {
58
+ @include -family("display");
59
+ font-size: var(--canopy-text-lg);
60
+ font-weight: var(--canopy-weight-bold);
61
+ line-height: 1.35;
62
+ letter-spacing: var(--canopy-tracking-snug);
63
+ }
64
+
65
+ // Words under a title, a standfirst: the reading serif, a step up, muted.
66
+ @mixin lede {
67
+ @include -family("body");
68
+ font-size: var(--canopy-text-lede);
69
+ font-weight: var(--canopy-weight-regular);
70
+ line-height: 1.5;
71
+ letter-spacing: normal;
72
+ color: var(--color-gray-muted);
73
+ }
74
+
75
+ // Reading text: what an author writes, in the serif.
76
+ @mixin body {
77
+ @include -family("body");
78
+ font-size: var(--canopy-text-body);
79
+ font-weight: var(--canopy-weight-regular);
80
+ line-height: 1.618;
81
+ letter-spacing: normal;
82
+ }
83
+
84
+ // The interface: navigation, fields, menus, a card's title (bold), a metadata value.
85
+ @mixin ui($weight: regular) {
86
+ @include -family("ui");
87
+ font-size: var(--canopy-text-md);
88
+ font-weight: var(--canopy-weight-#{$weight});
89
+ line-height: 1.5;
90
+ letter-spacing: normal;
91
+ }
92
+
93
+ // The interface, smaller: buttons, captions, a card's second line, the footer, tabs,
94
+ // filters, counts.
95
+ @mixin ui-sm($weight: regular) {
96
+ @include -family("ui");
97
+ font-size: var(--canopy-text-sm);
98
+ font-weight: var(--canopy-weight-#{$weight});
99
+ line-height: 1.5;
100
+ letter-spacing: normal;
101
+ }
102
+
103
+ // A label over a value or a section: uppercase, bold, open, muted. An eyebrow takes it in
104
+ // the accent's text step.
105
+ @mixin label {
106
+ @include -family("ui");
107
+ font-size: var(--canopy-text-label);
108
+ font-weight: var(--canopy-weight-bold);
109
+ line-height: 1.4;
110
+ letter-spacing: var(--canopy-tracking-label);
111
+ text-transform: uppercase;
112
+ color: var(--color-gray-muted);
113
+ }
114
+
115
+ // Code, in running text (its size follows the words around it) or a block.
116
+ @mixin code($block: false) {
117
+ font-family: var(--font-mono);
118
+ font-weight: var(--canopy-weight-regular);
119
+ letter-spacing: normal;
120
+ @if $block {
121
+ font-size: var(--canopy-text-code);
122
+ line-height: 1.55;
123
+ } @else {
124
+ font-size: 0.92em;
125
+ }
126
+ }
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Version parity: Canopy 1.x's styling of Clover 3, carried over to Clover 4's markup.
3
+ *
4
+ * Canopy 1.x styled Clover 3 by its class names (`.clover-viewer-header`,
5
+ * `.clover-slider-header-label`, `.swiper-slide`…), which Clover 4 does not draw, so
6
+ * those rules would have gone dead. Each rule here is one of them, aimed at the Clover 4
7
+ * element that took its place, under its 1.x selector, so a 2.x site looks as its 1.x
8
+ * one did. Everything else Clover 4 draws as Clover draws it.
9
+ *
10
+ * The root a site's own stylesheet scoped Clover by, `.clover-viewer` (docs: Theme, "Clover
11
+ * Component overrides"), is on Canopy's container around the Viewer (`Viewer.jsx`), so
12
+ * `.clover-viewer { --clover-color-accent: … }` still reaches it.
13
+ *
14
+ * Its sizes and weights are Canopy's text styles' (`settings/_type.scss`, DESIGN.md §1), so
15
+ * Clover's parts read as the rest of the page does.
16
+ *
17
+ * In `@layer components`: above Clover's own layer, below a site's unlayered CSS, which
18
+ * overrides any of it. The whole file goes in a later major release; nothing else reads
19
+ * it. Imported after Clover's stylesheets (`ui/scripts/build-ui.mjs`).
20
+ */
21
+ @layer components {
22
+ /* 1.x `.clover-viewer-header .label`: the title over the Viewer (`showTitle`). */
23
+ .clover-template-default-title {
24
+ font-size: var(--canopy-text-lg);
25
+ font-weight: var(--canopy-weight-bold);
26
+ }
27
+
28
+ /* 1.x `.clover-viewer-information-panel`, its `dt`, `dd` and links. */
29
+ .clover-template-default-panel {
30
+ font-size: var(--canopy-text-sm);
31
+ font-weight: var(--canopy-weight-regular);
32
+ }
33
+
34
+ .clover-template-default-panel dt {
35
+ font-weight: var(--canopy-weight-bold);
36
+ }
37
+
38
+ .clover-template-default-panel :is(a, dd) {
39
+ font-size: var(--canopy-text-sm);
40
+ font-weight: var(--canopy-weight-regular);
41
+ }
42
+
43
+ /* 1.x `.clover-viewer-media-navigation`: the thumbnail strip, in the sans face. */
44
+ .clover-template-default-rail {
45
+ font-family: var(--font-sans);
46
+ }
47
+
48
+ /* 1.x `.clover-slider-header-label`: a slider's title. */
49
+ .canopy-slider .clover-items-title {
50
+ font-size: var(--canopy-text-lg);
51
+ font-weight: var(--canopy-weight-bold);
52
+ letter-spacing: var(--canopy-tracking-snug);
53
+ }
54
+
55
+ /*
56
+ * 1.x `a.clover-slider-header-homepage`: "View all", in the accent. Its underline stays
57
+ * Clover 4's, where 1.x took it away: a link told from the words beside it by its
58
+ * color alone (WCAG 1.4.1).
59
+ */
60
+ .canopy-slider .clover-items-homepage {
61
+ color: var(--color-accent-default);
62
+ }
63
+
64
+ /* 1.x `.clover-slider-header-summary`. */
65
+ .canopy-slider .clover-items-description {
66
+ font-size: var(--canopy-text-sm);
67
+ font-weight: var(--canopy-weight-regular);
68
+ color: var(--color-gray-muted);
69
+ }
70
+
71
+ /* 1.x, under 800px: the slider's header centered over it. */
72
+ @media (max-width: 800px) {
73
+ .canopy-slider .clover-items-header {
74
+ justify-content: center;
75
+ text-align: center;
76
+ }
77
+ }
78
+
79
+ /*
80
+ * 1.x `.swiper-slide` and its link: each item a card, drawn as Canopy's `<Card>` is
81
+ * (`--canopy-card-shadow`, `--canopy-radius-lg`): raised and rounded in 2.x, and the
82
+ * 1.x hairline, square, where a site sets those tokens flat. Clover's focus ring is
83
+ * drawn on the item's pictures, inside, and stays.
84
+ */
85
+ .canopy-slider .clover-items-item {
86
+ padding-bottom: 1rem;
87
+ }
88
+
89
+ .canopy-slider .clover-items-link {
90
+ overflow: hidden;
91
+ border-radius: var(--canopy-radius-lg);
92
+ background-color: var(--canopy-surface-raised);
93
+ box-shadow: var(--canopy-card-shadow);
94
+ transition: color 150ms cubic-bezier(0.22, 1, 0.36, 1);
95
+ }
96
+
97
+ /*
98
+ * 1.x `figcaption` and its `span`: the card's caption, padded, in the text's color, the
99
+ * accent while its card is pointed at or focused. Its three lines are Clover 4's own
100
+ * (`--clover-items-lines`), whose full title shows on hover and focus.
101
+ */
102
+ .canopy-slider .clover-items-caption {
103
+ padding: 1rem;
104
+ color: var(--color-gray-default);
105
+ }
106
+
107
+ .canopy-slider .clover-items-label-text {
108
+ font-size: var(--canopy-text-md);
109
+ font-weight: var(--canopy-weight-bold);
110
+ line-height: 1.5;
111
+ }
112
+
113
+ .canopy-slider .clover-items-link:is(:hover, :focus-visible) .clover-items-caption {
114
+ color: var(--color-accent-default);
115
+ }
116
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Canopy IIIF Tailwind plugin
3
+ *
4
+ * Provides semantic component styles for Canopy UI elements.
5
+ * Users can disable these defaults by removing this plugin from
6
+ * their Tailwind config.
7
+ *
8
+ * @deprecated Removed in the next major release. Under Tailwind v4 this plugin
9
+ * adds no styles; component CSS comes from `@nulib/canopy/ui/styles/index.css`.
10
+ */
11
+ const plugin = require("tailwindcss/plugin");
12
+ const path = require("path");
13
+
14
+ function compileScss(filePath) {
15
+ try {
16
+ const sass = require("sass");
17
+ const stylesRoot = path.join(__dirname, "styles");
18
+ const loadPaths = [stylesRoot];
19
+ const relModule = path
20
+ .relative(stylesRoot, filePath)
21
+ .replace(/\\/g, "/")
22
+ .replace(/\.scss$/i, "");
23
+ const source = `@use '${relModule}';`;
24
+ const out = sass.compileString(source, { style: "expanded", loadPaths });
25
+ return out && out.css ? out.css : "";
26
+ } catch (e) {
27
+ const message = e && e.message ? e.message : e;
28
+ throw new Error(`Canopy UI: failed to compile ${filePath}: ${message}`);
29
+ }
30
+ }
31
+
32
+ module.exports = plugin(function ({ addComponents, postcss }) {
33
+ const entry = path.join(__dirname, 'styles', 'components', 'index.scss');
34
+ const css = compileScss(entry);
35
+ if (css && css.trim()) {
36
+ const root = postcss && postcss.parse ? postcss.parse(css) : null;
37
+ if (root) addComponents(root);
38
+ }
39
+ });
@@ -0,0 +1,32 @@
1
+ /**
2
+ * canopy-iiif-preset
3
+ *
4
+ * A Tailwind preset that sources design tokens (colors, fonts, sizes, etc.)
5
+ * from Sass under packages/ui/styles, injects them as CSS variables, and maps
6
+ * Tailwind theme.extend values to those variables for easy use in utilities.
7
+ *
8
+ * @deprecated Removed in the next major release. Under Tailwind v4 this preset
9
+ * adds no styles; the build injects the theme into each site's stylesheet.
10
+ */
11
+ const plugin = require("tailwindcss/plugin");
12
+ const {loadCanopyTheme} = require("./theme");
13
+
14
+ function compileVarsCss() {
15
+ const theme = loadCanopyTheme();
16
+ if (theme && theme.css) {
17
+ if (process.env.CANOPY_DEBUG_THEME) {
18
+ console.log("[preset] using theme css");
19
+ }
20
+ return theme.css;
21
+ }
22
+ }
23
+
24
+ module.exports = {
25
+ plugins: [
26
+ // Inject CSS variables (tokens) derived from Sass variables
27
+ plugin(function ({addBase, postcss}) {
28
+ const css = compileVarsCss();
29
+ if (css && postcss && postcss.parse) addBase(postcss.parse(css));
30
+ }),
31
+ ],
32
+ };
@@ -0,0 +1,29 @@
1
+ import type { Config } from 'tailwindcss';
2
+
3
+ /**
4
+ * @deprecated Removed in the next major release. Tailwind v4 reads a JS config
5
+ * only through `@config`; customize Tailwind in `app/styles/index.css`.
6
+ */
7
+ export interface DefineCanopyTailwindConfigOptions extends Config {
8
+ /**
9
+ * Override the detected project root (defaults to two directories up from the config file).
10
+ */
11
+ root?: string;
12
+ includeCanopyPreset?: boolean;
13
+ includeCanopyPlugin?: boolean;
14
+ includeCanopySafelist?: boolean;
15
+ includeCanopySources?: boolean;
16
+ }
17
+
18
+ export type TailwindConfigSource = string | URL;
19
+
20
+ /**
21
+ * @deprecated Removed in the next major release. Tailwind v4 reads a JS config
22
+ * only through `@config`; customize Tailwind in `app/styles/index.css`.
23
+ */
24
+ export declare function defineCanopyTailwindConfig(
25
+ sourceOrOptions?: TailwindConfigSource | DefineCanopyTailwindConfigOptions,
26
+ maybeOptions?: DefineCanopyTailwindConfigOptions
27
+ ): Config;
28
+
29
+ export default defineCanopyTailwindConfig;