@canopy-iiif/app 1.4.12 → 1.4.13
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/package.json +1 -1
- package/ui/dist/server.mjs +71 -159
- package/ui/dist/server.mjs.map +3 -3
- package/ui/theme.js +0 -136
package/ui/theme.js
CHANGED
|
@@ -88,121 +88,6 @@ function resolveRadixPalette(name, appearance) {
|
|
|
88
88
|
return fallback && fallback[`${name}1`] ? fallback : null;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function darkenHex(hex, amount = 0.15) {
|
|
92
|
-
if (!hex) return hex;
|
|
93
|
-
const normalized = hex.replace("#", "");
|
|
94
|
-
if (!/^[0-9a-fA-F]{6}$/.test(normalized)) return hex;
|
|
95
|
-
const num = parseInt(normalized, 16);
|
|
96
|
-
const r = (num >> 16) & 255;
|
|
97
|
-
const g = (num >> 8) & 255;
|
|
98
|
-
const b = num & 255;
|
|
99
|
-
const clamp = (value) => Math.max(0, Math.min(255, Math.round(value)));
|
|
100
|
-
const toHex = (value) => clamp(value).toString(16).padStart(2, "0");
|
|
101
|
-
const factor = 1 - amount;
|
|
102
|
-
return `#${toHex(r * factor)}${toHex(g * factor)}${toHex(b * factor)}`;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function lightenHex(hex, amount = 0.15) {
|
|
106
|
-
if (!hex) return hex;
|
|
107
|
-
const normalized = hex.replace("#", "");
|
|
108
|
-
if (!/^[0-9a-fA-F]{6}$/.test(normalized)) return hex;
|
|
109
|
-
const num = parseInt(normalized, 16);
|
|
110
|
-
const r = (num >> 16) & 255;
|
|
111
|
-
const g = (num >> 8) & 255;
|
|
112
|
-
const b = num & 255;
|
|
113
|
-
const clamp = (value) => Math.max(0, Math.min(255, Math.round(value)));
|
|
114
|
-
const toHex = (value) => clamp(value).toString(16).padStart(2, "0");
|
|
115
|
-
const adjust = (value) => value + (255 - value) * amount;
|
|
116
|
-
return `#${toHex(adjust(r))}${toHex(adjust(g))}${toHex(adjust(b))}`;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function adjustSaturation(hex, amount = 0.15) {
|
|
120
|
-
if (!hex) return hex;
|
|
121
|
-
const normalized = hex.replace("#", "");
|
|
122
|
-
if (!/^[0-9a-fA-F]{6}$/.test(normalized)) return hex;
|
|
123
|
-
const num = parseInt(normalized, 16);
|
|
124
|
-
let r = ((num >> 16) & 255) / 255;
|
|
125
|
-
let g = ((num >> 8) & 255) / 255;
|
|
126
|
-
let b = (num & 255) / 255;
|
|
127
|
-
const max = Math.max(r, g, b);
|
|
128
|
-
const min = Math.min(r, g, b);
|
|
129
|
-
let h = 0;
|
|
130
|
-
let s = 0;
|
|
131
|
-
const l = (max + min) / 2;
|
|
132
|
-
if (max !== min) {
|
|
133
|
-
const d = max - min;
|
|
134
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
135
|
-
switch (max) {
|
|
136
|
-
case r:
|
|
137
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
138
|
-
break;
|
|
139
|
-
case g:
|
|
140
|
-
h = (b - r) / d + 2;
|
|
141
|
-
break;
|
|
142
|
-
default:
|
|
143
|
-
h = (r - g) / d + 4;
|
|
144
|
-
}
|
|
145
|
-
h /= 6;
|
|
146
|
-
}
|
|
147
|
-
const delta = Number(amount);
|
|
148
|
-
if (!Number.isFinite(delta) || delta === 0) return hex;
|
|
149
|
-
s = Math.max(0, Math.min(1, s + delta));
|
|
150
|
-
const hueToRgb = (p, q, t) => {
|
|
151
|
-
if (t < 0) t += 1;
|
|
152
|
-
if (t > 1) t -= 1;
|
|
153
|
-
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
154
|
-
if (t < 1 / 2) return q;
|
|
155
|
-
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
156
|
-
return p;
|
|
157
|
-
};
|
|
158
|
-
let rOut;
|
|
159
|
-
let gOut;
|
|
160
|
-
let bOut;
|
|
161
|
-
if (s === 0) {
|
|
162
|
-
rOut = gOut = bOut = l;
|
|
163
|
-
} else {
|
|
164
|
-
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
165
|
-
const p = 2 * l - q;
|
|
166
|
-
rOut = hueToRgb(p, q, h + 1 / 3);
|
|
167
|
-
gOut = hueToRgb(p, q, h);
|
|
168
|
-
bOut = hueToRgb(p, q, h - 1 / 3);
|
|
169
|
-
}
|
|
170
|
-
const toHex = (value) =>
|
|
171
|
-
Math.round(Math.max(0, Math.min(1, value)) * 255)
|
|
172
|
-
.toString(16)
|
|
173
|
-
.padStart(2, "0");
|
|
174
|
-
return `#${toHex(rOut)}${toHex(gOut)}${toHex(bOut)}`;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function mixHexColors(colorA, colorB, amount = 0.5) {
|
|
178
|
-
const normalize = (hex) =>
|
|
179
|
-
hex && /^[0-9a-fA-F]{6}$/.test(hex.replace("#", ""))
|
|
180
|
-
? hex.replace("#", "")
|
|
181
|
-
: null;
|
|
182
|
-
const first = normalize(colorA);
|
|
183
|
-
const second = normalize(colorB);
|
|
184
|
-
if (!first || !second) return colorA || colorB || null;
|
|
185
|
-
const a = parseInt(first, 16);
|
|
186
|
-
const b = parseInt(second, 16);
|
|
187
|
-
const clampAmount = Math.max(0, Math.min(1, Number(amount) || 0));
|
|
188
|
-
const mixChannel = (shift) =>
|
|
189
|
-
Math.round(
|
|
190
|
-
((a >> shift) & 255) +
|
|
191
|
-
(((b >> shift) & 255) - ((a >> shift) & 255)) * clampAmount
|
|
192
|
-
);
|
|
193
|
-
const toHex = (value) => value.toString(16).padStart(2, "0");
|
|
194
|
-
const r = mixChannel(16);
|
|
195
|
-
const g = mixChannel(8);
|
|
196
|
-
const bl = mixChannel(0);
|
|
197
|
-
return `#${toHex(r)}${toHex(g)}${toHex(bl)}`;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function normalizeDarkenAmount(raw) {
|
|
201
|
-
const value = Number(raw);
|
|
202
|
-
if (!Number.isFinite(value)) return null;
|
|
203
|
-
return Math.min(0.95, Math.max(0, value));
|
|
204
|
-
}
|
|
205
|
-
|
|
206
91
|
function toTailwindScale(name, options = {}) {
|
|
207
92
|
if (!name || !AVAILABLE.has(name)) return null;
|
|
208
93
|
const appearance = normalizeAppearance(options.appearance);
|
|
@@ -210,7 +95,6 @@ function toTailwindScale(name, options = {}) {
|
|
|
210
95
|
if (!palette) return null;
|
|
211
96
|
const prefix = name;
|
|
212
97
|
const scale = {};
|
|
213
|
-
const darken900Amount = normalizeDarkenAmount(options.darken900Amount);
|
|
214
98
|
const steps = STEP_MAP;
|
|
215
99
|
for (const lvl of LEVELS) {
|
|
216
100
|
const radixStep = steps[lvl];
|
|
@@ -219,26 +103,6 @@ function toTailwindScale(name, options = {}) {
|
|
|
219
103
|
if (!value) return null;
|
|
220
104
|
scale[lvl] = value;
|
|
221
105
|
}
|
|
222
|
-
const saturate700 = options.saturate700 !== false;
|
|
223
|
-
if (scale["700"]) {
|
|
224
|
-
let adjusted =
|
|
225
|
-
appearance === "dark"
|
|
226
|
-
? lightenHex(scale["700"], 0.15)
|
|
227
|
-
: darkenHex(scale["700"], 0.15);
|
|
228
|
-
if (saturate700) adjusted = adjustSaturation(adjusted, 0.15);
|
|
229
|
-
scale["700"] = adjusted;
|
|
230
|
-
}
|
|
231
|
-
const darkestKey = `${prefix}${steps["900"]}`;
|
|
232
|
-
if (scale["800"] && palette[darkestKey]) {
|
|
233
|
-
const amount = darken900Amount != null ? darken900Amount : 0.25;
|
|
234
|
-
scale["900"] =
|
|
235
|
-
appearance === "dark"
|
|
236
|
-
? lightenHex(palette[darkestKey], amount)
|
|
237
|
-
: darkenHex(palette[darkestKey], amount);
|
|
238
|
-
}
|
|
239
|
-
if (scale["800"] && scale["900"]) {
|
|
240
|
-
scale["800"] = mixHexColors(scale["800"], scale["900"], 0.65);
|
|
241
|
-
}
|
|
242
106
|
return scale;
|
|
243
107
|
}
|
|
244
108
|
|