jb-core 0.6.0 → 0.7.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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "react component",
15
15
  "event"
16
16
  ],
17
- "version": "0.6.0",
17
+ "version": "0.7.0",
18
18
  "bugs": "https://github.com/javadbat/jb-core/issues",
19
19
  "license": "MIT",
20
20
  "files": [
package/theme/colors.ts CHANGED
@@ -1,48 +1,60 @@
1
+ import { setCssProperty } from "./utils";
2
+
3
+ const colors = {
4
+ single:{
5
+ black:"oklch(0.14 0 0)",
6
+ white:"oklch(1 0 0)",
7
+ }
8
+ }
1
9
  export function defineColors() {
2
- setColorProperty({
10
+ defineColorCodes();
11
+ defineTextColors();
12
+ }
13
+ function defineColorCodes(){
14
+ setCssProperty({
3
15
  name: "--jb-primary",
4
16
  syntax: "<color>",
5
17
  inherits: true,
6
18
  initialValue: "oklch(0.6 0.26 256)",
7
19
  });
8
- setColorProperty({
20
+ setCssProperty({
9
21
  name: "--jb-neutral",
10
22
  syntax: "<color>",
11
23
  inherits: true,
12
24
  initialValue: "oklch(0.18 0.014 258.36)",
13
25
  });
14
- setColorProperty({
26
+ setCssProperty({
15
27
  name: "--jb-black",
16
28
  syntax: "<color>",
17
29
  inherits: true,
18
- initialValue: "oklch(0.14 0 0)",
30
+ initialValue: colors.single.black,
19
31
  });
20
- setColorProperty({
32
+ setCssProperty({
21
33
  name: "--jb-white",
22
34
  syntax: "<color>",
23
35
  inherits: true,
24
- initialValue: "oklch(1 0 0)",
36
+ initialValue: colors.single.white ,
25
37
  });
26
- setColorProperty({
38
+ setCssProperty({
27
39
  name: "--jb-green",
28
40
  syntax: "<color>",
29
41
  inherits: true,
30
42
  initialValue: "oklch(0.68 0.1484 162.1)",
31
43
  });
32
- setColorProperty({
44
+ setCssProperty({
33
45
  name: "--jb-red",
34
46
  syntax: "<color>",
35
47
  inherits: true,
36
- initialValue: "oklch(0.64 0.2485 23.21)",
48
+ initialValue: "oklch(0.6 0.22 23.21)",
37
49
  });
38
- setColorProperty({
50
+ setCssProperty({
39
51
  name: `--jb-neutral`,
40
52
  syntax: "<color>",
41
53
  inherits: true,
42
54
  initialValue: getNeutralColor(0),
43
55
  });
44
56
  for(let i=1;i<=10;i++){
45
- setColorProperty({
57
+ setCssProperty({
46
58
  name: `--jb-neutral-${i}`,
47
59
  syntax: "<color>",
48
60
  inherits: true,
@@ -50,15 +62,21 @@ export function defineColors() {
50
62
  });
51
63
  }
52
64
  }
53
- function setColorProperty(value: PropertyDefinition) {
54
- try {
55
- window.CSS.registerProperty({
56
- ...value
57
- });
58
- } catch (e) {
59
- // if property is already defined
60
- }
65
+ function defineTextColors() {
66
+ setCssProperty({
67
+ name: "--jb-text-primary",
68
+ syntax: "<color>",
69
+ inherits: true,
70
+ initialValue: colors.single.black,
71
+ });
72
+ setCssProperty({
73
+ name: "--jb-text-secondary",
74
+ syntax: "<color>",
75
+ inherits: true,
76
+ initialValue: getNeutralColor(7),
77
+ });
61
78
  }
79
+
62
80
  //
63
81
  export function getNeutralColor(index: number) {
64
82
  return `oklch(${(6 * (3+index*1.3))*0.01} ${(14+(index*0.09))*0.001} 258.36)`;
package/theme/utils.ts ADDED
@@ -0,0 +1,9 @@
1
+ export function setCssProperty(value: PropertyDefinition) {
2
+ try {
3
+ window.CSS.registerProperty({
4
+ ...value
5
+ });
6
+ } catch (e) {
7
+ // if property is already defined
8
+ }
9
+ }