@hellboy/ds 0.1.2 → 0.2.7
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/README.md +568 -71
- package/{src/style/components/badge → dist/components}/badge.css +9 -25
- package/dist/components/badge.d.mts +12 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +42 -0
- package/dist/components/badge.mjs +15 -0
- package/dist/components/banner.css +280 -0
- package/dist/components/banner.d.mts +12 -0
- package/dist/components/banner.d.ts +12 -0
- package/dist/components/banner.js +184 -0
- package/dist/components/banner.mjs +147 -0
- package/dist/components/button-group.css +289 -0
- package/dist/components/button-group.d.mts +81 -0
- package/dist/components/button-group.d.ts +81 -0
- package/dist/components/button-group.js +180 -0
- package/dist/components/button-group.mjs +143 -0
- package/{src/style/components/button → dist/components}/button.css +59 -62
- package/dist/components/button.d.mts +57 -0
- package/dist/components/button.d.ts +57 -0
- package/dist/components/button.js +129 -0
- package/dist/components/button.mjs +92 -0
- package/{src/style/components/card → dist/components}/card.css +9 -30
- package/dist/components/card.d.mts +31 -0
- package/dist/components/card.d.ts +31 -0
- package/dist/components/card.js +59 -0
- package/dist/components/card.mjs +32 -0
- package/{src/style → dist}/components/checkbox.css +51 -43
- package/dist/components/checkbox.d.mts +31 -0
- package/dist/components/checkbox.d.ts +31 -0
- package/dist/components/checkbox.js +130 -0
- package/dist/components/checkbox.mjs +93 -0
- package/{src/style/components/code-block → dist/components}/code-block.css +3 -7
- package/dist/components/code-block.d.mts +24 -0
- package/dist/components/code-block.d.ts +24 -0
- package/dist/components/code-block.js +43 -0
- package/dist/components/code-block.mjs +16 -0
- package/dist/components/color-control.css +285 -0
- package/dist/components/color-control.d.mts +5 -0
- package/dist/components/color-control.d.ts +5 -0
- package/dist/components/color-control.js +534 -0
- package/dist/components/color-control.mjs +497 -0
- package/dist/components/dialog.css +930 -0
- package/dist/components/dialog.d.mts +32 -0
- package/dist/components/dialog.d.ts +32 -0
- package/dist/components/dialog.js +1111 -0
- package/dist/components/dialog.mjs +1074 -0
- package/dist/components/divider.css +356 -0
- package/dist/components/divider.d.mts +32 -0
- package/dist/components/divider.d.ts +32 -0
- package/dist/components/divider.js +344 -0
- package/dist/components/divider.mjs +307 -0
- package/{src/style/components/drag-handle → dist/components}/drag-handle.css +3 -18
- package/dist/components/drag-handle.d.mts +11 -0
- package/dist/components/drag-handle.d.ts +11 -0
- package/dist/components/drag-handle.js +103 -0
- package/dist/components/drag-handle.mjs +66 -0
- package/dist/components/drawer.css +1027 -0
- package/dist/components/drawer.d.mts +14 -0
- package/dist/components/drawer.d.ts +14 -0
- package/dist/components/drawer.js +1072 -0
- package/dist/components/drawer.mjs +1035 -0
- package/dist/components/floating-bar.css +17 -0
- package/dist/components/floating-bar.d.mts +25 -0
- package/dist/components/floating-bar.d.ts +25 -0
- package/dist/components/floating-bar.js +52 -0
- package/dist/components/floating-bar.mjs +25 -0
- package/dist/components/footer.css +40 -0
- package/dist/components/footer.d.mts +8 -0
- package/dist/components/footer.d.ts +8 -0
- package/dist/components/footer.js +44 -0
- package/dist/components/footer.mjs +17 -0
- package/dist/components/grid.css +47 -0
- package/dist/components/grid.d.mts +27 -0
- package/dist/components/grid.d.ts +27 -0
- package/dist/components/grid.js +52 -0
- package/dist/components/grid.mjs +25 -0
- package/dist/components/header.css +1075 -0
- package/dist/components/header.d.mts +35 -0
- package/dist/components/header.d.ts +35 -0
- package/dist/components/header.js +1402 -0
- package/dist/components/header.mjs +1365 -0
- package/dist/components/hero.css +121 -0
- package/dist/components/hero.d.mts +111 -0
- package/dist/components/hero.d.ts +111 -0
- package/dist/components/hero.js +285 -0
- package/dist/components/hero.mjs +248 -0
- package/{src/style/components/icons → dist/components}/icons.css +14 -15
- package/dist/components/icons.d.mts +104 -0
- package/dist/components/icons.d.ts +104 -0
- package/dist/components/icons.js +239 -0
- package/dist/components/icons.mjs +203 -0
- package/{src/style/components/input → dist/components}/input.css +189 -102
- package/dist/components/input.d.mts +114 -0
- package/dist/components/input.d.ts +114 -0
- package/dist/components/input.js +926 -0
- package/dist/components/input.mjs +879 -0
- package/dist/components/layout.css +551 -0
- package/dist/components/layout.d.mts +16 -0
- package/dist/components/layout.d.ts +16 -0
- package/dist/components/layout.js +387 -0
- package/dist/components/layout.mjs +352 -0
- package/{src/style/components/list → dist/components}/list.css +47 -41
- package/dist/components/list.d.mts +46 -0
- package/dist/components/list.d.ts +46 -0
- package/dist/components/list.js +124 -0
- package/dist/components/list.mjs +96 -0
- package/dist/components/navbar.css +706 -0
- package/dist/components/navbar.d.mts +56 -0
- package/dist/components/navbar.d.ts +56 -0
- package/dist/components/navbar.js +994 -0
- package/dist/components/navbar.mjs +952 -0
- package/{src/style/components/page-index → dist/components}/page-index.css +2 -47
- package/dist/components/page-index.d.mts +25 -0
- package/dist/components/page-index.d.ts +25 -0
- package/dist/components/page-index.js +239 -0
- package/dist/components/page-index.mjs +202 -0
- package/{src/style/components/page → dist/components}/page.css +4 -15
- package/dist/components/page.d.mts +30 -0
- package/dist/components/page.d.ts +30 -0
- package/dist/components/page.js +40 -0
- package/dist/components/page.mjs +13 -0
- package/dist/components/popover.css +87 -0
- package/dist/components/popover.d.mts +22 -0
- package/dist/components/popover.d.ts +22 -0
- package/dist/components/popover.js +243 -0
- package/dist/components/popover.mjs +206 -0
- package/{src/style → dist}/components/radio.css +8 -51
- package/dist/components/radio.d.mts +59 -0
- package/dist/components/radio.d.ts +59 -0
- package/dist/components/radio.js +133 -0
- package/dist/components/radio.mjs +95 -0
- package/dist/components/section.css +993 -0
- package/dist/components/section.d.mts +33 -0
- package/dist/components/section.d.ts +33 -0
- package/dist/components/section.js +1401 -0
- package/dist/components/section.mjs +1364 -0
- package/dist/components/select.css +391 -0
- package/dist/components/select.d.mts +63 -0
- package/dist/components/select.d.ts +63 -0
- package/dist/components/select.js +452 -0
- package/dist/components/select.mjs +415 -0
- package/{src/style/components/slider → dist/components}/slider.css +55 -33
- package/dist/components/slider.d.mts +69 -0
- package/dist/components/slider.d.ts +69 -0
- package/dist/components/slider.js +254 -0
- package/dist/components/slider.mjs +217 -0
- package/dist/components/switch.css +1081 -0
- package/dist/components/switch.d.mts +33 -0
- package/dist/components/switch.d.ts +33 -0
- package/dist/components/switch.js +1092 -0
- package/dist/components/switch.mjs +1055 -0
- package/{src/style/components/table → dist/components}/table.css +3 -28
- package/dist/components/table.d.mts +42 -0
- package/dist/components/table.d.ts +42 -0
- package/dist/components/table.js +108 -0
- package/dist/components/table.mjs +76 -0
- package/dist/components/tag.css +97 -0
- package/dist/components/tag.d.mts +12 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +42 -0
- package/dist/components/tag.mjs +15 -0
- package/dist/components/textarea.css +1359 -0
- package/dist/components/textarea.d.mts +84 -0
- package/dist/components/textarea.d.ts +84 -0
- package/dist/components/textarea.js +1962 -0
- package/dist/components/textarea.mjs +1924 -0
- package/{src/style/components/theme-control → dist/components}/theme-control.css +3 -7
- package/dist/components/theme-control.d.mts +9 -0
- package/dist/components/theme-control.d.ts +9 -0
- package/dist/components/theme-control.js +235 -0
- package/dist/components/theme-control.mjs +200 -0
- package/{src/style/components/tooltip → dist/components}/tooltip.css +5 -13
- package/dist/components/tooltip.d.mts +12 -0
- package/dist/components/tooltip.d.ts +12 -0
- package/dist/components/tooltip.js +200 -0
- package/dist/components/tooltip.mjs +163 -0
- package/dist/icons-Czahnf-r.d.mts +15 -0
- package/dist/icons-Czahnf-r.d.ts +15 -0
- package/dist/index.css +2915 -2068
- package/dist/index.d.mts +144 -721
- package/dist/index.d.ts +144 -721
- package/dist/index.js +4076 -2282
- package/dist/index.mjs +4132 -2366
- package/dist/theme.css +34 -34
- package/package.json +27 -8
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/hellboy-ds-0.1.2.tgz +0 -0
- package/src/components/badge/Badge.tsx +0 -29
- package/src/components/badge/index.ts +0 -1
- package/src/components/banner/Banner.tsx +0 -48
- package/src/components/banner/banner.css +0 -44
- package/src/components/banner/index.ts +0 -1
- package/src/components/button/button.tsx +0 -127
- package/src/components/button/index.ts +0 -1
- package/src/components/card/card.tsx +0 -57
- package/src/components/card/index.ts +0 -1
- package/src/components/checkbox/Checkbox.tsx +0 -98
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/code-block/code-block.tsx +0 -44
- package/src/components/code-block/index.ts +0 -1
- package/src/components/color-control/color-control.tsx +0 -322
- package/src/components/color-control/index.ts +0 -1
- package/src/components/drag-handle/DragHandle.tsx +0 -78
- package/src/components/drag-handle/index.ts +0 -1
- package/src/components/drawer/drawer.tsx +0 -82
- package/src/components/drawer/index.ts +0 -1
- package/src/components/floating-bar/floating-bar.tsx +0 -52
- package/src/components/floating-bar/index.ts +0 -2
- package/src/components/footer/footer.tsx +0 -28
- package/src/components/footer/index.ts +0 -1
- package/src/components/grid/Grid.tsx +0 -53
- package/src/components/grid/index.ts +0 -1
- package/src/components/header/header.tsx +0 -57
- package/src/components/header/index.ts +0 -1
- package/src/components/icons/icons.tsx +0 -44
- package/src/components/icons/index.ts +0 -1
- package/src/components/index.ts +0 -29
- package/src/components/input/DatePicker.tsx +0 -133
- package/src/components/input/Input.tsx +0 -220
- package/src/components/input/InputDate.tsx +0 -10
- package/src/components/input/InputDateTime.tsx +0 -10
- package/src/components/input/InputEmail.tsx +0 -10
- package/src/components/input/InputField.tsx +0 -137
- package/src/components/input/InputNumber.tsx +0 -10
- package/src/components/input/InputPassword.tsx +0 -10
- package/src/components/input/InputSearch.tsx +0 -10
- package/src/components/input/InputTel.tsx +0 -10
- package/src/components/input/InputText.tsx +0 -10
- package/src/components/input/InputTime.tsx +0 -10
- package/src/components/input/InputUrl.tsx +0 -10
- package/src/components/input/TimePicker.tsx +0 -151
- package/src/components/input/index.ts +0 -11
- package/src/components/layout/Layout.tsx +0 -244
- package/src/components/layout/index.ts +0 -1
- package/src/components/list/List.tsx +0 -159
- package/src/components/list/index.ts +0 -1
- package/src/components/navbar/MenuCategory.tsx +0 -20
- package/src/components/navbar/MenuGroup.tsx +0 -288
- package/src/components/navbar/MenuItem.tsx +0 -65
- package/src/components/navbar/Navbar.tsx +0 -23
- package/src/components/navbar/index.ts +0 -4
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.tsx +0 -46
- package/src/components/page-index/PageIndex.tsx +0 -275
- package/src/components/page-index/index.ts +0 -1
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.tsx +0 -199
- package/src/components/radio/Radio.tsx +0 -176
- package/src/components/radio/index.ts +0 -1
- package/src/components/section/index.ts +0 -1
- package/src/components/section/section.tsx +0 -66
- package/src/components/select/Select.tsx +0 -212
- package/src/components/select/index.ts +0 -1
- package/src/components/slider/Slider.tsx +0 -267
- package/src/components/slider/index.ts +0 -1
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/switch.tsx +0 -99
- package/src/components/table/Table.tsx +0 -147
- package/src/components/table/index.ts +0 -1
- package/src/components/theme-control/index.ts +0 -1
- package/src/components/theme-control/theme-control.tsx +0 -78
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/tooltip.tsx +0 -207
- package/src/contexts/NavbarTooltipContext.tsx +0 -48
- package/src/contexts/index.ts +0 -1
- package/src/foundations/motion.md +0 -136
- package/src/index.ts +0 -40
- package/src/style/_shared/field.css +0 -69
- package/src/style/components/color-control/color-control.css +0 -126
- package/src/style/components/drawer/drawer.css +0 -210
- package/src/style/components/floating-bar/floating-bar.css +0 -39
- package/src/style/components/footer/footer.css +0 -108
- package/src/style/components/grid/grid.css +0 -33
- package/src/style/components/header/header.css +0 -44
- package/src/style/components/layout/layout.css +0 -205
- package/src/style/components/navbar/navbar.css +0 -342
- package/src/style/components/popover/popover.css +0 -44
- package/src/style/components/section/section.css +0 -67
- package/src/style/components/select/select.css +0 -143
- package/src/style/components/switch/switch.css +0 -267
- package/src/style/foundations/global.css +0 -316
- package/src/style/foundations/motion.css +0 -164
- package/src/style/foundations/spacing.css +0 -51
- package/src/style/foundations/typography.css +0 -39
- package/src/style/foundations/z-index.css +0 -81
- package/src/style/modes/dark.css +0 -146
- package/src/style/modes/light.css +0 -147
- package/src/style/semantic.css +0 -52
- package/src/style/styles.css +0 -51
- package/src/style/themes/theme.json +0 -37
- package/src/utils/README.md +0 -305
- package/src/utils/USER_PREFERENCES.md +0 -558
- package/src/utils/theme.ts +0 -127
- package/src/utils/user-preferences.ts +0 -577
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -52
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
// src/components/color-control/color-control.tsx
|
|
2
|
+
import { useState as useState2, useEffect, useCallback as useCallback2 } from "react";
|
|
3
|
+
|
|
4
|
+
// src/components/slider/Slider.tsx
|
|
5
|
+
import React, { useState, useCallback, useRef } from "react";
|
|
6
|
+
|
|
7
|
+
// src/components/icons/icons.tsx
|
|
8
|
+
import { Icon as IconifyIcon } from "@iconify/react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var Icon = ({ name, size = 24, className, loading = false, ...rest }) => {
|
|
11
|
+
const iconName = name.includes(":") ? name : `heroicons:${name}`;
|
|
12
|
+
const classes = ["icon", className].filter(Boolean).join(" ");
|
|
13
|
+
if (loading) {
|
|
14
|
+
const style = { width: size, height: size };
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
"span",
|
|
17
|
+
{
|
|
18
|
+
className: `${classes} icon--skeleton`,
|
|
19
|
+
style,
|
|
20
|
+
"aria-hidden": rest["aria-label"] ? "false" : "true",
|
|
21
|
+
...rest["aria-label"] ? { "aria-label": rest["aria-label"] } : {}
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
IconifyIcon,
|
|
27
|
+
{
|
|
28
|
+
icon: iconName,
|
|
29
|
+
width: size,
|
|
30
|
+
height: size,
|
|
31
|
+
className: classes,
|
|
32
|
+
...rest
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/components/icons/iconConstants.ts
|
|
38
|
+
var NAVIGATION_ICONS = {
|
|
39
|
+
home: "home-solid",
|
|
40
|
+
dashboard: "squares-2x2-solid",
|
|
41
|
+
profile: "user-solid",
|
|
42
|
+
settings: "cog-solid",
|
|
43
|
+
logout: "arrow-right-on-rectangle-solid",
|
|
44
|
+
login: "arrow-left-on-rectangle-solid",
|
|
45
|
+
notifications: "bell-solid",
|
|
46
|
+
messages: "chat-bubble-left-solid",
|
|
47
|
+
help: "question-mark-circle-solid",
|
|
48
|
+
support: "lifebuoy-solid",
|
|
49
|
+
chevronDown: "chevron-down-solid",
|
|
50
|
+
chevronUp: "chevron-up-solid",
|
|
51
|
+
chevronLeft: "chevron-left-solid",
|
|
52
|
+
chevronRight: "chevron-right-solid"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/components/slider/Slider.tsx
|
|
56
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
57
|
+
var Slider = ({
|
|
58
|
+
min = 0,
|
|
59
|
+
max = 100,
|
|
60
|
+
value,
|
|
61
|
+
step = 1,
|
|
62
|
+
onChange,
|
|
63
|
+
onDragStart,
|
|
64
|
+
onChangeEnd,
|
|
65
|
+
label,
|
|
66
|
+
showValue = true,
|
|
67
|
+
className = "",
|
|
68
|
+
disabled = false,
|
|
69
|
+
type = "default",
|
|
70
|
+
baseHue = 0,
|
|
71
|
+
baseSaturation = 70
|
|
72
|
+
}) => {
|
|
73
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
74
|
+
const inputRef = useRef(null);
|
|
75
|
+
const containerRef = useRef(null);
|
|
76
|
+
const valueRef = useRef(value);
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
valueRef.current = value;
|
|
79
|
+
}, [value]);
|
|
80
|
+
const handleChange = useCallback((event) => {
|
|
81
|
+
const newValue = parseFloat(event.target.value);
|
|
82
|
+
onChange(newValue);
|
|
83
|
+
}, [onChange]);
|
|
84
|
+
const getValueFromPosition = useCallback((clientX) => {
|
|
85
|
+
if (!containerRef.current) return value;
|
|
86
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
87
|
+
const percentage = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
88
|
+
const rawValue = min + percentage * (max - min);
|
|
89
|
+
const steppedValue = Math.round(rawValue / step) * step;
|
|
90
|
+
return Math.max(min, Math.min(max, steppedValue));
|
|
91
|
+
}, [min, max, step, value]);
|
|
92
|
+
const handleMouseDown = useCallback((event) => {
|
|
93
|
+
if (disabled) return;
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
setIsDragging(true);
|
|
96
|
+
onDragStart?.();
|
|
97
|
+
const newValue = getValueFromPosition(event.clientX);
|
|
98
|
+
onChange(newValue);
|
|
99
|
+
}, [disabled, onDragStart, getValueFromPosition, onChange]);
|
|
100
|
+
const handleMouseMove = useCallback((event) => {
|
|
101
|
+
if (!isDragging) return;
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
const newValue = getValueFromPosition(event.clientX);
|
|
104
|
+
onChange(newValue);
|
|
105
|
+
}, [isDragging, getValueFromPosition, onChange]);
|
|
106
|
+
const handleMouseUp = useCallback(() => {
|
|
107
|
+
if (!isDragging) return;
|
|
108
|
+
setIsDragging(false);
|
|
109
|
+
onChangeEnd?.(valueRef.current);
|
|
110
|
+
}, [isDragging, onChangeEnd]);
|
|
111
|
+
React.useEffect(() => {
|
|
112
|
+
if (!isDragging) return;
|
|
113
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
114
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
115
|
+
return () => {
|
|
116
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
117
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
118
|
+
};
|
|
119
|
+
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
120
|
+
const handleTouchStart = useCallback((event) => {
|
|
121
|
+
if (disabled) return;
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
setIsDragging(true);
|
|
124
|
+
onDragStart?.();
|
|
125
|
+
const touch = event.touches[0];
|
|
126
|
+
const newValue = getValueFromPosition(touch.clientX);
|
|
127
|
+
onChange(newValue);
|
|
128
|
+
}, [disabled, onDragStart, getValueFromPosition, onChange]);
|
|
129
|
+
const handleTouchMove = useCallback((event) => {
|
|
130
|
+
if (!isDragging) return;
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
const touch = event.touches[0];
|
|
133
|
+
const newValue = getValueFromPosition(touch.clientX);
|
|
134
|
+
onChange(newValue);
|
|
135
|
+
}, [isDragging, getValueFromPosition, onChange]);
|
|
136
|
+
const handleTouchEnd = useCallback(() => {
|
|
137
|
+
if (!isDragging) return;
|
|
138
|
+
setIsDragging(false);
|
|
139
|
+
onChangeEnd?.(valueRef.current);
|
|
140
|
+
}, [isDragging, onChangeEnd]);
|
|
141
|
+
React.useEffect(() => {
|
|
142
|
+
if (!isDragging) return;
|
|
143
|
+
document.addEventListener("touchmove", handleTouchMove);
|
|
144
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
145
|
+
return () => {
|
|
146
|
+
document.removeEventListener("touchmove", handleTouchMove);
|
|
147
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
148
|
+
};
|
|
149
|
+
}, [isDragging, handleTouchMove, handleTouchEnd]);
|
|
150
|
+
const sliderClasses = [
|
|
151
|
+
"slider",
|
|
152
|
+
`slider--${type}`,
|
|
153
|
+
isDragging && "slider--dragging",
|
|
154
|
+
disabled && "slider--disabled",
|
|
155
|
+
className
|
|
156
|
+
].filter(Boolean).join(" ");
|
|
157
|
+
const getBackground = () => {
|
|
158
|
+
switch (type) {
|
|
159
|
+
case "hue":
|
|
160
|
+
return "linear-gradient(to right, hsl(0, 70%, 50%), hsl(60, 70%, 50%), hsl(120, 70%, 50%), hsl(180, 70%, 50%), hsl(240, 70%, 50%), hsl(300, 70%, 50%), hsl(360, 70%, 50%))";
|
|
161
|
+
case "saturation":
|
|
162
|
+
return `linear-gradient(to right, hsl(${baseHue}, 0%, 50%), hsl(${baseHue}, 100%, 50%))`;
|
|
163
|
+
case "lightness":
|
|
164
|
+
return `linear-gradient(to right, hsl(${baseHue}, ${baseSaturation}%, 0%), hsl(${baseHue}, ${baseSaturation}%, 50%), hsl(${baseHue}, ${baseSaturation}%, 100%))`;
|
|
165
|
+
default:
|
|
166
|
+
return "var(--color-action-primary)";
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const inputStyle = { background: getBackground() };
|
|
170
|
+
const stepMarks = step > 1 ? Array.from({ length: Math.floor((max - min) / step) + 1 }, (_, i) => min + i * step) : [];
|
|
171
|
+
const thumbPosition = (value - min) / (max - min) * 100;
|
|
172
|
+
return /* @__PURE__ */ jsxs("div", { className: sliderClasses, children: [
|
|
173
|
+
(label || showValue) && /* @__PURE__ */ jsxs("div", { className: "slider__header", children: [
|
|
174
|
+
label && /* @__PURE__ */ jsx2("label", { className: "slider__label", children: label }),
|
|
175
|
+
showValue && /* @__PURE__ */ jsx2("span", { className: "slider__value", children: value })
|
|
176
|
+
] }),
|
|
177
|
+
/* @__PURE__ */ jsxs("div", { className: "slider__container", ref: containerRef, onMouseDown: handleMouseDown, onTouchStart: handleTouchStart, children: [
|
|
178
|
+
/* @__PURE__ */ jsx2(
|
|
179
|
+
"input",
|
|
180
|
+
{
|
|
181
|
+
ref: inputRef,
|
|
182
|
+
type: "range",
|
|
183
|
+
min,
|
|
184
|
+
max,
|
|
185
|
+
step,
|
|
186
|
+
value,
|
|
187
|
+
onChange: handleChange,
|
|
188
|
+
className: "slider__input",
|
|
189
|
+
style: inputStyle,
|
|
190
|
+
disabled,
|
|
191
|
+
readOnly: true
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsx2(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
className: "slider__thumb",
|
|
198
|
+
style: {
|
|
199
|
+
left: `${thumbPosition}%`,
|
|
200
|
+
transform: "translateX(-50%)"
|
|
201
|
+
},
|
|
202
|
+
children: /* @__PURE__ */ jsx2("div", { className: "slider__thumb-icon", children: /* @__PURE__ */ jsx2(Icon, { name: NAVIGATION_ICONS.chevronDown, size: 16 }) })
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
stepMarks.length > 0 && /* @__PURE__ */ jsx2("div", { className: "slider__marks", children: stepMarks.map((mark) => /* @__PURE__ */ jsx2(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
className: "slider__mark",
|
|
209
|
+
style: {
|
|
210
|
+
left: `${(mark - min) / (max - min) * 100}%`
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
mark
|
|
214
|
+
)) })
|
|
215
|
+
] })
|
|
216
|
+
] });
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/components/color-control/color-control.tsx
|
|
220
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
221
|
+
var getCSSVariable = (variable) => {
|
|
222
|
+
if (typeof window === "undefined") return 0;
|
|
223
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
|
|
224
|
+
return value ? parseInt(value, 10) : 0;
|
|
225
|
+
};
|
|
226
|
+
var loadColorsFromCSS = () => {
|
|
227
|
+
return {
|
|
228
|
+
hues: {
|
|
229
|
+
primary: getCSSVariable("--primary-hue"),
|
|
230
|
+
secondary: getCSSVariable("--secondary-hue"),
|
|
231
|
+
accent: getCSSVariable("--accent-hue"),
|
|
232
|
+
success: getCSSVariable("--success-hue"),
|
|
233
|
+
warning: getCSSVariable("--warning-hue"),
|
|
234
|
+
error: getCSSVariable("--error-hue"),
|
|
235
|
+
info: getCSSVariable("--info-hue")
|
|
236
|
+
},
|
|
237
|
+
saturations: {
|
|
238
|
+
primary: getCSSVariable("--primary-saturation"),
|
|
239
|
+
secondary: getCSSVariable("--secondary-saturation"),
|
|
240
|
+
accent: getCSSVariable("--accent-saturation"),
|
|
241
|
+
success: getCSSVariable("--success-saturation"),
|
|
242
|
+
warning: getCSSVariable("--warning-saturation"),
|
|
243
|
+
error: getCSSVariable("--error-saturation"),
|
|
244
|
+
info: getCSSVariable("--info-saturation")
|
|
245
|
+
},
|
|
246
|
+
lightnesses: {
|
|
247
|
+
primary: getCSSVariable("--primary-lightness"),
|
|
248
|
+
secondary: getCSSVariable("--secondary-lightness"),
|
|
249
|
+
accent: getCSSVariable("--accent-lightness"),
|
|
250
|
+
success: getCSSVariable("--success-lightness"),
|
|
251
|
+
warning: getCSSVariable("--warning-lightness"),
|
|
252
|
+
error: getCSSVariable("--error-lightness"),
|
|
253
|
+
info: getCSSVariable("--info-lightness")
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
var ColorControl = () => {
|
|
258
|
+
const [colors, setColors] = useState2(() => {
|
|
259
|
+
const saved = localStorage.getItem("color-config");
|
|
260
|
+
return saved ? JSON.parse(saved) : loadColorsFromCSS();
|
|
261
|
+
});
|
|
262
|
+
const [pendingColors, setPendingColors] = useState2(colors);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
const root = document.documentElement;
|
|
265
|
+
root.style.setProperty("--hue-primary", colors.hues.primary.toString());
|
|
266
|
+
root.style.setProperty("--hue-secondary", colors.hues.secondary.toString());
|
|
267
|
+
root.style.setProperty("--hue-accent", colors.hues.accent.toString());
|
|
268
|
+
root.style.setProperty("--hue-success", colors.hues.success.toString());
|
|
269
|
+
root.style.setProperty("--hue-warning", colors.hues.warning.toString());
|
|
270
|
+
root.style.setProperty("--hue-error", colors.hues.error.toString());
|
|
271
|
+
root.style.setProperty("--hue-info", colors.hues.info.toString());
|
|
272
|
+
root.style.setProperty("--saturation-primary", `${colors.saturations.primary}%`);
|
|
273
|
+
root.style.setProperty("--saturation-secondary", `${colors.saturations.secondary}%`);
|
|
274
|
+
root.style.setProperty("--saturation-accent", `${colors.saturations.accent}%`);
|
|
275
|
+
root.style.setProperty("--saturation-success", `${colors.saturations.success}%`);
|
|
276
|
+
root.style.setProperty("--saturation-warning", `${colors.saturations.warning}%`);
|
|
277
|
+
root.style.setProperty("--saturation-error", `${colors.saturations.error}%`);
|
|
278
|
+
root.style.setProperty("--saturation-info", `${colors.saturations.info}%`);
|
|
279
|
+
root.style.setProperty("--lightness-primary", `${colors.lightnesses.primary}%`);
|
|
280
|
+
root.style.setProperty("--lightness-secondary", `${colors.lightnesses.secondary}%`);
|
|
281
|
+
root.style.setProperty("--lightness-accent", `${colors.lightnesses.accent}%`);
|
|
282
|
+
root.style.setProperty("--lightness-success", `${colors.lightnesses.success}%`);
|
|
283
|
+
root.style.setProperty("--lightness-warning", `${colors.lightnesses.warning}%`);
|
|
284
|
+
root.style.setProperty("--lightness-error", `${colors.lightnesses.error}%`);
|
|
285
|
+
root.style.setProperty("--lightness-info", `${colors.lightnesses.info}%`);
|
|
286
|
+
}, []);
|
|
287
|
+
const commitColorChange = useCallback2((color, property, value) => {
|
|
288
|
+
setColors((prev) => {
|
|
289
|
+
const newColors = {
|
|
290
|
+
...prev,
|
|
291
|
+
[property === "hue" ? "hues" : property === "saturation" ? "saturations" : "lightnesses"]: {
|
|
292
|
+
...prev[property === "hue" ? "hues" : property === "saturation" ? "saturations" : "lightnesses"],
|
|
293
|
+
[color]: value
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const root = document.documentElement;
|
|
297
|
+
const cssVar = property === "hue" ? `--hue-${color}` : `--${property}-${color}`;
|
|
298
|
+
const cssValue = property === "hue" ? value.toString() : `${value}%`;
|
|
299
|
+
root.style.setProperty(cssVar, cssValue);
|
|
300
|
+
localStorage.setItem("color-config", JSON.stringify(newColors));
|
|
301
|
+
return newColors;
|
|
302
|
+
});
|
|
303
|
+
}, []);
|
|
304
|
+
const resetToDefaults = useCallback2(() => {
|
|
305
|
+
const cssColors = loadColorsFromCSS();
|
|
306
|
+
setColors(cssColors);
|
|
307
|
+
setPendingColors(cssColors);
|
|
308
|
+
}, []);
|
|
309
|
+
const renderColorControls = (colorName) => {
|
|
310
|
+
const hue = pendingColors.hues[colorName];
|
|
311
|
+
const saturation = pendingColors.saturations[colorName];
|
|
312
|
+
const lightness = pendingColors.lightnesses[colorName];
|
|
313
|
+
return /* @__PURE__ */ jsxs2("div", { className: "color-control__color-group", children: [
|
|
314
|
+
/* @__PURE__ */ jsx3("h4", { className: "color-control__color-title", children: colorName.charAt(0).toUpperCase() + colorName.slice(1) }),
|
|
315
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__controls-row", children: [
|
|
316
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__control", children: [
|
|
317
|
+
/* @__PURE__ */ jsx3("label", { className: "color-control__label", children: "Hue" }),
|
|
318
|
+
/* @__PURE__ */ jsx3(
|
|
319
|
+
Slider,
|
|
320
|
+
{
|
|
321
|
+
label: "",
|
|
322
|
+
value: hue,
|
|
323
|
+
min: 0,
|
|
324
|
+
max: 360,
|
|
325
|
+
step: 1,
|
|
326
|
+
onChange: (v) => setPendingColors((prev) => ({
|
|
327
|
+
...prev,
|
|
328
|
+
hues: { ...prev.hues, [colorName]: v }
|
|
329
|
+
})),
|
|
330
|
+
onChangeEnd: (v) => {
|
|
331
|
+
setPendingColors((prev) => ({
|
|
332
|
+
...prev,
|
|
333
|
+
hues: { ...prev.hues, [colorName]: v }
|
|
334
|
+
}));
|
|
335
|
+
commitColorChange(colorName, "hue", v);
|
|
336
|
+
},
|
|
337
|
+
type: "hue",
|
|
338
|
+
showValue: false
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] }),
|
|
342
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__control", children: [
|
|
343
|
+
/* @__PURE__ */ jsx3("label", { className: "color-control__label", children: "Saturation" }),
|
|
344
|
+
/* @__PURE__ */ jsx3(
|
|
345
|
+
Slider,
|
|
346
|
+
{
|
|
347
|
+
label: "",
|
|
348
|
+
value: saturation,
|
|
349
|
+
min: 0,
|
|
350
|
+
max: 100,
|
|
351
|
+
step: 1,
|
|
352
|
+
onChange: (v) => setPendingColors((prev) => ({
|
|
353
|
+
...prev,
|
|
354
|
+
saturations: { ...prev.saturations, [colorName]: v }
|
|
355
|
+
})),
|
|
356
|
+
onChangeEnd: (v) => {
|
|
357
|
+
setPendingColors((prev) => ({
|
|
358
|
+
...prev,
|
|
359
|
+
saturations: { ...prev.saturations, [colorName]: v }
|
|
360
|
+
}));
|
|
361
|
+
commitColorChange(colorName, "saturation", v);
|
|
362
|
+
},
|
|
363
|
+
type: "saturation",
|
|
364
|
+
baseHue: hue,
|
|
365
|
+
showValue: false
|
|
366
|
+
}
|
|
367
|
+
)
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__control", children: [
|
|
370
|
+
/* @__PURE__ */ jsx3("label", { className: "color-control__label", children: "Lightness" }),
|
|
371
|
+
/* @__PURE__ */ jsx3(
|
|
372
|
+
Slider,
|
|
373
|
+
{
|
|
374
|
+
label: "",
|
|
375
|
+
value: lightness,
|
|
376
|
+
min: 0,
|
|
377
|
+
max: 100,
|
|
378
|
+
step: 1,
|
|
379
|
+
onChange: (v) => setPendingColors((prev) => ({
|
|
380
|
+
...prev,
|
|
381
|
+
lightnesses: { ...prev.lightnesses, [colorName]: v }
|
|
382
|
+
})),
|
|
383
|
+
onChangeEnd: (v) => {
|
|
384
|
+
setPendingColors((prev) => ({
|
|
385
|
+
...prev,
|
|
386
|
+
lightnesses: { ...prev.lightnesses, [colorName]: v }
|
|
387
|
+
}));
|
|
388
|
+
commitColorChange(colorName, "lightness", v);
|
|
389
|
+
},
|
|
390
|
+
type: "lightness",
|
|
391
|
+
baseHue: hue,
|
|
392
|
+
baseSaturation: saturation,
|
|
393
|
+
showValue: false
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ jsx3(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
className: "color-control__preview",
|
|
401
|
+
style: {
|
|
402
|
+
backgroundColor: `hsl(${hue}, ${saturation}%, ${lightness}%)`,
|
|
403
|
+
border: "2px solid var(--color-neutral-300)"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
] })
|
|
408
|
+
] }, colorName);
|
|
409
|
+
};
|
|
410
|
+
return /* @__PURE__ */ jsxs2("div", { className: "color-control", children: [
|
|
411
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__header", children: [
|
|
412
|
+
/* @__PURE__ */ jsx3("h3", { className: "color-control__title", children: "Paleta de Cores" }),
|
|
413
|
+
/* @__PURE__ */ jsx3("p", { className: "color-control__description", children: "Ajuste o matiz, satura\xE7\xE3o e luminosidade das cores. As mudan\xE7as s\xE3o aplicadas instantaneamente." })
|
|
414
|
+
] }),
|
|
415
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__sliders", children: [
|
|
416
|
+
renderColorControls("primary"),
|
|
417
|
+
renderColorControls("secondary"),
|
|
418
|
+
renderColorControls("accent"),
|
|
419
|
+
renderColorControls("success"),
|
|
420
|
+
renderColorControls("warning"),
|
|
421
|
+
renderColorControls("error"),
|
|
422
|
+
renderColorControls("info")
|
|
423
|
+
] }),
|
|
424
|
+
/* @__PURE__ */ jsx3("div", { className: "color-control__actions", children: /* @__PURE__ */ jsx3(
|
|
425
|
+
"button",
|
|
426
|
+
{
|
|
427
|
+
onClick: resetToDefaults,
|
|
428
|
+
className: "color-control__reset-btn",
|
|
429
|
+
children: "Restaurar Padr\xF5es"
|
|
430
|
+
}
|
|
431
|
+
) }),
|
|
432
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__preview-section", children: [
|
|
433
|
+
/* @__PURE__ */ jsx3("h4", { className: "color-control__preview-title", children: "Pr\xE9via das Cores" }),
|
|
434
|
+
/* @__PURE__ */ jsxs2("div", { className: "color-control__color-grid", children: [
|
|
435
|
+
/* @__PURE__ */ jsx3(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
className: "color-control__color-sample",
|
|
439
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.primary}, ${pendingColors.saturations.primary}%, ${pendingColors.lightnesses.primary}%)` },
|
|
440
|
+
children: "Primary"
|
|
441
|
+
}
|
|
442
|
+
),
|
|
443
|
+
/* @__PURE__ */ jsx3(
|
|
444
|
+
"div",
|
|
445
|
+
{
|
|
446
|
+
className: "color-control__color-sample",
|
|
447
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.secondary}, ${pendingColors.saturations.secondary}%, ${pendingColors.lightnesses.secondary}%)` },
|
|
448
|
+
children: "Secondary"
|
|
449
|
+
}
|
|
450
|
+
),
|
|
451
|
+
/* @__PURE__ */ jsx3(
|
|
452
|
+
"div",
|
|
453
|
+
{
|
|
454
|
+
className: "color-control__color-sample",
|
|
455
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.accent}, ${pendingColors.saturations.accent}%, ${pendingColors.lightnesses.accent}%)` },
|
|
456
|
+
children: "Accent"
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
/* @__PURE__ */ jsx3(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
className: "color-control__color-sample",
|
|
463
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.success}, ${pendingColors.saturations.success}%, ${pendingColors.lightnesses.success}%)` },
|
|
464
|
+
children: "Success"
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
/* @__PURE__ */ jsx3(
|
|
468
|
+
"div",
|
|
469
|
+
{
|
|
470
|
+
className: "color-control__color-sample",
|
|
471
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.warning}, ${pendingColors.saturations.warning}%, ${pendingColors.lightnesses.warning}%)` },
|
|
472
|
+
children: "Warning"
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
/* @__PURE__ */ jsx3(
|
|
476
|
+
"div",
|
|
477
|
+
{
|
|
478
|
+
className: "color-control__color-sample",
|
|
479
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.error}, ${pendingColors.saturations.error}%, ${pendingColors.lightnesses.error}%)` },
|
|
480
|
+
children: "Error"
|
|
481
|
+
}
|
|
482
|
+
),
|
|
483
|
+
/* @__PURE__ */ jsx3(
|
|
484
|
+
"div",
|
|
485
|
+
{
|
|
486
|
+
className: "color-control__color-sample",
|
|
487
|
+
style: { backgroundColor: `hsl(${pendingColors.hues.info}, ${pendingColors.saturations.info}%, ${pendingColors.lightnesses.info}%)` },
|
|
488
|
+
children: "Info"
|
|
489
|
+
}
|
|
490
|
+
)
|
|
491
|
+
] })
|
|
492
|
+
] })
|
|
493
|
+
] });
|
|
494
|
+
};
|
|
495
|
+
export {
|
|
496
|
+
ColorControl
|
|
497
|
+
};
|