@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,374 @@
|
|
|
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, useEffect, useMemo, useCallback } from 'react';
|
|
8
|
+
|
|
9
|
+
// --- START: Local Helper Functions ---
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Converts an HSL color value to Hex. Conversion formula
|
|
13
|
+
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
14
|
+
* Assumes h, s, and l are contained in the set [0, 360], [0, 100], [0, 100] respectively.
|
|
15
|
+
*
|
|
16
|
+
* @param {number} h The hue
|
|
17
|
+
* @param {number} s The saturation
|
|
18
|
+
* @param {number} l The lightness
|
|
19
|
+
* @return {string} The HEX color representation
|
|
20
|
+
*/
|
|
21
|
+
function hslToHex(h, s, l) {
|
|
22
|
+
s /= 100;
|
|
23
|
+
l /= 100;
|
|
24
|
+
var c = (1 - Math.abs(2 * l - 1)) * s;
|
|
25
|
+
var x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
26
|
+
var m = l - c / 2;
|
|
27
|
+
var r = 0,
|
|
28
|
+
g = 0,
|
|
29
|
+
b = 0;
|
|
30
|
+
if (0 <= h && h < 60) {
|
|
31
|
+
r = c;
|
|
32
|
+
g = x;
|
|
33
|
+
b = 0;
|
|
34
|
+
} else if (60 <= h && h < 120) {
|
|
35
|
+
r = x;
|
|
36
|
+
g = c;
|
|
37
|
+
b = 0;
|
|
38
|
+
} else if (120 <= h && h < 180) {
|
|
39
|
+
r = 0;
|
|
40
|
+
g = c;
|
|
41
|
+
b = x;
|
|
42
|
+
} else if (180 <= h && h < 240) {
|
|
43
|
+
r = 0;
|
|
44
|
+
g = x;
|
|
45
|
+
b = c;
|
|
46
|
+
} else if (240 <= h && h < 300) {
|
|
47
|
+
r = x;
|
|
48
|
+
g = 0;
|
|
49
|
+
b = c;
|
|
50
|
+
} else if (300 <= h && h < 360) {
|
|
51
|
+
r = c;
|
|
52
|
+
g = 0;
|
|
53
|
+
b = x;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Having calculated RGB, convert channels to hex
|
|
57
|
+
r = Math.round((r + m) * 255);
|
|
58
|
+
g = Math.round((g + m) * 255);
|
|
59
|
+
b = Math.round((b + m) * 255);
|
|
60
|
+
var toHex = function toHex(val) {
|
|
61
|
+
var hex = val.toString(16);
|
|
62
|
+
return hex.length === 1 ? '0' + hex : hex;
|
|
63
|
+
};
|
|
64
|
+
return "".concat(toHex(r)).concat(toHex(g)).concat(toHex(b));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Parses an HSL color string like 'hsl(240, 100%, 50%)'.
|
|
69
|
+
* @param hslString The HSL color string.
|
|
70
|
+
* @returns An object with h, s, l properties, or defaults if parsing fails.
|
|
71
|
+
*/
|
|
72
|
+
function parseHslString(hslString) {
|
|
73
|
+
var regex = /hsl\(\s*(\d+)\s*,\s*(\d+)%?\s*,\s*(\d+)%?\s*\)/i;
|
|
74
|
+
var match = hslString.match(regex);
|
|
75
|
+
if (match) {
|
|
76
|
+
return {
|
|
77
|
+
h: parseInt(match[1], 10),
|
|
78
|
+
s: parseInt(match[2], 10),
|
|
79
|
+
l: parseInt(match[3], 10)
|
|
80
|
+
};
|
|
81
|
+
} else {
|
|
82
|
+
// Return default values if parsing fails
|
|
83
|
+
console.warn("Failed to parse HSL string: \"".concat(hslString, "\". Using defaults."));
|
|
84
|
+
return {
|
|
85
|
+
h: 0,
|
|
86
|
+
s: 0,
|
|
87
|
+
l: 50
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// --- END: Local Helper Functions ---
|
|
93
|
+
|
|
94
|
+
export var HSLTool = function HSLTool(_ref) {
|
|
95
|
+
var _ref$initialColor = _ref.initialColor,
|
|
96
|
+
initialColor = _ref$initialColor === void 0 ? 'hsl(210, 100%, 50%)' : _ref$initialColor,
|
|
97
|
+
_ref$width = _ref.width,
|
|
98
|
+
width = _ref$width === void 0 ? 500 : _ref$width,
|
|
99
|
+
_ref$height = _ref.height,
|
|
100
|
+
height = _ref$height === void 0 ? 250 : _ref$height,
|
|
101
|
+
_ref$totalPoints = _ref.totalPoints,
|
|
102
|
+
totalPoints = _ref$totalPoints === void 0 ? 27 : _ref$totalPoints;
|
|
103
|
+
var svgPadding = 20;
|
|
104
|
+
var svgWidth = width;
|
|
105
|
+
var svgHeight = height;
|
|
106
|
+
var graphWidth = svgWidth - 2 * svgPadding;
|
|
107
|
+
var graphHeight = svgHeight - 2 * svgPadding;
|
|
108
|
+
var initialHsl = useMemo(function () {
|
|
109
|
+
return parseHslString(initialColor);
|
|
110
|
+
}, [initialColor]);
|
|
111
|
+
var _useState = useState(initialHsl.h),
|
|
112
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
113
|
+
hue = _useState2[0],
|
|
114
|
+
setHue = _useState2[1];
|
|
115
|
+
var _useState3 = useState(initialHsl.s),
|
|
116
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
117
|
+
saturation = _useState4[0],
|
|
118
|
+
setSaturation = _useState4[1];
|
|
119
|
+
// Point A: Bottom-left, interactive vertically (controls start lightness?)
|
|
120
|
+
var _useState5 = useState({
|
|
121
|
+
x: svgPadding,
|
|
122
|
+
y: svgHeight - svgPadding
|
|
123
|
+
}),
|
|
124
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
125
|
+
pointA = _useState6[0],
|
|
126
|
+
setPointA = _useState6[1];
|
|
127
|
+
// Point C: Fixed Top-right
|
|
128
|
+
var pointC = useMemo(function () {
|
|
129
|
+
return {
|
|
130
|
+
x: svgWidth - svgPadding,
|
|
131
|
+
y: svgPadding
|
|
132
|
+
};
|
|
133
|
+
}, [svgWidth, svgPadding]);
|
|
134
|
+
var _useState7 = useState(null),
|
|
135
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
136
|
+
draggingPoint = _useState8[0],
|
|
137
|
+
setDraggingPoint = _useState8[1];
|
|
138
|
+
var _useState9 = useState(null),
|
|
139
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
140
|
+
copiedHex = _useState0[0],
|
|
141
|
+
setCopiedHex = _useState0[1];
|
|
142
|
+
|
|
143
|
+
// Function to get point on the line segment AC
|
|
144
|
+
var getPointOnLine = useCallback(function (t, p1, p2) {
|
|
145
|
+
var x = p1.x + t * (p2.x - p1.x);
|
|
146
|
+
var y = p1.y + t * (p2.y - p1.y);
|
|
147
|
+
return {
|
|
148
|
+
x: x,
|
|
149
|
+
y: y
|
|
150
|
+
};
|
|
151
|
+
}, []);
|
|
152
|
+
var handleMouseDown = function handleMouseDown(pointName) {
|
|
153
|
+
return function (event) {
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
setDraggingPoint(pointName);
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
var handleMouseMove = useCallback(function (event) {
|
|
159
|
+
var _closest;
|
|
160
|
+
if (!draggingPoint) return;
|
|
161
|
+
var svgRect = (_closest = event.target.closest('svg')) === null || _closest === void 0 ? void 0 : _closest.getBoundingClientRect();
|
|
162
|
+
if (!svgRect) return;
|
|
163
|
+
var x = event.clientX - svgRect.left;
|
|
164
|
+
var y = event.clientY - svgRect.top;
|
|
165
|
+
|
|
166
|
+
// Clamp position within SVG bounds (considering padding)
|
|
167
|
+
x = Math.max(svgPadding, Math.min(x, svgWidth - svgPadding));
|
|
168
|
+
y = Math.max(svgPadding, Math.min(y, svgHeight - svgPadding));
|
|
169
|
+
if (draggingPoint === 'A') {
|
|
170
|
+
// Allow A to move freely for now, or restrict axis if needed
|
|
171
|
+
// For now, keep its x fixed to the left edge
|
|
172
|
+
setPointA({
|
|
173
|
+
x: svgPadding,
|
|
174
|
+
y: y
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}, [draggingPoint, svgWidth, svgHeight, svgPadding]);
|
|
178
|
+
var handleMouseUp = useCallback(function () {
|
|
179
|
+
setDraggingPoint(null);
|
|
180
|
+
}, []);
|
|
181
|
+
useEffect(function () {
|
|
182
|
+
if (draggingPoint) {
|
|
183
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
184
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
185
|
+
} else {
|
|
186
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
187
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
188
|
+
}
|
|
189
|
+
return function () {
|
|
190
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
191
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
192
|
+
};
|
|
193
|
+
}, [draggingPoint, handleMouseMove, handleMouseUp]);
|
|
194
|
+
|
|
195
|
+
// Calculate the path string for the line AC
|
|
196
|
+
var pathData = useMemo(function () {
|
|
197
|
+
// Simple straight line from A to C
|
|
198
|
+
return "M ".concat(pointA.x, " ").concat(pointA.y, " L ").concat(pointC.x, " ").concat(pointC.y);
|
|
199
|
+
// If a curve is still desired, a quadratic Bezier might be:
|
|
200
|
+
// const controlX = (pointA.x + pointC.x) / 2; // Example control point
|
|
201
|
+
// const controlY = pointA.y; // Keep control vertically aligned with A?
|
|
202
|
+
// return `M ${pointA.x} ${pointA.y} Q ${controlX} ${controlY}, ${pointC.x} ${pointC.y}`;
|
|
203
|
+
}, [pointA, pointC]);
|
|
204
|
+
var colorSwatches = useMemo(function () {
|
|
205
|
+
var swatches = [];
|
|
206
|
+
var minLightness = 5; // Darkest color on the right
|
|
207
|
+
var maxLightness = 95; // Lightest color on the left
|
|
208
|
+
// Lightness range based on vertical position of A?
|
|
209
|
+
// Or fixed range like 5-95?
|
|
210
|
+
// Let's use fixed range for now, influenced by the path's t
|
|
211
|
+
// const startL = ((svgHeight - svgPadding - pointA.y) / graphHeight) * 100;
|
|
212
|
+
// Let's map t (0 to 1) directly to lightness (maxLightness to minLightness)
|
|
213
|
+
|
|
214
|
+
for (var i = 0; i < totalPoints; i++) {
|
|
215
|
+
var t = i / (totalPoints - 1);
|
|
216
|
+
var point = getPointOnLine(t, pointA, pointC);
|
|
217
|
+
|
|
218
|
+
// Calculate lightness based on horizontal position (t)
|
|
219
|
+
var l = maxLightness - t * (maxLightness - minLightness);
|
|
220
|
+
var hslString = "hsl(".concat(hue, ", ").concat(saturation, "%, ").concat(l.toFixed(1), "%)");
|
|
221
|
+
var hex = hslToHex(hue, saturation, l);
|
|
222
|
+
swatches.push({
|
|
223
|
+
t: t,
|
|
224
|
+
hex: hex,
|
|
225
|
+
l: l,
|
|
226
|
+
point: point
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return swatches;
|
|
230
|
+
}, [totalPoints, pointA, pointC, hue, saturation, getPointOnLine, svgHeight, svgPadding, graphHeight]);
|
|
231
|
+
var handleCopyHex = function handleCopyHex(hex) {
|
|
232
|
+
navigator.clipboard.writeText("#".concat(hex));
|
|
233
|
+
setCopiedHex(hex);
|
|
234
|
+
setTimeout(function () {
|
|
235
|
+
return setCopiedHex(null);
|
|
236
|
+
}, 1500); // Reset after 1.5 seconds
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// Calculate gradient stops based on H/S and min/max Lightness
|
|
240
|
+
var gradientColorStart = "hsl(".concat(hue, ", ").concat(saturation, "%, ", 95, "%)"); // L=95% on left
|
|
241
|
+
var gradientColorEnd = "hsl(".concat(hue, ", ").concat(saturation, "%, ", 5, "%)"); // L=5% on right
|
|
242
|
+
|
|
243
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
className: "p-4 bg-gray-100 rounded-lg shadow-md flex flex-col items-center"
|
|
245
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
246
|
+
className: "flex gap-4 mb-4 w-full max-w-md"
|
|
247
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
248
|
+
className: "flex-1"
|
|
249
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
250
|
+
htmlFor: "hue",
|
|
251
|
+
className: "block text-sm font-medium text-gray-700"
|
|
252
|
+
}, "Hue: ", hue.toFixed(0)), /*#__PURE__*/React.createElement("input", {
|
|
253
|
+
type: "range",
|
|
254
|
+
id: "hue",
|
|
255
|
+
min: "0",
|
|
256
|
+
max: "360",
|
|
257
|
+
value: hue,
|
|
258
|
+
onChange: function onChange(e) {
|
|
259
|
+
return setHue(parseFloat(e.target.value));
|
|
260
|
+
},
|
|
261
|
+
className: "w-full h-2 bg-gradient-to-r from-red-500 via-lime-500 to-blue-500 rounded-lg appearance-none cursor-pointer"
|
|
262
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
263
|
+
className: "flex-1"
|
|
264
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
265
|
+
htmlFor: "saturation",
|
|
266
|
+
className: "block text-sm font-medium text-gray-700"
|
|
267
|
+
}, "Saturation: ", saturation.toFixed(0), "%"), /*#__PURE__*/React.createElement("input", {
|
|
268
|
+
type: "range",
|
|
269
|
+
id: "saturation",
|
|
270
|
+
min: "0",
|
|
271
|
+
max: "100",
|
|
272
|
+
value: saturation,
|
|
273
|
+
onChange: function onChange(e) {
|
|
274
|
+
return setSaturation(parseFloat(e.target.value));
|
|
275
|
+
},
|
|
276
|
+
className: "w-full h-2 bg-gradient-to-r from-gray-300 to-blue-500 rounded-lg appearance-none cursor-pointer",
|
|
277
|
+
style: {
|
|
278
|
+
background: "linear-gradient(to right, hsl(".concat(hue, ", 0%, 50%), hsl(").concat(hue, ", 100%, 50%))")
|
|
279
|
+
}
|
|
280
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
281
|
+
className: "relative",
|
|
282
|
+
style: {
|
|
283
|
+
width: svgWidth,
|
|
284
|
+
height: svgHeight
|
|
285
|
+
}
|
|
286
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
287
|
+
width: svgWidth,
|
|
288
|
+
height: svgHeight,
|
|
289
|
+
className: "border border-gray-300 bg-white rounded"
|
|
290
|
+
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
|
|
291
|
+
id: "grad",
|
|
292
|
+
x1: ": ",
|
|
293
|
+
y1: ", ",
|
|
294
|
+
x2: "100%",
|
|
295
|
+
y2: ": "
|
|
296
|
+
}, /*#__PURE__*/React.createElement("stop", {
|
|
297
|
+
offset: ", ",
|
|
298
|
+
stopColor: gradientColorStart
|
|
299
|
+
}), /*#__PURE__*/React.createElement("stop", {
|
|
300
|
+
offset: "100%",
|
|
301
|
+
stopColor: gradientColorEnd
|
|
302
|
+
}))), /*#__PURE__*/React.createElement("rect", {
|
|
303
|
+
x: svgPadding,
|
|
304
|
+
y: svgPadding,
|
|
305
|
+
width: graphWidth,
|
|
306
|
+
height: graphHeight,
|
|
307
|
+
fill: "url(#grad)"
|
|
308
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
309
|
+
d: pathData,
|
|
310
|
+
fill: "none",
|
|
311
|
+
stroke: "none" // Removed stroke color
|
|
312
|
+
,
|
|
313
|
+
strokeWidth: "2"
|
|
314
|
+
}), colorSwatches.map(function (_ref2, index) {
|
|
315
|
+
var point = _ref2.point,
|
|
316
|
+
hex = _ref2.hex,
|
|
317
|
+
l = _ref2.l;
|
|
318
|
+
return /*#__PURE__*/React.createElement("g", {
|
|
319
|
+
key: index
|
|
320
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
321
|
+
cx: point.x,
|
|
322
|
+
cy: point.y,
|
|
323
|
+
r: 4 // Smaller points
|
|
324
|
+
,
|
|
325
|
+
fill: "#".concat(hex) // Fill with the actual color at that point
|
|
326
|
+
,
|
|
327
|
+
stroke: "rgba(0,0,0,0.5)" // Optional subtle border
|
|
328
|
+
,
|
|
329
|
+
strokeWidth: "0.5"
|
|
330
|
+
}));
|
|
331
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
332
|
+
cx: pointA.x,
|
|
333
|
+
cy: pointA.y,
|
|
334
|
+
r: 8,
|
|
335
|
+
fill: "rgba(0, 0, 255, 0.7)",
|
|
336
|
+
stroke: "blue",
|
|
337
|
+
strokeWidth: "2",
|
|
338
|
+
cursor: "grab",
|
|
339
|
+
onMouseDown: handleMouseDown('A')
|
|
340
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
341
|
+
cx: pointC.x,
|
|
342
|
+
cy: pointC.y,
|
|
343
|
+
r: 8,
|
|
344
|
+
fill: "rgba(200, 200, 200, 0.7)" // Indicate non-draggable
|
|
345
|
+
,
|
|
346
|
+
stroke: "gray",
|
|
347
|
+
strokeWidth: "2"
|
|
348
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
349
|
+
className: "flex justify-center flex-wrap gap-1 mt-4 max-w-full overflow-x-auto px-2"
|
|
350
|
+
}, colorSwatches.map(function (_ref3, i) {
|
|
351
|
+
var t = _ref3.t,
|
|
352
|
+
hex = _ref3.hex,
|
|
353
|
+
l = _ref3.l;
|
|
354
|
+
// Removed border logic tied to middle points
|
|
355
|
+
var borderColorClass = 'border border-transparent';
|
|
356
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
357
|
+
key: "".concat(t, "-").concat(hex),
|
|
358
|
+
className: "relative w-10 h-16 rounded overflow-hidden cursor-pointer flex-shrink-0 ".concat(borderColorClass),
|
|
359
|
+
title: "L: ".concat(l.toFixed(1), "%\nClick to copy #").concat(hex),
|
|
360
|
+
onClick: function onClick() {
|
|
361
|
+
return handleCopyHex(hex);
|
|
362
|
+
}
|
|
363
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
364
|
+
className: "absolute inset-0",
|
|
365
|
+
style: {
|
|
366
|
+
backgroundColor: "#".concat(hex)
|
|
367
|
+
}
|
|
368
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
369
|
+
className: "absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 text-white text-[10px] text-center py-0.5 truncate"
|
|
370
|
+
}, "#", hex), copiedHex === hex && /*#__PURE__*/React.createElement("div", {
|
|
371
|
+
className: "absolute inset-0 bg-white bg-opacity-75 flex items-center justify-center text-xs font-bold text-green-600"
|
|
372
|
+
}, "Copied!"));
|
|
373
|
+
})));
|
|
374
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OKLCHTool } from "./OKLCHTool";
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Tools / OKLCH Color Tool',
|
|
5
|
+
component: OKLCHTool,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'fullscreen',
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: "\n# OKLCH Color Palette Generator\n\nA modern color palette generator using the OKLCH color space, which provides **perceptually uniform lightness** across all hues.\n\n## Why OKLCH?\n\nUnlike HSL where the same lightness value looks different across hues (green appears brighter than blue at L=50%), OKLCH provides:\n\n- **Perceptually uniform lightness:** L=0.5 looks equally bright for red, green, blue, and all other hues\n- **No hue shifts:** Colors stay consistent at extreme lightness values\n- **Modern standard:** Based on human vision research (Oklab color space)\n- **Wide gamut:** Can represent more colors than sRGB\n\n## Features\n\n### \uD83C\uDFA8 OKLCH Color Space\nGenerate palettes with truly uniform brightness across hues.\n\n### \uD83C\uDFAD Overlay/Tint Feature\nApply a semi-transparent wash to unify your palette - like color grading in film!\n\n### \uD83D\uDD27 Gentle Chroma Compensation\nOKLCH needs much less adjustment than HSL, preserving color accuracy.\n\n### \uD83D\uDCE6 Palette Collection\nSave multiple palettes and export them all together.\n\n## How to Use\n\n1. **Configure Base Color:** Set the hue, chroma (saturation), and lightness\n2. **Enable Overlay (Optional):** Add a tint to unify your palette\n3. **Adjust Shade Count:** Choose 9, 18, or 27 colors\n4. **Add to Collection:** Save your palette\n5. **Export:** Download as JSON, CSS, SCSS, or Tailwind config\n\n## Comparison: HSL vs OKLCH\n\n### HSL Problem\n```css\n/* All have L=50%, but green looks much brighter! */\nhsl(0, 100%, 50%) /* Red - medium bright */\nhsl(120, 100%, 50%) /* Green - very bright! */\nhsl(240, 100%, 50%) /* Blue - darker */\n```\n\n### OKLCH Solution\n```css\n/* All have L=0.5 and actually look equally bright! */\noklch(0.5 0.2 0) /* Red */\noklch(0.5 0.2 120) /* Green */\noklch(0.5 0.2 240) /* Blue */\n```\n\n## The Overlay Trick\n\nThe overlay feature implements a professional colorist technique:\n- Add a subtle tint (5-15% opacity) over your entire palette\n- Creates tonal unity like Instagram filters or film color grading\n- Perfect for creating branded color systems\n "
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export var OKLCHColorTool = function OKLCHColorTool() {
|
|
16
|
+
return /*#__PURE__*/React.createElement(OKLCHTool, null);
|
|
17
|
+
};
|
|
18
|
+
OKLCHColorTool.parameters = {
|
|
19
|
+
docs: {
|
|
20
|
+
source: {
|
|
21
|
+
code: '<OKLCHTool />'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|