@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
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
import { generateHarmonyRoleColors, type HexColor } from '@ankhorage/color-theory';
|
|
2
|
-
import { Button } from '@ankhorage/surface';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
Circle,
|
|
6
|
-
Defs,
|
|
7
|
-
Line,
|
|
8
|
-
LinearGradient,
|
|
9
|
-
Path,
|
|
10
|
-
Polygon,
|
|
11
|
-
RadialGradient,
|
|
12
|
-
Rect,
|
|
13
|
-
Stop,
|
|
14
|
-
Svg,
|
|
15
|
-
} from 'react-native-svg';
|
|
3
|
+
import { Circle, Defs, Line, Path, Polygon, RadialGradient, Stop, Svg } from 'react-native-svg';
|
|
16
4
|
|
|
17
5
|
import type { ColorWheelProps } from '../../types/color';
|
|
18
|
-
import { View } from '../layout/public';
|
|
19
6
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
20
7
|
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
21
|
-
import { Text } from '../typography/public';
|
|
22
|
-
import { ColorHexField } from './ColorHexField';
|
|
23
|
-
import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
|
|
24
8
|
import { ColorWheelKeyboardProxy } from './ColorWheelKeyboardProxy';
|
|
25
9
|
import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
|
|
26
10
|
import { resolveColorHue } from './utils/resolveColorHue';
|
|
@@ -28,16 +12,16 @@ import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
|
28
12
|
import { resolveWheelColor } from './utils/resolveWheelColor';
|
|
29
13
|
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
30
14
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
15
|
+
const VIEWBOX = 1000;
|
|
16
|
+
const CENTER = VIEWBOX / 2;
|
|
17
|
+
const RADIUS = 480;
|
|
18
|
+
const SEGMENTS = 96;
|
|
19
|
+
const MAX_CHROMA = 0.2;
|
|
36
20
|
|
|
37
|
-
/***
|
|
21
|
+
/*** Renders a size-owned, filled OKLCH wheel with controlled primary and harmony points. */
|
|
38
22
|
export const ColorWheel = withZoraThemeScope(ColorWheelInner);
|
|
39
23
|
|
|
40
|
-
/***
|
|
24
|
+
/*** Maps pointer and keyboard input through one viewBox into the controlled selected colour. */
|
|
41
25
|
function ColorWheelInner({
|
|
42
26
|
themeId: _themeId,
|
|
43
27
|
mode: _mode,
|
|
@@ -45,264 +29,160 @@ function ColorWheelInner({
|
|
|
45
29
|
interactionPolicy,
|
|
46
30
|
value,
|
|
47
31
|
harmony = null,
|
|
48
|
-
harmonies,
|
|
49
32
|
onChange,
|
|
33
|
+
size = 340,
|
|
50
34
|
testID,
|
|
51
35
|
}: ColorWheelProps) {
|
|
52
36
|
const { theme } = useZoraTheme();
|
|
53
37
|
const hue = resolveColorHue(value);
|
|
54
38
|
const { chroma, lightness } = resolveWheelColorComponents(value);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const wheelGradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
|
|
64
|
-
const changeColorAt = (x: number, y: number) => {
|
|
65
|
-
if (interactionPolicy === 'passive') return;
|
|
66
|
-
onChange({
|
|
67
|
-
color: resolveWheelColor(value, x, y, WHEEL_CENTER, WHEEL_RADIUS, WHEEL_MAX_CHROMA),
|
|
68
|
-
harmony,
|
|
69
|
-
});
|
|
39
|
+
const primaryPoint = pointFor(hue, Math.min(1, chroma / MAX_CHROMA));
|
|
40
|
+
const harmonyPoints = harmony
|
|
41
|
+
? generateHarmonyRoleColors(value, harmony).colors.map((color) => pointFor(color.hueDegrees))
|
|
42
|
+
: [];
|
|
43
|
+
const gradientId = `color-wheel-${React.useId().replaceAll(':', '')}`;
|
|
44
|
+
const changeAt = (x: number, y: number) => {
|
|
45
|
+
if (interactionPolicy !== 'passive')
|
|
46
|
+
onChange({ color: resolveWheelColor(value, x, y, CENTER, RADIUS, MAX_CHROMA), harmony });
|
|
70
47
|
};
|
|
71
|
-
const changeLightness = (nextLightness: number) =>
|
|
72
|
-
onChange({
|
|
73
|
-
color: resolveOklchColor({ chroma, lightness: Math.max(0, Math.min(1, nextLightness)) }, hue),
|
|
74
|
-
harmony,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
48
|
return (
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
49
|
+
<ColorWheelKeyboardProxy
|
|
50
|
+
chroma={chroma}
|
|
51
|
+
disabled={interactionPolicy === 'passive'}
|
|
52
|
+
hue={hue}
|
|
53
|
+
onChange={(nextHue, nextChroma) =>
|
|
54
|
+
onChange({ color: resolveOklchColor({ chroma: nextChroma, lightness }, nextHue), harmony })
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
<ColorWheelPointerProxy
|
|
81
58
|
disabled={interactionPolicy === 'passive'}
|
|
82
|
-
|
|
83
|
-
onChange={
|
|
84
|
-
|
|
85
|
-
color: resolveOklchColor(
|
|
86
|
-
{ lightness: resolveWheelLightness(value), chroma: nextChroma },
|
|
87
|
-
nextHue,
|
|
88
|
-
),
|
|
89
|
-
harmony,
|
|
90
|
-
})
|
|
91
|
-
}
|
|
59
|
+
height={VIEWBOX}
|
|
60
|
+
onChange={changeAt}
|
|
61
|
+
width={VIEWBOX}
|
|
92
62
|
>
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
height={
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
<Svg
|
|
64
|
+
accessibilityLabel="Color wheel"
|
|
65
|
+
height={size}
|
|
66
|
+
onResponderGrant={(event) =>
|
|
67
|
+
changeAt(
|
|
68
|
+
(event.nativeEvent.locationX / size) * VIEWBOX,
|
|
69
|
+
(event.nativeEvent.locationY / size) * VIEWBOX,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
onResponderMove={(event) =>
|
|
73
|
+
changeAt(
|
|
74
|
+
(event.nativeEvent.locationX / size) * VIEWBOX,
|
|
75
|
+
(event.nativeEvent.locationY / size) * VIEWBOX,
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
onResponderRelease={(event) =>
|
|
79
|
+
changeAt(
|
|
80
|
+
(event.nativeEvent.locationX / size) * VIEWBOX,
|
|
81
|
+
(event.nativeEvent.locationY / size) * VIEWBOX,
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
onStartShouldSetResponder={() => interactionPolicy !== 'passive'}
|
|
85
|
+
testID={testID}
|
|
86
|
+
viewBox={`0 0 ${VIEWBOX} ${VIEWBOX}`}
|
|
87
|
+
width={size}
|
|
98
88
|
>
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}}
|
|
106
|
-
onResponderMove={(event) => {
|
|
107
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
108
|
-
changeColorAt(locationX, locationY);
|
|
109
|
-
}}
|
|
110
|
-
onResponderRelease={(event) => {
|
|
111
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
112
|
-
changeColorAt(locationX, locationY);
|
|
113
|
-
}}
|
|
114
|
-
onStartShouldSetResponder={() => interactionPolicy !== 'passive'}
|
|
115
|
-
width={WHEEL_SIZE}
|
|
116
|
-
>
|
|
117
|
-
<Defs>
|
|
118
|
-
{resolveWheelSegments().map((segment) => (
|
|
119
|
-
<RadialGradient
|
|
120
|
-
cx={WHEEL_CENTER}
|
|
121
|
-
cy={WHEEL_CENTER}
|
|
122
|
-
id={`${wheelGradientId}-${segment.hue}`}
|
|
123
|
-
key={segment.hue}
|
|
124
|
-
r={WHEEL_RADIUS}
|
|
125
|
-
>
|
|
126
|
-
<Stop
|
|
127
|
-
offset="0"
|
|
128
|
-
stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0 }, segment.hue)}
|
|
129
|
-
/>
|
|
130
|
-
<Stop offset="1" stopColor={segment.color} />
|
|
131
|
-
</RadialGradient>
|
|
132
|
-
))}
|
|
133
|
-
</Defs>
|
|
134
|
-
{resolveWheelSegments().map((segment) => (
|
|
135
|
-
<Path
|
|
136
|
-
d={segment.path}
|
|
137
|
-
fill={`url(#${wheelGradientId}-${segment.hue})`}
|
|
89
|
+
<Defs>
|
|
90
|
+
{segments().map((segment) => (
|
|
91
|
+
<RadialGradient
|
|
92
|
+
cx={CENTER}
|
|
93
|
+
cy={CENTER}
|
|
94
|
+
id={`${gradientId}-${segment.hue}`}
|
|
138
95
|
key={segment.hue}
|
|
139
|
-
|
|
96
|
+
r={RADIUS}
|
|
97
|
+
>
|
|
98
|
+
<Stop
|
|
99
|
+
offset="0"
|
|
100
|
+
stopColor={resolveOklchColor({ chroma: 0, lightness: 0.72 }, segment.hue)}
|
|
101
|
+
/>
|
|
102
|
+
<Stop offset="1" stopColor={segment.color} />
|
|
103
|
+
</RadialGradient>
|
|
140
104
|
))}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
/>
|
|
148
|
-
) : (
|
|
149
|
-
harmonyLines
|
|
150
|
-
)}
|
|
151
|
-
{harmonyPoints.map((point) => (
|
|
152
|
-
<Circle
|
|
153
|
-
cx={point.x}
|
|
154
|
-
cy={point.y}
|
|
155
|
-
fill={theme.semantics.content.default}
|
|
156
|
-
key={`${point.x}-${point.y}`}
|
|
157
|
-
r={5}
|
|
158
|
-
/>
|
|
159
|
-
))}
|
|
160
|
-
<Circle
|
|
161
|
-
cx={selectedPoint.x}
|
|
162
|
-
cy={selectedPoint.y}
|
|
105
|
+
</Defs>
|
|
106
|
+
{segments().map((segment) => (
|
|
107
|
+
<Path d={segment.path} fill={`url(#${gradientId}-${segment.hue})`} key={segment.hue} />
|
|
108
|
+
))}
|
|
109
|
+
{harmonyPoints.length === 3 ? (
|
|
110
|
+
<Polygon
|
|
163
111
|
fill="none"
|
|
164
|
-
|
|
112
|
+
points={harmonyPoints.map((point) => `${point.x},${point.y}`).join(' ')}
|
|
165
113
|
stroke={theme.semantics.content.default}
|
|
166
|
-
strokeWidth={
|
|
114
|
+
strokeWidth={6}
|
|
115
|
+
/>
|
|
116
|
+
) : (
|
|
117
|
+
linesFor(harmonyPoints, primaryPoint, theme.semantics.content.default)
|
|
118
|
+
)}
|
|
119
|
+
{harmonyPoints.map((point) => (
|
|
120
|
+
<Circle
|
|
121
|
+
cx={point.x}
|
|
122
|
+
cy={point.y}
|
|
123
|
+
fill={theme.semantics.content.default}
|
|
124
|
+
key={`${point.x}-${point.y}`}
|
|
125
|
+
r={26}
|
|
167
126
|
/>
|
|
168
|
-
</Svg>
|
|
169
|
-
</ColorWheelPointerProxy>
|
|
170
|
-
</ColorWheelKeyboardProxy>
|
|
171
|
-
<ColorLightnessSlider
|
|
172
|
-
chroma={chroma}
|
|
173
|
-
disabled={interactionPolicy === 'passive'}
|
|
174
|
-
hue={hue}
|
|
175
|
-
lightness={lightness}
|
|
176
|
-
onChange={changeLightness}
|
|
177
|
-
selectionBorderColor={theme.semantics.content.default}
|
|
178
|
-
/>
|
|
179
|
-
<ColorHexField
|
|
180
|
-
disabled={interactionPolicy === 'passive'}
|
|
181
|
-
key={value}
|
|
182
|
-
onChange={(color) => onChange({ color, harmony })}
|
|
183
|
-
value={value}
|
|
184
|
-
/>
|
|
185
|
-
{harmonies ? (
|
|
186
|
-
<View direction="row" gap="xs" wrap="wrap">
|
|
187
|
-
<Button
|
|
188
|
-
disabled={interactionPolicy === 'passive'}
|
|
189
|
-
onPress={() => onChange({ color: value, harmony: null })}
|
|
190
|
-
variant={harmony === null ? 'solid' : 'outline'}
|
|
191
|
-
>
|
|
192
|
-
None
|
|
193
|
-
</Button>
|
|
194
|
-
{harmonies.map((candidate) => (
|
|
195
|
-
<Button
|
|
196
|
-
key={candidate}
|
|
197
|
-
disabled={interactionPolicy === 'passive'}
|
|
198
|
-
onPress={() => onChange({ color: value, harmony: candidate })}
|
|
199
|
-
variant={harmony === candidate ? 'solid' : 'outline'}
|
|
200
|
-
>
|
|
201
|
-
{candidate}
|
|
202
|
-
</Button>
|
|
203
127
|
))}
|
|
204
|
-
</View>
|
|
205
|
-
) : null}
|
|
206
|
-
</View>
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/*** Renders a continuous OKLCH lightness track without adding a second color persistence model. */
|
|
211
|
-
function ColorLightnessSlider({
|
|
212
|
-
chroma,
|
|
213
|
-
disabled,
|
|
214
|
-
hue,
|
|
215
|
-
lightness,
|
|
216
|
-
onChange,
|
|
217
|
-
selectionBorderColor,
|
|
218
|
-
}: {
|
|
219
|
-
readonly chroma: number;
|
|
220
|
-
readonly disabled: boolean;
|
|
221
|
-
readonly hue: number;
|
|
222
|
-
readonly lightness: number;
|
|
223
|
-
readonly onChange: (lightness: number) => void;
|
|
224
|
-
readonly selectionBorderColor: string;
|
|
225
|
-
}) {
|
|
226
|
-
const changeAt = (locationX: number) => {
|
|
227
|
-
if (!disabled) onChange(Math.max(0, Math.min(1, locationX / WHEEL_SIZE)));
|
|
228
|
-
};
|
|
229
|
-
return (
|
|
230
|
-
<View gap="xxs" width={WHEEL_SIZE}>
|
|
231
|
-
<View direction="row" justify="space-between">
|
|
232
|
-
<Text variant="label">Lightness</Text>
|
|
233
|
-
<Text variant="label">{`${Math.round(lightness * 100)}%`}</Text>
|
|
234
|
-
</View>
|
|
235
|
-
<ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={WHEEL_SIZE}>
|
|
236
|
-
<Svg accessibilityLabel="Color lightness" height={36} width={WHEEL_SIZE}>
|
|
237
|
-
<Defs>
|
|
238
|
-
<LinearGradient id="color-lightness" x1="0" x2="1" y1="0" y2="0">
|
|
239
|
-
<Stop offset="0" stopColor={resolveOklchColor({ chroma, lightness: 0 }, hue)} />
|
|
240
|
-
<Stop offset="1" stopColor={resolveOklchColor({ chroma, lightness: 1 }, hue)} />
|
|
241
|
-
</LinearGradient>
|
|
242
|
-
</Defs>
|
|
243
|
-
<Rect fill="url(#color-lightness)" height={10} rx={5} y={13} width={WHEEL_SIZE} />
|
|
244
128
|
<Circle
|
|
245
|
-
cx={
|
|
246
|
-
cy={
|
|
247
|
-
fill="
|
|
248
|
-
r={
|
|
249
|
-
stroke=
|
|
250
|
-
strokeWidth={
|
|
129
|
+
cx={primaryPoint.x}
|
|
130
|
+
cy={primaryPoint.y}
|
|
131
|
+
fill="none"
|
|
132
|
+
r={36}
|
|
133
|
+
stroke="white"
|
|
134
|
+
strokeWidth={12}
|
|
251
135
|
/>
|
|
252
|
-
<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
width={WHEEL_SIZE}
|
|
136
|
+
<Circle
|
|
137
|
+
cx={primaryPoint.x}
|
|
138
|
+
cy={primaryPoint.y}
|
|
139
|
+
fill="none"
|
|
140
|
+
r={42}
|
|
141
|
+
stroke={theme.semantics.content.default}
|
|
142
|
+
strokeWidth={6}
|
|
260
143
|
/>
|
|
261
144
|
</Svg>
|
|
262
|
-
</
|
|
263
|
-
</
|
|
145
|
+
</ColorWheelPointerProxy>
|
|
146
|
+
</ColorWheelKeyboardProxy>
|
|
264
147
|
);
|
|
265
148
|
}
|
|
266
149
|
|
|
267
|
-
/***
|
|
268
|
-
function
|
|
150
|
+
/*** Creates continuous-looking radial hue segments for the wheel viewBox. */
|
|
151
|
+
function segments(): readonly {
|
|
269
152
|
readonly color: HexColor;
|
|
270
153
|
readonly hue: number;
|
|
271
154
|
readonly path: string;
|
|
272
155
|
}[] {
|
|
273
|
-
return Array.from({ length:
|
|
274
|
-
const hue = (index * 360) /
|
|
156
|
+
return Array.from({ length: SEGMENTS }, (_, index) => {
|
|
157
|
+
const hue = (index * 360) / SEGMENTS;
|
|
275
158
|
return {
|
|
276
|
-
color: resolveOklchColor({ lightness: 0.65
|
|
159
|
+
color: resolveOklchColor({ chroma: MAX_CHROMA, lightness: 0.65 }, hue),
|
|
277
160
|
hue,
|
|
278
|
-
path:
|
|
161
|
+
path: segmentPath(hue, hue + 360 / SEGMENTS),
|
|
279
162
|
};
|
|
280
163
|
});
|
|
281
164
|
}
|
|
282
165
|
|
|
283
|
-
/***
|
|
284
|
-
function
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
return `M ${
|
|
166
|
+
/*** Describes one filled wheel segment in the stable coordinate system. */
|
|
167
|
+
function segmentPath(start: number, end: number) {
|
|
168
|
+
const startPoint = pointFor(start);
|
|
169
|
+
const endPoint = pointFor(end);
|
|
170
|
+
return `M ${CENTER} ${CENTER} L ${startPoint.x} ${startPoint.y} A ${RADIUS} ${RADIUS} 0 0 1 ${endPoint.x} ${endPoint.y} Z`;
|
|
288
171
|
}
|
|
289
172
|
|
|
290
|
-
/***
|
|
291
|
-
function
|
|
292
|
-
hue: number,
|
|
293
|
-
radiusRatio = 1,
|
|
294
|
-
): { readonly x: number; readonly y: number } {
|
|
173
|
+
/*** Projects an OKLCH hue and chroma ratio into the wheel coordinate system. */
|
|
174
|
+
function pointFor(hue: number, ratio = 1) {
|
|
295
175
|
const radians = ((hue - 90) * Math.PI) / 180;
|
|
296
176
|
return {
|
|
297
|
-
x:
|
|
298
|
-
y:
|
|
177
|
+
x: CENTER + RADIUS * ratio * Math.cos(radians),
|
|
178
|
+
y: CENTER + RADIUS * ratio * Math.sin(radians),
|
|
299
179
|
};
|
|
300
180
|
}
|
|
301
181
|
|
|
302
|
-
/***
|
|
303
|
-
function
|
|
182
|
+
/*** Connects derived harmony points behind their corresponding knobs. */
|
|
183
|
+
function linesFor(
|
|
304
184
|
points: readonly { readonly x: number; readonly y: number }[],
|
|
305
|
-
|
|
185
|
+
primary: { readonly x: number; readonly y: number },
|
|
306
186
|
stroke: string,
|
|
307
187
|
) {
|
|
308
188
|
return points.slice(1).reduce(
|
|
@@ -312,7 +192,7 @@ function resolveHarmonyLines(
|
|
|
312
192
|
<Line
|
|
313
193
|
key={`${previous.x}-${previous.y}-${point.x}-${point.y}`}
|
|
314
194
|
stroke={stroke}
|
|
315
|
-
strokeWidth={
|
|
195
|
+
strokeWidth={6}
|
|
316
196
|
x1={previous.x}
|
|
317
197
|
x2={point.x}
|
|
318
198
|
y1={previous.y}
|
|
@@ -321,12 +201,6 @@ function resolveHarmonyLines(
|
|
|
321
201
|
],
|
|
322
202
|
previous: point,
|
|
323
203
|
}),
|
|
324
|
-
{ lines: [] as React.ReactNode[], previous: points.at(0) ??
|
|
204
|
+
{ lines: [] as React.ReactNode[], previous: points.at(0) ?? primary },
|
|
325
205
|
).lines;
|
|
326
206
|
}
|
|
327
|
-
|
|
328
|
-
/*** Read the selected color's lightness for wheel-only hue and chroma changes. */
|
|
329
|
-
function resolveWheelLightness(color: HexColor): number {
|
|
330
|
-
const { lightness } = resolveWheelColorComponents(color);
|
|
331
|
-
return lightness;
|
|
332
|
-
}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import type { ColorWheelPointerProxyProps } from './ColorWheelPointerProxy';
|
|
4
4
|
|
|
5
|
-
/*** Maps
|
|
5
|
+
/*** Maps mouse, pen and touch coordinates into the wheel viewBox for click and drag selection. */
|
|
6
6
|
export function ColorWheelPointerProxy({
|
|
7
7
|
children,
|
|
8
8
|
disabled,
|
|
@@ -11,7 +11,7 @@ export function ColorWheelPointerProxy({
|
|
|
11
11
|
width,
|
|
12
12
|
}: ColorWheelPointerProxyProps) {
|
|
13
13
|
const dragging = React.useRef(false);
|
|
14
|
-
const changeAt = (event: React.
|
|
14
|
+
const changeAt = (event: React.PointerEvent<HTMLDivElement>) => {
|
|
15
15
|
const target = event.currentTarget as unknown as BrowserPointerTarget;
|
|
16
16
|
const rect = target.getBoundingClientRect();
|
|
17
17
|
onChange(
|
|
@@ -22,18 +22,24 @@ export function ColorWheelPointerProxy({
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<div
|
|
25
|
-
|
|
25
|
+
onPointerDown={(event) => {
|
|
26
26
|
if (disabled) return;
|
|
27
27
|
dragging.current = true;
|
|
28
|
+
(
|
|
29
|
+
event.currentTarget as unknown as { setPointerCapture: (pointerId: number) => void }
|
|
30
|
+
).setPointerCapture(event.pointerId);
|
|
28
31
|
changeAt(event);
|
|
29
32
|
}}
|
|
30
|
-
|
|
33
|
+
onPointerMove={(event) => {
|
|
31
34
|
if (!disabled && dragging.current) changeAt(event);
|
|
32
35
|
}}
|
|
33
|
-
|
|
36
|
+
onPointerUp={(event) => {
|
|
34
37
|
if (!disabled && dragging.current) changeAt(event);
|
|
35
38
|
dragging.current = false;
|
|
36
39
|
}}
|
|
40
|
+
onPointerCancel={() => {
|
|
41
|
+
dragging.current = false;
|
|
42
|
+
}}
|
|
37
43
|
style={{ touchAction: 'none' }}
|
|
38
44
|
>
|
|
39
45
|
{children}
|
package/src/index.ts
CHANGED
package/src/types/color.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ColorHarmony, HexColor } from '@ankhorage/color-theory';
|
|
|
2
2
|
|
|
3
3
|
import type { ZoraBaseProps } from './base';
|
|
4
4
|
|
|
5
|
-
export type ColorPickerTab = '
|
|
5
|
+
export type ColorPickerTab = 'grid' | 'wheel';
|
|
6
6
|
|
|
7
7
|
/** A consumer-owned OKLCH target from the published Templates tone catalog. */
|
|
8
8
|
export interface ColorToneTarget {
|
|
@@ -30,22 +30,10 @@ export interface ColorToneSelection {
|
|
|
30
30
|
readonly colors: readonly HexColor[];
|
|
31
31
|
}
|
|
32
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
33
|
export interface ColorWheelProps extends ZoraBaseProps {
|
|
48
34
|
readonly value: HexColor;
|
|
35
|
+
/** Square stage side derived by the owning ColorPicker geometry. */
|
|
36
|
+
readonly size?: number;
|
|
49
37
|
readonly harmony?: ColorHarmony | null;
|
|
50
38
|
readonly harmonies?: readonly ColorHarmony[];
|
|
51
39
|
readonly onChange: (selection: ColorWheelSelection) => void;
|
|
@@ -64,14 +52,30 @@ export interface ColorHueScaleProps extends ZoraBaseProps {
|
|
|
64
52
|
}
|
|
65
53
|
|
|
66
54
|
export interface ColorPickerProps extends ZoraBaseProps {
|
|
67
|
-
|
|
68
|
-
readonly
|
|
69
|
-
|
|
70
|
-
readonly
|
|
55
|
+
/** Enabled presentations, in Grid then Wheel order by default. */
|
|
56
|
+
readonly tabs?: readonly ColorPickerTab[];
|
|
57
|
+
/** The one authoritative selected colour. */
|
|
58
|
+
readonly primaryColor: HexColor;
|
|
59
|
+
/** Optional owner-provided harmony applied to both presentations. */
|
|
60
|
+
readonly harmony?: ColorHarmony;
|
|
61
|
+
/** Optional consumer-owned tone-family id. */
|
|
62
|
+
readonly tone?: string;
|
|
63
|
+
/** Consumer-owned tone catalogue; ZORA deliberately does not copy it. */
|
|
64
|
+
readonly tones?: readonly ColorToneDefinition[];
|
|
65
|
+
/** Requested outer logical width; hosts must provide at least 360 logical pixels. */
|
|
66
|
+
readonly width?: number;
|
|
67
|
+
/** Controlled active presentation. */
|
|
68
|
+
readonly activeTab?: ColorPickerTab;
|
|
69
|
+
/** Emits one canonical controlled selection payload. */
|
|
70
|
+
readonly onValueChange: (value: {
|
|
71
|
+
readonly primaryColor: HexColor;
|
|
72
|
+
readonly harmony?: ColorHarmony;
|
|
73
|
+
readonly tone?: string;
|
|
74
|
+
}) => void;
|
|
75
|
+
/** Notifies a consumer that a controlled active presentation must change. */
|
|
76
|
+
readonly onActiveTabChange?: (tab: ColorPickerTab) => void;
|
|
71
77
|
/** Requests dismissal from the owning Popover or BottomSheet presentation. */
|
|
72
78
|
readonly onDismiss?: () => void;
|
|
73
79
|
readonly hideTabListWhenSingle?: boolean;
|
|
74
|
-
readonly wheel?: Omit<ColorWheelProps, 'onChange' | 'value'>;
|
|
75
|
-
readonly tone?: Omit<ColorToneProps, 'onChange' | 'value'>;
|
|
76
|
-
readonly hue?: Omit<ColorHueScaleProps, 'onChange' | 'value'>;
|
|
80
|
+
readonly wheel?: Omit<ColorWheelProps, 'onChange' | 'value' | 'harmony'>;
|
|
77
81
|
}
|