@nobak/design-system 1.0.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/LICENSE +73 -0
- package/README.md +142 -0
- package/lib/assets/icons.js +67 -0
- package/lib/components/AccountOverview/AccountOverview.js +122 -0
- package/lib/components/AdminPanel.js +58 -0
- package/lib/components/AssetExchange/AssetExchange.js +189 -0
- package/lib/components/AuthenticationFlow.js +216 -0
- package/lib/components/ConversationInterface/ConversationInterface.js +232 -0
- package/lib/components/DevFooter.js +38 -0
- package/lib/components/DevMenu.js +35 -0
- package/lib/components/DevSidebar.js +28 -0
- package/lib/components/DigitalDisplay.js +83 -0
- package/lib/components/Footer.js +45 -0
- package/lib/components/HeroContainer.js +10 -0
- package/lib/components/IntentRecognition/IntentRecognition.js +174 -0
- package/lib/components/Logo.js +259 -0
- package/lib/components/MenuBar.js +56 -0
- package/lib/components/NetworkSettings.js +223 -0
- package/lib/components/RecoverySetup/RecoverySetup.js +354 -0
- package/lib/components/RisingSun.js +122 -0
- package/lib/components/Symbol.js +226 -0
- package/lib/components/TransactionComposer/TransactionComposer.js +258 -0
- package/lib/components/TransactionConfirmation.js +184 -0
- package/lib/components/WalletMenu.js +33 -0
- package/lib/components/console/code/CodeBlock.js +150 -0
- package/lib/components/console/code/index.js +9 -0
- package/lib/components/console/data/DataTable.js +245 -0
- package/lib/components/console/data/MetricCard.js +79 -0
- package/lib/components/console/data/index.js +11 -0
- package/lib/components/console/documentation/index.js +10 -0
- package/lib/components/console/forms/APIKeyGenerator.js +261 -0
- package/lib/components/console/forms/SearchBar.js +210 -0
- package/lib/components/console/forms/index.js +10 -0
- package/lib/components/console/index.js +29 -0
- package/lib/components/console/layout/ConsoleCard.js +82 -0
- package/lib/components/console/layout/ConsoleLayout.js +86 -0
- package/lib/components/console/layout/index.js +10 -0
- package/lib/components/console/monitoring/StatusIndicator.js +128 -0
- package/lib/components/console/monitoring/index.js +9 -0
- package/lib/components/console/navigation/DevFooter.js +38 -0
- package/lib/components/console/navigation/DevMenu.js +35 -0
- package/lib/components/console/navigation/DevSidebar.js +28 -0
- package/lib/components/console/navigation/index.js +11 -0
- package/lib/components/console/settings/index.js +10 -0
- package/lib/components/index.js +12 -0
- package/lib/design/ColorPicker.stories.js +9 -0
- package/lib/design/HSLTool-V1.js +345 -0
- package/lib/design/HSLTool-V2.js +475 -0
- package/lib/design/HSLTool-V3.js +543 -0
- package/lib/design/HSLTool-V4.js +1139 -0
- package/lib/design/HSLTool.js +374 -0
- package/lib/design/OKLCHColorPicker.stories.js +24 -0
- package/lib/design/OKLCHTool.js +1014 -0
- package/lib/index.js +4 -0
- package/lib/shared/components/Avatar/Avatar.js +18 -0
- package/lib/shared/components/Avatar/index.js +1 -0
- package/lib/shared/components/Badge/Badge.js +34 -0
- package/lib/shared/components/Badge/index.js +1 -0
- package/lib/shared/components/Breadcrumb/Breadcrumb.js +13 -0
- package/lib/shared/components/Breadcrumb/index.js +1 -0
- package/lib/shared/components/Button/Button.js +184 -0
- package/lib/shared/components/Button/index.js +1 -0
- package/lib/shared/components/Calendar/Calendar.js +155 -0
- package/lib/shared/components/Calendar/CalendarDay.js +251 -0
- package/lib/shared/components/Calendar/CalendarHeader.js +88 -0
- package/lib/shared/components/Calendar/CalendarMonth.js +106 -0
- package/lib/shared/components/Calendar/CalendarWeek.js +267 -0
- package/lib/shared/components/Calendar/constants.js +73 -0
- package/lib/shared/components/Calendar/index.js +3 -0
- package/lib/shared/components/Calendar/types.d.js +0 -0
- package/lib/shared/components/Cartel/Cartel.js +44 -0
- package/lib/shared/components/Cartel/index.js +1 -0
- package/lib/shared/components/Cell/Cell.js +105 -0
- package/lib/shared/components/Cell/index.js +1 -0
- package/lib/shared/components/Checkbox/Checkbox.js +27 -0
- package/lib/shared/components/Checkbox/index.js +1 -0
- package/lib/shared/components/Clock/Clock.js +6 -0
- package/lib/shared/components/Clock/index.js +1 -0
- package/lib/shared/components/ColorChecker/ColorChecker.js +89 -0
- package/lib/shared/components/ColorChecker/index.js +2 -0
- package/lib/shared/components/ColorChecker/utils.js +159 -0
- package/lib/shared/components/Command/Command.js +95 -0
- package/lib/shared/components/Command/index.js +1 -0
- package/lib/shared/components/Container/Container.js +18 -0
- package/lib/shared/components/Container/index.js +1 -0
- package/lib/shared/components/Cover/Cover.js +17 -0
- package/lib/shared/components/Cover/index.js +1 -0
- package/lib/shared/components/DatePicker/DatePicker.js +52 -0
- package/lib/shared/components/DatePicker/components/Calendar.js +125 -0
- package/lib/shared/components/DatePicker/components/CalendarDay.js +23 -0
- package/lib/shared/components/DatePicker/components/DateWrapper.js +15 -0
- package/lib/shared/components/DatePicker/components/index.js +2 -0
- package/lib/shared/components/DatePicker/index.js +1 -0
- package/lib/shared/components/DateTime/DateTime.js +51 -0
- package/lib/shared/components/DateTime/index.js +1 -0
- package/lib/shared/components/Debug/Debug.js +12 -0
- package/lib/shared/components/Debug/index.js +1 -0
- package/lib/shared/components/Disclosure/Disclosure.js +31 -0
- package/lib/shared/components/Disclosure/index.js +1 -0
- package/lib/shared/components/Dropdown/Dropdown.js +91 -0
- package/lib/shared/components/Dropdown/index.js +1 -0
- package/lib/shared/components/EmptyState/EmptyState.js +40 -0
- package/lib/shared/components/EmptyState/index.js +1 -0
- package/lib/shared/components/Form/Form.js +41 -0
- package/lib/shared/components/Form/components/DynamicForm.js +66 -0
- package/lib/shared/components/Form/components/StepperForm.js +266 -0
- package/lib/shared/components/Form/components/index.js +2 -0
- package/lib/shared/components/Form/context/Form.js +164 -0
- package/lib/shared/components/Form/context/index.js +1 -0
- package/lib/shared/components/Form/index.js +1 -0
- package/lib/shared/components/Form/types.d.js +1 -0
- package/lib/shared/components/Form/utils/index.js +31 -0
- package/lib/shared/components/GroupItems/GroupItems.js +17 -0
- package/lib/shared/components/GroupItems/index.js +1 -0
- package/lib/shared/components/Header/Header.js +26 -0
- package/lib/shared/components/Header/index.js +1 -0
- package/lib/shared/components/Heading/Heading.js +5 -0
- package/lib/shared/components/Heading/index.js +1 -0
- package/lib/shared/components/Icon/Icon.js +28 -0
- package/lib/shared/components/Icon/index.js +1 -0
- package/lib/shared/components/Identicons/Identicons.js +6 -0
- package/lib/shared/components/Identicons/index.d.js +0 -0
- package/lib/shared/components/Identicons/index.js +1 -0
- package/lib/shared/components/Image/Image.js +22 -0
- package/lib/shared/components/Image/index.js +1 -0
- package/lib/shared/components/Input/Input.js +201 -0
- package/lib/shared/components/Input/components/CheckBoxInput.js +81 -0
- package/lib/shared/components/Input/components/DateInput.js +89 -0
- package/lib/shared/components/Input/components/DefaultInput.js +102 -0
- package/lib/shared/components/Input/components/FileReaderInput.js +88 -0
- package/lib/shared/components/Input/components/NumberInput.js +141 -0
- package/lib/shared/components/Input/components/PickerInput.js +122 -0
- package/lib/shared/components/Input/components/RCInput.js +112 -0
- package/lib/shared/components/Input/components/Radiobox/RadioboxBasic.js +56 -0
- package/lib/shared/components/Input/components/Radiobox/RadioboxCard.js +27 -0
- package/lib/shared/components/Input/components/Radiobox/RadioboxFull.js +44 -0
- package/lib/shared/components/Input/components/Radiobox/index.js +3 -0
- package/lib/shared/components/Input/components/RadioboxInput.js +102 -0
- package/lib/shared/components/Input/components/SelectInput.js +70 -0
- package/lib/shared/components/Input/components/TextAreaInput.js +67 -0
- package/lib/shared/components/Input/components/TextInput.js +139 -0
- package/lib/shared/components/Input/components/TimeInput.js +37 -0
- package/lib/shared/components/Input/components/UploadFileInput.js +123 -0
- package/lib/shared/components/Input/components/index.js +13 -0
- package/lib/shared/components/Input/components/types.d.js +0 -0
- package/lib/shared/components/Input/index.js +1 -0
- package/lib/shared/components/Input/types.d.js +0 -0
- package/lib/shared/components/Layout/Layout.js +13 -0
- package/lib/shared/components/Layout/index.js +1 -0
- package/lib/shared/components/List/List.js +30 -0
- package/lib/shared/components/List/index.js +1 -0
- package/lib/shared/components/Loader/Loader.js +27 -0
- package/lib/shared/components/Loader/index.js +1 -0
- package/lib/shared/components/Modal/Modal.js +102 -0
- package/lib/shared/components/Modal/index.js +1 -0
- package/lib/shared/components/Notification/Notification.js +39 -0
- package/lib/shared/components/Notification/index.js +1 -0
- package/lib/shared/components/Person/Person.js +81 -0
- package/lib/shared/components/Person/index.js +1 -0
- package/lib/shared/components/Popover/Popover.js +39 -0
- package/lib/shared/components/Popover/index.js +1 -0
- package/lib/shared/components/QRCode/QRCode.js +329 -0
- package/lib/shared/components/QRCode/index.js +1 -0
- package/lib/shared/components/RadioGroup/RadioGroup.js +35 -0
- package/lib/shared/components/RadioGroup/components/DefaultGroup.js +71 -0
- package/lib/shared/components/RadioGroup/components/VerticalGroup.js +83 -0
- package/lib/shared/components/RadioGroup/components/index.js +2 -0
- package/lib/shared/components/RadioGroup/index.js +1 -0
- package/lib/shared/components/Search/Search.js +12 -0
- package/lib/shared/components/Search/index.js +1 -0
- package/lib/shared/components/Select/Select.js +90 -0
- package/lib/shared/components/Select/index.js +1 -0
- package/lib/shared/components/Sidebar/Sidebar.js +42 -0
- package/lib/shared/components/Sidebar/index.js +1 -0
- package/lib/shared/components/SlideOver/SlideOver.js +81 -0
- package/lib/shared/components/SlideOver/index.js +1 -0
- package/lib/shared/components/Slider/Slider.js +80 -0
- package/lib/shared/components/Slider/index.js +1 -0
- package/lib/shared/components/Stepper/Stepper.js +32 -0
- package/lib/shared/components/Stepper/index.js +1 -0
- package/lib/shared/components/Steps/Steps.js +53 -0
- package/lib/shared/components/Steps/index.js +1 -0
- package/lib/shared/components/Switch/Switch.js +26 -0
- package/lib/shared/components/Switch/index.js +1 -0
- package/lib/shared/components/Tab/Tab.js +59 -0
- package/lib/shared/components/Tab/index.js +1 -0
- package/lib/shared/components/Table/Table.js +47 -0
- package/lib/shared/components/Table/index.js +1 -0
- package/lib/shared/components/Text/Text.js +11 -0
- package/lib/shared/components/Text/index.js +1 -0
- package/lib/shared/components/TextList/TextList.js +15 -0
- package/lib/shared/components/TextList/index.js +1 -0
- package/lib/shared/components/TimePicker/TimePicker.js +161 -0
- package/lib/shared/components/TimePicker/index.js +1 -0
- package/lib/shared/components/Tooltip/Tooltip.js +13 -0
- package/lib/shared/components/Tooltip/index.js +1 -0
- package/lib/shared/components/Uploader/Uploader.js +63 -0
- package/lib/shared/components/Uploader/index.js +1 -0
- package/lib/shared/components/Video/Video.js +20 -0
- package/lib/shared/components/Video/index.js +1 -0
- package/lib/shared/components/index.d.js +0 -0
- package/lib/shared/components/index.js +50 -0
- package/lib/shared/elements/Color/ColorPallet.js +20 -0
- package/lib/shared/elements/Color/index.js +1 -0
- package/lib/shared/elements/Text.js +37 -0
- package/lib/shared/elements/index.js +1 -0
- package/lib/shared/helpers/FakeLink.js +8 -0
- package/lib/shared/helpers/constants.js +359 -0
- package/lib/shared/helpers/index.js +2 -0
- package/lib/shared/helpers/isEqual.js +56 -0
- package/lib/shared/index.d.js +0 -0
- package/lib/shared/index.js +1 -0
- package/lib/shared/stories/components/Avatar.stories.js +17 -0
- package/lib/shared/stories/components/Badge.stories.dev.js +37 -0
- package/lib/shared/stories/components/Button.stories.js +553 -0
- package/lib/shared/stories/components/Calendar.stories.js +62 -0
- package/lib/shared/stories/components/Cartel.stories.js +32 -0
- package/lib/shared/stories/components/Checkbox.stories.js +15 -0
- package/lib/shared/stories/components/ColorChecker.stories.dev.js +16 -0
- package/lib/shared/stories/components/DateTime.stories.js +27 -0
- package/lib/shared/stories/components/Disclosure.stories.js +30 -0
- package/lib/shared/stories/components/Dropdown.stories.js +39 -0
- package/lib/shared/stories/components/Form/Default.stories.js +201 -0
- package/lib/shared/stories/components/Form/DummyForm.stories.js +48 -0
- package/lib/shared/stories/components/Form/DynamicForm.stories.js +155 -0
- package/lib/shared/stories/components/Form/StepperForm.stories.js +138 -0
- package/lib/shared/stories/components/Form/ValidateForm.stories.js +70 -0
- package/lib/shared/stories/components/Form/Validation.stories.js +184 -0
- package/lib/shared/stories/components/GroupItems.stories.js +23 -0
- package/lib/shared/stories/components/Header.stories.js +29 -0
- package/lib/shared/stories/components/Heading.stories.js +27 -0
- package/lib/shared/stories/components/Icon.stories.js +22 -0
- package/lib/shared/stories/components/Image.stories.js +23 -0
- package/lib/shared/stories/components/Input/Checkbox.stories.js +45 -0
- package/lib/shared/stories/components/Input/DatePicker.stories.js +23 -0
- package/lib/shared/stories/components/Input/Defaut.stories.js +24 -0
- package/lib/shared/stories/components/Input/Number.stories.js +24 -0
- package/lib/shared/stories/components/Input/RCI.stories.js +59 -0
- package/lib/shared/stories/components/Input/Radiobox.stories.dev.js +28 -0
- package/lib/shared/stories/components/Input/Select.stories.dev.js +27 -0
- package/lib/shared/stories/components/Input/SelectMultiple.stories.dev.js +510 -0
- package/lib/shared/stories/components/Input/Textarea.stories.js +24 -0
- package/lib/shared/stories/components/List.stories.js +34 -0
- package/lib/shared/stories/components/Loader.stories.js +15 -0
- package/lib/shared/stories/components/Modal.stories.js +50 -0
- package/lib/shared/stories/components/Notification.stories.js +22 -0
- package/lib/shared/stories/components/Person.stories.js +41 -0
- package/lib/shared/stories/components/Picker.stories.js +15 -0
- package/lib/shared/stories/components/Popover.stories.js +36 -0
- package/lib/shared/stories/components/QRCode.stories.js +20 -0
- package/lib/shared/stories/components/RadioGroup.stories.js +56 -0
- package/lib/shared/stories/components/Select.stories.js +50 -0
- package/lib/shared/stories/components/Sidebar.stories.js +35 -0
- package/lib/shared/stories/components/Slider.stories.dev.js +48 -0
- package/lib/shared/stories/components/Stepper/Stepper.stories.js +38 -0
- package/lib/shared/stories/components/Steps.stories.js +15 -0
- package/lib/shared/stories/components/Switch.stories.js +15 -0
- package/lib/shared/stories/components/Tab.stories.js +15 -0
- package/lib/shared/stories/components/Table.stories.js +95 -0
- package/lib/shared/stories/components/TextList.stories.js +23 -0
- package/lib/shared/stories/components/Tooltip.stories.dev.js +40 -0
- package/lib/shared/stories/elements/Color.stories.js +269 -0
- package/lib/shared/stories/elements/Text.stories.js +45 -0
- package/lib/shared/types/index.js +1 -0
- package/lib/stories/Foundation/BrandIdentity.prod.stories.js +510 -0
- package/lib/stories/Foundation/Logo.stories.js +19 -0
- package/lib/stories/Foundation/RisingSun.stories.js +16 -0
- package/lib/stories/Foundation/Shadows.stories.js +601 -0
- package/lib/stories/Foundation/Symbol.stories.js +18 -0
- package/lib/stories/HeroContainer.stories.js +18 -0
- package/lib/styles/accessibilityTokens.js +72 -0
- package/lib/styles/borderWidth.js +10 -0
- package/lib/styles/colors.js +303 -0
- package/lib/styles/elevation.js +240 -0
- package/lib/styles/icons.js +218 -0
- package/lib/styles/index.js +29 -0
- package/lib/styles/motion.js +668 -0
- package/lib/styles/opacity.js +10 -0
- package/lib/styles/radius.js +11 -0
- package/lib/styles/sizing.js +35 -0
- package/lib/styles/space.js +24 -0
- package/lib/styles/theme/darkTheme.js +471 -0
- package/lib/styles/theme/index.js +44 -0
- package/lib/styles/theme/lightTheme.js +480 -0
- package/lib/styles/theme/themeTypes.js +1 -0
- package/lib/styles/theme/themeUtils.js +63 -0
- package/lib/styles/typography-advanced.js +510 -0
- package/lib/styles/typography.js +1419 -0
- package/lib/styles/zIndex.js +19 -0
- package/lib/tokens/borders.js +161 -0
- package/lib/tokens/colors.js +426 -0
- package/lib/tokens/components.js +499 -0
- package/lib/tokens/index.js +84 -0
- package/lib/tokens/lighting.js +384 -0
- package/lib/tokens/motion.js +284 -0
- package/lib/tokens/semantic.js +367 -0
- package/lib/tokens/shadows.js +114 -0
- package/lib/tokens/spacing.js +189 -0
- package/lib/tokens/typography.js +268 -0
- package/package.json +176 -0
- package/styles/generated-tokens.css +677 -0
- package/styles/index.css +2 -0
- package/styles/main.css +610 -0
- package/tailwind.config.js +64 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useState, useRef } from 'react';
|
|
8
|
+
import { rgbToHex } from "../shared/components/ColorChecker/utils";
|
|
9
|
+
|
|
10
|
+
// Helper: Convert HSL to RGB
|
|
11
|
+
function hslToRgb(h, s, l) {
|
|
12
|
+
s /= 100;
|
|
13
|
+
l /= 100;
|
|
14
|
+
var c = (1 - Math.abs(2 * l - 1)) * s;
|
|
15
|
+
var x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
16
|
+
var m = l - c / 2;
|
|
17
|
+
var r = 0,
|
|
18
|
+
g = 0,
|
|
19
|
+
b = 0;
|
|
20
|
+
if (0 <= h && h < 60) {
|
|
21
|
+
r = c;
|
|
22
|
+
g = x;
|
|
23
|
+
b = 0;
|
|
24
|
+
} else if (60 <= h && h < 120) {
|
|
25
|
+
r = x;
|
|
26
|
+
g = c;
|
|
27
|
+
b = 0;
|
|
28
|
+
} else if (120 <= h && h < 180) {
|
|
29
|
+
r = 0;
|
|
30
|
+
g = c;
|
|
31
|
+
b = x;
|
|
32
|
+
} else if (180 <= h && h < 240) {
|
|
33
|
+
r = 0;
|
|
34
|
+
g = x;
|
|
35
|
+
b = c;
|
|
36
|
+
} else if (240 <= h && h < 300) {
|
|
37
|
+
r = x;
|
|
38
|
+
g = 0;
|
|
39
|
+
b = c;
|
|
40
|
+
} else if (300 <= h && h < 360) {
|
|
41
|
+
r = c;
|
|
42
|
+
g = 0;
|
|
43
|
+
b = x;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
r: Math.round((r + m) * 255),
|
|
47
|
+
g: Math.round((g + m) * 255),
|
|
48
|
+
b: Math.round((b + m) * 255)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Helper: Cubic Bezier interpolation
|
|
53
|
+
function cubicBezier(t, p0, c1, c2, p3) {
|
|
54
|
+
var x = Math.pow(1 - t, 3) * p0[0] + 3 * Math.pow(1 - t, 2) * t * c1[0] + 3 * (1 - t) * Math.pow(t, 2) * c2[0] + Math.pow(t, 3) * p3[0];
|
|
55
|
+
var y = Math.pow(1 - t, 3) * p0[1] + 3 * Math.pow(1 - t, 2) * t * c1[1] + 3 * (1 - t) * Math.pow(t, 2) * c2[1] + Math.pow(t, 3) * p3[1];
|
|
56
|
+
return [x, y];
|
|
57
|
+
}
|
|
58
|
+
export var HSLTool = function HSLTool() {
|
|
59
|
+
// User-controlled state
|
|
60
|
+
var _useState = useState(220),
|
|
61
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
+
hue = _useState2[0],
|
|
63
|
+
setHue = _useState2[1];
|
|
64
|
+
var _useState3 = useState(80),
|
|
65
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
66
|
+
sat = _useState4[0],
|
|
67
|
+
setSat = _useState4[1];
|
|
68
|
+
var _useState5 = useState(27),
|
|
69
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
70
|
+
numPoints = _useState6[0],
|
|
71
|
+
setNumPoints = _useState6[1];
|
|
72
|
+
var width = 1200; // spectrum width fixed
|
|
73
|
+
var height = 480; // taller spectrum for better UX
|
|
74
|
+
|
|
75
|
+
// Curve control points (draggable)
|
|
76
|
+
var _useState7 = useState([0, height]),
|
|
77
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
78
|
+
start = _useState8[0],
|
|
79
|
+
setStart = _useState8[1]; // A (P0)
|
|
80
|
+
var _useState9 = useState([width, height]),
|
|
81
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
82
|
+
end = _useState0[0],
|
|
83
|
+
setEnd = _useState0[1]; // C (P3)
|
|
84
|
+
|
|
85
|
+
// NEW: Independent handles for cubic Bezier
|
|
86
|
+
var _useState1 = useState([width * 0.25, 0]),
|
|
87
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
88
|
+
handle1 = _useState10[0],
|
|
89
|
+
setHandle1 = _useState10[1]; // C1 (Near A)
|
|
90
|
+
var _useState11 = useState([width * 0.75, 0]),
|
|
91
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
92
|
+
handle2 = _useState12[0],
|
|
93
|
+
setHandle2 = _useState12[1]; // C2 (Near C)
|
|
94
|
+
|
|
95
|
+
// Drag state
|
|
96
|
+
var dragRef = useRef({
|
|
97
|
+
point: null
|
|
98
|
+
}); // Updated points
|
|
99
|
+
|
|
100
|
+
// Clamp numPoints between 3 and 99
|
|
101
|
+
var n = Math.max(3, Math.min(99, numPoints));
|
|
102
|
+
var points = Array.from({
|
|
103
|
+
length: n
|
|
104
|
+
}, function (_, i) {
|
|
105
|
+
return i / (n - 1);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Gradient background string for spectrum
|
|
109
|
+
var grad = "linear-gradient(to top, hsl(".concat(hue, ",").concat(sat, "%,20%), hsl(").concat(hue, ",").concat(sat, "%,95%))");
|
|
110
|
+
|
|
111
|
+
// Handlers for dragging
|
|
112
|
+
function handleDragStart(point, e) {
|
|
113
|
+
// Updated points
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
dragRef.current.point = point;
|
|
116
|
+
document.body.style.cursor = 'grabbing'; // Use grabbing for any drag
|
|
117
|
+
}
|
|
118
|
+
function handleDrag(e) {
|
|
119
|
+
var _ownerSVGElement;
|
|
120
|
+
if (!dragRef.current.point) return;
|
|
121
|
+
var rect = (_ownerSVGElement = e.target.ownerSVGElement) === null || _ownerSVGElement === void 0 ? void 0 : _ownerSVGElement.getBoundingClientRect();
|
|
122
|
+
if (!rect) return;
|
|
123
|
+
var x = e.clientX - rect.left;
|
|
124
|
+
var y = e.clientY - rect.top;
|
|
125
|
+
// Clamp to bounds, but allow Y to go a bit above the spectrum for full access to lightest colors
|
|
126
|
+
x = Math.max(0, Math.min(width, x));
|
|
127
|
+
y = Math.max(-32, Math.min(height, y)); // allow up to 32px above the spectrum
|
|
128
|
+
if (dragRef.current.point === 'A') setStart([x, y]);
|
|
129
|
+
if (dragRef.current.point === 'C') setEnd([x, y]);
|
|
130
|
+
// NEW: Handle drag for cubic control points
|
|
131
|
+
if (dragRef.current.point === 'HANDLE1') setHandle1([x, y]);
|
|
132
|
+
if (dragRef.current.point === 'HANDLE2') setHandle2([x, y]);
|
|
133
|
+
}
|
|
134
|
+
function handleDragEnd() {
|
|
135
|
+
dragRef.current.point = null;
|
|
136
|
+
document.body.style.cursor = ''; // Reset cursor
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Bezier path string (Updated to Cubic)
|
|
140
|
+
var pathD = "M ".concat(start[0], " ").concat(start[1], " C ").concat(handle1[0], " ").concat(handle1[1], " ").concat(handle2[0], " ").concat(handle2[1], " ").concat(end[0], " ").concat(end[1]);
|
|
141
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
142
|
+
className: "p-4",
|
|
143
|
+
onMouseMove: handleDrag,
|
|
144
|
+
onMouseUp: handleDragEnd,
|
|
145
|
+
onMouseLeave: handleDragEnd
|
|
146
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: "flex justify-center items-center gap-4 mb-4"
|
|
148
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
149
|
+
className: "flex flex-col items-center"
|
|
150
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
151
|
+
className: "text-xs text-gray-600"
|
|
152
|
+
}, "Hue"), /*#__PURE__*/React.createElement("input", {
|
|
153
|
+
type: "range",
|
|
154
|
+
min: "0",
|
|
155
|
+
max: "360",
|
|
156
|
+
value: hue,
|
|
157
|
+
onChange: function onChange(e) {
|
|
158
|
+
return setHue(parseInt(e.target.value));
|
|
159
|
+
},
|
|
160
|
+
className: "w-48"
|
|
161
|
+
}), /*#__PURE__*/React.createElement("span", null, hue, "\xB0")), /*#__PURE__*/React.createElement("label", {
|
|
162
|
+
className: "flex flex-col items-center"
|
|
163
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
164
|
+
className: "text-xs text-gray-600"
|
|
165
|
+
}, "Saturation"), /*#__PURE__*/React.createElement("input", {
|
|
166
|
+
type: "range",
|
|
167
|
+
min: "0",
|
|
168
|
+
max: "100",
|
|
169
|
+
value: sat,
|
|
170
|
+
onChange: function onChange(e) {
|
|
171
|
+
return setSat(parseInt(e.target.value));
|
|
172
|
+
},
|
|
173
|
+
className: "w-48"
|
|
174
|
+
}), /*#__PURE__*/React.createElement("span", null, sat, "%")), /*#__PURE__*/React.createElement("label", {
|
|
175
|
+
className: "flex flex-col items-center"
|
|
176
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
177
|
+
className: "text-xs text-gray-600"
|
|
178
|
+
}, "Points"), /*#__PURE__*/React.createElement("input", {
|
|
179
|
+
type: "number",
|
|
180
|
+
min: "3",
|
|
181
|
+
max: ": ",
|
|
182
|
+
value: numPoints,
|
|
183
|
+
onChange: function onChange(e) {
|
|
184
|
+
return setNumPoints(parseInt(e.target.value));
|
|
185
|
+
},
|
|
186
|
+
className: "w-16 p-1 border rounded"
|
|
187
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
188
|
+
className: "relative mx-auto border border-gray-300 overflow-hidden mb-4",
|
|
189
|
+
style: {
|
|
190
|
+
width: width,
|
|
191
|
+
height: height,
|
|
192
|
+
background: grad
|
|
193
|
+
}
|
|
194
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
195
|
+
width: width,
|
|
196
|
+
height: height,
|
|
197
|
+
viewBox: "0 0 ".concat(width, " ").concat(height),
|
|
198
|
+
style: {
|
|
199
|
+
display: 'block',
|
|
200
|
+
overflow: 'visible'
|
|
201
|
+
}
|
|
202
|
+
}, /*#__PURE__*/React.createElement("line", {
|
|
203
|
+
x1: start[0],
|
|
204
|
+
y1: start[1],
|
|
205
|
+
x2: handle1[0],
|
|
206
|
+
y2: handle1[1],
|
|
207
|
+
stroke: "rgba(0,0,0,0.4)",
|
|
208
|
+
strokeWidth: 1,
|
|
209
|
+
strokeDasharray: "4 2"
|
|
210
|
+
}), /*#__PURE__*/React.createElement("line", {
|
|
211
|
+
x1: end[0],
|
|
212
|
+
y1: end[1],
|
|
213
|
+
x2: handle2[0],
|
|
214
|
+
y2: handle2[1],
|
|
215
|
+
stroke: "rgba(0,0,0,0.4)",
|
|
216
|
+
strokeWidth: 1,
|
|
217
|
+
strokeDasharray: "4 2"
|
|
218
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
219
|
+
d: pathD,
|
|
220
|
+
stroke: "rgba(0,0,0,0.6)",
|
|
221
|
+
strokeWidth: 2,
|
|
222
|
+
fill: "none"
|
|
223
|
+
}), points.map(function (t, i) {
|
|
224
|
+
// Use cubicBezier helper
|
|
225
|
+
var _cubicBezier = cubicBezier(t, start, handle1, handle2, end),
|
|
226
|
+
_cubicBezier2 = _slicedToArray(_cubicBezier, 2),
|
|
227
|
+
px = _cubicBezier2[0],
|
|
228
|
+
py = _cubicBezier2[1];
|
|
229
|
+
var l = (1 - py / height) * 75 + 20; // Lightness calculation remains the same
|
|
230
|
+
var _hslToRgb = hslToRgb(hue, sat, l),
|
|
231
|
+
r = _hslToRgb.r,
|
|
232
|
+
g = _hslToRgb.g,
|
|
233
|
+
b = _hslToRgb.b;
|
|
234
|
+
return /*#__PURE__*/React.createElement("circle", {
|
|
235
|
+
key: i,
|
|
236
|
+
cx: px,
|
|
237
|
+
cy: py,
|
|
238
|
+
r: 4,
|
|
239
|
+
fill: "rgb(".concat(r, ",").concat(g, ",").concat(b, ")"),
|
|
240
|
+
stroke: "rgba(0,0,0,0.5)",
|
|
241
|
+
strokeWidth: 1
|
|
242
|
+
});
|
|
243
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
244
|
+
cx: start[0],
|
|
245
|
+
cy: start[1],
|
|
246
|
+
r: 12,
|
|
247
|
+
fill: "#fff",
|
|
248
|
+
stroke: "#3498db",
|
|
249
|
+
strokeWidth: 3,
|
|
250
|
+
style: {
|
|
251
|
+
cursor: 'grab'
|
|
252
|
+
},
|
|
253
|
+
onMouseDown: function onMouseDown(e) {
|
|
254
|
+
return handleDragStart('A', e);
|
|
255
|
+
}
|
|
256
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
257
|
+
cx: end[0],
|
|
258
|
+
cy: end[1],
|
|
259
|
+
r: 12,
|
|
260
|
+
fill: "#fff",
|
|
261
|
+
stroke: "#e74c3c",
|
|
262
|
+
strokeWidth: 3,
|
|
263
|
+
style: {
|
|
264
|
+
cursor: 'grab'
|
|
265
|
+
},
|
|
266
|
+
onMouseDown: function onMouseDown(e) {
|
|
267
|
+
return handleDragStart('C', e);
|
|
268
|
+
}
|
|
269
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
270
|
+
cx: handle1[0],
|
|
271
|
+
cy: handle1[1],
|
|
272
|
+
r: 9 // Smaller handle size
|
|
273
|
+
,
|
|
274
|
+
fill: "#f9e7c0",
|
|
275
|
+
stroke: "#f39c12",
|
|
276
|
+
strokeWidth: 2,
|
|
277
|
+
style: {
|
|
278
|
+
cursor: 'grab'
|
|
279
|
+
} // Use grab cursor
|
|
280
|
+
,
|
|
281
|
+
onMouseDown: function onMouseDown(e) {
|
|
282
|
+
return handleDragStart('HANDLE1', e);
|
|
283
|
+
}
|
|
284
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
285
|
+
cx: handle2[0],
|
|
286
|
+
cy: handle2[1],
|
|
287
|
+
r: 9 // Smaller handle size
|
|
288
|
+
,
|
|
289
|
+
fill: "#f9e7c0",
|
|
290
|
+
stroke: "#f39c12",
|
|
291
|
+
strokeWidth: 2,
|
|
292
|
+
style: {
|
|
293
|
+
cursor: 'grab'
|
|
294
|
+
} // Use grab cursor
|
|
295
|
+
,
|
|
296
|
+
onMouseDown: function onMouseDown(e) {
|
|
297
|
+
return handleDragStart('HANDLE2', e);
|
|
298
|
+
}
|
|
299
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
300
|
+
className: "flex flex-wrap gap-2 justify-center"
|
|
301
|
+
}, points.map(function (t, i) {
|
|
302
|
+
// Use cubicBezier helper
|
|
303
|
+
var _cubicBezier3 = cubicBezier(t, start, handle1, handle2, end),
|
|
304
|
+
_cubicBezier4 = _slicedToArray(_cubicBezier3, 2),
|
|
305
|
+
px = _cubicBezier4[0],
|
|
306
|
+
py = _cubicBezier4[1];
|
|
307
|
+
var l = (1 - py / height) * 75 + 20;
|
|
308
|
+
var rgb = hslToRgb(hue, sat, l);
|
|
309
|
+
var hex = '#' + rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
310
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
311
|
+
key: i,
|
|
312
|
+
style: {
|
|
313
|
+
display: 'flex',
|
|
314
|
+
flexDirection: 'column',
|
|
315
|
+
alignItems: 'center',
|
|
316
|
+
minWidth: 56
|
|
317
|
+
}
|
|
318
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
319
|
+
style: {
|
|
320
|
+
background: hex,
|
|
321
|
+
width: 32,
|
|
322
|
+
height: 32,
|
|
323
|
+
borderRadius: 16,
|
|
324
|
+
border: '1px solid #eee',
|
|
325
|
+
marginBottom: 4
|
|
326
|
+
}
|
|
327
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
328
|
+
style: {
|
|
329
|
+
fontSize: 12,
|
|
330
|
+
fontFamily: 'monospace'
|
|
331
|
+
}
|
|
332
|
+
}, hex), /*#__PURE__*/React.createElement("span", {
|
|
333
|
+
style: {
|
|
334
|
+
fontSize: 11,
|
|
335
|
+
color: '#666'
|
|
336
|
+
}
|
|
337
|
+
}, "HSL(", hue, ",", sat, "%,", Math.round(l), "%)"));
|
|
338
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
339
|
+
style: {
|
|
340
|
+
marginTop: 24,
|
|
341
|
+
fontSize: 13,
|
|
342
|
+
color: '#555'
|
|
343
|
+
}
|
|
344
|
+
}, /*#__PURE__*/React.createElement("b", null, "How it works:"), " Drag the blue (A) and red (C) handles, or the smaller yellow handles, to reshape the spectrum curve. The points show their HEX and HSL values."));
|
|
345
|
+
};
|