@tecsinapse/cortex-core 2.0.1 → 2.0.2-beta.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.
@@ -153,9 +153,9 @@ const fontFamily = {
153
153
  mono: "Consolas, monaco, monospace"
154
154
  };
155
155
  const textColor = {
156
- light: "#fff",
157
- medium: "#85807a",
158
- dark: "#353231",
156
+ light: "var(--color-text-light, #fff)",
157
+ medium: "var(--color-text-medium, #85807a)",
158
+ dark: "var(--color-text-dark, #353231)",
159
159
  orange: "#f89907"
160
160
  };
161
161
  const zIndex = {
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var polished = require('polished');
4
+
3
5
  const updateThemeColors = (theme) => {
4
6
  const root = document.documentElement;
5
7
  Object.entries(theme).forEach(([colorName, colorShades]) => {
@@ -7,6 +9,15 @@ const updateThemeColors = (theme) => {
7
9
  Object.entries(colorShades).forEach(([shade, hexValue]) => {
8
10
  if (!hexValue) return;
9
11
  root.style.setProperty(`--color-${colorName}-${shade}`, hexValue);
12
+ if (shade !== "xlight" && shade !== "xdark" && polished.getContrast(
13
+ root.style.getPropertyValue(`--color-text-${shade}`),
14
+ hexValue
15
+ ) < 4.5) {
16
+ root.style.setProperty(
17
+ `--color-text-${shade}`,
18
+ polished.readableColor(hexValue)
19
+ );
20
+ }
10
21
  });
11
22
  });
12
23
  };
@@ -151,9 +151,9 @@ const fontFamily = {
151
151
  mono: "Consolas, monaco, monospace"
152
152
  };
153
153
  const textColor = {
154
- light: "#fff",
155
- medium: "#85807a",
156
- dark: "#353231",
154
+ light: "var(--color-text-light, #fff)",
155
+ medium: "var(--color-text-medium, #85807a)",
156
+ dark: "var(--color-text-dark, #353231)",
157
157
  orange: "#f89907"
158
158
  };
159
159
  const zIndex = {
@@ -1,3 +1,5 @@
1
+ import { getContrast, readableColor } from 'polished';
2
+
1
3
  const updateThemeColors = (theme) => {
2
4
  const root = document.documentElement;
3
5
  Object.entries(theme).forEach(([colorName, colorShades]) => {
@@ -5,6 +7,15 @@ const updateThemeColors = (theme) => {
5
7
  Object.entries(colorShades).forEach(([shade, hexValue]) => {
6
8
  if (!hexValue) return;
7
9
  root.style.setProperty(`--color-${colorName}-${shade}`, hexValue);
10
+ if (shade !== "xlight" && shade !== "xdark" && getContrast(
11
+ root.style.getPropertyValue(`--color-text-${shade}`),
12
+ hexValue
13
+ ) < 4.5) {
14
+ root.style.setProperty(
15
+ `--color-text-${shade}`,
16
+ readableColor(hexValue)
17
+ );
18
+ }
8
19
  });
9
20
  });
10
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-core",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-beta.1",
4
4
  "license": "MIT",
5
5
  "description": "Core library for tailwindcss based design",
6
6
  "main": "dist/esm/index.js",
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "clsx": "2.1.1",
20
+ "polished": "^4.3.1",
20
21
  "tailwind-variants": "3.1.1"
21
22
  },
22
23
  "devDependencies": {
@@ -34,5 +35,5 @@
34
35
  "peerDependencies": {
35
36
  "tailwindcss": "^4.1.16"
36
37
  },
37
- "gitHead": "450f025db0e2b628bd39e2d75125c84e0dd8b5be"
38
+ "gitHead": "7312335a32c082dd8cf3b264bae6cda03678f5f1"
38
39
  }