@tecsinapse/cortex-core 1.2.1-beta.1 → 1.3.0-beta.0

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/dist/cjs/index.js CHANGED
@@ -73,4 +73,5 @@ exports.fontSize = definitions.fontSize;
73
73
  exports.spacing = definitions.spacing;
74
74
  exports.textColor = definitions.textColor;
75
75
  exports.zIndex = definitions.zIndex;
76
+ exports.setDarkMode = index$1.setDarkMode;
76
77
  exports.updateThemeColors = index$1.updateThemeColors;
@@ -44,7 +44,7 @@ const colors = {
44
44
  xdark: "#58240e"
45
45
  },
46
46
  miscellaneous: {
47
- body: "#f8f7f7"
47
+ body: "var(--color-body, #f8f7f7)"
48
48
  }
49
49
  };
50
50
  const spacing = {
@@ -153,9 +153,9 @@ const fontFamily = {
153
153
  mono: "Consolas, monaco, monospace"
154
154
  };
155
155
  const textColor = {
156
- light: "var(--color-text-light, #fff)",
157
- medium: "var(--color-text-medium, #85807a)",
158
- dark: "var(--color-text-dark, #353231)",
156
+ light: "#fff",
157
+ medium: "#85807a",
158
+ dark: "#353231",
159
159
  orange: "#f89907"
160
160
  };
161
161
  const zIndex = {
@@ -1,33 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var polished = require('polished');
4
-
5
3
  const updateThemeColors = (theme) => {
6
4
  const root = document.documentElement;
7
- console.log(
8
- "Primary Medium: ",
9
- root.style.getPropertyValue("--color-primary-medium")
10
- );
11
- console.log(
12
- "Text Medium: ",
13
- root.style.getPropertyValue("--color-text-medium")
14
- );
15
5
  Object.entries(theme).forEach(([colorName, colorShades]) => {
16
6
  if (!colorShades) return;
17
7
  Object.entries(colorShades).forEach(([shade, hexValue]) => {
18
8
  if (!hexValue) return;
19
9
  root.style.setProperty(`--color-${colorName}-${shade}`, hexValue);
20
- if (shade !== "xlight" && shade !== "xdark" && polished.getContrast(
21
- root.style.getPropertyValue(`--color-text-${shade}`),
22
- hexValue
23
- ) < 4.5) {
24
- root.style.setProperty(
25
- `--color-text-${shade}`,
26
- polished.readableColor(hexValue)
27
- );
28
- }
29
10
  });
30
11
  });
31
12
  };
13
+ const setDarkMode = () => {
14
+ const style = document.documentElement.style;
15
+ const isDark = style.getPropertyValue("--color-body") !== "#f8f7f7";
16
+ if (!isDark) {
17
+ style.setProperty("--color-body", "#1e1e1e");
18
+ } else {
19
+ style.setProperty("--color-body", "#f8f7f7");
20
+ }
21
+ };
32
22
 
23
+ exports.setDarkMode = setDarkMode;
33
24
  exports.updateThemeColors = updateThemeColors;
package/dist/esm/index.js CHANGED
@@ -19,4 +19,4 @@ export { tooltip, tooltipContainer } from './components/tooltip/tooltip.js';
19
19
  export { manager } from './components/manager/manager.js';
20
20
  export { default as preset } from './preset/index.js';
21
21
  export { borderColor, borderRadius, borderWidth, boxShadow, colors, fontFamily, fontSize, spacing, textColor, zIndex } from './tokens/definitions.js';
22
- export { updateThemeColors } from './utils/index.js';
22
+ export { setDarkMode, updateThemeColors } from './utils/index.js';
@@ -42,7 +42,7 @@ const colors = {
42
42
  xdark: "#58240e"
43
43
  },
44
44
  miscellaneous: {
45
- body: "#f8f7f7"
45
+ body: "var(--color-body, #f8f7f7)"
46
46
  }
47
47
  };
48
48
  const spacing = {
@@ -151,9 +151,9 @@ const fontFamily = {
151
151
  mono: "Consolas, monaco, monospace"
152
152
  };
153
153
  const textColor = {
154
- light: "var(--color-text-light, #fff)",
155
- medium: "var(--color-text-medium, #85807a)",
156
- dark: "var(--color-text-dark, #353231)",
154
+ light: "#fff",
155
+ medium: "#85807a",
156
+ dark: "#353231",
157
157
  orange: "#f89907"
158
158
  };
159
159
  const zIndex = {
@@ -1,31 +1,21 @@
1
- import { getContrast, readableColor } from 'polished';
2
-
3
1
  const updateThemeColors = (theme) => {
4
2
  const root = document.documentElement;
5
- console.log(
6
- "Primary Medium: ",
7
- root.style.getPropertyValue("--color-primary-medium")
8
- );
9
- console.log(
10
- "Text Medium: ",
11
- root.style.getPropertyValue("--color-text-medium")
12
- );
13
3
  Object.entries(theme).forEach(([colorName, colorShades]) => {
14
4
  if (!colorShades) return;
15
5
  Object.entries(colorShades).forEach(([shade, hexValue]) => {
16
6
  if (!hexValue) return;
17
7
  root.style.setProperty(`--color-${colorName}-${shade}`, hexValue);
18
- if (shade !== "xlight" && shade !== "xdark" && getContrast(
19
- root.style.getPropertyValue(`--color-text-${shade}`),
20
- hexValue
21
- ) < 4.5) {
22
- root.style.setProperty(
23
- `--color-text-${shade}`,
24
- readableColor(hexValue)
25
- );
26
- }
27
8
  });
28
9
  });
29
10
  };
11
+ const setDarkMode = () => {
12
+ const style = document.documentElement.style;
13
+ const isDark = style.getPropertyValue("--color-body") !== "#f8f7f7";
14
+ if (!isDark) {
15
+ style.setProperty("--color-body", "#1e1e1e");
16
+ } else {
17
+ style.setProperty("--color-body", "#f8f7f7");
18
+ }
19
+ };
30
20
 
31
- export { updateThemeColors };
21
+ export { setDarkMode, updateThemeColors };
@@ -1,2 +1,3 @@
1
1
  import { colors } from '../tokens/definitions';
2
2
  export declare const updateThemeColors: (theme: Partial<typeof colors>) => void;
3
+ export declare const setDarkMode: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-core",
3
- "version": "1.2.1-beta.1",
3
+ "version": "1.3.0-beta.0",
4
4
  "license": "MIT",
5
5
  "description": "Core library for tailwindcss based design",
6
6
  "main": "dist/esm/index.js",
@@ -17,7 +17,6 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "clsx": "2.1.1",
20
- "polished": "^4.3.1",
21
20
  "tailwind-variants": "1.0.0"
22
21
  },
23
22
  "repository": {
@@ -32,5 +31,5 @@
32
31
  "peerDependencies": {
33
32
  "tailwindcss": ">=3.3.0"
34
33
  },
35
- "gitHead": "588758fc26e21e75393c8349311f0633d9e7b5c7"
34
+ "gitHead": "c267542fbb45c9c598be530f2c2d4211365a816e"
36
35
  }