@ankhorage/zora 27.3.9 → 27.4.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 +1 -1
- package/dist/features/color/ColorHueScale.d.ts +4 -0
- package/dist/features/color/ColorHueScale.d.ts.map +1 -0
- package/dist/features/color/ColorHueScale.js +22 -0
- package/dist/features/color/ColorHueScale.js.map +1 -0
- package/dist/features/color/ColorPicker.d.ts +5 -0
- package/dist/features/color/ColorPicker.d.ts.map +1 -0
- package/dist/features/color/ColorPicker.js +48 -0
- package/dist/features/color/ColorPicker.js.map +1 -0
- package/dist/features/color/ColorTone.d.ts +5 -0
- package/dist/features/color/ColorTone.d.ts.map +1 -0
- package/dist/features/color/ColorTone.js +65 -0
- package/dist/features/color/ColorTone.js.map +1 -0
- package/dist/features/color/ColorWheel.d.ts +5 -0
- package/dist/features/color/ColorWheel.d.ts.map +1 -0
- package/dist/features/color/ColorWheel.js +125 -0
- package/dist/features/color/ColorWheel.js.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.d.ts +10 -0
- package/dist/features/color/ColorWheelKeyboardProxy.d.ts.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.js +2 -0
- package/dist/features/color/ColorWheelKeyboardProxy.js.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.d.ts +4 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.js +17 -0
- package/dist/features/color/ColorWheelKeyboardProxy.native.js.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.d.ts +5 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.js +29 -0
- package/dist/features/color/ColorWheelKeyboardProxy.web.js.map +1 -0
- package/dist/features/color/public.d.ts +6 -0
- package/dist/features/color/public.d.ts.map +1 -0
- package/dist/features/color/public.js +5 -0
- package/dist/features/color/public.js.map +1 -0
- package/dist/features/color/utils/resolveColorAtHue.d.ts +4 -0
- package/dist/features/color/utils/resolveColorAtHue.d.ts.map +1 -0
- package/dist/features/color/utils/resolveColorAtHue.js +12 -0
- package/dist/features/color/utils/resolveColorAtHue.js.map +1 -0
- package/dist/features/color/utils/resolveColorHue.d.ts +4 -0
- package/dist/features/color/utils/resolveColorHue.d.ts.map +1 -0
- package/dist/features/color/utils/resolveColorHue.js +8 -0
- package/dist/features/color/utils/resolveColorHue.js.map +1 -0
- package/dist/features/color/utils/resolveOklchColor.d.ts +5 -0
- package/dist/features/color/utils/resolveOklchColor.d.ts.map +1 -0
- package/dist/features/color/utils/resolveOklchColor.js +10 -0
- package/dist/features/color/utils/resolveOklchColor.js.map +1 -0
- package/dist/features/color/utils/resolveWheelColor.d.ts +4 -0
- package/dist/features/color/utils/resolveWheelColor.d.ts.map +1 -0
- package/dist/features/color/utils/resolveWheelColor.js +17 -0
- package/dist/features/color/utils/resolveWheelColor.js.map +1 -0
- package/dist/features/color/utils/resolveWheelColorComponents.d.ts +7 -0
- package/dist/features/color/utils/resolveWheelColorComponents.d.ts.map +1 -0
- package/dist/features/color/utils/resolveWheelColorComponents.js +11 -0
- package/dist/features/color/utils/resolveWheelColorComponents.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/color.d.ts +70 -0
- package/dist/types/color.d.ts.map +1 -0
- package/dist/types/color.js +2 -0
- package/dist/types/color.js.map +1 -0
- package/package.json +3 -1
- package/src/audit.test.ts +3 -3
- package/src/features/color/ColorHueScale.tsx +57 -0
- package/src/features/color/ColorPicker.tsx +105 -0
- package/src/features/color/ColorTone.tsx +137 -0
- package/src/features/color/ColorWheel.tsx +251 -0
- package/src/features/color/ColorWheelKeyboardProxy.native.tsx +34 -0
- package/src/features/color/ColorWheelKeyboardProxy.tsx +11 -0
- package/src/features/color/ColorWheelKeyboardProxy.web.tsx +47 -0
- package/src/features/color/public.ts +17 -0
- package/src/features/color/utils/colorMath.test.ts +37 -0
- package/src/features/color/utils/resolveColorAtHue.ts +14 -0
- package/src/features/color/utils/resolveColorHue.ts +10 -0
- package/src/features/color/utils/resolveOklchColor.ts +13 -0
- package/src/features/color/utils/resolveWheelColor.ts +28 -0
- package/src/features/color/utils/resolveWheelColorComponents.ts +16 -0
- package/src/index.ts +14 -0
- package/src/types/color.ts +75 -0
- package/src/webPackageExports.test.ts +15 -0
- package/web-dist/chunks/{Accordion-5w8chhxm.js → Accordion-001ymezm.js} +3 -63
- package/web-dist/chunks/{Accordion-2d5jdxeg.js → Accordion-01s50nga.js} +2 -2
- package/web-dist/chunks/{Accordion-dhnd347t.js → Accordion-09jkcm1x.js} +695 -4591
- package/web-dist/chunks/Accordion-0z2t95zw.js +548 -0
- package/web-dist/chunks/{Accordion-z1k4wg10.js → Accordion-120nmpbe.js} +3 -3
- package/web-dist/chunks/{Accordion-zrn4dy6s.js → Accordion-401452az.js} +6 -6
- package/web-dist/chunks/{Accordion-yy6qy5y2.js → Accordion-44bcsg35.js} +6 -6
- package/web-dist/chunks/{Accordion-5hvq2r84.js → Accordion-49m38edd.js} +4 -4
- package/web-dist/chunks/{Accordion-x4bpna1q.js → Accordion-49mzcav8.js} +4 -4
- package/web-dist/chunks/{Accordion-h3r90b65.js → Accordion-52a3dpsm.js} +4 -4
- package/web-dist/chunks/{Accordion-bhr3r525.js → Accordion-549akrjn.js} +4 -4
- package/web-dist/chunks/{Accordion-7atd70rg.js → Accordion-64px84rh.js} +10 -10
- package/web-dist/chunks/{Accordion-enracgev.js → Accordion-6ec9bfd8.js} +4 -4
- package/web-dist/chunks/Accordion-6jb7b67v.js +66 -0
- package/web-dist/chunks/{Accordion-5gbd0wzf.js → Accordion-8ac6dkcs.js} +1 -1
- package/web-dist/chunks/{Accordion-w18jbs39.js → Accordion-8q7hn9aj.js} +1 -1
- package/web-dist/chunks/{Accordion-825x4t0z.js → Accordion-8vcs6nz6.js} +1 -1
- package/web-dist/chunks/{Accordion-qqv9mak2.js → Accordion-9d3rd7ne.js} +1 -1
- package/web-dist/chunks/{Accordion-zfsnh03k.js → Accordion-9hcbf56f.js} +2 -2
- package/web-dist/chunks/{Accordion-s6n61fx6.js → Accordion-9n062we9.js} +2 -2
- package/web-dist/chunks/{Accordion-rrmy3736.js → Accordion-a6xxvydp.js} +2 -2
- package/web-dist/chunks/{Accordion-dv281jw0.js → Accordion-b4yr6yq3.js} +2 -2
- package/web-dist/chunks/{Accordion-c1x8bqnr.js → Accordion-b8t2gq8g.js} +9 -9
- package/web-dist/chunks/{Accordion-25xjvp3t.js → Accordion-dk40hsc0.js} +2 -2
- package/web-dist/chunks/{Accordion-1dr6ktbf.js → Accordion-dxhs3xwx.js} +7 -7
- package/web-dist/chunks/{Accordion-q5swmcwm.js → Accordion-e1krqvc4.js} +3 -3
- package/web-dist/chunks/{Accordion-b7jgtnvm.js → Accordion-ew2cebyd.js} +3 -3
- package/web-dist/chunks/{Accordion-j3twwxyt.js → Accordion-g9m813fh.js} +2 -2
- package/web-dist/chunks/{Accordion-b36h9a7g.js → Accordion-gysa24fk.js} +1 -1
- package/web-dist/chunks/{Accordion-2xdwc579.js → Accordion-h21ah8w3.js} +6 -6
- package/web-dist/chunks/{Accordion-2rtkfs9t.js → Accordion-hfb983jm.js} +3 -3
- package/web-dist/chunks/{Accordion-5p0pc8wp.js → Accordion-j61qh3rb.js} +2 -2
- package/web-dist/chunks/{Accordion-tf459afq.js → Accordion-kexh248h.js} +2 -2
- package/web-dist/chunks/{Accordion-gbe84kyw.js → Accordion-kx6695j5.js} +2 -2
- package/web-dist/chunks/{Accordion-w42y21pt.js → Accordion-mrhkw8n6.js} +1 -1
- package/web-dist/chunks/{Accordion-vyr0wyp9.js → Accordion-ng9pnz9r.js} +9 -9
- package/web-dist/chunks/{Accordion-x3shxr1k.js → Accordion-p43psvv8.js} +6 -6
- package/web-dist/chunks/{Accordion-6y9ac3ad.js → Accordion-rcs75kj4.js} +3 -3
- package/web-dist/chunks/Accordion-rj3ayvn5.js +3925 -0
- package/web-dist/chunks/{Accordion-4d12nnq0.js → Accordion-sheqvs8c.js} +11 -11
- package/web-dist/chunks/{Accordion-j77vvja1.js → Accordion-ss57gqjb.js} +5 -5
- package/web-dist/chunks/{Accordion-hsnh2dgt.js → Accordion-sttjd4rs.js} +7 -7
- package/web-dist/chunks/{Accordion-n95zwem8.js → Accordion-sz17szqm.js} +8 -8
- package/web-dist/chunks/{Accordion-0ecj6p6b.js → Accordion-tchccn9f.js} +5 -5
- package/web-dist/chunks/{Accordion-4d4xahgg.js → Accordion-tpd1vvy9.js} +77 -74
- package/web-dist/chunks/{Accordion-bm75sm6d.js → Accordion-vzgpdtr2.js} +1 -1
- package/web-dist/chunks/{Accordion-4hthnyjj.js → Accordion-wdefxczv.js} +9 -9
- package/web-dist/chunks/{Accordion-2pq8kbaq.js → Accordion-wtqev4qa.js} +7 -7
- package/web-dist/chunks/{Accordion-5zx8d19h.js → Accordion-xfdp8w37.js} +13 -13
- package/web-dist/chunks/{Accordion-st7rj6hc.js → Accordion-xs9aspze.js} +4 -4
- package/web-dist/chunks/{Accordion-nf16vayy.js → Accordion-z4m47w0b.js} +2 -2
- package/web-dist/chunks/{Accordion-x2d68rrj.js → Accordion-z5kr43w5.js} +4 -4
- package/web-dist/chunks/{Accordion-nks69epp.js → Accordion-z8c7y6d8.js} +5 -5
- 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 +16 -15
- package/web-dist/components/app-header/AppHeader.js +16 -15
- package/web-dist/components/app-shell/AppShell.js +4 -4
- package/web-dist/components/auth-screen/AuthScreen.js +21 -19
- 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 +19 -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 +15 -14
- package/web-dist/components/button/Button.js +11 -10
- package/web-dist/components/button-group/ButtonGroup.js +11 -10
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +19 -18
- package/web-dist/components/card/Card.js +18 -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/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 +20 -19
- package/web-dist/components/color-hue-scale/ColorHueScale.d.ts +6 -0
- package/web-dist/components/color-hue-scale/ColorHueScale.js +33 -0
- package/web-dist/components/color-hue-scale/index.d.ts +1 -0
- package/web-dist/components/color-hue-scale/index.js +2 -0
- package/web-dist/components/color-picker/ColorPicker.d.ts +6 -0
- package/web-dist/components/color-picker/ColorPicker.js +33 -0
- package/web-dist/components/color-picker/index.d.ts +1 -0
- package/web-dist/components/color-picker/index.js +2 -0
- package/web-dist/components/color-tone/ColorTone.d.ts +6 -0
- package/web-dist/components/color-tone/ColorTone.js +33 -0
- package/web-dist/components/color-tone/index.d.ts +1 -0
- package/web-dist/components/color-tone/index.js +2 -0
- package/web-dist/components/color-wheel/ColorWheel.d.ts +6 -0
- package/web-dist/components/color-wheel/ColorWheel.js +33 -0
- package/web-dist/components/color-wheel/index.d.ts +1 -0
- package/web-dist/components/color-wheel/index.js +2 -0
- package/web-dist/components/content-rail/ContentRail.js +14 -13
- package/web-dist/components/data-table/DataTable.js +25 -24
- package/web-dist/components/date-picker/DatePicker.js +16 -15
- 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 +19 -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 +21 -19
- package/web-dist/components/form/Form.js +15 -14
- package/web-dist/components/form-actions/FormActions.js +15 -14
- package/web-dist/components/form-error/FormError.js +15 -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 +20 -19
- package/web-dist/components/icon/Icon.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +11 -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/matrix-grid/MatrixGrid.js +4 -4
- package/web-dist/components/media-card/MediaCard.js +18 -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 +18 -17
- package/web-dist/components/missing-element/MissingElement.js +9 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +21 -19
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +21 -19
- package/web-dist/components/opening-book/OpeningBook.js +4 -4
- package/web-dist/components/otp-form/OtpForm.js +21 -19
- package/web-dist/components/pagination/Pagination.js +14 -13
- package/web-dist/components/palette-item/PaletteItem.js +18 -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 +18 -17
- package/web-dist/components/product-card/ProductCard.js +18 -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 +21 -20
- package/web-dist/components/scan-overlay/ScanOverlay.js +19 -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 +14 -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 +14 -13
- 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 +21 -19
- package/web-dist/components/sign-up-form/SignUpForm.js +21 -19
- package/web-dist/components/skeleton/Skeleton.js +21 -20
- package/web-dist/components/skeleton-card/SkeletonCard.js +21 -20
- package/web-dist/components/skeleton-list/SkeletonList.js +21 -20
- package/web-dist/components/skeleton-text/SkeletonText.js +21 -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 +14 -12
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +13 -12
- package/web-dist/components/time-picker/TimePicker.js +16 -15
- package/web-dist/components/timeline/Timeline.js +9 -9
- 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 +18 -17
- package/web-dist/components/tree-item/TreeItem.js +18 -17
- package/web-dist/components/uploader/Uploader.js +23 -22
- package/web-dist/components/view/View.js +4 -4
- package/web-dist/manifest.json +1466 -1264
- package/web-dist/runtime/ZoraProvider.js +6 -6
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { generateHarmonyRoleColors, type HexColor, isHexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { Button, TextInput } from '@ankhorage/surface';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Circle, Line, Path, Polygon, Svg } from 'react-native-svg';
|
|
5
|
+
|
|
6
|
+
import type { ColorWheelProps } from '../../types/color';
|
|
7
|
+
import { View } from '../layout/public';
|
|
8
|
+
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
9
|
+
import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
|
|
10
|
+
import { resolveColorHue } from './utils/resolveColorHue';
|
|
11
|
+
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
12
|
+
import { resolveWheelColor } from './utils/resolveWheelColor';
|
|
13
|
+
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
14
|
+
|
|
15
|
+
const WHEEL_SIZE = 240;
|
|
16
|
+
const WHEEL_CENTER = WHEEL_SIZE / 2;
|
|
17
|
+
const WHEEL_RADIUS = 104;
|
|
18
|
+
const WHEEL_SEGMENT_COUNT = 36;
|
|
19
|
+
const WHEEL_MAX_CHROMA = 0.2;
|
|
20
|
+
|
|
21
|
+
/*** Selects an OKLCH hue and optionally visualizes the existing color-theory harmony. */
|
|
22
|
+
export const ColorWheel = withZoraThemeScope(ColorWheelInner);
|
|
23
|
+
|
|
24
|
+
/*** Renders a directly manipulable hue wheel and harmony controls without returning derived colors. */
|
|
25
|
+
function ColorWheelInner({
|
|
26
|
+
themeId: _themeId,
|
|
27
|
+
mode: _mode,
|
|
28
|
+
inverted: _inverted,
|
|
29
|
+
interactionPolicy,
|
|
30
|
+
value,
|
|
31
|
+
harmony = null,
|
|
32
|
+
harmonies,
|
|
33
|
+
onChange,
|
|
34
|
+
testID,
|
|
35
|
+
}: ColorWheelProps) {
|
|
36
|
+
const hue = resolveColorHue(value);
|
|
37
|
+
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
38
|
+
const harmonyColors = harmony ? generateHarmonyRoleColors(value, harmony).colors : [];
|
|
39
|
+
const selectedPoint = resolveWheelPoint(hue, Math.min(1, chroma / WHEEL_MAX_CHROMA));
|
|
40
|
+
const harmonyPoints = harmonyColors.map((color) => resolveWheelPoint(color.hueDegrees));
|
|
41
|
+
const harmonyLines = resolveHarmonyLines(harmonyPoints, selectedPoint);
|
|
42
|
+
const changeColorAt = (x: number, y: number) => {
|
|
43
|
+
if (interactionPolicy === 'passive') return;
|
|
44
|
+
onChange({
|
|
45
|
+
color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),
|
|
46
|
+
harmony,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const changeLightness = (offset: number) =>
|
|
50
|
+
onChange({
|
|
51
|
+
color: resolveOklchColor(
|
|
52
|
+
{ chroma, lightness: Math.max(0, Math.min(1, lightness + offset)) },
|
|
53
|
+
hue,
|
|
54
|
+
),
|
|
55
|
+
harmony,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View align="center" gap="sm" testID={testID}>
|
|
60
|
+
<ColorWheelKeyboardProxy
|
|
61
|
+
chroma={chroma}
|
|
62
|
+
disabled={interactionPolicy === 'passive'}
|
|
63
|
+
hue={hue}
|
|
64
|
+
onChange={(nextHue, nextChroma) =>
|
|
65
|
+
onChange({
|
|
66
|
+
color: resolveOklchColor(
|
|
67
|
+
{ lightness: resolveWheelLightness(value), chroma: nextChroma },
|
|
68
|
+
nextHue,
|
|
69
|
+
),
|
|
70
|
+
harmony,
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
>
|
|
74
|
+
<Svg
|
|
75
|
+
accessibilityLabel="Color wheel"
|
|
76
|
+
height={WHEEL_SIZE}
|
|
77
|
+
onResponderGrant={(event) => {
|
|
78
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
79
|
+
changeColorAt(locationX, locationY);
|
|
80
|
+
}}
|
|
81
|
+
onResponderMove={(event) => {
|
|
82
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
83
|
+
changeColorAt(locationX, locationY);
|
|
84
|
+
}}
|
|
85
|
+
onStartShouldSetResponder={() => interactionPolicy !== 'passive'}
|
|
86
|
+
width={WHEEL_SIZE}
|
|
87
|
+
>
|
|
88
|
+
{resolveWheelSegments().map((segment) => (
|
|
89
|
+
<Path d={segment.path} fill={segment.color} key={segment.hue} />
|
|
90
|
+
))}
|
|
91
|
+
{harmony === 'triadic' && harmonyPoints.length === 3 ? (
|
|
92
|
+
<Polygon
|
|
93
|
+
fill="none"
|
|
94
|
+
points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}
|
|
95
|
+
stroke="currentColor"
|
|
96
|
+
strokeWidth={2}
|
|
97
|
+
/>
|
|
98
|
+
) : (
|
|
99
|
+
harmonyLines
|
|
100
|
+
)}
|
|
101
|
+
{harmonyPoints.map((point) => (
|
|
102
|
+
<Circle
|
|
103
|
+
cx={point.x}
|
|
104
|
+
cy={point.y}
|
|
105
|
+
fill="currentColor"
|
|
106
|
+
key={`${point.x}-${point.y}`}
|
|
107
|
+
r={5}
|
|
108
|
+
/>
|
|
109
|
+
))}
|
|
110
|
+
<Circle
|
|
111
|
+
cx={selectedPoint.x}
|
|
112
|
+
cy={selectedPoint.y}
|
|
113
|
+
fill="none"
|
|
114
|
+
r={9}
|
|
115
|
+
stroke="currentColor"
|
|
116
|
+
strokeWidth={3}
|
|
117
|
+
/>
|
|
118
|
+
</Svg>
|
|
119
|
+
</ColorWheelKeyboardProxy>
|
|
120
|
+
<View direction="row" gap="xs" wrap="wrap">
|
|
121
|
+
<Button
|
|
122
|
+
disabled={interactionPolicy === 'passive' || lightness <= 0}
|
|
123
|
+
onPress={() => changeLightness(-0.05)}
|
|
124
|
+
>
|
|
125
|
+
Lightness -
|
|
126
|
+
</Button>
|
|
127
|
+
<Button
|
|
128
|
+
disabled={interactionPolicy === 'passive' || lightness >= 1}
|
|
129
|
+
onPress={() => changeLightness(0.05)}
|
|
130
|
+
>
|
|
131
|
+
Lightness +
|
|
132
|
+
</Button>
|
|
133
|
+
</View>
|
|
134
|
+
<ColorHexInput
|
|
135
|
+
disabled={interactionPolicy === 'passive'}
|
|
136
|
+
harmony={harmony}
|
|
137
|
+
key={value}
|
|
138
|
+
onChange={onChange}
|
|
139
|
+
value={value}
|
|
140
|
+
/>
|
|
141
|
+
{harmonies ? (
|
|
142
|
+
<View direction="row" gap="xs" wrap="wrap">
|
|
143
|
+
<Button
|
|
144
|
+
disabled={interactionPolicy === 'passive'}
|
|
145
|
+
onPress={() => onChange({ color: value, harmony: null })}
|
|
146
|
+
variant={harmony === null ? 'solid' : 'outline'}
|
|
147
|
+
>
|
|
148
|
+
None
|
|
149
|
+
</Button>
|
|
150
|
+
{harmonies.map((candidate) => (
|
|
151
|
+
<Button
|
|
152
|
+
key={candidate}
|
|
153
|
+
disabled={interactionPolicy === 'passive'}
|
|
154
|
+
onPress={() => onChange({ color: value, harmony: candidate })}
|
|
155
|
+
variant={harmony === candidate ? 'solid' : 'outline'}
|
|
156
|
+
>
|
|
157
|
+
{candidate}
|
|
158
|
+
</Button>
|
|
159
|
+
))}
|
|
160
|
+
</View>
|
|
161
|
+
) : null}
|
|
162
|
+
</View>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/*** Build the wheel's OKLCH segments from the existing conversion tool. */
|
|
167
|
+
function resolveWheelSegments(): readonly {
|
|
168
|
+
readonly color: HexColor;
|
|
169
|
+
readonly hue: number;
|
|
170
|
+
readonly path: string;
|
|
171
|
+
}[] {
|
|
172
|
+
return Array.from({ length: WHEEL_SEGMENT_COUNT }, (_, index) => {
|
|
173
|
+
const hue = (index * 360) / WHEEL_SEGMENT_COUNT;
|
|
174
|
+
return {
|
|
175
|
+
color: resolveOklchColor({ lightness: 0.65, chroma: WHEEL_MAX_CHROMA }, hue),
|
|
176
|
+
hue,
|
|
177
|
+
path: resolveSegmentPath(hue, hue + 360 / WHEEL_SEGMENT_COUNT),
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/*** Describe one wedge in the visual hue wheel. */
|
|
183
|
+
function resolveSegmentPath(startHue: number, endHue: number): string {
|
|
184
|
+
const start = resolveWheelPoint(startHue);
|
|
185
|
+
const end = resolveWheelPoint(endHue);
|
|
186
|
+
return `M ${WHEEL_CENTER} ${WHEEL_CENTER} L ${start.x} ${start.y} A ${WHEEL_RADIUS} ${WHEEL_RADIUS} 0 0 1 ${end.x} ${end.y} Z`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/*** Convert a hue degree to the corresponding visual wheel coordinate. */
|
|
190
|
+
function resolveWheelPoint(
|
|
191
|
+
hue: number,
|
|
192
|
+
radiusRatio = 1,
|
|
193
|
+
): { readonly x: number; readonly y: number } {
|
|
194
|
+
const radians = ((hue - 90) * Math.PI) / 180;
|
|
195
|
+
return {
|
|
196
|
+
x: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.cos(radians),
|
|
197
|
+
y: WHEEL_CENTER + WHEEL_RADIUS * radiusRatio * Math.sin(radians),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/*** Connect consecutive harmony points without dynamic collection indexing. */
|
|
202
|
+
function resolveHarmonyLines(
|
|
203
|
+
points: readonly { readonly x: number; readonly y: number }[],
|
|
204
|
+
selectedPoint: { readonly x: number; readonly y: number },
|
|
205
|
+
) {
|
|
206
|
+
return points.slice(1).reduce(
|
|
207
|
+
({ lines, previous }, point) => ({
|
|
208
|
+
lines: [
|
|
209
|
+
...lines,
|
|
210
|
+
<Line
|
|
211
|
+
key={`${previous.x}-${previous.y}-${point.x}-${point.y}`}
|
|
212
|
+
stroke="currentColor"
|
|
213
|
+
strokeWidth={2}
|
|
214
|
+
x1={previous.x}
|
|
215
|
+
x2={point.x}
|
|
216
|
+
y1={previous.y}
|
|
217
|
+
y2={point.y}
|
|
218
|
+
/>,
|
|
219
|
+
],
|
|
220
|
+
previous: point,
|
|
221
|
+
}),
|
|
222
|
+
{ lines: [] as React.ReactNode[], previous: points.at(0) ?? selectedPoint },
|
|
223
|
+
).lines;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/*** Read the selected color's lightness for wheel-only hue and chroma changes. */
|
|
227
|
+
function resolveWheelLightness(color: HexColor): number {
|
|
228
|
+
const { lightness } = resolveWheelColorComponents(color);
|
|
229
|
+
return lightness;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/*** Retains in-progress hexadecimal input while resetting for an externally controlled color. */
|
|
233
|
+
function ColorHexInput({
|
|
234
|
+
disabled,
|
|
235
|
+
harmony,
|
|
236
|
+
onChange,
|
|
237
|
+
value,
|
|
238
|
+
}: Pick<ColorWheelProps, 'harmony' | 'onChange' | 'value'> & { readonly disabled: boolean }) {
|
|
239
|
+
const [input, setInput] = React.useState<string>(value);
|
|
240
|
+
return (
|
|
241
|
+
<TextInput
|
|
242
|
+
accessibilityLabel="Color hex value"
|
|
243
|
+
disabled={disabled}
|
|
244
|
+
onChangeText={(nextValue) => {
|
|
245
|
+
setInput(nextValue);
|
|
246
|
+
if (isHexColor(nextValue)) onChange({ color: nextValue, harmony: harmony ?? null });
|
|
247
|
+
}}
|
|
248
|
+
value={input}
|
|
249
|
+
/>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { ColorWheelKeyboardProxyProps } from './ColorWheelKeyboardProxy';
|
|
4
|
+
|
|
5
|
+
/*** Exposes native accessibility increment and decrement actions for the controlled color wheel. */
|
|
6
|
+
export function ColorWheelKeyboardProxy({
|
|
7
|
+
children,
|
|
8
|
+
chroma,
|
|
9
|
+
disabled,
|
|
10
|
+
hue,
|
|
11
|
+
onChange,
|
|
12
|
+
}: ColorWheelKeyboardProxyProps) {
|
|
13
|
+
return (
|
|
14
|
+
<View
|
|
15
|
+
accessible
|
|
16
|
+
accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}
|
|
17
|
+
accessibilityLabel="Color wheel"
|
|
18
|
+
accessibilityRole="adjustable"
|
|
19
|
+
accessibilityState={{ disabled }}
|
|
20
|
+
accessibilityValue={{
|
|
21
|
+
max: 360,
|
|
22
|
+
min: 0,
|
|
23
|
+
now: Math.round(hue),
|
|
24
|
+
text: `Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`,
|
|
25
|
+
}}
|
|
26
|
+
onAccessibilityAction={(event) => {
|
|
27
|
+
if (disabled) return;
|
|
28
|
+
onChange(event.nativeEvent.actionName === 'increment' ? hue + 5 : hue - 5, chroma);
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
export { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy.native';
|
|
4
|
+
|
|
5
|
+
export interface ColorWheelKeyboardProxyProps {
|
|
6
|
+
readonly children: React.ReactNode;
|
|
7
|
+
readonly chroma: number;
|
|
8
|
+
readonly disabled: boolean;
|
|
9
|
+
readonly hue: number;
|
|
10
|
+
readonly onChange: (hue: number, chroma: number) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ColorWheelKeyboardProxyProps } from './ColorWheelKeyboardProxy';
|
|
4
|
+
|
|
5
|
+
/*** Bridges browser keyboard input to controlled OKLCH wheel hue and chroma changes. */
|
|
6
|
+
export function ColorWheelKeyboardProxy({
|
|
7
|
+
children,
|
|
8
|
+
chroma,
|
|
9
|
+
disabled,
|
|
10
|
+
hue,
|
|
11
|
+
onChange,
|
|
12
|
+
}: ColorWheelKeyboardProxyProps) {
|
|
13
|
+
return (
|
|
14
|
+
<div
|
|
15
|
+
aria-label={`Color wheel, hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`}
|
|
16
|
+
aria-valuemax={360}
|
|
17
|
+
aria-valuemin={0}
|
|
18
|
+
aria-valuenow={Math.round(hue)}
|
|
19
|
+
aria-valuetext={`Hue ${Math.round(hue)}, chroma ${chroma.toFixed(2)}`}
|
|
20
|
+
aria-disabled={disabled}
|
|
21
|
+
onKeyDown={(event) => {
|
|
22
|
+
const nextValue = resolveKeyboardWheelValue(event.key, hue, chroma);
|
|
23
|
+
if (!nextValue || disabled) return;
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
onChange(nextValue.hue, nextValue.chroma);
|
|
26
|
+
}}
|
|
27
|
+
role="slider"
|
|
28
|
+
tabIndex={disabled ? -1 : 0}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*** Resolve portable arrow keys into bounded color-wheel increments. */
|
|
36
|
+
function resolveKeyboardWheelValue(key: string, hue: number, chroma: number) {
|
|
37
|
+
if (key === 'ArrowLeft') return { chroma, hue: normalizeHue(hue - 5) };
|
|
38
|
+
if (key === 'ArrowRight') return { chroma, hue: normalizeHue(hue + 5) };
|
|
39
|
+
if (key === 'ArrowDown') return { chroma: Math.max(0, chroma - 0.02), hue };
|
|
40
|
+
if (key === 'ArrowUp') return { chroma: Math.min(0.2, chroma + 0.02), hue };
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*** Normalize keyboard hue increments to the slider's documented range. */
|
|
45
|
+
function normalizeHue(hue: number): number {
|
|
46
|
+
return hue < 0 ? hue + 360 : hue >= 360 ? hue - 360 : hue;
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
ColorHueScaleProps,
|
|
3
|
+
ColorPickerProps,
|
|
4
|
+
ColorPickerSelection,
|
|
5
|
+
ColorPickerTab,
|
|
6
|
+
ColorPickerValue,
|
|
7
|
+
ColorToneDefinition,
|
|
8
|
+
ColorToneProps,
|
|
9
|
+
ColorToneSelection,
|
|
10
|
+
ColorToneTarget,
|
|
11
|
+
ColorWheelProps,
|
|
12
|
+
ColorWheelSelection,
|
|
13
|
+
} from '../../types/color';
|
|
14
|
+
export { ColorHueScale } from './ColorHueScale';
|
|
15
|
+
export { ColorPicker } from './ColorPicker';
|
|
16
|
+
export { ColorTone } from './ColorTone';
|
|
17
|
+
export { ColorWheel } from './ColorWheel';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isHexColor, parseHexColorOrThrow } from '@ankhorage/color-theory';
|
|
2
|
+
import { expect, test } from 'bun:test';
|
|
3
|
+
|
|
4
|
+
import { resolveColorAtHue } from './resolveColorAtHue';
|
|
5
|
+
import { resolveColorHue } from './resolveColorHue';
|
|
6
|
+
import { resolveOklchColor } from './resolveOklchColor';
|
|
7
|
+
import { resolveWheelColor } from './resolveWheelColor';
|
|
8
|
+
import { resolveWheelColorComponents } from './resolveWheelColorComponents';
|
|
9
|
+
|
|
10
|
+
test('converts a consumer-provided OKLCH target without a ZORA tone catalog', () => {
|
|
11
|
+
const color = resolveOklchColor({ lightness: 0.53, chroma: 0.18 }, 280);
|
|
12
|
+
|
|
13
|
+
expect(isHexColor(color)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('preserves an editable hue through the published color-theory conversion boundary', () => {
|
|
17
|
+
const base = parseHexColorOrThrow('#2563eb');
|
|
18
|
+
const adjusted = resolveColorAtHue(base, 120);
|
|
19
|
+
|
|
20
|
+
expect(isHexColor(adjusted)).toBe(true);
|
|
21
|
+
expect(Math.abs(resolveColorHue(adjusted) - 120)).toBeLessThan(5);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('maps wheel radius to chroma while preserving a selected color lightness', () => {
|
|
25
|
+
const base = parseHexColorOrThrow('#2563eb');
|
|
26
|
+
const centerColor = resolveWheelColor(base, 120, 120, 120, 104, 0.2);
|
|
27
|
+
const edgeColor = resolveWheelColor(base, 120, 16, 120, 104, 0.2);
|
|
28
|
+
const baseValues = resolveWheelColorComponents(base);
|
|
29
|
+
const centerValues = resolveWheelColorComponents(centerColor);
|
|
30
|
+
const edgeValues = resolveWheelColorComponents(edgeColor);
|
|
31
|
+
|
|
32
|
+
expect(centerValues.chroma).toBeLessThan(0.01);
|
|
33
|
+
expect(edgeValues.chroma).toBeGreaterThan(centerValues.chroma);
|
|
34
|
+
expect(Math.abs(edgeValues.lightness - baseValues.lightness)).toBeLessThan(0.02);
|
|
35
|
+
const edgeHue = resolveColorHue(edgeColor);
|
|
36
|
+
expect(Math.min(edgeHue, 360 - edgeHue)).toBeLessThan(5);
|
|
37
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { parseHexColorOrThrow } from '@ankhorage/color-theory';
|
|
3
|
+
import { converter, formatHex } from '@ankhorage/color-theory/culori/fn';
|
|
4
|
+
|
|
5
|
+
const toOklch = converter('oklch');
|
|
6
|
+
|
|
7
|
+
/*** Preserve the selected color's lightness and chroma while changing its hue. */
|
|
8
|
+
export function resolveColorAtHue(color: HexColor, hue: number): HexColor {
|
|
9
|
+
const parsed = toOklch(color);
|
|
10
|
+
if (!parsed || typeof parsed.l !== 'number' || typeof parsed.c !== 'number') return color;
|
|
11
|
+
|
|
12
|
+
const formatted = formatHex({ mode: 'oklch', l: parsed.l, c: parsed.c, h: hue });
|
|
13
|
+
return formatted ? parseHexColorOrThrow(formatted) : color;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { converter } from '@ankhorage/color-theory/culori/fn';
|
|
3
|
+
|
|
4
|
+
const toOklch = converter('oklch');
|
|
5
|
+
|
|
6
|
+
/*** Read the editable hue from a selected hex color. */
|
|
7
|
+
export function resolveColorHue(color: HexColor): number {
|
|
8
|
+
const parsed = toOklch(color);
|
|
9
|
+
return typeof parsed?.h === 'number' ? parsed.h : 0;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { parseHexColorOrThrow } from '@ankhorage/color-theory';
|
|
3
|
+
import { formatHex } from '@ankhorage/color-theory/culori/fn';
|
|
4
|
+
|
|
5
|
+
import type { ColorToneTarget } from '../../../types/color';
|
|
6
|
+
|
|
7
|
+
/*** Resolve a valid hex color from a bounded OKLCH target without owning color theory policy. */
|
|
8
|
+
export function resolveOklchColor(target: ColorToneTarget, hue: number): HexColor {
|
|
9
|
+
const formatted = formatHex({ mode: 'oklch', l: target.lightness, c: target.chroma, h: hue });
|
|
10
|
+
if (!formatted)
|
|
11
|
+
throw new Error('The supplied OKLCH target cannot be represented as a hex color.');
|
|
12
|
+
return parseHexColorOrThrow(formatted);
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
|
|
3
|
+
import { resolveOklchColor } from './resolveOklchColor';
|
|
4
|
+
import { resolveWheelColorComponents } from './resolveWheelColorComponents';
|
|
5
|
+
|
|
6
|
+
/*** Resolve a wheel coordinate into a bounded OKLCH color while retaining the selected lightness. */
|
|
7
|
+
export function resolveWheelColor(
|
|
8
|
+
color: HexColor,
|
|
9
|
+
x: number,
|
|
10
|
+
y: number,
|
|
11
|
+
center: number,
|
|
12
|
+
radius: number,
|
|
13
|
+
maxChroma: number,
|
|
14
|
+
): HexColor {
|
|
15
|
+
const { lightness } = resolveWheelColorComponents(color);
|
|
16
|
+
|
|
17
|
+
const deltaX = x - center;
|
|
18
|
+
const deltaY = y - center;
|
|
19
|
+
const distance = Math.min(Math.hypot(deltaX, deltaY), radius);
|
|
20
|
+
const hue = normalizeHue((Math.atan2(deltaY, deltaX) * 180) / Math.PI + 90);
|
|
21
|
+
const chroma = (distance / radius) * maxChroma;
|
|
22
|
+
return resolveOklchColor({ lightness, chroma }, hue);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/*** Normalize an angular wheel coordinate to the OKLCH hue range. */
|
|
26
|
+
function normalizeHue(hue: number): number {
|
|
27
|
+
return hue < 0 ? hue + 360 : hue;
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { converter } from '@ankhorage/color-theory/culori/fn';
|
|
3
|
+
|
|
4
|
+
const toOklch = converter('oklch');
|
|
5
|
+
|
|
6
|
+
/*** Read the selected OKLCH values used by wheel keyboard and accessibility controls. */
|
|
7
|
+
export function resolveWheelColorComponents(color: HexColor): {
|
|
8
|
+
readonly chroma: number;
|
|
9
|
+
readonly lightness: number;
|
|
10
|
+
} {
|
|
11
|
+
const parsed = toOklch(color);
|
|
12
|
+
return {
|
|
13
|
+
chroma: typeof parsed?.c === 'number' ? parsed.c : 0,
|
|
14
|
+
lightness: typeof parsed?.l === 'number' ? parsed.l : 0.65,
|
|
15
|
+
};
|
|
16
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,20 @@ export {
|
|
|
14
14
|
AuthoringSelectionAdapter,
|
|
15
15
|
ThemeEditorAdapter,
|
|
16
16
|
} from './authoring';
|
|
17
|
+
export type {
|
|
18
|
+
ColorHueScaleProps,
|
|
19
|
+
ColorPickerProps,
|
|
20
|
+
ColorPickerSelection,
|
|
21
|
+
ColorPickerTab,
|
|
22
|
+
ColorPickerValue,
|
|
23
|
+
ColorToneDefinition,
|
|
24
|
+
ColorToneProps,
|
|
25
|
+
ColorToneSelection,
|
|
26
|
+
ColorToneTarget,
|
|
27
|
+
ColorWheelProps,
|
|
28
|
+
ColorWheelSelection,
|
|
29
|
+
} from './features/color/public';
|
|
30
|
+
export { ColorHueScale, ColorPicker, ColorTone, ColorWheel } from './features/color/public';
|
|
17
31
|
export type {
|
|
18
32
|
ReaderColorScheme,
|
|
19
33
|
ReaderDocumentFormat,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ColorHarmony, HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
|
|
3
|
+
import type { ZoraBaseProps } from './base';
|
|
4
|
+
|
|
5
|
+
export type ColorPickerTab = 'wheel' | 'tone' | 'hue';
|
|
6
|
+
|
|
7
|
+
/** A consumer-owned OKLCH target from the published Templates tone catalog. */
|
|
8
|
+
export interface ColorToneTarget {
|
|
9
|
+
readonly lightness: number;
|
|
10
|
+
readonly chroma: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Structural boundary for a Templates tone-pair entry. ZORA intentionally owns
|
|
15
|
+
* neither the catalog nor its classifications.
|
|
16
|
+
*/
|
|
17
|
+
export interface ColorToneDefinition {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly accent: string;
|
|
20
|
+
readonly accentTarget: ColorToneTarget;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ColorWheelSelection {
|
|
24
|
+
readonly color: HexColor;
|
|
25
|
+
readonly harmony: ColorHarmony | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ColorToneSelection {
|
|
29
|
+
readonly toneId: string;
|
|
30
|
+
readonly colors: readonly HexColor[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The persistent, controlled state for every independently selectable picker mode. */
|
|
34
|
+
export interface ColorPickerValue {
|
|
35
|
+
readonly tab: ColorPickerTab;
|
|
36
|
+
readonly wheel: ColorWheelSelection;
|
|
37
|
+
readonly tone: ColorToneSelection | null;
|
|
38
|
+
readonly hue: HexColor;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A single mode-specific update emitted by the composed picker. */
|
|
42
|
+
export type ColorPickerSelection =
|
|
43
|
+
| { readonly mode: 'wheel'; readonly value: ColorWheelSelection }
|
|
44
|
+
| { readonly mode: 'tone'; readonly value: ColorToneSelection }
|
|
45
|
+
| { readonly mode: 'hue'; readonly value: HexColor };
|
|
46
|
+
|
|
47
|
+
export interface ColorWheelProps extends ZoraBaseProps {
|
|
48
|
+
readonly value: HexColor;
|
|
49
|
+
readonly harmony?: ColorHarmony | null;
|
|
50
|
+
readonly harmonies?: readonly ColorHarmony[];
|
|
51
|
+
readonly onChange: (selection: ColorWheelSelection) => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ColorToneProps extends ZoraBaseProps {
|
|
55
|
+
readonly tones: readonly ColorToneDefinition[];
|
|
56
|
+
readonly selectionMode?: 'single' | 'multiple';
|
|
57
|
+
readonly value: ColorToneSelection | null;
|
|
58
|
+
readonly onChange: (selection: ColorToneSelection) => void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ColorHueScaleProps extends ZoraBaseProps {
|
|
62
|
+
readonly value: HexColor;
|
|
63
|
+
readonly onChange: (color: HexColor) => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ColorPickerProps extends ZoraBaseProps {
|
|
67
|
+
readonly tabs: readonly ColorPickerTab[];
|
|
68
|
+
readonly value: ColorPickerValue;
|
|
69
|
+
readonly onValueChange: (value: ColorPickerValue) => void;
|
|
70
|
+
readonly onSelectionChange?: (selection: ColorPickerSelection) => void;
|
|
71
|
+
readonly hideTabListWhenSingle?: boolean;
|
|
72
|
+
readonly wheel?: Omit<ColorWheelProps, 'onChange' | 'value'>;
|
|
73
|
+
readonly tone?: Omit<ColorToneProps, 'onChange' | 'value'>;
|
|
74
|
+
readonly hue?: Omit<ColorHueScaleProps, 'onChange' | 'value'>;
|
|
75
|
+
}
|
|
@@ -118,6 +118,21 @@ test('SSR-renders ordinary UI from its public web subpaths', async () => {
|
|
|
118
118
|
expect(markup).toContain('Continue');
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
+
/** Verifies that the color controls are available through their generated public web entrypoints. */
|
|
122
|
+
test('publishes the independent color controls through canonical web subpaths', async () => {
|
|
123
|
+
const [{ ColorPicker }, { ColorWheel }, { ColorTone }, { ColorHueScale }] = await Promise.all([
|
|
124
|
+
import('@ankhorage/zora/web/color-picker'),
|
|
125
|
+
import('@ankhorage/zora/web/color-wheel'),
|
|
126
|
+
import('@ankhorage/zora/web/color-tone'),
|
|
127
|
+
import('@ankhorage/zora/web/color-hue-scale'),
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
expect(ColorPicker).toBeDefined();
|
|
131
|
+
expect(ColorWheel).toBeDefined();
|
|
132
|
+
expect(ColorTone).toBeDefined();
|
|
133
|
+
expect(ColorHueScale).toBeDefined();
|
|
134
|
+
});
|
|
135
|
+
|
|
121
136
|
/** Verifies that the authoring boundary delegates its portable controls to released Surface. */
|
|
122
137
|
test('publishes browser-safe authoring controls through the released Surface boundary', async () => {
|
|
123
138
|
const entrypoint = await Bun.file(join('src', 'authoring.ts')).text();
|