@sikka/hawa 0.0.145 → 0.0.147

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.
Files changed (35) hide show
  1. package/dist/styles.css +195 -72
  2. package/es/blocks/Misc/EmptyState.d.ts +3 -1
  3. package/es/blocks/Misc/NotFound.d.ts +3 -1
  4. package/es/index.es.js +1 -1
  5. package/es/layout/HawaContainer.d.ts +1 -1
  6. package/es/util.d.ts +8 -4
  7. package/lib/blocks/Misc/EmptyState.d.ts +3 -1
  8. package/lib/blocks/Misc/NotFound.d.ts +3 -1
  9. package/lib/index.js +1 -1
  10. package/lib/layout/HawaContainer.d.ts +1 -1
  11. package/lib/util.d.ts +8 -4
  12. package/package.json +3 -2
  13. package/src/blocks/Misc/EmptyState.tsx +13 -11
  14. package/src/blocks/Misc/NotFound.tsx +11 -16
  15. package/src/blocks/Payment/SelectPayment.tsx +0 -1
  16. package/src/elements/DraggableCard.tsx +1 -1
  17. package/src/elements/HawaButton.tsx +6 -5
  18. package/src/elements/HawaLogoButton.tsx +1 -1
  19. package/src/elements/HawaMenu.tsx +1 -1
  20. package/src/layout/HawaAppLayout.tsx +139 -95
  21. package/src/layout/HawaContainer.tsx +6 -4
  22. package/src/styles.css +195 -72
  23. package/src/tailwind.css +0 -14
  24. package/src/util.ts +142 -29
  25. package/storybook-static/{767.232e4e4c88bb0a2ed02d.manager.bundle.js → 767.8e4ffb17eae12c283b3b.manager.bundle.js} +2 -2
  26. package/storybook-static/{767.232e4e4c88bb0a2ed02d.manager.bundle.js.LICENSE.txt → 767.8e4ffb17eae12c283b3b.manager.bundle.js.LICENSE.txt} +0 -0
  27. package/storybook-static/870.c002064e.iframe.bundle.js +2 -0
  28. package/storybook-static/{870.32eb3abe.iframe.bundle.js.LICENSE.txt → 870.c002064e.iframe.bundle.js.LICENSE.txt} +0 -0
  29. package/storybook-static/iframe.html +1 -1
  30. package/storybook-static/index.html +1 -1
  31. package/storybook-static/main.780d09cf.iframe.bundle.js +1 -0
  32. package/storybook-static/project.json +1 -1
  33. package/tailwind.config.js +62 -0
  34. package/storybook-static/870.32eb3abe.iframe.bundle.js +0 -2
  35. package/storybook-static/main.caad440f.iframe.bundle.js +0 -1
package/src/tailwind.css CHANGED
@@ -13,17 +13,3 @@
13
13
  body {
14
14
  font-family: "IBM Plex Sans Arabic", sans-serif;
15
15
  }
16
- /* <div className="react-select-container">
17
- <div className="react-select__control">
18
- <div className="react-select__value-container">...</div>
19
- <div className="react-select__indicators">...</div>
20
- </div>
21
- <div className="react-select__menu">
22
- <div className="react-select__menu-list">
23
- <div className="react-select__option">...</div>
24
- </div>
25
- </div>
26
- </div> */
27
- .hawa-select-container {
28
- background-color: red;
29
- }
package/src/util.ts CHANGED
@@ -1,30 +1,143 @@
1
- const hexToRgb = (hex) => {
2
- let d = hex?.split("#")[1];
3
- var aRgbHex = d?.match(/.{1,2}/g);
4
- var aRgb = [
5
- parseInt(aRgbHex[0], 16),
6
- parseInt(aRgbHex[1], 16),
7
- parseInt(aRgbHex[2], 16)
8
- ];
9
- return aRgb;
10
- };
11
- const getTextColor = (backColor) => {
12
- let rgbArray = hexToRgb(backColor);
13
- if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {
14
- return "#000000";
15
- } else {
16
- return "#ffffff";
1
+
2
+ type Palette = {
3
+ name: string
4
+ colors: {
5
+ [key: number]: string
6
+ }
7
+ }
8
+ type Rgb = {
9
+ r: number
10
+ g: number
11
+ b: number
12
+ }
13
+ function hexToRgb(hex: string): Rgb | null {
14
+ const sanitizedHex = hex.replaceAll("##", "#")
15
+ const colorParts = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(
16
+ sanitizedHex
17
+ )
18
+
19
+ if (!colorParts) {
20
+ return null
21
+ }
22
+
23
+ const [, r, g, b] = colorParts
24
+
25
+ return {
26
+ r: parseInt(r, 16),
27
+ g: parseInt(g, 16),
28
+ b: parseInt(b, 16),
29
+ } as Rgb
30
+ }
31
+
32
+ function rgbToHex(r: number, g: number, b: number): string {
33
+ const toHex = (c: number) => `0${c.toString(16)}`.slice(-2)
34
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`
35
+ }
36
+
37
+ function getTextColor(color: string): "#FFF" | "#333" {
38
+ const rgbColor = hexToRgb(color)
39
+
40
+ if (!rgbColor) {
41
+ return "#333"
42
+ }
43
+
44
+ const { r, g, b } = rgbColor
45
+ const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b
46
+
47
+ return luma < 120 ? "#FFF" : "#333"
48
+ }
49
+
50
+ function lighten(hex: string, intensity: number): string {
51
+ const color = hexToRgb(`#${hex}`)
52
+
53
+ if (!color) {
54
+ return ""
17
55
  }
18
- };
19
- const replaceAt = function (string, index, replacement) {
20
- // if (replacement == "" || replacement == " ") {
21
- // return (
22
- // string.substring(0, index) +
23
- // string.substring(index + replacement.length )
24
- // );
25
- // }
26
- const replaced = string.substring(0, index) + replacement + string.substring(index + 1)
27
- return replaced
28
- };
29
-
30
- export { hexToRgb, getTextColor, replaceAt };
56
+
57
+ const r = Math.round(color.r + (255 - color.r) * intensity)
58
+ const g = Math.round(color.g + (255 - color.g) * intensity)
59
+ const b = Math.round(color.b + (255 - color.b) * intensity)
60
+
61
+ return rgbToHex(r, g, b)
62
+ }
63
+
64
+ function darken(hex: string, intensity: number): string {
65
+ const color = hexToRgb(hex)
66
+
67
+ if (!color) {
68
+ return ""
69
+ }
70
+
71
+ const r = Math.round(color.r * intensity)
72
+ const g = Math.round(color.g * intensity)
73
+ const b = Math.round(color.b * intensity)
74
+
75
+ return rgbToHex(r, g, b)
76
+ }
77
+
78
+ function getPallette(baseColor: string): Palette {
79
+ const name = baseColor
80
+
81
+ const response: Palette = {
82
+ name,
83
+ colors: {
84
+ 500: `#${baseColor}`.replace("##", "#"),
85
+ },
86
+ }
87
+
88
+ const intensityMap: {
89
+ [key: number]: number
90
+ } = {
91
+ 50: 0.95,
92
+ 100: 0.9,
93
+ 200: 0.75,
94
+ 300: 0.6,
95
+ 400: 0.3,
96
+ 600: 0.9,
97
+ 700: 0.75,
98
+ 800: 0.6,
99
+ 900: 0.49,
100
+ }
101
+
102
+ ;[50, 100, 200, 300, 400].forEach((level) => {
103
+ response.colors[level] = lighten(baseColor, intensityMap[level])
104
+ })
105
+ ;[600, 700, 800, 900].forEach((level) => {
106
+ response.colors[level] = darken(baseColor, intensityMap[level])
107
+ })
108
+
109
+ return response as Palette
110
+ }
111
+
112
+ export { getPallette };
113
+
114
+ // const hexToRgb = (hex) => {
115
+ // let d = hex?.split("#")[1];
116
+ // var aRgbHex = d?.match(/.{1,2}/g);
117
+ // var aRgb = [
118
+ // parseInt(aRgbHex[0], 16),
119
+ // parseInt(aRgbHex[1], 16),
120
+ // parseInt(aRgbHex[2], 16)
121
+ // ];
122
+ // return aRgb;
123
+ // };
124
+ // const getTextColor = (backColor) => {
125
+ // let rgbArray = hexToRgb(backColor);
126
+ // if (rgbArray[0] * 0.299 + rgbArray[1] * 0.587 + rgbArray[2] * 0.114 > 186) {
127
+ // return "#000000";
128
+ // } else {
129
+ // return "#ffffff";
130
+ // }
131
+ // };
132
+ // const replaceAt = function (string, index, replacement) {
133
+ // // if (replacement == "" || replacement == " ") {
134
+ // // return (
135
+ // // string.substring(0, index) +
136
+ // // string.substring(index + replacement.length )
137
+ // // );
138
+ // // }
139
+ // const replaced = string.substring(0, index) + replacement + string.substring(index + 1)
140
+ // return replaced
141
+ // };
142
+
143
+ // export { hexToRgb, getTextColor, replaceAt };