@ankhorage/zora 27.11.3 → 28.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/CHANGELOG.md +6 -0
- package/README.md +4 -3
- package/dist/features/color/ColorHexField.d.ts +1 -1
- package/dist/features/color/ColorHexField.d.ts.map +1 -1
- package/dist/features/color/ColorHexField.js +2 -3
- package/dist/features/color/ColorHexField.js.map +1 -1
- package/dist/features/color/ColorPicker.d.ts +1 -1
- package/dist/features/color/ColorPicker.d.ts.map +1 -1
- package/dist/features/color/ColorPicker.js +106 -52
- package/dist/features/color/ColorPicker.js.map +1 -1
- package/dist/features/color/ColorWheel.d.ts +1 -1
- package/dist/features/color/ColorWheel.d.ts.map +1 -1
- package/dist/features/color/ColorWheel.js +50 -117
- package/dist/features/color/ColorWheel.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts +1 -1
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.web.js +7 -4
- package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -1
- package/dist/features/color/public.d.ts +1 -1
- package/dist/features/color/public.d.ts.map +1 -1
- package/dist/features/color/public.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/color.d.ts +26 -26
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/color.js.map +1 -1
- package/package.json +2 -2
- package/src/features/color/ColorHexField.tsx +1 -3
- package/src/features/color/ColorPicker.layout.test.tsx +11 -16
- package/src/features/color/ColorPicker.tsx +217 -93
- package/src/features/color/ColorWheel.tsx +122 -248
- package/src/features/color/ColorWheelPointerProxy.web.tsx +11 -5
- package/src/features/color/public.ts +0 -2
- package/src/index.ts +0 -2
- package/src/types/color.ts +26 -22
- package/web-dist/chunks/Accordion-00h253nv.js +252 -0
- package/web-dist/chunks/{Accordion-qhn8z92r.js → Accordion-0gae3kzr.js} +3 -3
- package/web-dist/chunks/{Accordion-3jkeydhb.js → Accordion-0t53jhx1.js} +4 -4
- package/web-dist/chunks/{Accordion-vk2v1zwv.js → Accordion-1b2t4k36.js} +2 -2
- package/web-dist/chunks/{Accordion-aws0caav.js → Accordion-1dv8wytq.js} +3 -3
- package/web-dist/chunks/{Accordion-ysmzrvhn.js → Accordion-238zba4h.js} +3 -3
- package/web-dist/chunks/{Accordion-z8ryq8cb.js → Accordion-36674tfw.js} +7 -7
- package/web-dist/chunks/{Accordion-bd6q61s1.js → Accordion-36j1fw8r.js} +5 -5
- package/web-dist/chunks/{Accordion-jd26f516.js → Accordion-3ar6p84m.js} +3 -3
- package/web-dist/chunks/{Accordion-gezcm372.js → Accordion-3t2936t6.js} +4 -4
- package/web-dist/chunks/{Accordion-rzf52xq8.js → Accordion-43gp801f.js} +2 -2
- package/web-dist/chunks/{Accordion-c0a7mhq3.js → Accordion-52s4t1aq.js} +2 -2
- package/web-dist/chunks/{Accordion-vewhx028.js → Accordion-5adv6dv1.js} +4 -4
- package/web-dist/chunks/{Accordion-49w9bc2f.js → Accordion-5wx67nhg.js} +2 -2
- package/web-dist/chunks/{Accordion-p29kmwh9.js → Accordion-6225tr9r.js} +1 -1
- package/web-dist/chunks/{Accordion-x7ynjdv7.js → Accordion-6r1e7k5r.js} +1 -1
- package/web-dist/chunks/{Accordion-1mxnyexh.js → Accordion-6wcbzxzb.js} +13 -13
- package/web-dist/chunks/{Accordion-an5prgty.js → Accordion-7d0e5vhe.js} +1 -1
- package/web-dist/chunks/{Accordion-phtyg3k4.js → Accordion-7ppf31tg.js} +5 -5
- package/web-dist/chunks/{Accordion-5vs1k81g.js → Accordion-81rx3bh0.js} +8 -8
- package/web-dist/chunks/{Accordion-1etqb3cj.js → Accordion-8wm25z0h.js} +2 -2
- package/web-dist/chunks/{Accordion-f60g73bp.js → Accordion-94vndckf.js} +6 -6
- package/web-dist/chunks/{Accordion-ne91vwkd.js → Accordion-9fhsfynt.js} +2 -2
- package/web-dist/chunks/{Accordion-9c63jn3m.js → Accordion-ah1d9b6z.js} +4 -4
- package/web-dist/chunks/{Accordion-0kr0h68p.js → Accordion-b41rev86.js} +8 -8
- package/web-dist/chunks/{Accordion-q1tdazgq.js → Accordion-c8mmgjtj.js} +5 -5
- package/web-dist/chunks/{Accordion-pcj256bc.js → Accordion-d2kg4729.js} +5 -5
- package/web-dist/chunks/{Accordion-g451f3g9.js → Accordion-d4dp5ryp.js} +4 -4
- package/web-dist/chunks/{Accordion-dfq04q82.js → Accordion-dfv6p6gt.js} +4 -4
- package/web-dist/chunks/{Accordion-e3r3573t.js → Accordion-dpkp0y4p.js} +3 -3
- package/web-dist/chunks/{Accordion-pmfdf08d.js → Accordion-dxh9yn4f.js} +1 -1
- package/web-dist/chunks/{Accordion-zx8gmww4.js → Accordion-ec1tt3be.js} +9 -9
- package/web-dist/chunks/{Accordion-vnrqvfca.js → Accordion-epwpdegg.js} +1 -1
- package/web-dist/chunks/{Accordion-8g9c7890.js → Accordion-hbkzy0bg.js} +4 -4
- package/web-dist/chunks/{Accordion-c3nna2bz.js → Accordion-j6hgazmz.js} +1 -1
- package/web-dist/chunks/{Accordion-6nrpdbmb.js → Accordion-jara9sqj.js} +7 -7
- package/web-dist/chunks/{Accordion-3ecnh8d0.js → Accordion-knb3e18b.js} +4 -4
- package/web-dist/chunks/{Accordion-6m3k4avp.js → Accordion-m5baah44.js} +2 -2
- package/web-dist/chunks/{Accordion-3zw817fr.js → Accordion-nkppqfz4.js} +6 -6
- package/web-dist/chunks/{Accordion-3wkd5x2q.js → Accordion-phcp8d5v.js} +3 -3
- package/web-dist/chunks/{Accordion-x0p3wxfp.js → Accordion-pm2f2j32.js} +2 -2
- package/web-dist/chunks/{Accordion-j0zhpq4s.js → Accordion-q697hacs.js} +7 -7
- package/web-dist/chunks/{Accordion-eak89n4n.js → Accordion-re4r47xn.js} +6 -6
- package/web-dist/chunks/{Accordion-r1wkgt7c.js → Accordion-rev9ssd4.js} +516 -544
- package/web-dist/chunks/{Accordion-h2nd5y0z.js → Accordion-sn241nek.js} +5 -5
- package/web-dist/chunks/{Accordion-jbwey4za.js → Accordion-tppk4vwt.js} +9 -9
- package/web-dist/chunks/{Accordion-6yv4beha.js → Accordion-wbmzvfaw.js} +1 -1
- package/web-dist/chunks/{Accordion-4g54je0w.js → Accordion-wcw153f0.js} +2 -2
- package/web-dist/chunks/{Accordion-705yrq6w.js → Accordion-wpj8pd40.js} +1 -1
- package/web-dist/chunks/{Accordion-z4qakakw.js → Accordion-ytxgphds.js} +2 -2
- package/web-dist/chunks/{Accordion-h0e95qxp.js → Accordion-z1cq2mnx.js} +9 -9
- package/web-dist/chunks/{Accordion-xb174981.js → Accordion-z9yw0xy9.js} +8 -8
- package/web-dist/chunks/{Accordion-e5jr9ahb.js → Accordion-zte416jw.js} +1 -1
- package/web-dist/chunks/{Accordion-xwstve3k.js → Accordion-zzymcpty.js} +2 -2
- package/web-dist/components/accordion/Accordion.js +10 -10
- package/web-dist/components/accordion-item/AccordionItem.js +10 -10
- package/web-dist/components/activity-indicator/ActivityIndicator.js +3 -3
- package/web-dist/components/app-bar/AppBar.js +15 -15
- package/web-dist/components/app-header/AppHeader.js +15 -15
- package/web-dist/components/app-shell/AppShell.js +4 -4
- package/web-dist/components/auth-screen/AuthScreen.js +20 -20
- package/web-dist/components/avatar/Avatar.js +10 -10
- package/web-dist/components/avatar-group/AvatarGroup.js +10 -10
- package/web-dist/components/badge/Badge.js +5 -5
- package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +18 -18
- package/web-dist/components/bottom-sheet/BottomSheet.js +6 -6
- package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +6 -6
- package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +6 -6
- package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +6 -6
- package/web-dist/components/bottom-sheet-view/BottomSheetView.js +6 -6
- package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +6 -6
- package/web-dist/components/breadcrumbs/Breadcrumbs.js +12 -12
- package/web-dist/components/button/Button.js +10 -10
- package/web-dist/components/button-group/ButtonGroup.js +10 -10
- package/web-dist/components/calendar/Calendar.js +12 -12
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +18 -18
- package/web-dist/components/card/Card.js +17 -17
- package/web-dist/components/card-back/CardBack.js +4 -4
- package/web-dist/components/card-hand/CardHand.js +4 -4
- package/web-dist/components/carousel/Carousel.js +2 -2
- package/web-dist/components/chat-list-item/ChatListItem.js +14 -14
- package/web-dist/components/checkbox/Checkbox.js +10 -10
- package/web-dist/components/checkbox-group/CheckboxGroup.js +10 -10
- package/web-dist/components/chess-board/ChessBoard.js +4 -4
- package/web-dist/components/chip/Chip.js +11 -11
- package/web-dist/components/chip-group/ChipGroup.js +11 -11
- package/web-dist/components/collection-editor/CollectionEditor.js +17 -17
- package/web-dist/components/color-hue-scale/ColorHueScale.js +27 -16
- package/web-dist/components/color-picker/ColorPicker.d.ts +2 -2
- package/web-dist/components/color-picker/ColorPicker.js +27 -16
- package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +26 -45
- package/web-dist/components/color-picker/index.d.ts +1 -1
- package/web-dist/components/color-tone/ColorTone.js +27 -16
- package/web-dist/components/color-wheel/ColorWheel.d.ts +1 -1
- package/web-dist/components/color-wheel/ColorWheel.js +27 -16
- package/web-dist/components/color-wheel/ColorWheel.types-0.d.ts +2 -0
- package/web-dist/components/content-rail/ContentRail.js +11 -11
- package/web-dist/components/data-table/DataTable.js +23 -23
- package/web-dist/components/date-picker/DatePicker.js +16 -16
- package/web-dist/components/dialog/Dialog.js +9 -9
- package/web-dist/components/divider/Divider.js +4 -4
- package/web-dist/components/empty-state/EmptyState.js +18 -18
- package/web-dist/components/explorer/Explorer.js +11 -11
- package/web-dist/components/field/Field.js +10 -10
- package/web-dist/components/file-explorer/FileExplorer.js +11 -11
- package/web-dist/components/flat-list/FlatList.js +11 -11
- package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +20 -20
- package/web-dist/components/form/Form.js +14 -14
- package/web-dist/components/form-actions/FormActions.js +14 -14
- package/web-dist/components/form-error/FormError.js +14 -14
- package/web-dist/components/game/Game.js +5 -5
- package/web-dist/components/game-entity/GameEntity.js +5 -5
- package/web-dist/components/game-field/GameField.js +5 -5
- package/web-dist/components/game-input-zone/GameInputZone.js +5 -5
- package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +5 -5
- package/web-dist/components/game-overlay/GameOverlay.js +5 -5
- package/web-dist/components/gradient/Gradient.js +5 -5
- package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +5 -5
- package/web-dist/components/grid/Grid.js +4 -4
- package/web-dist/components/grid-line-overlay/GridLineOverlay.js +4 -4
- package/web-dist/components/grid-ruler/GridRuler.js +4 -4
- package/web-dist/components/heading/Heading.js +5 -5
- package/web-dist/components/hero/Hero.js +17 -17
- package/web-dist/components/icon/Icon.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +10 -10
- package/web-dist/components/image/Image.js +8 -8
- package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +3 -3
- package/web-dist/components/list/List.js +11 -11
- package/web-dist/components/list-item/ListItem.js +11 -11
- package/web-dist/components/list-section/ListSection.js +11 -11
- package/web-dist/components/master-detail/MasterDetail.js +4 -4
- package/web-dist/components/matrix-grid/MatrixGrid.js +4 -4
- package/web-dist/components/media-card/MediaCard.js +17 -17
- package/web-dist/components/media-explorer/MediaExplorer.js +11 -11
- package/web-dist/components/message-bubble/MessageBubble.js +14 -14
- package/web-dist/components/metric-card/MetricCard.js +17 -17
- package/web-dist/components/missing-element/MissingElement.js +9 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +20 -20
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +20 -20
- package/web-dist/components/opening-book/OpeningBook.js +4 -4
- package/web-dist/components/otp-form/OtpForm.js +20 -20
- package/web-dist/components/pagination/Pagination.js +11 -11
- package/web-dist/components/palette-item/PaletteItem.js +17 -17
- package/web-dist/components/playing-card/PlayingCard.js +4 -4
- package/web-dist/components/poker-training-table/PokerTrainingTable.js +4 -4
- package/web-dist/components/popover-menu/PopoverMenu.js +10 -10
- package/web-dist/components/post-card/PostCard.js +17 -17
- package/web-dist/components/product-card/ProductCard.js +17 -17
- package/web-dist/components/progress/Progress.js +8 -8
- package/web-dist/components/progress-ring/ProgressRing.js +8 -8
- package/web-dist/components/radio/Radio.js +12 -12
- package/web-dist/components/radio-group/RadioGroup.js +12 -12
- package/web-dist/components/rating/Rating.js +7 -7
- package/web-dist/components/reader/Reader.js +18 -18
- package/web-dist/components/scan-overlay/ScanOverlay.js +18 -18
- package/web-dist/components/screen/Screen.js +4 -4
- package/web-dist/components/screen-section/ScreenSection.js +8 -8
- package/web-dist/components/scroll-view/ScrollView.js +4 -4
- package/web-dist/components/search-input/SearchInput.js +12 -12
- package/web-dist/components/section-header/SectionHeader.js +8 -8
- package/web-dist/components/section-list/SectionList.js +11 -11
- package/web-dist/components/select/Select.js +21 -257
- package/web-dist/components/selectable-item/SelectableItem.js +3 -3
- package/web-dist/components/selection-provider/SelectionProvider.js +3 -3
- package/web-dist/components/sign-in-form/SignInForm.js +20 -20
- package/web-dist/components/sign-up-form/SignUpForm.js +20 -20
- package/web-dist/components/skeleton/Skeleton.js +20 -20
- package/web-dist/components/skeleton-card/SkeletonCard.js +20 -20
- package/web-dist/components/skeleton-list/SkeletonList.js +20 -20
- package/web-dist/components/skeleton-text/SkeletonText.js +20 -20
- package/web-dist/components/surface/Surface.js +5 -5
- package/web-dist/components/switch/Switch.js +5 -5
- package/web-dist/components/tab/Tab.js +5 -5
- package/web-dist/components/tab-list/TabList.js +5 -5
- package/web-dist/components/tab-panel/TabPanel.js +5 -5
- package/web-dist/components/tabletop-table/TabletopTable.js +4 -4
- package/web-dist/components/tabs/Tabs.js +5 -5
- package/web-dist/components/text/Text.js +5 -5
- package/web-dist/components/text-input/TextInput.js +12 -12
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +10 -10
- package/web-dist/components/time-picker/TimePicker.js +15 -15
- package/web-dist/components/timeline/Timeline.js +10 -10
- package/web-dist/components/toast/Toast.js +7 -7
- package/web-dist/components/toast-provider/ToastProvider.js +7 -7
- package/web-dist/components/toolbar/Toolbar.js +17 -17
- package/web-dist/components/tree-item/TreeItem.js +15 -15
- package/web-dist/components/uploader/Uploader.js +20 -20
- package/web-dist/components/view/View.js +4 -4
- package/web-dist/manifest.json +1495 -1446
- package/web-dist/runtime/ZoraProvider.js +6 -6
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# ZORA
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Provides opinionated React Native and React Native Web UI components, theme primitives, registries, and reader surfaces built on @ankhorage/surface.
|
|
9
9
|
|
|
@@ -50,8 +50,9 @@ Open `./paradox/index.html` locally in your browser to browse the complete docum
|
|
|
50
50
|
|
|
51
51
|
## Contributors
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
<a href="https://github.com/artiphishle"><img src="https://avatars.githubusercontent.com/u/137318798?s=64" width="40" height="40" alt="artiphishle" /></a>
|
|
54
|
+
<a href="https://github.com/faeb187"><img src="https://avatars.githubusercontent.com/u/389333?s=64" width="40" height="40" alt="faeb187" /></a>
|
|
55
|
+
<a href="https://github.com/artiphishle-agent"><img src="https://avatars.githubusercontent.com/u/341682830?s=64" width="40" height="40" alt="artiphishle-agent" /></a>
|
|
55
56
|
|
|
56
57
|
## Donation
|
|
57
58
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HexColor } from '@ankhorage/color-theory';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
/*** Edits one controlled HEX color
|
|
3
|
+
/*** Edits one controlled HEX color until the host-backed clipboard capability is available. */
|
|
4
4
|
export declare function ColorHexField({ disabled, onChange, value, }: {
|
|
5
5
|
readonly disabled: boolean;
|
|
6
6
|
readonly onChange: (color: HexColor) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorHexField.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHexField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorHexField.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHexField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAEpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B,qBA0BA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { isHexColor } from '@ankhorage/color-theory';
|
|
2
2
|
import { TextInput } from '@ankhorage/surface';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Icon } from '../icon/public';
|
|
5
4
|
import { View } from '../layout/public';
|
|
6
5
|
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
7
|
-
/*** Edits one controlled HEX color
|
|
6
|
+
/*** Edits one controlled HEX color until the host-backed clipboard capability is available. */
|
|
8
7
|
export function ColorHexField({ disabled, onChange, value, }) {
|
|
9
8
|
const [input, setInput] = React.useState(value);
|
|
10
9
|
const { theme } = useZoraTheme();
|
|
@@ -12,6 +11,6 @@ export function ColorHexField({ disabled, onChange, value, }) {
|
|
|
12
11
|
setInput(nextValue);
|
|
13
12
|
if (isHexColor(nextValue))
|
|
14
13
|
onChange(nextValue);
|
|
15
|
-
}}
|
|
14
|
+
}} value={input}/>);
|
|
16
15
|
}
|
|
17
16
|
//# sourceMappingURL=ColorHexField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorHexField.js","sourceRoot":"","sources":["../../../src/features/color/ColorHexField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ColorHexField.js","sourceRoot":"","sources":["../../../src/features/color/ColorHexField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,+FAA+F;AAC/F,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,EACR,KAAK,GAKN;IACC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,CAAC;IACxD,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC;IAEjC,OAAO,CACL,CAAC,SAAS,CACR,kBAAkB,CAAC,iBAAiB,CACpC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,GAAG,CAAC,CAAC,KAAK,CAAC,CACX,gBAAgB,CAAC,CACf,CAAC,IAAI,CACH,EAAE,CAAC,CAAC,KAAK,CAAC,CACV,WAAW,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAC5C,WAAW,CAAC,CAAC,CAAC,CAAC,CACf,MAAM,CAAC,CAAC,EAAE,CAAC,CACX,MAAM,CAAC,GAAG,CACV,KAAK,CAAC,CAAC,EAAE,CAAC,EAEd,CAAC,CACD,YAAY,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1B,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,IAAI,UAAU,CAAC,SAAS,CAAC;gBAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,KAAK,CAAC,EACb,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { type HexColor, isHexColor } from '@ankhorage/color-theory';\nimport { TextInput } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { View } from '../layout/public';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\n\n/*** Edits one controlled HEX color until the host-backed clipboard capability is available. */\nexport function ColorHexField({\n disabled,\n onChange,\n value,\n}: {\n readonly disabled: boolean;\n readonly onChange: (color: HexColor) => void;\n readonly value: HexColor;\n}) {\n const [input, setInput] = React.useState<string>(value);\n const { theme } = useZoraTheme();\n\n return (\n <TextInput\n accessibilityLabel=\"Color hex value\"\n disabled={disabled}\n key={value}\n leadingAccessory={\n <View\n bg={value}\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n height={30}\n radius=\"s\"\n width={30}\n />\n }\n onChangeText={(nextValue) => {\n setInput(nextValue);\n if (isHexColor(nextValue)) onChange(nextValue);\n }}\n value={input}\n />\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ColorPickerProps } from '../../types/color';
|
|
3
|
-
/***
|
|
3
|
+
/*** Replaces the former Tone/Hue picker with one controlled Grid/Wheel presentation. */
|
|
4
4
|
export declare const ColorPicker: (props: ColorPickerProps) => React.ReactElement | null;
|
|
5
5
|
//# sourceMappingURL=ColorPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAuC,MAAM,mBAAmB,CAAC;AAe/F,wFAAwF;AACxF,eAAO,MAAM,WAAW,wDAAuC,CAAC"}
|
|
@@ -1,75 +1,129 @@
|
|
|
1
|
+
import { COLOR_HARMONY_CATALOG } from '@ankhorage/color-theory';
|
|
2
|
+
import { Pressable } from '@ankhorage/surface';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { IconButton } from '../button/public';
|
|
3
|
-
import {
|
|
5
|
+
import { Card } from '../card/public';
|
|
6
|
+
import { Select } from '../form/select/public';
|
|
7
|
+
import { Divider, View } from '../layout/public';
|
|
4
8
|
import { Tab, TabList, TabPanel, Tabs } from '../tabs/public';
|
|
5
9
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
6
10
|
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ColorTone } from './ColorTone';
|
|
11
|
+
import { Heading } from '../typography/public';
|
|
12
|
+
import { ColorHexField } from './ColorHexField';
|
|
10
13
|
import { ColorWheel } from './ColorWheel';
|
|
11
|
-
|
|
14
|
+
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
15
|
+
const DEFAULT_TABS = ['grid', 'wheel'];
|
|
16
|
+
/*** Replaces the former Tone/Hue picker with one controlled Grid/Wheel presentation. */
|
|
12
17
|
export const ColorPicker = withZoraThemeScope(ColorPickerInner);
|
|
13
|
-
/*** Coordinates
|
|
14
|
-
function ColorPickerInner({ themeId: _themeId, mode: _mode, inverted: _inverted, tabs,
|
|
18
|
+
/*** Coordinates the shared colour, tone and harmony state across both picker presentations. */
|
|
19
|
+
function ColorPickerInner({ themeId: _themeId, mode: _mode, inverted: _inverted, tabs = DEFAULT_TABS, primaryColor, harmony, tone, tones = [], width = 560, activeTab, onValueChange, onActiveTabChange, onDismiss, hideTabListWhenSingle = true, wheel, interactionPolicy, testID, }) {
|
|
15
20
|
const { theme } = useZoraTheme();
|
|
16
|
-
|
|
21
|
+
const enabledTabs = resolveEnabledTabs(tabs);
|
|
22
|
+
const firstTab = enabledTabs.at(0);
|
|
23
|
+
if (!firstTab)
|
|
17
24
|
throw new Error('ColorPicker requires at least one tab.');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const resolvedTab = activeTab && enabledTabs.includes(activeTab) ? activeTab : firstTab;
|
|
26
|
+
const geometry = resolveGeometry(width);
|
|
27
|
+
const selectedTone = tones.find((entry) => entry.id === tone);
|
|
28
|
+
const emit = (next) => onValueChange({
|
|
29
|
+
primaryColor: next.primaryColor ?? primaryColor,
|
|
30
|
+
...(next.harmony === undefined ? (harmony ? { harmony } : {}) : { harmony: next.harmony }),
|
|
31
|
+
...(next.tone === undefined ? (tone ? { tone } : {}) : { tone: next.tone }),
|
|
32
|
+
});
|
|
33
|
+
const settings = (children) => (<PickerRow geometry={geometry} tone={tone} tones={tones} harmony={harmony} onHarmonyChange={(next) => emit({ harmony: next })} onToneChange={(next) => emit({ tone: next })}>
|
|
34
|
+
{children}
|
|
35
|
+
</PickerRow>);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (activeTab && activeTab !== resolvedTab)
|
|
38
|
+
onActiveTabChange?.(resolvedTab);
|
|
39
|
+
}, [activeTab, onActiveTabChange, resolvedTab]);
|
|
40
|
+
return (<View alignSelf="center" bg={theme.semantics.surface.raised} borderColor={theme.semantics.border.default} borderWidth={1} gap="m" maxWidth="100%" p={geometry.padding} radius="xl" testID={testID} width={geometry.width}>
|
|
41
|
+
<View align="center" direction="row" justify="space-between" minHeight={48}>
|
|
42
|
+
<Heading level={2}>Color</Heading>
|
|
26
43
|
<View align="center" direction="row" gap="s">
|
|
27
|
-
<View bg={
|
|
44
|
+
<View bg={primaryColor} borderColor={theme.semantics.border.default} borderWidth={1} height={36} radius="s" width={52}/>
|
|
28
45
|
{onDismiss ? (<IconButton iconName="close" label="Close color picker" onPress={onDismiss}/>) : null}
|
|
29
46
|
</View>
|
|
30
47
|
</View>
|
|
31
|
-
<Tabs
|
|
32
|
-
if (isColorPickerTab(
|
|
33
|
-
|
|
34
|
-
}}
|
|
35
|
-
{
|
|
48
|
+
<Tabs onValueChange={(next) => {
|
|
49
|
+
if (isColorPickerTab(next) && enabledTabs.includes(next))
|
|
50
|
+
onActiveTabChange?.(next);
|
|
51
|
+
}} value={resolvedTab} variant="attached">
|
|
52
|
+
{enabledTabs.length > 1 || !hideTabListWhenSingle ? (<View borderColor={theme.semantics.border.default} borderWidth={1} overflow="hidden" radius="m">
|
|
36
53
|
<TabList fill>
|
|
37
|
-
{
|
|
54
|
+
{enabledTabs.map((tab) => (<Tab key={tab} label={tab === 'grid' ? 'Grid' : 'Wheel'} value={tab}/>))}
|
|
38
55
|
</TabList>
|
|
39
56
|
</View>) : null}
|
|
40
|
-
{
|
|
41
|
-
{
|
|
42
|
-
</TabPanel>)
|
|
57
|
+
{enabledTabs.includes('grid') ? (<TabPanel value="grid">
|
|
58
|
+
{settings(<ColorGrid onSelect={(color) => emit({ primaryColor: color })} palette={resolvePalette(selectedTone)} selectionBorderColor={theme.semantics.content.default} selected={primaryColor} size={geometry.stage}/>)}
|
|
59
|
+
</TabPanel>) : null}
|
|
60
|
+
{enabledTabs.includes('wheel') ? (<TabPanel value="wheel">
|
|
61
|
+
{settings(<ColorWheel {...wheel} harmony={harmony ?? null} onChange={(next) => emit({ primaryColor: next.color, harmony: next.harmony ?? undefined })} size={geometry.stage} value={primaryColor}/>)}
|
|
62
|
+
</TabPanel>) : null}
|
|
43
63
|
</Tabs>
|
|
64
|
+
<Divider />
|
|
65
|
+
<ColorHexField disabled={interactionPolicy === 'passive'} onChange={(color) => emit({ primaryColor: color })} value={primaryColor}/>
|
|
44
66
|
</View>);
|
|
45
67
|
}
|
|
46
|
-
/***
|
|
47
|
-
function
|
|
48
|
-
return
|
|
68
|
+
/*** Keeps the settings rail identical while the stage changes presentation. */
|
|
69
|
+
function PickerRow({ children, geometry, tone, tones, harmony, onToneChange, onHarmonyChange, }) {
|
|
70
|
+
return (<View align="flex-start" direction="row" gap={geometry.gap}>
|
|
71
|
+
<View gap="m" width={geometry.rail}>
|
|
72
|
+
<Card compact title="Tone">
|
|
73
|
+
<Select onValueChange={onToneChange} options={tones.map((entry) => ({ label: entry.accent, value: entry.id }))} placeholder="Any tone" value={tone}/>
|
|
74
|
+
</Card>
|
|
75
|
+
<Card compact title="Harmony">
|
|
76
|
+
<Select onValueChange={onHarmonyChange} options={COLOR_HARMONY_CATALOG.map((entry) => ({
|
|
77
|
+
label: entry.label,
|
|
78
|
+
value: entry.id,
|
|
79
|
+
}))} placeholder="None" value={harmony}/>
|
|
80
|
+
</Card>
|
|
81
|
+
</View>
|
|
82
|
+
{children}
|
|
83
|
+
</View>);
|
|
84
|
+
}
|
|
85
|
+
/*** Renders all 64 deterministic OKLCH candidates without scrolling or virtualisation. */
|
|
86
|
+
function ColorGrid({ palette, selectionBorderColor, selected, size, onSelect, }) {
|
|
87
|
+
const gap = Math.max(3, Math.round(size / 68));
|
|
88
|
+
const cell = (size - 7 * gap) / 8;
|
|
89
|
+
return (<View accessibilityLabel="Color grid" direction="row" gap={gap} width={size} wrap="wrap">
|
|
90
|
+
{palette.map((color) => (<Pressable accessibilityLabel={`Select ${color}`} bg={color} borderColor={color === selected ? selectionBorderColor : 'transparent'} borderWidth={color === selected ? 3 : 1} height={cell} key={color} onPress={() => onSelect(color)} radius="s" width={cell}/>))}
|
|
91
|
+
</View>);
|
|
49
92
|
}
|
|
50
|
-
/***
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
93
|
+
/*** Samples hue, chroma and lightness deterministically into the 8-by-8 grid. */
|
|
94
|
+
function resolvePalette(tone) {
|
|
95
|
+
const target = tone?.accentTarget;
|
|
96
|
+
return Array.from({ length: 64 }, (_, index) => resolveOklchColor({
|
|
97
|
+
chroma: target?.chroma ?? 0.08 + (index % 8) * 0.018,
|
|
98
|
+
lightness: target?.lightness ?? 0.35 + Math.floor(index / 8) * 0.065,
|
|
99
|
+
}, (index * 137.508) % 360));
|
|
57
100
|
}
|
|
58
|
-
/***
|
|
59
|
-
function
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
/*** Resolves continuous width-owned rail and stage geometry from the specified picker width. */
|
|
102
|
+
function resolveGeometry(requestedWidth) {
|
|
103
|
+
if (requestedWidth < 360)
|
|
104
|
+
throw new Error('ColorPicker requires a host width of at least 360 logical pixels.');
|
|
105
|
+
const scale = Math.max(0, (Math.min(requestedWidth, 560) - 360) / 200);
|
|
106
|
+
const padding = 12 + scale * 12;
|
|
107
|
+
const rail = 104 + scale * 46;
|
|
108
|
+
const gap = 12 + scale * 8;
|
|
109
|
+
return {
|
|
110
|
+
width: requestedWidth,
|
|
111
|
+
padding,
|
|
112
|
+
rail,
|
|
113
|
+
gap,
|
|
114
|
+
stage: requestedWidth - 2 - 2 * padding - rail - gap,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/*** Rejects empty and legacy tab configurations before they render focusable controls. */
|
|
118
|
+
function resolveEnabledTabs(tabs) {
|
|
119
|
+
if (tabs.length === 0)
|
|
120
|
+
throw new Error('ColorPicker requires at least one tab.');
|
|
121
|
+
if (tabs.some((tab) => !isColorPickerTab(tab)))
|
|
122
|
+
throw new Error('ColorPicker supports only Grid and Wheel tabs.');
|
|
123
|
+
return tabs;
|
|
124
|
+
}
|
|
125
|
+
/*** Narrows a Surface tab value to the new ColorPicker vocabulary. */
|
|
126
|
+
function isColorPickerTab(value) {
|
|
127
|
+
return value === 'grid' || value === 'wheel';
|
|
74
128
|
}
|
|
75
129
|
//# sourceMappingURL=ColorPicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,iGAAiG;AACjG,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAEhE,mGAAmG;AACnG,SAAS,gBAAgB,CAAC,EACxB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,EACnB,IAAI,EACJ,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,qBAAqB,GAAG,IAAI,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CACF,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ColorPickerProps, ColorPickerTab, ColorPickerValue } from '../../types/color';\nimport { IconButton } from '../button/public';\nimport { View } from '../layout/public';\nimport { Tab, TabList, TabPanel, Tabs } from '../tabs/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { Text } from '../typography/public';\nimport { ColorHueScale } from './ColorHueScale';\nimport { ColorTone } from './ColorTone';\nimport { ColorWheel } from './ColorWheel';\n\n/*** Composes independently usable color controls into an ordered, consumer-configured picker. */\nexport const ColorPicker = withZoraThemeScope(ColorPickerInner);\n\n/*** Coordinates persistent controlled color selections across independently usable picker tabs. */\nfunction ColorPickerInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n tabs,\n value,\n onValueChange,\n onSelectionChange,\n onDismiss,\n hideTabListWhenSingle = true,\n wheel,\n tone,\n hue,\n testID,\n}: ColorPickerProps) {\n const { theme } = useZoraTheme();\n if (tabs.length === 0) throw new Error('ColorPicker requires at least one tab.');\n if (!tabs.includes(value.tab)) throw new Error('ColorPicker value must be configured in tabs.');\n const previewColor = resolvePickerPreviewColor(value);\n\n return (\n <View\n alignSelf=\"center\"\n bg={theme.semantics.surface.raised}\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n flexShrink={1}\n gap=\"s\"\n maxWidth={400}\n p=\"m\"\n radius=\"l\"\n testID={testID}\n width=\"100%\"\n >\n <View align=\"center\" direction=\"row\" justify=\"space-between\">\n <Text variant=\"lead\" weight=\"semiBold\">\n Color\n </Text>\n <View align=\"center\" direction=\"row\" gap=\"s\">\n <View\n bg={previewColor}\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n height={38}\n radius=\"s\"\n width={38}\n />\n {onDismiss ? (\n <IconButton iconName=\"close\" label=\"Close color picker\" onPress={onDismiss} />\n ) : null}\n </View>\n </View>\n <Tabs\n defaultValue={value.tab}\n onValueChange={(nextValue) => {\n if (isColorPickerTab(nextValue) && tabs.includes(nextValue))\n onValueChange({ ...value, tab: nextValue });\n }}\n testID={testID ? `${testID}-tabs` : undefined}\n value={value.tab}\n variant=\"attached\"\n >\n {tabs.length > 1 || !hideTabListWhenSingle ? (\n <View\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n overflow=\"hidden\"\n radius=\"m\"\n >\n <TabList fill>\n {tabs.map((tab) => (\n <Tab key={tab} label={tab} value={tab} />\n ))}\n </TabList>\n </View>\n ) : null}\n {tabs.map((tab) => (\n <TabPanel key={tab} value={tab}>\n {resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)}\n </TabPanel>\n ))}\n </Tabs>\n </View>\n );\n}\n\n/*** Check whether a Surface tab value belongs to the configured picker vocabulary. */\nfunction isColorPickerTab(value: string): value is ColorPickerTab {\n return value === 'wheel' || value === 'tone' || value === 'hue';\n}\n\n/*** Resolves the visible active-tab color without introducing a second picker state. */\nfunction resolvePickerPreviewColor(value: ColorPickerValue) {\n if (value.tab === 'hue') return value.hue;\n if (value.tab === 'tone') return value.tone?.colors.at(0) ?? value.wheel.color;\n return value.wheel.color;\n}\n\n/*** Resolve the configured control for one picker tab without adding fallback feature modes. */\nfunction resolveTabContent(\n tab: ColorPickerTab,\n value: ColorPickerValue,\n wheel: ColorPickerProps['wheel'],\n tone: ColorPickerProps['tone'],\n hue: ColorPickerProps['hue'],\n onValueChange: (value: ColorPickerValue) => void,\n onSelectionChange: ColorPickerProps['onSelectionChange'],\n) {\n if (tab === 'wheel')\n return wheel ? (\n <ColorWheel\n {...wheel}\n harmony={value.wheel.harmony}\n onChange={(next) => {\n onValueChange({ ...value, wheel: next });\n onSelectionChange?.({ mode: 'wheel', value: next });\n }}\n value={value.wheel.color}\n />\n ) : null;\n if (tab === 'tone')\n return tone ? (\n <ColorTone\n {...tone}\n onChange={(next) => {\n onValueChange({ ...value, tone: next });\n onSelectionChange?.({ mode: 'tone', value: next });\n }}\n value={value.tone}\n />\n ) : null;\n return hue ? (\n <ColorHueScale\n {...hue}\n onChange={(next) => {\n onValueChange({ ...value, hue: next });\n onSelectionChange?.({ mode: 'hue', value: next });\n }}\n value={value.hue}\n />\n ) : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAoC,MAAM,yBAAyB,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,YAAY,GAA8B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElE,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAEhE,+FAA+F;AAC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AC;AAED,gGAAgG;AAChG,SAAS,eAAe,CAAC,cAAsB;IAC7C,IAAI,cAAc,GAAG,GAAG;QACtB,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,GAAG,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;IAC3B,OAAO;QACL,KAAK,EAAE,cAAc;QACrB,OAAO;QACP,IAAI;QACJ,GAAG;QACH,KAAK,EAAE,cAAc,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG;KACrD,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,kBAAkB,CAAC,IAA+B;IACzD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACjF,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sEAAsE;AACtE,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,CAAC;AAC/C,CAAC","sourcesContent":["import { COLOR_HARMONY_CATALOG, type ColorHarmony, type HexColor } from '@ankhorage/color-theory';\nimport { Pressable } from '@ankhorage/surface';\nimport React from 'react';\n\nimport type { ColorPickerProps, ColorPickerTab, ColorToneDefinition } from '../../types/color';\nimport { IconButton } from '../button/public';\nimport { Card } from '../card/public';\nimport { Select } from '../form/select/public';\nimport { Divider, View } from '../layout/public';\nimport { Tab, TabList, TabPanel, Tabs } from '../tabs/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { Heading } from '../typography/public';\nimport { ColorHexField } from './ColorHexField';\nimport { ColorWheel } from './ColorWheel';\nimport { resolveOklchColor } from './utils/resolveOklchColor';\n\nconst DEFAULT_TABS: readonly ColorPickerTab[] = ['grid', 'wheel'];\n\n/*** Replaces the former Tone/Hue picker with one controlled Grid/Wheel presentation. */\nexport const ColorPicker = withZoraThemeScope(ColorPickerInner);\n\n/*** Coordinates the shared colour, tone and harmony state across both picker presentations. */\nfunction ColorPickerInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n tabs = DEFAULT_TABS,\n primaryColor,\n harmony,\n tone,\n tones = [],\n width = 560,\n activeTab,\n onValueChange,\n onActiveTabChange,\n onDismiss,\n hideTabListWhenSingle = true,\n wheel,\n interactionPolicy,\n testID,\n}: ColorPickerProps) {\n const { theme } = useZoraTheme();\n const enabledTabs = resolveEnabledTabs(tabs);\n const firstTab = enabledTabs.at(0);\n if (!firstTab) throw new Error('ColorPicker requires at least one tab.');\n const resolvedTab = activeTab && enabledTabs.includes(activeTab) ? activeTab : firstTab;\n const geometry = resolveGeometry(width);\n const selectedTone = tones.find((entry) => entry.id === tone);\n const emit = (next: Partial<{ primaryColor: HexColor; harmony: ColorHarmony; tone: string }>) =>\n onValueChange({\n primaryColor: next.primaryColor ?? primaryColor,\n ...(next.harmony === undefined ? (harmony ? { harmony } : {}) : { harmony: next.harmony }),\n ...(next.tone === undefined ? (tone ? { tone } : {}) : { tone: next.tone }),\n });\n const settings = (children: React.ReactNode) => (\n <PickerRow\n geometry={geometry}\n tone={tone}\n tones={tones}\n harmony={harmony}\n onHarmonyChange={(next) => emit({ harmony: next })}\n onToneChange={(next) => emit({ tone: next })}\n >\n {children}\n </PickerRow>\n );\n React.useEffect(() => {\n if (activeTab && activeTab !== resolvedTab) onActiveTabChange?.(resolvedTab);\n }, [activeTab, onActiveTabChange, resolvedTab]);\n return (\n <View\n alignSelf=\"center\"\n bg={theme.semantics.surface.raised}\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n gap=\"m\"\n maxWidth=\"100%\"\n p={geometry.padding}\n radius=\"xl\"\n testID={testID}\n width={geometry.width}\n >\n <View align=\"center\" direction=\"row\" justify=\"space-between\" minHeight={48}>\n <Heading level={2}>Color</Heading>\n <View align=\"center\" direction=\"row\" gap=\"s\">\n <View\n bg={primaryColor}\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n height={36}\n radius=\"s\"\n width={52}\n />\n {onDismiss ? (\n <IconButton iconName=\"close\" label=\"Close color picker\" onPress={onDismiss} />\n ) : null}\n </View>\n </View>\n <Tabs\n onValueChange={(next) => {\n if (isColorPickerTab(next) && enabledTabs.includes(next)) onActiveTabChange?.(next);\n }}\n value={resolvedTab}\n variant=\"attached\"\n >\n {enabledTabs.length > 1 || !hideTabListWhenSingle ? (\n <View\n borderColor={theme.semantics.border.default}\n borderWidth={1}\n overflow=\"hidden\"\n radius=\"m\"\n >\n <TabList fill>\n {enabledTabs.map((tab) => (\n <Tab key={tab} label={tab === 'grid' ? 'Grid' : 'Wheel'} value={tab} />\n ))}\n </TabList>\n </View>\n ) : null}\n {enabledTabs.includes('grid') ? (\n <TabPanel value=\"grid\">\n {settings(\n <ColorGrid\n onSelect={(color) => emit({ primaryColor: color })}\n palette={resolvePalette(selectedTone)}\n selectionBorderColor={theme.semantics.content.default}\n selected={primaryColor}\n size={geometry.stage}\n />,\n )}\n </TabPanel>\n ) : null}\n {enabledTabs.includes('wheel') ? (\n <TabPanel value=\"wheel\">\n {settings(\n <ColorWheel\n {...wheel}\n harmony={harmony ?? null}\n onChange={(next) =>\n emit({ primaryColor: next.color, harmony: next.harmony ?? undefined })\n }\n size={geometry.stage}\n value={primaryColor}\n />,\n )}\n </TabPanel>\n ) : null}\n </Tabs>\n <Divider />\n <ColorHexField\n disabled={interactionPolicy === 'passive'}\n onChange={(color) => emit({ primaryColor: color })}\n value={primaryColor}\n />\n </View>\n );\n}\n\n/*** Keeps the settings rail identical while the stage changes presentation. */\nfunction PickerRow({\n children,\n geometry,\n tone,\n tones,\n harmony,\n onToneChange,\n onHarmonyChange,\n}: {\n readonly children: React.ReactNode;\n readonly geometry: ReturnType<typeof resolveGeometry>;\n readonly tone?: string;\n readonly tones: readonly ColorToneDefinition[];\n readonly harmony?: ColorHarmony;\n readonly onToneChange: (tone: string) => void;\n readonly onHarmonyChange: (harmony?: ColorHarmony) => void;\n}) {\n return (\n <View align=\"flex-start\" direction=\"row\" gap={geometry.gap}>\n <View gap=\"m\" width={geometry.rail}>\n <Card compact title=\"Tone\">\n <Select\n onValueChange={onToneChange}\n options={tones.map((entry) => ({ label: entry.accent, value: entry.id }))}\n placeholder=\"Any tone\"\n value={tone}\n />\n </Card>\n <Card compact title=\"Harmony\">\n <Select\n onValueChange={onHarmonyChange}\n options={COLOR_HARMONY_CATALOG.map((entry) => ({\n label: entry.label,\n value: entry.id,\n }))}\n placeholder=\"None\"\n value={harmony}\n />\n </Card>\n </View>\n {children}\n </View>\n );\n}\n\n/*** Renders all 64 deterministic OKLCH candidates without scrolling or virtualisation. */\nfunction ColorGrid({\n palette,\n selectionBorderColor,\n selected,\n size,\n onSelect,\n}: {\n readonly palette: readonly HexColor[];\n readonly selectionBorderColor: string;\n readonly selected: HexColor;\n readonly size: number;\n readonly onSelect: (color: HexColor) => void;\n}) {\n const gap = Math.max(3, Math.round(size / 68));\n const cell = (size - 7 * gap) / 8;\n return (\n <View accessibilityLabel=\"Color grid\" direction=\"row\" gap={gap} width={size} wrap=\"wrap\">\n {palette.map((color) => (\n <Pressable\n accessibilityLabel={`Select ${color}`}\n bg={color}\n borderColor={color === selected ? selectionBorderColor : 'transparent'}\n borderWidth={color === selected ? 3 : 1}\n height={cell}\n key={color}\n onPress={() => onSelect(color)}\n radius=\"s\"\n width={cell}\n />\n ))}\n </View>\n );\n}\n\n/*** Samples hue, chroma and lightness deterministically into the 8-by-8 grid. */\nfunction resolvePalette(tone?: ColorToneDefinition): readonly HexColor[] {\n const target = tone?.accentTarget;\n return Array.from({ length: 64 }, (_, index) =>\n resolveOklchColor(\n {\n chroma: target?.chroma ?? 0.08 + (index % 8) * 0.018,\n lightness: target?.lightness ?? 0.35 + Math.floor(index / 8) * 0.065,\n },\n (index * 137.508) % 360,\n ),\n );\n}\n\n/*** Resolves continuous width-owned rail and stage geometry from the specified picker width. */\nfunction resolveGeometry(requestedWidth: number) {\n if (requestedWidth < 360)\n throw new Error('ColorPicker requires a host width of at least 360 logical pixels.');\n const scale = Math.max(0, (Math.min(requestedWidth, 560) - 360) / 200);\n const padding = 12 + scale * 12;\n const rail = 104 + scale * 46;\n const gap = 12 + scale * 8;\n return {\n width: requestedWidth,\n padding,\n rail,\n gap,\n stage: requestedWidth - 2 - 2 * padding - rail - gap,\n };\n}\n\n/*** Rejects empty and legacy tab configurations before they render focusable controls. */\nfunction resolveEnabledTabs(tabs: readonly ColorPickerTab[]) {\n if (tabs.length === 0) throw new Error('ColorPicker requires at least one tab.');\n if (tabs.some((tab) => !isColorPickerTab(tab)))\n throw new Error('ColorPicker supports only Grid and Wheel tabs.');\n return tabs;\n}\n\n/*** Narrows a Surface tab value to the new ColorPicker vocabulary. */\nfunction isColorPickerTab(value: string): value is ColorPickerTab {\n return value === 'grid' || value === 'wheel';\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ColorWheelProps } from '../../types/color';
|
|
3
|
-
/***
|
|
3
|
+
/*** Renders a size-owned, filled OKLCH wheel with controlled primary and harmony points. */
|
|
4
4
|
export declare const ColorWheel: (props: ColorWheelProps) => React.ReactElement | null;
|
|
5
5
|
//# sourceMappingURL=ColorWheel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorWheel.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColorWheel.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorWheel.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAgBzD,4FAA4F;AAC5F,eAAO,MAAM,UAAU,uDAAsC,CAAC"}
|
|
@@ -1,153 +1,86 @@
|
|
|
1
1
|
import { generateHarmonyRoleColors } from '@ankhorage/color-theory';
|
|
2
|
-
import { Button } from '@ankhorage/surface';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import { Circle, Defs, Line,
|
|
5
|
-
import { View } from '../layout/public';
|
|
3
|
+
import { Circle, Defs, Line, Path, Polygon, RadialGradient, Stop, Svg } from 'react-native-svg';
|
|
6
4
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
7
5
|
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
8
|
-
import { Text } from '../typography/public';
|
|
9
|
-
import { ColorHexField } from './ColorHexField';
|
|
10
|
-
import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
|
|
11
6
|
import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
|
|
12
7
|
import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
|
|
13
8
|
import { resolveColorHue } from './utils/resolveColorHue';
|
|
14
9
|
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
15
10
|
import { resolveWheelColor } from './utils/resolveWheelColor';
|
|
16
11
|
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
/***
|
|
12
|
+
const VIEWBOX = 1000;
|
|
13
|
+
const CENTER = VIEWBOX / 2;
|
|
14
|
+
const RADIUS = 480;
|
|
15
|
+
const SEGMENTS = 96;
|
|
16
|
+
const MAX_CHROMA = 0.2;
|
|
17
|
+
/*** Renders a size-owned, filled OKLCH wheel with controlled primary and harmony points. */
|
|
23
18
|
export const ColorWheel = withZoraThemeScope(ColorWheelInner);
|
|
24
|
-
/***
|
|
25
|
-
function ColorWheelInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, value, harmony = null,
|
|
19
|
+
/*** Maps pointer and keyboard input through one viewBox into the controlled selected colour. */
|
|
20
|
+
function ColorWheelInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, value, harmony = null, onChange, size = 340, testID, }) {
|
|
26
21
|
const { theme } = useZoraTheme();
|
|
27
22
|
const hue = resolveColorHue(value);
|
|
28
23
|
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
if (interactionPolicy
|
|
36
|
-
|
|
37
|
-
onChange({
|
|
38
|
-
color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),
|
|
39
|
-
harmony,
|
|
40
|
-
});
|
|
24
|
+
const primaryPoint = pointFor(hue, Math.min(1, chroma / MAX_CHROMA));
|
|
25
|
+
const harmonyPoints = harmony
|
|
26
|
+
? generateHarmonyRoleColors(value, harmony).colors.map((color) => pointFor(color.hueDegrees))
|
|
27
|
+
: [];
|
|
28
|
+
const gradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
|
|
29
|
+
const changeAt = (x, y) => {
|
|
30
|
+
if (interactionPolicy !== 'passive')
|
|
31
|
+
onChange({ color: resolveWheelColor(value, x, y, CENTER, RADIUS, MAX_CHROMA), harmony });
|
|
41
32
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
return (<View align="center" gap="s" testID={testID}>
|
|
47
|
-
<ColorWheelKeyboardProxy chroma={chroma} disabled={interactionPolicy === 'passive'} hue={hue} onChange={(nextHue, nextChroma) => onChange({
|
|
48
|
-
color: resolveOklchColor({ lightness: resolveWheelLightness(value), chroma: nextChroma }, nextHue),
|
|
49
|
-
harmony,
|
|
50
|
-
})}>
|
|
51
|
-
<ColorWheelPointerProxy disabled={interactionPolicy === 'passive'} height={WHEEL_SIZE} onChange={changeColorAt} width={WHEEL_SIZE}>
|
|
52
|
-
<Svg accessibilityLabel="Color wheel" height={WHEEL_SIZE} onResponderGrant={(event) => {
|
|
53
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
54
|
-
changeColorAt(locationX, locationY);
|
|
55
|
-
}} onResponderMove={(event) => {
|
|
56
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
57
|
-
changeColorAt(locationX, locationY);
|
|
58
|
-
}} onResponderRelease={(event) => {
|
|
59
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
60
|
-
changeColorAt(locationX, locationY);
|
|
61
|
-
}} onStartShouldSetResponder={() => interactionPolicy !== 'passive'} width={WHEEL_SIZE}>
|
|
62
|
-
<Defs>
|
|
63
|
-
{resolveWheelSegments().map((segment) => (<RadialGradient cx={WHEEL_CENTER} cy={WHEEL_CENTER} id={`${wheelGradientId}-${segment.hue}`} key={segment.hue} r={WHEEL_RADIUS}>
|
|
64
|
-
<Stop offset="0" stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)}/>
|
|
65
|
-
<Stop offset="1" stopColor={segment.color}/>
|
|
66
|
-
</RadialGradient>))}
|
|
67
|
-
</Defs>
|
|
68
|
-
{resolveWheelSegments().map((segment) => (<Path d={segment.path} fill={`url(#${wheelGradientId}-${segment.hue})`} key={segment.hue}/>))}
|
|
69
|
-
{harmony === 'triadic' && harmonyPoints.length === 3 ? (<Polygon fill="none" points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')} stroke={theme.semantics.content.default} strokeWidth={2}/>) : (harmonyLines)}
|
|
70
|
-
{harmonyPoints.map((point) => (<Circle cx={point.x} cy={point.y} fill={theme.semantics.content.default} key={`${point.x}-${point.y}`} r={5}/>))}
|
|
71
|
-
<Circle cx={selectedPoint.x} cy={selectedPoint.y} fill="none" r={9} stroke={theme.semantics.content.default} strokeWidth={3}/>
|
|
72
|
-
</Svg>
|
|
73
|
-
</ColorWheelPointerProxy>
|
|
74
|
-
</ColorWheelKeyboardProxy>
|
|
75
|
-
<ColorLightnessSlider chroma={chroma} disabled={interactionPolicy === 'passive'} hue={hue} lightness={lightness} onChange={changeLightness} selectionBorderColor={theme.semantics.content.default}/>
|
|
76
|
-
<ColorHexField disabled={interactionPolicy === 'passive'} key={value} onChange={(color) => onChange({ color, harmony })} value={value}/>
|
|
77
|
-
{harmonies ? (<View direction="row" gap="xs" wrap="wrap">
|
|
78
|
-
<Button disabled={interactionPolicy === 'passive'} onPress={() => onChange({ color: value, harmony: null })} variant={harmony === null ? 'solid' : 'outline'}>
|
|
79
|
-
None
|
|
80
|
-
</Button>
|
|
81
|
-
{harmonies.map((candidate) => (<Button key={candidate} disabled={interactionPolicy === 'passive'} onPress={() => onChange({ color: value, harmony: candidate })} variant={harmony === candidate ? 'solid' : 'outline'}>
|
|
82
|
-
{candidate}
|
|
83
|
-
</Button>))}
|
|
84
|
-
</View>) : null}
|
|
85
|
-
</View>);
|
|
86
|
-
}
|
|
87
|
-
/*** Renders a continuous OKLCH lightness track without adding a second color persistence model. */
|
|
88
|
-
function ColorLightnessSlider({ chroma, disabled, hue, lightness, onChange, selectionBorderColor, }) {
|
|
89
|
-
const changeAt = (locationX) => {
|
|
90
|
-
if (!disabled)
|
|
91
|
-
onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));
|
|
92
|
-
};
|
|
93
|
-
return (<View gap="xxs" width={WHEEL_SIZE}>
|
|
94
|
-
<View direction="row" justify="space-between">
|
|
95
|
-
<Text variant="label">Lightness</Text>
|
|
96
|
-
<Text variant="label">{`${Math.round(lightness * 100)}%`}</Text>
|
|
97
|
-
</View>
|
|
98
|
-
<ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={WHEEL_SIZE}>
|
|
99
|
-
<Svg accessibilityLabel="Color lightness" height={36} width={WHEEL_SIZE}>
|
|
33
|
+
return (<ColorWheelKeyboardProxy chroma={chroma} disabled={interactionPolicy === 'passive'} hue={hue} onChange={(nextHue, nextChroma) => onChange({ color: resolveOklchColor({ chroma: nextChroma, lightness }, nextHue), harmony })}>
|
|
34
|
+
<ColorWheelPointerProxy disabled={interactionPolicy === 'passive'} height={VIEWBOX} onChange={changeAt} width={VIEWBOX}>
|
|
35
|
+
<Svg accessibilityLabel="Color wheel" height={size} onResponderGrant={(event) => changeAt((event.nativeEvent.locationX / size) * VIEWBOX, (event.nativeEvent.locationY / size) * VIEWBOX)} onResponderMove={(event) => changeAt((event.nativeEvent.locationX / size) * VIEWBOX, (event.nativeEvent.locationY / size) * VIEWBOX)} onResponderRelease={(event) => changeAt((event.nativeEvent.locationX / size) * VIEWBOX, (event.nativeEvent.locationY / size) * VIEWBOX)} onStartShouldSetResponder={() => interactionPolicy !== 'passive'} testID={testID} viewBox={`0 0 ${VIEWBOX} ${VIEWBOX}`} width={size}>
|
|
100
36
|
<Defs>
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
37
|
+
{segments().map((segment) => (<RadialGradient cx={CENTER} cy={CENTER} id={`${gradientId}-${segment.hue}`} key={segment.hue} r={RADIUS}>
|
|
38
|
+
<Stop offset="0" stopColor={resolveOklchColor({ chroma: 0, lightness: 0.72 }, segment.hue)}/>
|
|
39
|
+
<Stop offset="1" stopColor={segment.color}/>
|
|
40
|
+
</RadialGradient>))}
|
|
105
41
|
</Defs>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
42
|
+
{segments().map((segment) => (<Path d={segment.path} fill={`url(#${gradientId}-${segment.hue})`} key={segment.hue}/>))}
|
|
43
|
+
{harmonyPoints.length === 3 ? (<Polygon fill="none" points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')} stroke={theme.semantics.content.default} strokeWidth={6}/>) : (linesFor(harmonyPoints, primaryPoint, theme.semantics.content.default))}
|
|
44
|
+
{harmonyPoints.map((point) => (<Circle cx={point.x} cy={point.y} fill={theme.semantics.content.default} key={`${point.x}-${point.y}`} r={26}/>))}
|
|
45
|
+
<Circle cx={primaryPoint.x} cy={primaryPoint.y} fill="none" r={36} stroke="white" strokeWidth={12}/>
|
|
46
|
+
<Circle cx={primaryPoint.x} cy={primaryPoint.y} fill="none" r={42} stroke={theme.semantics.content.default} strokeWidth={6}/>
|
|
109
47
|
</Svg>
|
|
110
|
-
</
|
|
111
|
-
</
|
|
48
|
+
</ColorWheelPointerProxy>
|
|
49
|
+
</ColorWheelKeyboardProxy>);
|
|
112
50
|
}
|
|
113
|
-
/***
|
|
114
|
-
function
|
|
115
|
-
return Array.from({ length:
|
|
116
|
-
const hue = (index * 360) /
|
|
51
|
+
/*** Creates continuous-looking radial hue segments for the wheel viewBox. */
|
|
52
|
+
function segments() {
|
|
53
|
+
return Array.from({ length: SEGMENTS }, (_, index) => {
|
|
54
|
+
const hue = (index * 360) / SEGMENTS;
|
|
117
55
|
return {
|
|
118
|
-
color: resolveOklchColor({ lightness: 0.65
|
|
56
|
+
color: resolveOklchColor({ chroma: MAX_CHROMA, lightness: 0.65 }, hue),
|
|
119
57
|
hue,
|
|
120
|
-
path:
|
|
58
|
+
path: segmentPath(hue, hue + 360 / SEGMENTS),
|
|
121
59
|
};
|
|
122
60
|
});
|
|
123
61
|
}
|
|
124
|
-
/***
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
return `M ${
|
|
62
|
+
/*** Describes one filled wheel segment in the stable coordinate system. */
|
|
63
|
+
function segmentPath(start, end) {
|
|
64
|
+
const startPoint = pointFor(start);
|
|
65
|
+
const endPoint = pointFor(end);
|
|
66
|
+
return `M ${CENTER} ${CENTER} L ${startPoint.x} ${startPoint.y} A ${RADIUS} ${RADIUS} 0 0 1 ${endPoint.x} ${endPoint.y} Z`;
|
|
129
67
|
}
|
|
130
|
-
/***
|
|
131
|
-
function
|
|
68
|
+
/*** Projects an OKLCH hue and chroma ratio into the wheel coordinate system. */
|
|
69
|
+
function pointFor(hue, ratio = 1) {
|
|
132
70
|
const radians = ((hue - 90) * Math.PI) / 180;
|
|
133
71
|
return {
|
|
134
|
-
x:
|
|
135
|
-
y:
|
|
72
|
+
x: CENTER + RADIUS * ratio * Math.cos(radians),
|
|
73
|
+
y: CENTER + RADIUS * ratio * Math.sin(radians),
|
|
136
74
|
};
|
|
137
75
|
}
|
|
138
|
-
/***
|
|
139
|
-
function
|
|
76
|
+
/*** Connects derived harmony points behind their corresponding knobs. */
|
|
77
|
+
function linesFor(points, primary, stroke) {
|
|
140
78
|
return points.slice(1).reduce(({ lines, previous }, point) => ({
|
|
141
79
|
lines: [
|
|
142
80
|
...lines,
|
|
143
|
-
<Line key={`${previous.x}-${previous.y}-${point.x}-${point.y}`} stroke={stroke} strokeWidth={
|
|
81
|
+
<Line key={`${previous.x}-${previous.y}-${point.x}-${point.y}`} stroke={stroke} strokeWidth={6} x1={previous.x} x2={point.x} y1={previous.y} y2={point.y}/>,
|
|
144
82
|
],
|
|
145
83
|
previous: point,
|
|
146
|
-
}), { lines: [], previous: points.at(0) ??
|
|
147
|
-
}
|
|
148
|
-
/*** Read the selected color's lightness for wheel-only hue and chroma changes. */
|
|
149
|
-
function resolveWheelLightness(color) {
|
|
150
|
-
const { lightness } = resolveWheelColorComponents(color);
|
|
151
|
-
return lightness;
|
|
84
|
+
}), { lines: [], previous: points.at(0) ?? primary }).lines;
|
|
152
85
|
}
|
|
153
86
|
//# sourceMappingURL=ColorWheel.js.map
|