@canopy-iiif/app 0.10.7 → 0.10.9

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/ui/theme.js CHANGED
@@ -8,8 +8,6 @@ const DEFAULT_GRAY = "slate";
8
8
  const DEFAULT_APPEARANCE = "light";
9
9
  const DEBUG_FLAG_RAW = String(process.env.CANOPY_DEBUG_THEME || "");
10
10
  const DEBUG_ENABLED = /^(1|true|yes|on)$/i.test(DEBUG_FLAG_RAW.trim());
11
- const SASS_STYLES_DIR = path.join(__dirname, "styles");
12
- const SASS_VARIABLES_ENTRY = path.join(SASS_STYLES_DIR, "_variables.scss");
13
11
 
14
12
  function debugLog(...args) {
15
13
  if (!DEBUG_ENABLED) return;
@@ -18,31 +16,6 @@ function debugLog(...args) {
18
16
  } catch (_) {}
19
17
  }
20
18
 
21
- function loadSassVariableTokens() {
22
- try {
23
- if (!fs.existsSync(SASS_VARIABLES_ENTRY)) return {map: {}, css: ""};
24
- const sass = require("sass");
25
- const source = `@use 'sass:meta';\n@use 'sass:string';\n@use 'variables';\n$__canopy_tokens: meta.module-variables('variables');\n@function canopy-token-name($name) {\n $identifier: #{$name};\n @if $identifier == null or $identifier == '' {\n @return null;\n }\n @if string.slice($identifier, 1, 1) == '_' {\n @return null;\n }\n @return '--#{$identifier}';\n}\n@mixin canopy-emit-tokens() {\n @each $name, $value in $__canopy_tokens {\n $css-name: canopy-token-name($name);\n @if $css-name {\n #{$css-name}: #{meta.inspect($value)};\n }\n }\n}\n:root {\n @include canopy-emit-tokens();\n}\n:host {\n @include canopy-emit-tokens();\n}\n`;
26
- const result = sass.compileString(source, {
27
- loadPaths: [SASS_STYLES_DIR],
28
- style: "expanded",
29
- });
30
- const css = (result && result.css ? result.css : "").trim();
31
- const vars = {};
32
- const regex = /--([A-Za-z0-9_-]+)\s*:\s*([^;]+);/g;
33
- let match;
34
- while ((match = regex.exec(css))) {
35
- vars[`--${match[1]}`] = match[2].trim();
36
- }
37
- return {map: vars, css};
38
- } catch (error) {
39
- debugLog(
40
- "failed to compile Sass variables",
41
- error && error.message ? error.message : error
42
- );
43
- return {map: {}, css: ""};
44
- }
45
- }
46
19
  const LEVELS = [
47
20
  "50",
48
21
  "100",
@@ -267,12 +240,8 @@ function loadCanopyTheme(options = {}) {
267
240
  });
268
241
  }
269
242
 
270
- const sassTokens = loadSassVariableTokens();
271
243
  const dynamicVars = buildVariablesMap(accentScale, grayScale, {appearance});
272
- const mergedVars = {
273
- ...(sassTokens && sassTokens.map ? sassTokens.map : {}),
274
- ...dynamicVars,
275
- };
244
+ const mergedVars = dynamicVars;
276
245
  const css = variablesToCss(mergedVars);
277
246
  const sassConfig = buildSassConfig(accentScale, grayScale);
278
247