@rovula/ui 0.0.31 → 0.0.32
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/bundle.css +920 -20
- package/dist/cjs/types/stories/ColorPreview.d.ts +9 -5
- package/dist/cjs/types/utils/colors.d.ts +1 -0
- package/dist/components/Text/Text.stories.js +5 -1
- package/dist/esm/bundle.css +920 -20
- package/dist/esm/types/stories/ColorPreview.d.ts +9 -5
- package/dist/esm/types/utils/colors.d.ts +1 -0
- package/dist/src/theme/global.css +1343 -217
- package/dist/stories/ColorGroupPreview.js +282 -472
- package/dist/stories/ColorPreview.js +76 -6
- package/dist/theme/main-preset.js +8 -0
- package/dist/theme/plugins/utilities/typography.js +3 -0
- package/dist/theme/presets/colors.js +0 -3
- package/dist/utils/colors.js +31 -0
- package/package.json +1 -1
- package/src/components/Text/Text.stories.tsx +5 -1
- package/src/stories/ColorGroupPreview.tsx +394 -486
- package/src/stories/ColorPreview.tsx +122 -33
- package/src/theme/main-preset.js +8 -0
- package/src/theme/plugins/utilities/typography.js +3 -0
- package/src/theme/presets/colors.js +0 -3
- package/src/utils/colors.ts +33 -0
|
@@ -1,7 +1,77 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { srgbToHex } from "@/utils/colors";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "..";
|
|
5
|
+
export const ColorBox = ({ className }) => {
|
|
6
|
+
const boxRef = useRef(null);
|
|
7
|
+
const [hex, setHex] = useState("");
|
|
8
|
+
const [isOpen, setOpen] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (boxRef.current) {
|
|
11
|
+
const bgColor = window.getComputedStyle(boxRef.current).backgroundColor;
|
|
12
|
+
const hexColor = srgbToHex(bgColor);
|
|
13
|
+
setHex(hexColor);
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
let time;
|
|
18
|
+
if (isOpen) {
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
setOpen(false);
|
|
21
|
+
}, 1000);
|
|
22
|
+
}
|
|
23
|
+
return () => {
|
|
24
|
+
if (time) {
|
|
25
|
+
clearTimeout(time);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}, [isOpen]);
|
|
29
|
+
return (_jsxs("div", { className: "flex flex-1 flex-col gap-1", children: [_jsxs(Popover, { open: isOpen, children: [_jsx(PopoverTrigger, { onClick: () => {
|
|
30
|
+
if (className) {
|
|
31
|
+
navigator.clipboard
|
|
32
|
+
.writeText(className)
|
|
33
|
+
.then(() => {
|
|
34
|
+
console.log("ClassName copied to clipboard");
|
|
35
|
+
})
|
|
36
|
+
.catch((err) => {
|
|
37
|
+
console.error("Failed to copy className: ", err);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
setOpen(true);
|
|
41
|
+
}, children: _jsx("div", { ref: boxRef, className: `${className} h-12 rounded border shadow` }) }), _jsx(PopoverContent, { className: "p-3 w-fit min-w-fit", children: "Copied to clipboard" })] }), _jsxs("div", { className: "text-gray-500 flex flex-col justify-center items-center", children: [_jsx("div", { style: { fontSize: 12, whiteSpace: "pre" }, children: className }), _jsx("div", { style: {
|
|
42
|
+
fontSize: 12,
|
|
43
|
+
textTransform: "uppercase",
|
|
44
|
+
whiteSpace: "pre",
|
|
45
|
+
}, children: hex || "Loading..." })] })] }));
|
|
46
|
+
};
|
|
47
|
+
export const ColorItems = ({ title, subTitle, colors, col = -1, }) => {
|
|
48
|
+
const gridColumnsClass = useMemo(() => {
|
|
49
|
+
if (col !== undefined) {
|
|
50
|
+
switch (col) {
|
|
51
|
+
case 1:
|
|
52
|
+
return "grid grid-cols-1";
|
|
53
|
+
case 2:
|
|
54
|
+
return "grid grid-cols-2";
|
|
55
|
+
case 3:
|
|
56
|
+
return "grid grid-cols-3";
|
|
57
|
+
case 4:
|
|
58
|
+
return "grid grid-cols-4";
|
|
59
|
+
case 5:
|
|
60
|
+
return "grid grid-cols-5";
|
|
61
|
+
case 6:
|
|
62
|
+
return "grid grid-cols-6";
|
|
63
|
+
case 7:
|
|
64
|
+
return "grid grid-cols-7";
|
|
65
|
+
case 8:
|
|
66
|
+
return "grid grid-cols-8";
|
|
67
|
+
case 9:
|
|
68
|
+
return "grid grid-cols-9";
|
|
69
|
+
case 10:
|
|
70
|
+
return "grid grid-cols-10";
|
|
71
|
+
default:
|
|
72
|
+
return colors.length >= 8 ? "grid grid-cols-4" : `flex `;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [col]);
|
|
76
|
+
return (_jsxs("div", { className: "flex flex-wrap flex-col", children: [title && _jsx("div", { style: { fontSize: 16, fontWeight: "600" }, children: title }), subTitle && (_jsx("div", { style: { fontSize: 14, fontWeight: "600" }, children: subTitle })), _jsx("div", { className: ` gap-2 mt-3 ${gridColumnsClass}`, style: { marginTop: 12 }, children: colors.map((color) => (_jsx(ColorBox, { className: color }, color))) })] }));
|
|
77
|
+
};
|
|
@@ -204,6 +204,14 @@ module.exports = {
|
|
|
204
204
|
fontFamily: "var(--small8-family, 'Poppins')",
|
|
205
205
|
},
|
|
206
206
|
],
|
|
207
|
+
small9: [
|
|
208
|
+
"var(--small9-size, 8px)",
|
|
209
|
+
{
|
|
210
|
+
lineHeight: "var(--small9-line-height, 10px)",
|
|
211
|
+
fontWeight: "var(--small9-weight, 400)",
|
|
212
|
+
fontFamily: "var(--small9-family, 'Poppins')",
|
|
213
|
+
},
|
|
214
|
+
],
|
|
207
215
|
label1: [
|
|
208
216
|
"var(--label-label1-size, 12px)",
|
|
209
217
|
{
|
|
@@ -76,9 +76,6 @@ module.exports = {
|
|
|
76
76
|
"function-default-hover-bg": withColorMixin(
|
|
77
77
|
"--function-default-hover-bg"
|
|
78
78
|
),
|
|
79
|
-
"function-default-hover-bg": withColorMixin(
|
|
80
|
-
"--function-default-hover-bg"
|
|
81
|
-
),
|
|
82
79
|
"function-default-stroke": withColorMixin("--function-default-stroke"),
|
|
83
80
|
"function-default-icon": withColorMixin("--function-default-icon"),
|
|
84
81
|
"function-default-outline": withColorMixin(
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const srgbToHex = (color) => {
|
|
2
|
+
if (color.startsWith("color(")) {
|
|
3
|
+
const rgbValues = color.match(/([\d.]+)/g);
|
|
4
|
+
if (rgbValues && rgbValues.length >= 3) {
|
|
5
|
+
const [r, g, b] = rgbValues
|
|
6
|
+
.slice(0, 3)
|
|
7
|
+
.map((x) => Math.round(parseFloat(x) * 255));
|
|
8
|
+
let hex = `#${[r, g, b]
|
|
9
|
+
.map((x) => ("0" + x.toString(16)).slice(-2))
|
|
10
|
+
.join("")}`;
|
|
11
|
+
if (rgbValues.length === 4) {
|
|
12
|
+
const alpha = Math.round(parseFloat(rgbValues[3]) * 255);
|
|
13
|
+
hex += ("0" + alpha.toString(16)).slice(-2);
|
|
14
|
+
}
|
|
15
|
+
return hex;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else if (color.startsWith("#")) {
|
|
19
|
+
return color;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const rgbValues = color.match(/\d+/g);
|
|
23
|
+
if (rgbValues && rgbValues.length >= 3) {
|
|
24
|
+
return `#${rgbValues
|
|
25
|
+
.slice(0, 3)
|
|
26
|
+
.map((x) => ("0" + parseInt(x).toString(16)).slice(-2))
|
|
27
|
+
.join("")}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return color;
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
},
|
|
15
15
|
decorators: [
|
|
16
16
|
(Story) => (
|
|
17
|
-
<div className="p-5 flex w-full">
|
|
17
|
+
<div className="p-5 flex w-full bg-base-bg2">
|
|
18
18
|
<Story />
|
|
19
19
|
</div>
|
|
20
20
|
),
|
|
@@ -45,6 +45,10 @@ const variant: any = [
|
|
|
45
45
|
"small3",
|
|
46
46
|
"small4",
|
|
47
47
|
"small5",
|
|
48
|
+
"small6",
|
|
49
|
+
"small7",
|
|
50
|
+
"small8",
|
|
51
|
+
"small9",
|
|
48
52
|
"label1",
|
|
49
53
|
"label2",
|
|
50
54
|
"buttonL",
|