@tecsinapse/cortex-core 2.0.2-beta.1 → 2.0.2-beta.3

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.
@@ -3,7 +3,7 @@
3
3
  var tailwindVariants = require('tailwind-variants');
4
4
 
5
5
  const buttonStyles = tailwindVariants.tv({
6
- base: "text-base h-fit font-bold disabled:text-white enabled:active:scale-95 transform transition hover:text-white text-white cursor-pointer items-center flex justify-center",
6
+ base: "text-base h-fit font-bold disabled:text-on-primary enabled:active:scale-95 transform transition hover:text-on-primary text-on-primary cursor-pointer items-center flex justify-center",
7
7
  variants: {
8
8
  intent: {
9
9
  primary: "bg-primary-medium disabled:bg-primary-light active:bg-primary-dark enabled:hover:border-primary-dark hover:bg-primary-dark",
@@ -15,7 +15,7 @@ const tagStyles = myTV({
15
15
  base: "rounded-micro px-micro py-nano w-fit font-bold text-label items-center flex gap-1",
16
16
  variants: {
17
17
  intent: {
18
- primary: "bg-primary-medium text-white",
18
+ primary: "bg-primary-medium text-on-primary",
19
19
  secondary: "bg-secondary-medium text-white",
20
20
  info: "bg-info-medium text-white",
21
21
  success: "bg-success-medium text-white",
package/dist/cjs/index.js CHANGED
@@ -74,3 +74,4 @@ exports.spacing = definitions.spacing;
74
74
  exports.textColor = definitions.textColor;
75
75
  exports.zIndex = definitions.zIndex;
76
76
  exports.updateThemeColors = index.updateThemeColors;
77
+ exports.updateThemeText = index.updateThemeText;
@@ -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: "var(--color-on-primary, #fff)",
157
+ medium: "var(--color-medium, #85807a)",
158
+ dark: "var(--color-dark, #353231)",
159
159
  orange: "#f89907"
160
160
  };
161
161
  const zIndex = {
@@ -2,24 +2,30 @@
2
2
 
3
3
  var polished = require('polished');
4
4
 
5
- const updateThemeColors = (theme) => {
5
+ const updateThemeText = (colorName, shade, hexValue) => {
6
+ const root = document.documentElement;
7
+ if (colorName === "primary" && shade === "medium") {
8
+ if (polished.getContrast(hexValue, "#fff") < 2.5) {
9
+ root.setAttribute("data-contrast", "black");
10
+ } else {
11
+ root.setAttribute("data-contrast", "white");
12
+ }
13
+ }
14
+ };
15
+ const updateThemeColors = ({
16
+ theme,
17
+ updateText = false
18
+ }) => {
6
19
  const root = document.documentElement;
7
20
  Object.entries(theme).forEach(([colorName, colorShades]) => {
8
21
  if (!colorShades) return;
9
22
  Object.entries(colorShades).forEach(([shade, hexValue]) => {
10
23
  if (!hexValue) return;
11
24
  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
- }
25
+ if (updateText) updateThemeText(colorName, shade, hexValue);
21
26
  });
22
27
  });
23
28
  };
24
29
 
25
30
  exports.updateThemeColors = updateThemeColors;
31
+ exports.updateThemeText = updateThemeText;
package/dist/default.css CHANGED
@@ -1,5 +1,13 @@
1
1
  @import "tailwindcss";
2
2
 
3
+ :root {
4
+ --color-on-primary: #fff
5
+ }
6
+
7
+ :root[data-contrast='black'] {
8
+ --color-on-primary: #000
9
+ }
10
+
3
11
  @theme {
4
12
  /* Colors - primary */
5
13
  --color-primary-xlight: #fef9f0;
@@ -128,10 +136,11 @@
128
136
  --color-border-success-light: #99E6C9;
129
137
 
130
138
  /* Text colors */
131
- --color-text-light: #fff;
132
- --color-text-medium: #85807a;
133
- --color-text-dark: #353231;
134
- --color-text-orange: #f89907;
139
+ --color-on-primary: var(--color-on-primary);
140
+ --color-light: #fff;
141
+ --color-medium: #85807a;
142
+ --color-dark: #353231;
143
+ --color-orange: #f89907;
135
144
 
136
145
  /* Z-index */
137
146
  --z-index-default: 0;
@@ -1,7 +1,7 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
 
3
3
  const buttonStyles = tv({
4
- base: "text-base h-fit font-bold disabled:text-white enabled:active:scale-95 transform transition hover:text-white text-white cursor-pointer items-center flex justify-center",
4
+ base: "text-base h-fit font-bold disabled:text-on-primary enabled:active:scale-95 transform transition hover:text-on-primary text-on-primary cursor-pointer items-center flex justify-center",
5
5
  variants: {
6
6
  intent: {
7
7
  primary: "bg-primary-medium disabled:bg-primary-light active:bg-primary-dark enabled:hover:border-primary-dark hover:bg-primary-dark",
@@ -13,7 +13,7 @@ const tagStyles = myTV({
13
13
  base: "rounded-micro px-micro py-nano w-fit font-bold text-label items-center flex gap-1",
14
14
  variants: {
15
15
  intent: {
16
- primary: "bg-primary-medium text-white",
16
+ primary: "bg-primary-medium text-on-primary",
17
17
  secondary: "bg-secondary-medium text-white",
18
18
  info: "bg-info-medium text-white",
19
19
  success: "bg-success-medium text-white",
package/dist/esm/index.js CHANGED
@@ -18,4 +18,4 @@ export { styleInputElement, styleLabelElement, toggle } from './components/toggl
18
18
  export { tooltip, tooltipContainer } from './components/tooltip/tooltip.js';
19
19
  export { manager } from './components/manager/manager.js';
20
20
  export { borderColor, borderRadius, borderWidth, boxShadow, colors, fontFamily, fontSize, spacing, textColor, zIndex } from './tokens/definitions.js';
21
- export { updateThemeColors } from './utils/index.js';
21
+ export { updateThemeColors, updateThemeText } from './utils/index.js';
@@ -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: "var(--color-on-primary, #fff)",
155
+ medium: "var(--color-medium, #85807a)",
156
+ dark: "var(--color-dark, #353231)",
157
157
  orange: "#f89907"
158
158
  };
159
159
  const zIndex = {
@@ -1,23 +1,28 @@
1
- import { getContrast, readableColor } from 'polished';
1
+ import { getContrast } from 'polished';
2
2
 
3
- const updateThemeColors = (theme) => {
3
+ const updateThemeText = (colorName, shade, hexValue) => {
4
+ const root = document.documentElement;
5
+ if (colorName === "primary" && shade === "medium") {
6
+ if (getContrast(hexValue, "#fff") < 2.5) {
7
+ root.setAttribute("data-contrast", "black");
8
+ } else {
9
+ root.setAttribute("data-contrast", "white");
10
+ }
11
+ }
12
+ };
13
+ const updateThemeColors = ({
14
+ theme,
15
+ updateText = false
16
+ }) => {
4
17
  const root = document.documentElement;
5
18
  Object.entries(theme).forEach(([colorName, colorShades]) => {
6
19
  if (!colorShades) return;
7
20
  Object.entries(colorShades).forEach(([shade, hexValue]) => {
8
21
  if (!hexValue) return;
9
22
  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
- }
23
+ if (updateText) updateThemeText(colorName, shade, hexValue);
19
24
  });
20
25
  });
21
26
  };
22
27
 
23
- export { updateThemeColors };
28
+ export { updateThemeColors, updateThemeText };
@@ -20,7 +20,7 @@ export declare const buttonStyles: import("tailwind-variants").TVReturnType<{
20
20
  circle: string;
21
21
  base: string;
22
22
  };
23
- }, undefined, "text-base h-fit font-bold disabled:text-white enabled:active:scale-95 transform transition hover:text-white text-white cursor-pointer items-center flex justify-center", {
23
+ }, undefined, "text-base h-fit font-bold disabled:text-on-primary enabled:active:scale-95 transform transition hover:text-on-primary text-on-primary cursor-pointer items-center flex justify-center", {
24
24
  intent: {
25
25
  primary: string;
26
26
  secondary: string;
@@ -62,7 +62,7 @@ export declare const buttonStyles: import("tailwind-variants").TVReturnType<{
62
62
  circle: string;
63
63
  base: string;
64
64
  };
65
- }, undefined, "text-base h-fit font-bold disabled:text-white enabled:active:scale-95 transform transition hover:text-white text-white cursor-pointer items-center flex justify-center", unknown, unknown, undefined>>;
65
+ }, undefined, "text-base h-fit font-bold disabled:text-on-primary enabled:active:scale-95 transform transition hover:text-on-primary text-on-primary cursor-pointer items-center flex justify-center", unknown, unknown, undefined>>;
66
66
  export type ButtonVariants = VariantProps<typeof buttonStyles> & {
67
67
  className?: string;
68
68
  };
@@ -1,2 +1,6 @@
1
1
  import { colors } from '../tokens/definitions';
2
- export declare const updateThemeColors: (theme: Partial<typeof colors>) => void;
2
+ export declare const updateThemeText: (colorName: string, shade: string, hexValue: string) => void;
3
+ export declare const updateThemeColors: ({ theme, updateText, }: {
4
+ theme: Partial<typeof colors>;
5
+ updateText?: boolean;
6
+ }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-core",
3
- "version": "2.0.2-beta.1",
3
+ "version": "2.0.2-beta.3",
4
4
  "license": "MIT",
5
5
  "description": "Core library for tailwindcss based design",
6
6
  "main": "dist/esm/index.js",
@@ -35,5 +35,5 @@
35
35
  "peerDependencies": {
36
36
  "tailwindcss": "^4.1.16"
37
37
  },
38
- "gitHead": "7312335a32c082dd8cf3b264bae6cda03678f5f1"
38
+ "gitHead": "5de99380c3dbe5a345730503a21bf91fc17eba3d"
39
39
  }