@ankhorage/zora 27.10.4 → 27.10.5
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 +7 -0
- package/README.md +1 -1
- package/dist/features/color/ColorHexField.d.ts +9 -0
- package/dist/features/color/ColorHexField.d.ts.map +1 -0
- package/dist/features/color/ColorHexField.js +17 -0
- package/dist/features/color/ColorHexField.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.d.ts +9 -0
- package/dist/features/color/ColorHorizontalPointerProxy.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.js +2 -0
- package/dist/features/color/ColorHorizontalPointerProxy.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts +4 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.js +5 -0
- package/dist/features/color/ColorHorizontalPointerProxy.native.js.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts +5 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.js +26 -0
- package/dist/features/color/ColorHorizontalPointerProxy.web.js.map +1 -0
- package/dist/features/color/ColorHueScale.d.ts.map +1 -1
- package/dist/features/color/ColorHueScale.js +18 -7
- package/dist/features/color/ColorHueScale.js.map +1 -1
- package/dist/features/color/ColorPicker.d.ts.map +1 -1
- package/dist/features/color/ColorPicker.js +37 -10
- package/dist/features/color/ColorPicker.js.map +1 -1
- package/dist/features/color/ColorSpectrumSlider.d.ts +9 -0
- package/dist/features/color/ColorSpectrumSlider.d.ts.map +1 -0
- package/dist/features/color/ColorSpectrumSlider.js +38 -0
- package/dist/features/color/ColorSpectrumSlider.js.map +1 -0
- package/dist/features/color/ColorTone.d.ts.map +1 -1
- package/dist/features/color/ColorTone.js +71 -12
- package/dist/features/color/ColorTone.js.map +1 -1
- package/dist/features/color/ColorWheel.d.ts.map +1 -1
- package/dist/features/color/ColorWheel.js +64 -36
- package/dist/features/color/ColorWheel.js.map +1 -1
- package/dist/features/color/ColorWheelPointerProxy.d.ts +10 -0
- package/dist/features/color/ColorWheelPointerProxy.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.js +2 -0
- package/dist/features/color/ColorWheelPointerProxy.js.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts +4 -0
- package/dist/features/color/ColorWheelPointerProxy.native.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.native.js +5 -0
- package/dist/features/color/ColorWheelPointerProxy.native.js.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts +5 -0
- package/dist/features/color/ColorWheelPointerProxy.web.d.ts.map +1 -0
- package/dist/features/color/ColorWheelPointerProxy.web.js +26 -0
- package/dist/features/color/ColorWheelPointerProxy.web.js.map +1 -0
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +14 -2
- package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
- package/dist/types/color.d.ts +2 -0
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/color.js.map +1 -1
- package/package.json +1 -1
- package/src/features/color/ColorHexField.tsx +45 -0
- package/src/features/color/ColorHorizontalPointerProxy.native.tsx +6 -0
- package/src/features/color/ColorHorizontalPointerProxy.tsx +10 -0
- package/src/features/color/ColorHorizontalPointerProxy.web.tsx +45 -0
- package/src/features/color/ColorHueScale.tsx +48 -29
- package/src/features/color/ColorPicker.layout.test.tsx +72 -0
- package/src/features/color/ColorPicker.tsx +74 -20
- package/src/features/color/ColorSpectrumSlider.tsx +79 -0
- package/src/features/color/ColorTone.tsx +138 -21
- package/src/features/color/ColorWheel.tsx +173 -92
- package/src/features/color/ColorWheelPointerProxy.native.tsx +6 -0
- package/src/features/color/ColorWheelPointerProxy.tsx +11 -0
- package/src/features/color/ColorWheelPointerProxy.web.tsx +51 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +18 -0
- package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +18 -2
- package/src/types/color.ts +2 -0
- package/web-dist/chunks/{Accordion-mxad79vq.js → Accordion-0kr0h68p.js} +4568 -669
- package/web-dist/chunks/{Accordion-0jkpvxwd.js → Accordion-1etqb3cj.js} +2 -2
- package/web-dist/chunks/{Accordion-jr0201qc.js → Accordion-1mxnyexh.js} +17 -17
- package/web-dist/chunks/{Accordion-9kkfz7s8.js → Accordion-3ecnh8d0.js} +4 -4
- package/web-dist/chunks/{Accordion-jsapannb.js → Accordion-3jkeydhb.js} +4 -4
- package/web-dist/chunks/{Accordion-r6gwemh9.js → Accordion-3wkd5x2q.js} +3 -3
- package/web-dist/chunks/{Accordion-0bgzetnd.js → Accordion-3zw817fr.js} +6 -6
- package/web-dist/chunks/{Accordion-91v243pz.js → Accordion-49w9bc2f.js} +2 -2
- package/web-dist/chunks/{Accordion-8vw4k0s6.js → Accordion-4g54je0w.js} +2 -2
- package/web-dist/chunks/{Accordion-1andv7gg.js → Accordion-5vs1k81g.js} +8 -8
- package/web-dist/chunks/{Accordion-ttjyk97v.js → Accordion-6m3k4avp.js} +2 -2
- package/web-dist/chunks/{Accordion-dnfrzbpb.js → Accordion-6nrpdbmb.js} +7 -7
- package/web-dist/chunks/{Accordion-y524ph0g.js → Accordion-6yv4beha.js} +1 -1
- package/web-dist/chunks/{Accordion-9cpm8x92.js → Accordion-705yrq6w.js} +1 -1
- package/web-dist/chunks/{Accordion-th8pkeqc.js → Accordion-8g9c7890.js} +4 -4
- package/web-dist/chunks/{Accordion-6qesggn9.js → Accordion-9c63jn3m.js} +4 -4
- package/web-dist/chunks/{Accordion-1mjn0atk.js → Accordion-aws0caav.js} +3 -3
- package/web-dist/chunks/{Accordion-hha54x4c.js → Accordion-bd6q61s1.js} +5 -5
- package/web-dist/chunks/{Accordion-8rkwd0wx.js → Accordion-c0a7mhq3.js} +2 -2
- package/web-dist/chunks/{Accordion-j5wsx41j.js → Accordion-c3nna2bz.js} +1 -1
- package/web-dist/chunks/{Accordion-r6mc7qtj.js → Accordion-dfq04q82.js} +9 -9
- package/web-dist/chunks/{Accordion-nbje2ywp.js → Accordion-e3r3573t.js} +3 -3
- package/web-dist/chunks/{Accordion-hqg1zbxk.js → Accordion-e5jr9ahb.js} +1 -1
- package/web-dist/chunks/{Accordion-pkbvsn5y.js → Accordion-eak89n4n.js} +6 -6
- package/web-dist/chunks/{Accordion-7e0mb55z.js → Accordion-f60g73bp.js} +6 -6
- package/web-dist/chunks/{Accordion-grtf75xt.js → Accordion-g451f3g9.js} +4 -4
- package/web-dist/chunks/{Accordion-27rxpbvf.js → Accordion-gezcm372.js} +4 -4
- package/web-dist/chunks/{Accordion-45tbe5v0.js → Accordion-h0e95qxp.js} +9 -9
- package/web-dist/chunks/{Accordion-m7jt3c87.js → Accordion-h2nd5y0z.js} +5 -5
- package/web-dist/chunks/{Accordion-f6k281sv.js → Accordion-j0zhpq4s.js} +7 -7
- package/web-dist/chunks/{Accordion-q6xnm1k4.js → Accordion-jbwey4za.js} +17 -17
- package/web-dist/chunks/{Accordion-vdqc8rxv.js → Accordion-jd26f516.js} +3 -3
- package/web-dist/chunks/{Accordion-1k7pyxdd.js → Accordion-ne91vwkd.js} +2 -2
- package/web-dist/chunks/{Accordion-k058095e.js → Accordion-p29kmwh9.js} +1 -1
- package/web-dist/chunks/{Accordion-0pbcs0xf.js → Accordion-pcj256bc.js} +5 -5
- package/web-dist/chunks/{Accordion-8wq38d9b.js → Accordion-phtyg3k4.js} +7 -7
- package/web-dist/chunks/{Accordion-b991pn6e.js → Accordion-pmfdf08d.js} +1 -1
- package/web-dist/chunks/{Accordion-xp2t3pkj.js → Accordion-q1tdazgq.js} +8 -8
- package/web-dist/chunks/{Accordion-v21vz0cg.js → Accordion-qhn8z92r.js} +3 -3
- package/web-dist/chunks/Accordion-r1wkgt7c.js +1074 -0
- package/web-dist/chunks/{Accordion-ctcxh9pk.js → Accordion-rzf52xq8.js} +2 -2
- package/web-dist/chunks/{Accordion-hrxdchkq.js → Accordion-vewhx028.js} +8 -8
- package/web-dist/chunks/{Accordion-jsdjgfn2.js → Accordion-vk2v1zwv.js} +2 -2
- package/web-dist/chunks/{Accordion-19zt3dyq.js → Accordion-vnrqvfca.js} +1 -1
- package/web-dist/chunks/{Accordion-rt4jfq2r.js → Accordion-x0p3wxfp.js} +2 -2
- package/web-dist/chunks/{Accordion-w1ag7sr4.js → Accordion-x7ynjdv7.js} +1 -1
- package/web-dist/chunks/{Accordion-ga82tcs9.js → Accordion-xb174981.js} +10 -10
- package/web-dist/chunks/{Accordion-yskcfahv.js → Accordion-xwstve3k.js} +2 -2
- package/web-dist/chunks/{Accordion-xb2nj0q6.js → Accordion-ysmzrvhn.js} +3 -3
- package/web-dist/chunks/{Accordion-tnq8bt8v.js → Accordion-z4qakakw.js} +2 -2
- package/web-dist/chunks/{Accordion-w9vbdg9r.js → Accordion-z8ryq8cb.js} +11 -11
- package/web-dist/chunks/{Accordion-x3em7tpd.js → Accordion-zx8gmww4.js} +9 -9
- 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 -16
- package/web-dist/components/app-header/AppHeader.js +15 -16
- package/web-dist/components/app-shell/AppShell.js +4 -4
- package/web-dist/components/auth-screen/AuthScreen.js +20 -21
- 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 -19
- 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 -16
- package/web-dist/components/button/Button.js +13 -14
- package/web-dist/components/button-group/ButtonGroup.js +11 -12
- package/web-dist/components/calendar/Calendar.js +12 -13
- package/web-dist/components/camera-permission-view/CameraPermissionView.js +18 -19
- package/web-dist/components/card/Card.js +17 -18
- 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 +21 -22
- package/web-dist/components/color-hue-scale/ColorHueScale.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.js +15 -14
- package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +2 -0
- package/web-dist/components/color-tone/ColorTone.js +15 -14
- package/web-dist/components/color-wheel/ColorWheel.js +15 -14
- package/web-dist/components/content-rail/ContentRail.js +13 -14
- package/web-dist/components/data-table/DataTable.js +27 -28
- package/web-dist/components/date-picker/DatePicker.js +19 -20
- 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 -19
- 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 -21
- package/web-dist/components/form/Form.js +14 -15
- package/web-dist/components/form-actions/FormActions.js +14 -15
- package/web-dist/components/form-error/FormError.js +14 -15
- 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/graph-view/GraphView.js +9 -2
- 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 -21
- package/web-dist/components/icon/Icon.js +4 -4
- package/web-dist/components/icon-button/IconButton.js +11 -12
- 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 -18
- 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 -18
- package/web-dist/components/missing-element/MissingElement.js +9 -9
- package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +20 -21
- package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +20 -21
- package/web-dist/components/opening-book/OpeningBook.js +4 -4
- package/web-dist/components/otp-form/OtpForm.js +20 -21
- package/web-dist/components/pagination/Pagination.js +18 -19
- package/web-dist/components/palette-item/PaletteItem.js +17 -18
- 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 -18
- package/web-dist/components/product-card/ProductCard.js +17 -18
- 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 +20 -21
- package/web-dist/components/scan-overlay/ScanOverlay.js +18 -19
- 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 -13
- 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 +16 -17
- 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 -21
- package/web-dist/components/sign-up-form/SignUpForm.js +20 -21
- package/web-dist/components/skeleton/Skeleton.js +20 -21
- package/web-dist/components/skeleton-card/SkeletonCard.js +20 -21
- package/web-dist/components/skeleton-list/SkeletonList.js +20 -21
- package/web-dist/components/skeleton-text/SkeletonText.js +20 -21
- 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 -13
- package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +12 -13
- package/web-dist/components/time-picker/TimePicker.js +19 -20
- 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 -18
- package/web-dist/components/tree-item/TreeItem.js +17 -18
- package/web-dist/components/uploader/Uploader.js +26 -27
- package/web-dist/components/view/View.js +4 -4
- package/web-dist/manifest.json +1417 -1459
- package/web-dist/runtime/ZoraProvider.js +6 -6
- package/web-dist/chunks/Accordion-fjnb7anx.js +0 -548
- package/web-dist/chunks/Accordion-ztcmb44y.js +0 -3928
- package/web-dist/chunks/{Accordion-ng79nxzz.js → Accordion-an5prgty.js} +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 27.10.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b8aaf87: Improve the controlled ColorPicker header and wheel press selection while consuming the viewport-safe Surface Popover release.
|
|
8
|
+
- e0eb68b: Preserve retained GraphView positions when rich-node measurements arrive after a controlled topology update.
|
|
9
|
+
|
|
3
10
|
## 27.10.4
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
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
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/*** Edits one controlled HEX color with the Studio-style swatch and copy affordance. */
|
|
4
|
+
export declare function ColorHexField({ disabled, onChange, value, }: {
|
|
5
|
+
readonly disabled: boolean;
|
|
6
|
+
readonly onChange: (color: HexColor) => void;
|
|
7
|
+
readonly value: HexColor;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ColorHexField.d.ts.map
|
|
@@ -0,0 +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;AAM1B,wFAAwF;AACxF,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,qBA2BA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isHexColor } from '@ankhorage/color-theory';
|
|
2
|
+
import { TextInput } from '@ankhorage/surface';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Icon } from '../icon/public';
|
|
5
|
+
import { View } from '../layout/public';
|
|
6
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
7
|
+
/*** Edits one controlled HEX color with the Studio-style swatch and copy affordance. */
|
|
8
|
+
export function ColorHexField({ disabled, onChange, value, }) {
|
|
9
|
+
const [input, setInput] = React.useState(value);
|
|
10
|
+
const { theme } = useZoraTheme();
|
|
11
|
+
return (<TextInput accessibilityLabel="Color hex value" disabled={disabled} key={value} leadingAccessory={<View bg={value} borderColor={theme.semantics.border.default} borderWidth={1} height={30} radius="s" width={30}/>} onChangeText={(nextValue) => {
|
|
12
|
+
setInput(nextValue);
|
|
13
|
+
if (isHexColor(nextValue))
|
|
14
|
+
onChange(nextValue);
|
|
15
|
+
}} trailingAccessory={<Icon color="textMuted" name="copy-outline" size="m"/>} value={input}/>);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ColorHexField.js.map
|
|
@@ -0,0 +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,gBAAgB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,wFAAwF;AACxF,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,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAG,CAAC,CAC3E,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 { Icon } from '../icon/public';\nimport { View } from '../layout/public';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\n\n/*** Edits one controlled HEX color with the Studio-style swatch and copy affordance. */\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 trailingAccessory={<Icon color=\"textMuted\" name=\"copy-outline\" size=\"m\" />}\n value={input}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy.native';
|
|
3
|
+
export interface ColorHorizontalPointerProxyProps {
|
|
4
|
+
readonly children: React.ReactNode;
|
|
5
|
+
readonly disabled: boolean;
|
|
6
|
+
readonly onChange: (locationX: number) => void;
|
|
7
|
+
readonly width: number;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ColorHorizontalPointerProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHorizontalPointerProxy.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHorizontalPointerProxy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHorizontalPointerProxy.js","sourceRoot":"","sources":["../../../src/features/color/ColorHorizontalPointerProxy.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC","sourcesContent":["import type React from 'react';\n\nexport { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy.native';\n\nexport interface ColorHorizontalPointerProxyProps {\n readonly children: React.ReactNode;\n readonly disabled: boolean;\n readonly onChange: (locationX: number) => void;\n readonly width: number;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorHorizontalPointerProxyProps } from './ColorHorizontalPointerProxy';
|
|
2
|
+
/*** Leaves native SVG responders in charge of horizontal slider gestures. */
|
|
3
|
+
export declare function ColorHorizontalPointerProxy({ children }: ColorHorizontalPointerProxyProps): import("react").ReactNode;
|
|
4
|
+
//# sourceMappingURL=ColorHorizontalPointerProxy.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHorizontalPointerProxy.native.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHorizontalPointerProxy.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAEtF,6EAA6E;AAC7E,wBAAgB,2BAA2B,CAAC,EAAE,QAAQ,EAAE,EAAE,gCAAgC,6BAEzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHorizontalPointerProxy.native.js","sourceRoot":"","sources":["../../../src/features/color/ColorHorizontalPointerProxy.native.tsx"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,MAAM,UAAU,2BAA2B,CAAC,EAAE,QAAQ,EAAoC;IACxF,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { ColorHorizontalPointerProxyProps } from './ColorHorizontalPointerProxy';\n\n/*** Leaves native SVG responders in charge of horizontal slider gestures. */\nexport function ColorHorizontalPointerProxy({ children }: ColorHorizontalPointerProxyProps) {\n return children;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorHorizontalPointerProxyProps } from './ColorHorizontalPointerProxy';
|
|
3
|
+
/*** Maps browser drag coordinates into an SVG slider's stable viewbox width. */
|
|
4
|
+
export declare function ColorHorizontalPointerProxy({ children, disabled, onChange, width, }: ColorHorizontalPointerProxyProps): React.JSX.Element;
|
|
5
|
+
//# sourceMappingURL=ColorHorizontalPointerProxy.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHorizontalPointerProxy.web.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHorizontalPointerProxy.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAEtF,gFAAgF;AAChF,wBAAgB,2BAA2B,CAAC,EAC1C,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE,gCAAgC,qBA2BlC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/*** Maps browser drag coordinates into an SVG slider's stable viewbox width. */
|
|
3
|
+
export function ColorHorizontalPointerProxy({ children, disabled, onChange, width, }) {
|
|
4
|
+
const dragging = React.useRef(false);
|
|
5
|
+
const changeAt = (event) => {
|
|
6
|
+
const target = event.currentTarget;
|
|
7
|
+
const rect = target.getBoundingClientRect();
|
|
8
|
+
onChange(((event.clientX - rect.left) / rect.width) * width);
|
|
9
|
+
};
|
|
10
|
+
return (<div onMouseDown={(event) => {
|
|
11
|
+
if (disabled)
|
|
12
|
+
return;
|
|
13
|
+
dragging.current = true;
|
|
14
|
+
changeAt(event);
|
|
15
|
+
}} onMouseMove={(event) => {
|
|
16
|
+
if (!disabled && dragging.current)
|
|
17
|
+
changeAt(event);
|
|
18
|
+
}} onMouseUp={(event) => {
|
|
19
|
+
if (!disabled && dragging.current)
|
|
20
|
+
changeAt(event);
|
|
21
|
+
dragging.current = false;
|
|
22
|
+
}} style={{ touchAction: 'none' }}>
|
|
23
|
+
{children}
|
|
24
|
+
</div>);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ColorHorizontalPointerProxy.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHorizontalPointerProxy.web.js","sourceRoot":"","sources":["../../../src/features/color/ColorHorizontalPointerProxy.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,gFAAgF;AAChF,MAAM,UAAU,2BAA2B,CAAC,EAC1C,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,GAC4B;IACjC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,CAAC,KAAuC,EAAE,EAAE;QAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,aAAgD,CAAC;QACtE,MAAM,IAAI,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;QAC5C,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/D,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,GAAG,CACF,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO;gBAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC,CACF,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACnB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO;gBAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnD,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAC3B,CAAC,CAAC,CACF,KAAK,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAE/B;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport type { ColorHorizontalPointerProxyProps } from './ColorHorizontalPointerProxy';\n\n/*** Maps browser drag coordinates into an SVG slider's stable viewbox width. */\nexport function ColorHorizontalPointerProxy({\n children,\n disabled,\n onChange,\n width,\n}: ColorHorizontalPointerProxyProps) {\n const dragging = React.useRef(false);\n const changeAt = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.currentTarget as unknown as BrowserPointerTarget;\n const rect = target.getBoundingClientRect();\n onChange(((event.clientX - rect.left) / rect.width) * width);\n };\n\n return (\n <div\n onMouseDown={(event) => {\n if (disabled) return;\n dragging.current = true;\n changeAt(event);\n }}\n onMouseMove={(event) => {\n if (!disabled && dragging.current) changeAt(event);\n }}\n onMouseUp={(event) => {\n if (!disabled && dragging.current) changeAt(event);\n dragging.current = false;\n }}\n style={{ touchAction: 'none' }}\n >\n {children}\n </div>\n );\n}\n\ninterface BrowserPointerTarget {\n readonly getBoundingClientRect: () => {\n readonly left: number;\n readonly width: number;\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorHueScale.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHueScale.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorHueScale.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorHueScale.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAU5D,6EAA6E;AAC7E,eAAO,MAAM,aAAa,0DAAyC,CAAC"}
|
|
@@ -2,21 +2,32 @@ import { generateColorSwatch } from '@ankhorage/color-theory';
|
|
|
2
2
|
import { Pressable } from '@ankhorage/surface';
|
|
3
3
|
import { View } from '../layout/public';
|
|
4
4
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
5
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
5
6
|
import { Text } from '../typography/public';
|
|
7
|
+
import { ColorHexField } from './ColorHexField';
|
|
8
|
+
import { ColorSpectrumSlider } from './ColorSpectrumSlider';
|
|
9
|
+
import { resolveColorAtHue } from './utils/resolveColorAtHue';
|
|
10
|
+
import { resolveColorHue } from './utils/resolveColorHue';
|
|
6
11
|
/*** Edits the 500 base color and previews its canonical 50-to-950 swatch. */
|
|
7
12
|
export const ColorHueScale = withZoraThemeScope(ColorHueScaleInner);
|
|
8
13
|
/*** Maps generated previews to an explicitly editable 500 base without misreporting preview selection. */
|
|
9
14
|
function ColorHueScaleInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, value, onChange, testID, }) {
|
|
15
|
+
const { theme } = useZoraTheme();
|
|
10
16
|
const { swatch } = generateColorSwatch(value);
|
|
11
17
|
const swatches = Object.entries(swatch);
|
|
12
|
-
return (<View
|
|
13
|
-
{
|
|
18
|
+
return (<View gap="m" testID={testID}>
|
|
19
|
+
<ColorSpectrumSlider disabled={interactionPolicy === 'passive'} hue={resolveColorHue(value)} onChange={(nextHue) => onChange(resolveColorAtHue(value, nextHue))}/>
|
|
20
|
+
<Text variant="label">Intensity</Text>
|
|
21
|
+
<View accessibilityLabel="Color scale previews; choose a preview as the next 500 base color" direction="row" gap="xs" wrap="wrap">
|
|
22
|
+
{swatches.map(([step, color]) => (<Pressable key={step} accessibilityLabel={Number(step) === 500
|
|
14
23
|
? `Current editable base color 500: ${color}`
|
|
15
|
-
: `Use generated ${step} preview ${color} as the next base color 500`} bg={color} borderColor=
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
: `Use generated ${step} preview ${color} as the next base color 500`} bg={color} borderColor={theme.semantics.border.default} borderWidth={Number(step) === 500 ? 3 : 1} disabled={interactionPolicy === 'passive'} height={48} onPress={() => onChange(color)} radius="s" width="18%">
|
|
25
|
+
<Text align="center" variant="caption">
|
|
26
|
+
{step}
|
|
27
|
+
</Text>
|
|
28
|
+
</Pressable>))}
|
|
29
|
+
</View>
|
|
30
|
+
<ColorHexField disabled={interactionPolicy === 'passive'} key={value} onChange={onChange} value={value}/>
|
|
20
31
|
</View>);
|
|
21
32
|
}
|
|
22
33
|
//# sourceMappingURL=ColorHueScale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorHueScale.js","sourceRoot":"","sources":["../../../src/features/color/ColorHueScale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,CAAC,CAC1C,MAAM,CAAC,CAAC,EAAE,CAAC,CACX,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAC/B,MAAM,CAAC,GAAG,CACV,KAAK,CAAC,KAAK,CAEX;YAAA,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CACpC;cAAA,CAAC,IAAI,CACP;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,SAAS,CAAC,CACb,CAAC,CACJ;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,aAAa,CACZ,QAAQ,CAAC,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAC1C,GAAG,CAAC,CAAC,KAAK,CAAC,CACX,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,KAAK,CAAC,CAAC,KAAK,CAAC,EAEjB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { generateColorSwatch } from '@ankhorage/color-theory';\nimport { Pressable } from '@ankhorage/surface';\n\nimport type { ColorHueScaleProps } from '../../types/color';\nimport { View } from '../layout/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { Text } from '../typography/public';\nimport { ColorHexField } from './ColorHexField';\nimport { ColorSpectrumSlider } from './ColorSpectrumSlider';\nimport { resolveColorAtHue } from './utils/resolveColorAtHue';\nimport { resolveColorHue } from './utils/resolveColorHue';\n\n/*** Edits the 500 base color and previews its canonical 50-to-950 swatch. */\nexport const ColorHueScale = withZoraThemeScope(ColorHueScaleInner);\n\n/*** Maps generated previews to an explicitly editable 500 base without misreporting preview selection. */\nfunction ColorHueScaleInner({\n themeId: _themeId,\n mode: _mode,\n inverted: _inverted,\n interactionPolicy,\n value,\n onChange,\n testID,\n}: ColorHueScaleProps) {\n const { theme } = useZoraTheme();\n const { swatch } = generateColorSwatch(value);\n const swatches = Object.entries(swatch);\n\n return (\n <View gap=\"m\" testID={testID}>\n <ColorSpectrumSlider\n disabled={interactionPolicy === 'passive'}\n hue={resolveColorHue(value)}\n onChange={(nextHue) => onChange(resolveColorAtHue(value, nextHue))}\n />\n <Text variant=\"label\">Intensity</Text>\n <View\n accessibilityLabel=\"Color scale previews; choose a preview as the next 500 base color\"\n direction=\"row\"\n gap=\"xs\"\n wrap=\"wrap\"\n >\n {swatches.map(([step, color]) => (\n <Pressable\n key={step}\n accessibilityLabel={\n Number(step) === 500\n ? `Current editable base color 500: ${color}`\n : `Use generated ${step} preview ${color} as the next base color 500`\n }\n bg={color}\n borderColor={theme.semantics.border.default}\n borderWidth={Number(step) === 500 ? 3 : 1}\n disabled={interactionPolicy === 'passive'}\n height={48}\n onPress={() => onChange(color)}\n radius=\"s\"\n width=\"18%\"\n >\n <Text align=\"center\" variant=\"caption\">\n {step}\n </Text>\n </Pressable>\n ))}\n </View>\n <ColorHexField\n disabled={interactionPolicy === 'passive'}\n key={value}\n onChange={onChange}\n value={value}\n />\n </View>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAoC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAoC,MAAM,mBAAmB,CAAC;AAW5F,iGAAiG;AACjG,eAAO,MAAM,WAAW,wDAAuC,CAAC"}
|
|
@@ -1,33 +1,60 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IconButton } from '../button/public';
|
|
3
|
+
import { View } from '../layout/public';
|
|
2
4
|
import { Tab, TabList, TabPanel, Tabs } from '../tabs/public';
|
|
3
5
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
6
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
7
|
+
import { Text } from '../typography/public';
|
|
4
8
|
import { ColorHueScale } from './ColorHueScale';
|
|
5
9
|
import { ColorTone } from './ColorTone';
|
|
6
10
|
import { ColorWheel } from './ColorWheel';
|
|
7
11
|
/*** Composes independently usable color controls into an ordered, consumer-configured picker. */
|
|
8
12
|
export const ColorPicker = withZoraThemeScope(ColorPickerInner);
|
|
9
13
|
/*** Coordinates persistent controlled color selections across independently usable picker tabs. */
|
|
10
|
-
function ColorPickerInner({ themeId: _themeId, mode: _mode, inverted: _inverted, tabs, value, onValueChange, onSelectionChange, hideTabListWhenSingle = true, wheel, tone, hue, testID, }) {
|
|
14
|
+
function ColorPickerInner({ themeId: _themeId, mode: _mode, inverted: _inverted, tabs, value, onValueChange, onSelectionChange, onDismiss, hideTabListWhenSingle = true, wheel, tone, hue, testID, }) {
|
|
15
|
+
const { theme } = useZoraTheme();
|
|
11
16
|
if (tabs.length === 0)
|
|
12
17
|
throw new Error('ColorPicker requires at least one tab.');
|
|
13
18
|
if (!tabs.includes(value.tab))
|
|
14
19
|
throw new Error('ColorPicker value must be configured in tabs.');
|
|
15
|
-
|
|
20
|
+
const previewColor = resolvePickerPreviewColor(value);
|
|
21
|
+
return (<View alignSelf="center" bg={theme.semantics.surface.raised} borderColor={theme.semantics.border.default} borderWidth={1} flexShrink={1} gap="s" maxWidth={400} p="m" radius="l" testID={testID} width="100%">
|
|
22
|
+
<View align="center" direction="row" justify="space-between">
|
|
23
|
+
<Text variant="lead" weight="semiBold">
|
|
24
|
+
Color
|
|
25
|
+
</Text>
|
|
26
|
+
<View align="center" direction="row" gap="s">
|
|
27
|
+
<View bg={previewColor} borderColor={theme.semantics.border.default} borderWidth={1} height={38} radius="s" width={38}/>
|
|
28
|
+
{onDismiss ? (<IconButton iconName="close" label="Close color picker" onPress={onDismiss}/>) : null}
|
|
29
|
+
</View>
|
|
30
|
+
</View>
|
|
31
|
+
<Tabs defaultValue={value.tab} onValueChange={(nextValue) => {
|
|
16
32
|
if (isColorPickerTab(nextValue) && tabs.includes(nextValue))
|
|
17
33
|
onValueChange({ ...value, tab: nextValue });
|
|
18
|
-
}} testID={testID} value={value.tab}>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
}} testID={testID ? `${testID}-tabs` : undefined} value={value.tab} variant="attached">
|
|
35
|
+
{tabs.length > 1 || !hideTabListWhenSingle ? (<View borderColor={theme.semantics.border.default} borderWidth={1} overflow="hidden" radius="m">
|
|
36
|
+
<TabList fill>
|
|
37
|
+
{tabs.map((tab) => (<Tab key={tab} label={tab} value={tab}/>))}
|
|
38
|
+
</TabList>
|
|
39
|
+
</View>) : null}
|
|
40
|
+
{tabs.map((tab) => (<TabPanel key={tab} value={tab}>
|
|
41
|
+
{resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange)}
|
|
42
|
+
</TabPanel>))}
|
|
43
|
+
</Tabs>
|
|
44
|
+
</View>);
|
|
26
45
|
}
|
|
27
46
|
/*** Check whether a Surface tab value belongs to the configured picker vocabulary. */
|
|
28
47
|
function isColorPickerTab(value) {
|
|
29
48
|
return value === 'wheel' || value === 'tone' || value === 'hue';
|
|
30
49
|
}
|
|
50
|
+
/*** Resolves the visible active-tab color without introducing a second picker state. */
|
|
51
|
+
function resolvePickerPreviewColor(value) {
|
|
52
|
+
if (value.tab === 'hue')
|
|
53
|
+
return value.hue;
|
|
54
|
+
if (value.tab === 'tone')
|
|
55
|
+
return value.tone?.colors.at(0) ?? value.wheel.color;
|
|
56
|
+
return value.wheel.color;
|
|
57
|
+
}
|
|
31
58
|
/*** Resolve the configured control for one picker tab without adding fallback feature modes. */
|
|
32
59
|
function resolveTabContent(tab, value, wheel, tone, hue, onValueChange, onSelectionChange) {
|
|
33
60
|
if (tab === 'wheel')
|
|
@@ -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,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,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,qBAAqB,GAAG,IAAI,EAC5B,KAAK,EACL,IAAI,EACJ,GAAG,EACH,MAAM,GACW;IACjB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACjF,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAEhG,OAAO,CACL,CAAC,IAAI,CACH,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CACxB,aAAa,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE;YAC3B,IAAI,gBAAgB,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS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C;QACpD,CAAC,CAAC,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 { Tab, TabList, TabPanel, Tabs } from '../tabs/public';\nimport { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';\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 hideTabListWhenSingle = true,\n wheel,\n tone,\n hue,\n testID,\n}: ColorPickerProps) {\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\n return (\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}\n value={value.tab}\n >\n {tabs.length > 1 || !hideTabListWhenSingle ? (\n <TabList fill>\n {tabs.map((tab) => (\n <Tab key={tab} label={tab} value={tab} />\n ))}\n </TabList>\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 );\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/*** 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,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,C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C,CAAC,CAAC,CACX,CAAC,aAAa,CACZ,IAAI,GAAG,CAAC,CACR,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;YACjB,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC,CAAC,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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/*** Selects a controlled hue across the same full-spectrum track used by Studio tabs. */
|
|
3
|
+
export declare function ColorSpectrumSlider({ disabled, hue, label, onChange, }: {
|
|
4
|
+
readonly disabled: boolean;
|
|
5
|
+
readonly hue: number;
|
|
6
|
+
readonly label?: string;
|
|
7
|
+
readonly onChange: (hue: number) => void;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
//# sourceMappingURL=ColorSpectrumSlider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSpectrumSlider.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorSpectrumSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,GAAG,EACH,KAAa,EACb,QAAQ,GACT,EAAE;IACD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,qBAuDA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Circle, Defs, LinearGradient, Rect, Stop, Svg } from 'react-native-svg';
|
|
3
|
+
import { View } from '../layout/public';
|
|
4
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
5
|
+
import { Text } from '../typography/public';
|
|
6
|
+
import { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';
|
|
7
|
+
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
8
|
+
const SPECTRUM_WIDTH = 280;
|
|
9
|
+
const SPECTRUM_HUES = [0, 60, 120, 180, 240, 300, 360];
|
|
10
|
+
/*** Selects a controlled hue across the same full-spectrum track used by Studio tabs. */
|
|
11
|
+
export function ColorSpectrumSlider({ disabled, hue, label = 'Hue', onChange, }) {
|
|
12
|
+
const { theme } = useZoraTheme();
|
|
13
|
+
const [trackWidth, setTrackWidth] = React.useState(SPECTRUM_WIDTH);
|
|
14
|
+
const gradientId = `color-spectrum-${React.useId().replaceAll(':', '')}`;
|
|
15
|
+
const changeAt = (locationX) => {
|
|
16
|
+
if (!disabled)
|
|
17
|
+
onChange(Math.max(0, Math.min(360, (locationX / trackWidth) * 360)));
|
|
18
|
+
};
|
|
19
|
+
return (<View gap="xxs" width="100%">
|
|
20
|
+
<View direction="row" justify="space-between">
|
|
21
|
+
<Text variant="label">{label}</Text>
|
|
22
|
+
<Text variant="label">{`${Math.round(hue)}°`}</Text>
|
|
23
|
+
</View>
|
|
24
|
+
<ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={SPECTRUM_WIDTH}>
|
|
25
|
+
<Svg accessibilityLabel={`${label} spectrum`} height={36} onLayout={(event) => setTrackWidth(Math.max(1, event.nativeEvent.layout.width))} viewBox={`0 0 ${SPECTRUM_WIDTH} 36`} width="100%">
|
|
26
|
+
<Defs>
|
|
27
|
+
<LinearGradient id={gradientId} x1="0" x2="1" y1="0" y2="0">
|
|
28
|
+
{SPECTRUM_HUES.map((stopHue, index) => (<Stop key={stopHue} offset={String(index / (SPECTRUM_HUES.length - 1))} stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0.2 }, stopHue)}/>))}
|
|
29
|
+
</LinearGradient>
|
|
30
|
+
</Defs>
|
|
31
|
+
<Rect fill={`url(#${gradientId})`} height={12} rx={6} width={SPECTRUM_WIDTH} y={12}/>
|
|
32
|
+
<Circle cx={(hue / 360) * SPECTRUM_WIDTH} cy={18} fill="white" r={10} stroke={theme.semantics.content.default} strokeWidth={2}/>
|
|
33
|
+
<Rect fill="transparent" height={36} onResponderGrant={(event) => changeAt(event.nativeEvent.locationX)} onResponderMove={(event) => changeAt(event.nativeEvent.locationX)} onResponderRelease={(event) => changeAt(event.nativeEvent.locationX)} onStartShouldSetResponder={() => !disabled} width={SPECTRUM_WIDTH}/>
|
|
34
|
+
</Svg>
|
|
35
|
+
</ColorHorizontalPointerProxy>
|
|
36
|
+
</View>);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ColorSpectrumSlider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSpectrumSlider.js","sourceRoot":"","sources":["../../../src/features/color/ColorSpectrumSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E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cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACnF;UAAA,CAAC,MAAM,CACL,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,cAAc,CAAC,CACjC,EAAE,CAAC,CAAC,EAAE,CAAC,CACP,IAAI,CAAC,OAAO,CACZ,CAAC,CAAC,CAAC,EAAE,CAAC,CACN,MAAM,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CACxC,WAAW,CAAC,CAAC,CAAC,CAAC,EAEjB;UAAA,CAAC,IAAI,CACH,IAAI,CAAC,aAAa,CAClB,MAAM,CAAC,CAAC,EAAE,CAAC,CACX,gBAAgB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CACnE,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAClE,kBAAkB,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CACrE,yBAAyB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAC3C,KAAK,CAAC,CAAC,cAAc,CAAC,EAE1B;QAAA,EAAE,GAAG,CACP;MAAA,EAAE,2BAA2B,CAC/B;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Circle, Defs, LinearGradient, Rect, Stop, Svg } from 'react-native-svg';\n\nimport { View } from '../layout/public';\nimport { useZoraTheme } from '../theme/composition/useZoraTheme';\nimport { Text } from '../typography/public';\nimport { ColorHorizontalPointerProxy } from './ColorHorizontalPointerProxy';\nimport { resolveOklchColor } from './utils/resolveOklchColor';\n\nconst SPECTRUM_WIDTH = 280;\nconst SPECTRUM_HUES = [0, 60, 120, 180, 240, 300, 360] as const;\n\n/*** Selects a controlled hue across the same full-spectrum track used by Studio tabs. */\nexport function ColorSpectrumSlider({\n disabled,\n hue,\n label = 'Hue',\n onChange,\n}: {\n readonly disabled: boolean;\n readonly hue: number;\n readonly label?: string;\n readonly onChange: (hue: number) => void;\n}) {\n const { theme } = useZoraTheme();\n const [trackWidth, setTrackWidth] = React.useState(SPECTRUM_WIDTH);\n const gradientId = `color-spectrum-${React.useId().replaceAll(':', '')}`;\n const changeAt = (locationX: number) => {\n if (!disabled) onChange(Math.max(0, Math.min(360, (locationX / trackWidth) * 360)));\n };\n\n return (\n <View gap=\"xxs\" width=\"100%\">\n <View direction=\"row\" justify=\"space-between\">\n <Text variant=\"label\">{label}</Text>\n <Text variant=\"label\">{`${Math.round(hue)}°`}</Text>\n </View>\n <ColorHorizontalPointerProxy disabled={disabled} onChange={changeAt} width={SPECTRUM_WIDTH}>\n <Svg\n accessibilityLabel={`${label} spectrum`}\n height={36}\n onLayout={(event) => setTrackWidth(Math.max(1, event.nativeEvent.layout.width))}\n viewBox={`0 0 ${SPECTRUM_WIDTH} 36`}\n width=\"100%\"\n >\n <Defs>\n <LinearGradient id={gradientId} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n {SPECTRUM_HUES.map((stopHue, index) => (\n <Stop\n key={stopHue}\n offset={String(index / (SPECTRUM_HUES.length - 1))}\n stopColor={resolveOklchColor({ lightness: 0.65, chroma: 0.2 }, stopHue)}\n />\n ))}\n </LinearGradient>\n </Defs>\n <Rect fill={`url(#${gradientId})`} height={12} rx={6} width={SPECTRUM_WIDTH} y={12} />\n <Circle\n cx={(hue / 360) * SPECTRUM_WIDTH}\n cy={18}\n fill=\"white\"\n r={10}\n stroke={theme.semantics.content.default}\n strokeWidth={2}\n />\n <Rect\n fill=\"transparent\"\n height={36}\n onResponderGrant={(event) => changeAt(event.nativeEvent.locationX)}\n onResponderMove={(event) => changeAt(event.nativeEvent.locationX)}\n onResponderRelease={(event) => changeAt(event.nativeEvent.locationX)}\n onStartShouldSetResponder={() => !disabled}\n width={SPECTRUM_WIDTH}\n />\n </Svg>\n </ColorHorizontalPointerProxy>\n </View>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorTone.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorTone.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColorTone.d.ts","sourceRoot":"","sources":["../../../src/features/color/ColorTone.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAiBxD,kFAAkF;AAClF,eAAO,MAAM,SAAS,sDAAqC,CAAC"}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
+
import {} from '@ankhorage/color-theory';
|
|
1
2
|
import { Button, Pressable } from '@ankhorage/surface';
|
|
2
3
|
import React from 'react';
|
|
4
|
+
import { Circle, Defs, LinearGradient, Rect, Stop, Svg } from 'react-native-svg';
|
|
3
5
|
import { View } from '../layout/public';
|
|
4
6
|
import { withZoraThemeScope } from '../theme/adapters/inbound/withZoraThemeScope';
|
|
5
|
-
import {
|
|
7
|
+
import { useZoraTheme } from '../theme/composition/useZoraTheme';
|
|
8
|
+
import { Text } from '../typography/public';
|
|
9
|
+
import { ColorHexField } from './ColorHexField';
|
|
10
|
+
import { ColorSpectrumSlider } from './ColorSpectrumSlider';
|
|
11
|
+
import { ColorWheelPointerProxy } from './ColorWheelPointerProxy';
|
|
6
12
|
import { resolveColorHue } from './utils/resolveColorHue';
|
|
7
13
|
import { resolveOklchColor } from './utils/resolveOklchColor';
|
|
14
|
+
import { resolveWheelColorComponents } from './utils/resolveWheelColorComponents';
|
|
8
15
|
const MAX_TONE_COLORS = 4;
|
|
16
|
+
const TONE_MAP_WIDTH = 280;
|
|
17
|
+
const TONE_MAP_HEIGHT = 220;
|
|
18
|
+
const TONE_MAX_CHROMA = 0.2;
|
|
9
19
|
/*** Selects consumer-provided OKLCH tone targets while keeping hue adjustable. */
|
|
10
20
|
export const ColorTone = withZoraThemeScope(ColorToneInner);
|
|
11
21
|
/*** Renders one supplied tone and its actual, editable OKLCH color selections. */
|
|
12
22
|
function ColorToneInner({ themeId: _themeId, mode: _mode, inverted: _inverted, interactionPolicy, tones, selectionMode = 'single', value, onChange, testID, }) {
|
|
23
|
+
const { theme } = useZoraTheme();
|
|
13
24
|
const [editingColorIndex, setEditingColorIndex] = React.useState(0);
|
|
14
25
|
const selectedTone = tones.find((tone) => tone.id === value?.toneId);
|
|
15
26
|
const colors = value
|
|
@@ -24,17 +35,33 @@ function ColorToneInner({ themeId: _themeId, mode: _mode, inverted: _inverted, i
|
|
|
24
35
|
setEditingColorIndex(0);
|
|
25
36
|
onChange({ toneId: tone.id, colors: [resolveOklchColor(tone.accentTarget, hue)] });
|
|
26
37
|
};
|
|
27
|
-
return (<View gap="
|
|
28
|
-
<View
|
|
38
|
+
return (<View gap="m" testID={testID}>
|
|
39
|
+
<View gap="xs">
|
|
40
|
+
<Text variant="label">Tone</Text>
|
|
41
|
+
<Text emphasis="muted" variant="caption">
|
|
42
|
+
Choose a catalog tone
|
|
43
|
+
</Text>
|
|
44
|
+
</View>
|
|
45
|
+
<View direction="row" gap="s" wrap="wrap">
|
|
29
46
|
{tones.map((tone) => {
|
|
30
47
|
const selected = value?.toneId === tone.id;
|
|
31
48
|
const color = selected && selectedColor ? selectedColor : resolveOklchColor(tone.accentTarget, 0);
|
|
32
|
-
return (<Pressable key={tone.id} accessibilityLabel={tone.accent} accessibilityRole="radio" accessibilityState={{ checked: selected }} bg={color} borderColor=
|
|
49
|
+
return (<Pressable key={tone.id} accessibilityLabel={tone.accent} accessibilityRole="radio" accessibilityState={{ checked: selected }} bg={color} borderColor={theme.semantics.border.default} borderWidth={selected ? 3 : 1} disabled={interactionPolicy === 'passive'} height={56} onPress={() => selectTone(tone)} radius="m" width={56}>
|
|
50
|
+
<Text align="center" variant="caption">
|
|
51
|
+
{tone.accent}
|
|
52
|
+
</Text>
|
|
53
|
+
</Pressable>);
|
|
33
54
|
})}
|
|
34
55
|
</View>
|
|
35
56
|
{selectedTone && selectedColor && value ? (<>
|
|
57
|
+
<ColorToneMap color={selectedColor} disabled={interactionPolicy === 'passive'} onChange={(lightness, chroma) => onChange({
|
|
58
|
+
toneId: selectedTone.id,
|
|
59
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex
|
|
60
|
+
? resolveOklchColor({ chroma, lightness }, resolveColorHue(entry))
|
|
61
|
+
: entry),
|
|
62
|
+
})}/>
|
|
36
63
|
<View direction="row" gap="xs" wrap="wrap">
|
|
37
|
-
{colors.map((color, index) => (<Pressable key={`${color}-${index}`} accessibilityLabel={`Selected ${selectedTone.accent} color ${index + 1}: ${color}`} accessibilityRole="radio" accessibilityState={{ checked: currentEditingColorIndex === index }} bg={color} borderColor=
|
|
64
|
+
{colors.map((color, index) => (<Pressable key={`${color}-${index}`} accessibilityLabel={`Selected ${selectedTone.accent} color ${index + 1}: ${color}`} accessibilityRole="radio" accessibilityState={{ checked: currentEditingColorIndex === index }} bg={color} borderColor={theme.semantics.border.default} borderWidth={currentEditingColorIndex === index ? 3 : 1} disabled={interactionPolicy === 'passive'} height={44} onPress={() => setEditingColorIndex(index)} radius="m" width={44}/>))}
|
|
38
65
|
{selectionMode === 'multiple' ? (<Button disabled={interactionPolicy === 'passive' || colors.length >= MAX_TONE_COLORS} onPress={() => {
|
|
39
66
|
setEditingColorIndex(colors.length);
|
|
40
67
|
onChange({
|
|
@@ -52,14 +79,46 @@ function ColorToneInner({ themeId: _themeId, mode: _mode, inverted: _inverted, i
|
|
|
52
79
|
Remove color
|
|
53
80
|
</Button>) : null}
|
|
54
81
|
</View>
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
<ColorSpectrumSlider disabled={interactionPolicy === 'passive'} hue={resolveColorHue(selectedColor)} onChange={(nextHue) => onChange({
|
|
83
|
+
toneId: selectedTone.id,
|
|
84
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex
|
|
85
|
+
? resolveOklchColor(selectedTone.accentTarget, nextHue)
|
|
86
|
+
: entry),
|
|
87
|
+
})}/>
|
|
88
|
+
<ColorHexField disabled={interactionPolicy === 'passive'} key={selectedColor} onChange={(color) => onChange({
|
|
89
|
+
toneId: selectedTone.id,
|
|
90
|
+
colors: colors.map((entry, index) => index === currentEditingColorIndex ? color : entry),
|
|
91
|
+
})} value={selectedColor}/>
|
|
62
92
|
</>) : null}
|
|
63
93
|
</View>);
|
|
64
94
|
}
|
|
95
|
+
/*** Renders the Studio-style saturation and lightness plane for the active catalog color. */
|
|
96
|
+
function ColorToneMap({ color, disabled, onChange, }) {
|
|
97
|
+
const hue = resolveColorHue(color);
|
|
98
|
+
const { chroma, lightness } = resolveWheelColorComponents(color);
|
|
99
|
+
const gradientId = `color-tone-${React.useId().replaceAll(':', '')}`;
|
|
100
|
+
const changeAt = (x, y) => {
|
|
101
|
+
if (disabled)
|
|
102
|
+
return;
|
|
103
|
+
onChange(Math.max(0, Math.min(1, 1 - y / TONE_MAP_HEIGHT)), Math.max(0, Math.min(TONE_MAX_CHROMA, (x / TONE_MAP_WIDTH) * TONE_MAX_CHROMA)));
|
|
104
|
+
};
|
|
105
|
+
return (<ColorWheelPointerProxy disabled={disabled} height={TONE_MAP_HEIGHT} onChange={changeAt} width={TONE_MAP_WIDTH}>
|
|
106
|
+
<Svg accessibilityLabel="Tone color plane" height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH}>
|
|
107
|
+
<Defs>
|
|
108
|
+
<LinearGradient id={`${gradientId}-white`} x1="0" x2="1" y1="0" y2="0">
|
|
109
|
+
<Stop offset="0" stopColor="white"/>
|
|
110
|
+
<Stop offset="1" stopColor={resolveOklchColor({ chroma: TONE_MAX_CHROMA, lightness: 0.65 }, hue)}/>
|
|
111
|
+
</LinearGradient>
|
|
112
|
+
<LinearGradient id={`${gradientId}-black`} x1="0" x2="0" y1="0" y2="1">
|
|
113
|
+
<Stop offset="0" stopColor="transparent"/>
|
|
114
|
+
<Stop offset="1" stopColor="black"/>
|
|
115
|
+
</LinearGradient>
|
|
116
|
+
</Defs>
|
|
117
|
+
<Rect fill={`url(#${gradientId}-white)`} height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH}/>
|
|
118
|
+
<Rect fill={`url(#${gradientId}-black)`} height={TONE_MAP_HEIGHT} width={TONE_MAP_WIDTH}/>
|
|
119
|
+
<Circle cx={(chroma / TONE_MAX_CHROMA) * TONE_MAP_WIDTH} cy={(1 - lightness) * TONE_MAP_HEIGHT} fill="none" r={10} stroke="white" strokeWidth={3}/>
|
|
120
|
+
<Rect fill="transparent" height={TONE_MAP_HEIGHT} onResponderGrant={(event) => changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)} onResponderMove={(event) => changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)} onResponderRelease={(event) => changeAt(event.nativeEvent.locationX, event.nativeEvent.locationY)} onStartShouldSetResponder={() => !disabled} width={TONE_MAP_WIDTH}/>
|
|
121
|
+
</Svg>
|
|
122
|
+
</ColorWheelPointerProxy>);
|
|
123
|
+
}
|
|
65
124
|
//# sourceMappingURL=ColorTone.js.map
|