sk-clib 2.0.5 → 2.0.7

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.
@@ -15,7 +15,7 @@ export declare function build(seed: string, mode?: Mode, variant?: Variant, cont
15
15
  *
16
16
  * @param scheme Generated scheme that will be applied to the root element
17
17
  */
18
- export declare function applyScheme(scheme: DynamicScheme): void;
18
+ export declare function applyScheme(scheme: DynamicScheme): Record<string, any>;
19
19
  /**
20
20
  * Stores the theme as a string in cookies
21
21
  *
@@ -49,24 +49,29 @@ export function applyScheme(scheme) {
49
49
  "neutralPaletteKeyColor",
50
50
  "neutralVariantPaletteKeyColor"
51
51
  ];
52
+ // This variable will be saved in the cookies, also what is returned.
53
+ let cached_scheme = {};
52
54
  // Set the color properties
53
55
  const allColors = [...scheme.colors.allColors, ...missingColors];
54
56
  allColors.forEach((dynamicColor) => {
55
57
  const colorName = typeof dynamicColor === 'string' ? dynamicColor : dynamicColor.name;
56
- console.log(colorName);
57
58
  const prop = snakeOrKebabToCamel(colorName);
58
59
  const value = scheme[prop];
59
60
  root.style.setProperty(`--md-${snakeToKebab(colorName)}`, hexFromArgb(value));
61
+ cached_scheme[`--md-${snakeToKebab(colorName)}`] = hexFromArgb(value);
60
62
  });
61
63
  const conf_out = {
62
64
  '--md-seed': hexFromArgb(scheme.sourceColorArgb),
63
65
  '--md-mode': mode,
64
66
  '--md-variant': variant
65
67
  };
68
+ // Add conf_out to cached_scheme
69
+ cached_scheme = { ...cached_scheme, ...conf_out };
66
70
  // Set the config properties
67
71
  for (const [key, value] of Object.entries(conf_out)) {
68
72
  root.style.setProperty(key, value);
69
73
  }
74
+ return cached_scheme;
70
75
  }
71
76
  /**
72
77
  * Stores the theme as a string in cookies
@@ -38,7 +38,7 @@
38
38
  const built = build(theme.seedColor, theme.mode, theme.variant);
39
39
 
40
40
  // Create css variables object and save to body
41
- let applied = applyScheme(built, theme.seedColor, theme.mode, theme.variant);
41
+ let applied = applyScheme(built);
42
42
 
43
43
  // Save the theme to the user's cookies
44
44
  saveTheme(applied);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sk-clib",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/TreltaSev/sk-clib"