@oxy.so/bloom 20.0.0 → 21.1.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/docs/adoption-matrix.mdx +6 -7
- package/docs/agent-avatar.mdx +8 -5
- package/docs/agent-creator.mdx +13 -11
- package/docs/multi-agent-chat.mdx +6 -2
- package/docs/public-parts.mdx +2 -2
- package/docs/task-catalog.json +1 -1
- package/docs/task-catalog.mdx +1 -1
- package/lib/commonjs/agent-avatar/VectorCharacterAvatar.js +16 -11
- package/lib/commonjs/agent-avatar/VectorCharacterAvatar.js.map +1 -1
- package/lib/commonjs/agent-avatar/character.js +4 -4
- package/lib/commonjs/agent-avatar/use-static-portraits.js +51 -0
- package/lib/commonjs/agent-avatar/use-static-portraits.js.map +1 -0
- package/lib/commonjs/agent-creator/AgentCreator.js +4 -0
- package/lib/commonjs/agent-creator/AgentCreator.js.map +1 -1
- package/lib/commonjs/agent-creator/AgentCreator.web.js +12 -8
- package/lib/commonjs/agent-creator/AgentCreator.web.js.map +1 -1
- package/lib/commonjs/agent-creator/AgentCreatorBase.js +93 -48
- package/lib/commonjs/agent-creator/AgentCreatorBase.js.map +1 -1
- package/lib/commonjs/agent-creator/CustomColorPicker.js +431 -0
- package/lib/commonjs/agent-creator/CustomColorPicker.js.map +1 -0
- package/lib/commonjs/agent-creator/GlossArt.js +212 -0
- package/lib/commonjs/agent-creator/GlossArt.js.map +1 -0
- package/lib/commonjs/agent-creator/ShapeSilhouette.js +4 -3
- package/lib/commonjs/agent-creator/ShapeSilhouette.js.map +1 -1
- package/lib/commonjs/agent-creator/context.js.map +1 -1
- package/lib/commonjs/agent-creator/messages.js +22 -1
- package/lib/commonjs/agent-creator/messages.js.map +1 -1
- package/lib/commonjs/agent-creator/paint.js +19 -7
- package/lib/commonjs/agent-creator/paint.js.map +1 -1
- package/lib/commonjs/agent-creator/rainbow-artwork.js +10 -0
- package/lib/commonjs/agent-creator/rainbow-artwork.js.map +1 -0
- package/lib/commonjs/agent-creator/shared.js +28 -0
- package/lib/commonjs/agent-creator/shared.js.map +1 -1
- package/lib/commonjs/locale/translations/ar.js +22 -1
- package/lib/commonjs/locale/translations/ar.js.map +1 -1
- package/lib/commonjs/locale/translations/bn.js +22 -1
- package/lib/commonjs/locale/translations/bn.js.map +1 -1
- package/lib/commonjs/locale/translations/ca.js +22 -1
- package/lib/commonjs/locale/translations/ca.js.map +1 -1
- package/lib/commonjs/locale/translations/de.js +22 -1
- package/lib/commonjs/locale/translations/de.js.map +1 -1
- package/lib/commonjs/locale/translations/es.js +22 -1
- package/lib/commonjs/locale/translations/es.js.map +1 -1
- package/lib/commonjs/locale/translations/fr.js +22 -1
- package/lib/commonjs/locale/translations/fr.js.map +1 -1
- package/lib/commonjs/locale/translations/hi.js +22 -1
- package/lib/commonjs/locale/translations/hi.js.map +1 -1
- package/lib/commonjs/locale/translations/id.js +22 -1
- package/lib/commonjs/locale/translations/id.js.map +1 -1
- package/lib/commonjs/locale/translations/it.js +22 -1
- package/lib/commonjs/locale/translations/it.js.map +1 -1
- package/lib/commonjs/locale/translations/ja.js +22 -1
- package/lib/commonjs/locale/translations/ja.js.map +1 -1
- package/lib/commonjs/locale/translations/pt.js +22 -1
- package/lib/commonjs/locale/translations/pt.js.map +1 -1
- package/lib/commonjs/locale/translations/ru.js +22 -1
- package/lib/commonjs/locale/translations/ru.js.map +1 -1
- package/lib/commonjs/locale/translations/tr.js +22 -1
- package/lib/commonjs/locale/translations/tr.js.map +1 -1
- package/lib/commonjs/locale/translations/zh.js +22 -1
- package/lib/commonjs/locale/translations/zh.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/data.js +2 -2
- package/lib/commonjs/multi-agent-chat/data.js.map +1 -1
- package/lib/commonjs/multi-agent-chat/selected-agent-preview.js +19 -0
- package/lib/commonjs/multi-agent-chat/selected-agent-preview.js.map +1 -0
- package/lib/module/agent-avatar/VectorCharacterAvatar.js +16 -11
- package/lib/module/agent-avatar/VectorCharacterAvatar.js.map +1 -1
- package/lib/module/agent-avatar/character.js +4 -4
- package/lib/module/agent-avatar/use-static-portraits.js +44 -0
- package/lib/module/agent-avatar/use-static-portraits.js.map +1 -0
- package/lib/module/agent-creator/AgentCreator.js +4 -0
- package/lib/module/agent-creator/AgentCreator.js.map +1 -1
- package/lib/module/agent-creator/AgentCreator.web.js +4 -0
- package/lib/module/agent-creator/AgentCreator.web.js.map +1 -1
- package/lib/module/agent-creator/AgentCreatorBase.js +89 -44
- package/lib/module/agent-creator/AgentCreatorBase.js.map +1 -1
- package/lib/module/agent-creator/CustomColorPicker.js +426 -0
- package/lib/module/agent-creator/CustomColorPicker.js.map +1 -0
- package/lib/module/agent-creator/GlossArt.js +207 -0
- package/lib/module/agent-creator/GlossArt.js.map +1 -0
- package/lib/module/agent-creator/ShapeSilhouette.js +4 -3
- package/lib/module/agent-creator/ShapeSilhouette.js.map +1 -1
- package/lib/module/agent-creator/context.js.map +1 -1
- package/lib/module/agent-creator/messages.js +22 -1
- package/lib/module/agent-creator/messages.js.map +1 -1
- package/lib/module/agent-creator/paint.js +18 -7
- package/lib/module/agent-creator/paint.js.map +1 -1
- package/lib/module/agent-creator/rainbow-artwork.js +6 -0
- package/lib/module/agent-creator/rainbow-artwork.js.map +1 -0
- package/lib/module/agent-creator/shared.js +26 -0
- package/lib/module/agent-creator/shared.js.map +1 -1
- package/lib/module/locale/translations/ar.js +22 -1
- package/lib/module/locale/translations/ar.js.map +1 -1
- package/lib/module/locale/translations/bn.js +22 -1
- package/lib/module/locale/translations/bn.js.map +1 -1
- package/lib/module/locale/translations/ca.js +22 -1
- package/lib/module/locale/translations/ca.js.map +1 -1
- package/lib/module/locale/translations/de.js +22 -1
- package/lib/module/locale/translations/de.js.map +1 -1
- package/lib/module/locale/translations/es.js +22 -1
- package/lib/module/locale/translations/es.js.map +1 -1
- package/lib/module/locale/translations/fr.js +22 -1
- package/lib/module/locale/translations/fr.js.map +1 -1
- package/lib/module/locale/translations/hi.js +22 -1
- package/lib/module/locale/translations/hi.js.map +1 -1
- package/lib/module/locale/translations/id.js +22 -1
- package/lib/module/locale/translations/id.js.map +1 -1
- package/lib/module/locale/translations/it.js +22 -1
- package/lib/module/locale/translations/it.js.map +1 -1
- package/lib/module/locale/translations/ja.js +22 -1
- package/lib/module/locale/translations/ja.js.map +1 -1
- package/lib/module/locale/translations/pt.js +22 -1
- package/lib/module/locale/translations/pt.js.map +1 -1
- package/lib/module/locale/translations/ru.js +22 -1
- package/lib/module/locale/translations/ru.js.map +1 -1
- package/lib/module/locale/translations/tr.js +22 -1
- package/lib/module/locale/translations/tr.js.map +1 -1
- package/lib/module/locale/translations/zh.js +22 -1
- package/lib/module/locale/translations/zh.js.map +1 -1
- package/lib/module/multi-agent-chat/data.js +3 -3
- package/lib/module/multi-agent-chat/data.js.map +1 -1
- package/lib/module/multi-agent-chat/selected-agent-preview.js +9 -0
- package/lib/module/multi-agent-chat/selected-agent-preview.js.map +1 -0
- package/lib/typescript/commonjs/agent-avatar/VectorCharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-avatar/character.d.ts +4 -4
- package/lib/typescript/commonjs/agent-avatar/use-static-portraits.d.ts +16 -0
- package/lib/typescript/commonjs/agent-avatar/use-static-portraits.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/AgentCreator.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/AgentCreator.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/AgentCreatorBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/CustomColorPicker.d.ts +9 -0
- package/lib/typescript/commonjs/agent-creator/CustomColorPicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/GlossArt.d.ts +9 -0
- package/lib/typescript/commonjs/agent-creator/GlossArt.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/ShapeSilhouette.d.ts +1 -1
- package/lib/typescript/commonjs/agent-creator/ShapeSilhouette.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/context.d.ts +13 -1
- package/lib/typescript/commonjs/agent-creator/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/messages.d.ts +11 -0
- package/lib/typescript/commonjs/agent-creator/messages.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/paint.d.ts +9 -4
- package/lib/typescript/commonjs/agent-creator/paint.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/rainbow-artwork.d.ts +3 -0
- package/lib/typescript/commonjs/agent-creator/rainbow-artwork.d.ts.map +1 -0
- package/lib/typescript/commonjs/agent-creator/shared.d.ts +7 -0
- package/lib/typescript/commonjs/agent-creator/shared.d.ts.map +1 -1
- package/lib/typescript/commonjs/agent-creator/types.d.ts +4 -7
- package/lib/typescript/commonjs/agent-creator/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/avatar/types.d.ts +1 -2
- package/lib/typescript/commonjs/avatar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ar.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/bn.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ca.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/de.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/es.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/fr.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/hi.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/id.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/it.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ja.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/pt.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/ru.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/tr.d.ts.map +1 -1
- package/lib/typescript/commonjs/locale/translations/zh.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/data.d.ts.map +1 -1
- package/lib/typescript/commonjs/multi-agent-chat/selected-agent-preview.d.ts +7 -0
- package/lib/typescript/commonjs/multi-agent-chat/selected-agent-preview.d.ts.map +1 -0
- package/lib/typescript/module/agent-avatar/VectorCharacterAvatar.d.ts.map +1 -1
- package/lib/typescript/module/agent-avatar/character.d.ts +4 -4
- package/lib/typescript/module/agent-avatar/use-static-portraits.d.ts +16 -0
- package/lib/typescript/module/agent-avatar/use-static-portraits.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/AgentCreator.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/AgentCreator.web.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/AgentCreatorBase.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/CustomColorPicker.d.ts +9 -0
- package/lib/typescript/module/agent-creator/CustomColorPicker.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/GlossArt.d.ts +9 -0
- package/lib/typescript/module/agent-creator/GlossArt.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/ShapeSilhouette.d.ts +1 -1
- package/lib/typescript/module/agent-creator/ShapeSilhouette.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/context.d.ts +13 -1
- package/lib/typescript/module/agent-creator/context.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/messages.d.ts +11 -0
- package/lib/typescript/module/agent-creator/messages.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/paint.d.ts +9 -4
- package/lib/typescript/module/agent-creator/paint.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/rainbow-artwork.d.ts +3 -0
- package/lib/typescript/module/agent-creator/rainbow-artwork.d.ts.map +1 -0
- package/lib/typescript/module/agent-creator/shared.d.ts +7 -0
- package/lib/typescript/module/agent-creator/shared.d.ts.map +1 -1
- package/lib/typescript/module/agent-creator/types.d.ts +4 -7
- package/lib/typescript/module/agent-creator/types.d.ts.map +1 -1
- package/lib/typescript/module/avatar/types.d.ts +1 -2
- package/lib/typescript/module/avatar/types.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ar.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/bn.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ca.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/de.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/es.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/fr.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/hi.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/id.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/it.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ja.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/pt.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/ru.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/tr.d.ts.map +1 -1
- package/lib/typescript/module/locale/translations/zh.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/data.d.ts.map +1 -1
- package/lib/typescript/module/multi-agent-chat/selected-agent-preview.d.ts +7 -0
- package/lib/typescript/module/multi-agent-chat/selected-agent-preview.d.ts.map +1 -0
- package/package.json +18 -1
- package/src/__tests__/support/adoption-matrix.ts +0 -5
- package/src/agent-avatar/VectorCharacterAvatar.tsx +19 -16
- package/src/agent-avatar/character.ts +4 -4
- package/src/agent-avatar/use-static-portraits.ts +50 -0
- package/src/agent-creator/AgentCreator.tsx +4 -0
- package/src/agent-creator/AgentCreator.web.tsx +4 -0
- package/src/agent-creator/AgentCreatorBase.tsx +83 -39
- package/src/agent-creator/CustomColorPicker.tsx +443 -0
- package/src/agent-creator/GlossArt.tsx +160 -0
- package/src/agent-creator/ShapeSilhouette.tsx +4 -3
- package/src/agent-creator/context.ts +2 -0
- package/src/agent-creator/messages.ts +37 -1
- package/src/agent-creator/paint.ts +17 -7
- package/src/agent-creator/rainbow-artwork.ts +5 -0
- package/src/agent-creator/shared.ts +27 -0
- package/src/agent-creator/types.ts +4 -7
- package/src/avatar/types.ts +1 -2
- package/src/locale/translations/ar.ts +23 -1
- package/src/locale/translations/bn.ts +23 -1
- package/src/locale/translations/ca.ts +23 -1
- package/src/locale/translations/de.ts +23 -1
- package/src/locale/translations/es.ts +23 -1
- package/src/locale/translations/fr.ts +23 -1
- package/src/locale/translations/hi.ts +23 -1
- package/src/locale/translations/id.ts +23 -1
- package/src/locale/translations/it.ts +23 -1
- package/src/locale/translations/ja.ts +23 -1
- package/src/locale/translations/pt.ts +23 -1
- package/src/locale/translations/ru.ts +23 -1
- package/src/locale/translations/tr.ts +23 -1
- package/src/locale/translations/zh.ts +23 -1
- package/src/multi-agent-chat/data.ts +5 -3
- package/src/multi-agent-chat/selected-agent-preview.ts +6 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentRef,
|
|
3
|
+
type ComponentType,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
memo,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import {
|
|
13
|
+
Platform,
|
|
14
|
+
TextInput,
|
|
15
|
+
type StyleProp,
|
|
16
|
+
type TextInputProps,
|
|
17
|
+
type TextStyle,
|
|
18
|
+
type View,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
import { styled } from 'react-native-css';
|
|
21
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
22
|
+
import Svg, { ClipPath, Defs, G, LinearGradient, Rect, Stop } from 'react-native-svg';
|
|
23
|
+
import { normalizeAvatarSkinColor } from '../agent-avatar/skin-color';
|
|
24
|
+
import { useFieldMembership } from '../field/membership';
|
|
25
|
+
import { StyledView } from '../styles/styled-primitives';
|
|
26
|
+
import { useSvgIdPrefix } from '../styles/svg-id';
|
|
27
|
+
import { useTheme } from '../theme/use-theme';
|
|
28
|
+
import { useAgentCreatorMessages } from './context';
|
|
29
|
+
import { GlossArt } from './GlossArt';
|
|
30
|
+
import { hexToHsv, hsvToHex, type Hsv } from './shared';
|
|
31
|
+
import { useTrackEvents } from './use-track-events';
|
|
32
|
+
import { svgA11yProps } from '../styles/svg-a11y';
|
|
33
|
+
|
|
34
|
+
// `styled()` is told only about `style`: a dot-path union over React Native
|
|
35
|
+
// 0.88's whole `TextInputProps` overflows the checker (TS2590). The annotation
|
|
36
|
+
// is the real contract — `styles/styled-primitives.ts` does the same.
|
|
37
|
+
const StyledTextInput: ComponentType<TextInputProps> = styled(
|
|
38
|
+
TextInput as (props: { style?: StyleProp<TextStyle> }) => ReactNode,
|
|
39
|
+
{ className: 'style' },
|
|
40
|
+
);
|
|
41
|
+
const clamp01 = (n: number) => Math.min(1, Math.max(0, n));
|
|
42
|
+
const THUMB =
|
|
43
|
+
'pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white bg-white/0 ' +
|
|
44
|
+
'shadow-[0_2px_4px_rgb(0_0_0/0.18),inset_0_0_0_1px_rgb(0_0_0/0.06)]';
|
|
45
|
+
|
|
46
|
+
const SkinColorField = memo(function SkinColorField({ hue, id }: { hue: number; id: string }) {
|
|
47
|
+
// Hue changes rebuild this small vector field. Saturation/value dragging only
|
|
48
|
+
// moves the thumb; every displayed stop uses the same policy as saved skin.
|
|
49
|
+
const fieldColors = useMemo(
|
|
50
|
+
() =>
|
|
51
|
+
Array.from({ length: 32 }, (_, x) =>
|
|
52
|
+
Array.from({ length: 13 }, (_, y) =>
|
|
53
|
+
normalizeAvatarSkinColor(hsvToHex({ h: hue, s: (x + 0.5) / 32, v: 1 - y / 12 })),
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
[hue],
|
|
57
|
+
);
|
|
58
|
+
return (
|
|
59
|
+
<Svg
|
|
60
|
+
testID="avatar-skin-color-field"
|
|
61
|
+
width="100%"
|
|
62
|
+
height="100%"
|
|
63
|
+
{...svgA11yProps()}
|
|
64
|
+
style={{ position: 'absolute', left: 0, top: 0, borderRadius: 16, overflow: 'hidden' }}
|
|
65
|
+
>
|
|
66
|
+
<Defs>
|
|
67
|
+
<ClipPath id={`${id}-field-clip`}>
|
|
68
|
+
<Rect rx={16} width="100%" height="100%" />
|
|
69
|
+
</ClipPath>
|
|
70
|
+
{fieldColors.map((stops, column) => (
|
|
71
|
+
<LinearGradient key={column} id={`${id}-field-${column}`} x1="0" x2="0" y1="0" y2="1">
|
|
72
|
+
{stops.map((color, row) => (
|
|
73
|
+
<Stop key={row} offset={row / 12} stopColor={color} />
|
|
74
|
+
))}
|
|
75
|
+
</LinearGradient>
|
|
76
|
+
))}
|
|
77
|
+
</Defs>
|
|
78
|
+
<G clipPath={`url(#${id}-field-clip)`}>
|
|
79
|
+
{fieldColors.map((_, column) => (
|
|
80
|
+
<Rect
|
|
81
|
+
key={column}
|
|
82
|
+
x={`${(column * 100) / 32}%`}
|
|
83
|
+
width={`${100 / 32 + 0.5}%`}
|
|
84
|
+
height="100%"
|
|
85
|
+
fill={`url(#${id}-field-${column})`}
|
|
86
|
+
/>
|
|
87
|
+
))}
|
|
88
|
+
</G>
|
|
89
|
+
</Svg>
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/** Source HSV picker: own two-dimensional field and 12px hue rail, rAF-throttled. */
|
|
94
|
+
export function CustomColorPicker({
|
|
95
|
+
value,
|
|
96
|
+
onChange,
|
|
97
|
+
onInteractionStart,
|
|
98
|
+
onInteractionEnd,
|
|
99
|
+
className,
|
|
100
|
+
}: {
|
|
101
|
+
value: string;
|
|
102
|
+
onChange: (hex: string) => void;
|
|
103
|
+
onInteractionStart?: () => void;
|
|
104
|
+
onInteractionEnd?: () => void;
|
|
105
|
+
className?: string;
|
|
106
|
+
}) {
|
|
107
|
+
const messages = useAgentCreatorMessages();
|
|
108
|
+
const membership = useFieldMembership({ label: messages.hexColor });
|
|
109
|
+
const { colors } = useTheme();
|
|
110
|
+
const id = useSvgIdPrefix('bloom-color-picker');
|
|
111
|
+
const fieldRef = useRef<ComponentRef<typeof View>>(null);
|
|
112
|
+
const railRef = useRef<ComponentRef<typeof View>>(null);
|
|
113
|
+
const [hsv, setHsv] = useState<Hsv>(
|
|
114
|
+
() => hexToHsv(normalizeAvatarSkinColor(value)) ?? { h: 259, s: 0.83, v: 1 },
|
|
115
|
+
);
|
|
116
|
+
const [hexDraft, setHexDraft] = useState(() => normalizeAvatarSkinColor(value));
|
|
117
|
+
const [seenValue, setSeenValue] = useState(() => normalizeAvatarSkinColor(value));
|
|
118
|
+
const [lastEmitted, setLastEmitted] = useState(() => normalizeAvatarSkinColor(value));
|
|
119
|
+
const [width, setWidth] = useState(228);
|
|
120
|
+
const [hexFocused, setHexFocused] = useState(false);
|
|
121
|
+
const frame = useRef(0);
|
|
122
|
+
const nextValue = normalizeAvatarSkinColor(value);
|
|
123
|
+
if (nextValue !== seenValue) {
|
|
124
|
+
setSeenValue(nextValue);
|
|
125
|
+
if (nextValue !== lastEmitted) {
|
|
126
|
+
const parsed = hexToHsv(nextValue);
|
|
127
|
+
if (parsed) {
|
|
128
|
+
setLastEmitted(nextValue);
|
|
129
|
+
setHsv(parsed);
|
|
130
|
+
setHexDraft(nextValue);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const pendingHsv = useRef<Hsv | undefined>(undefined);
|
|
135
|
+
const interacting = useRef(false);
|
|
136
|
+
const latest = useRef({ onChange, onInteractionEnd, disabled: membership.disabled });
|
|
137
|
+
latest.current = { onChange, onInteractionEnd, disabled: membership.disabled };
|
|
138
|
+
const flush = useCallback(() => {
|
|
139
|
+
if (frame.current) cancelAnimationFrame(frame.current);
|
|
140
|
+
frame.current = 0;
|
|
141
|
+
const next = pendingHsv.current;
|
|
142
|
+
pendingHsv.current = undefined;
|
|
143
|
+
if (!next || latest.current.disabled) return;
|
|
144
|
+
const hex = normalizeAvatarSkinColor(hsvToHex(next));
|
|
145
|
+
setHsv(next);
|
|
146
|
+
setLastEmitted(hex);
|
|
147
|
+
setHexDraft(hex);
|
|
148
|
+
latest.current.onChange(hex);
|
|
149
|
+
}, []);
|
|
150
|
+
const emit = useCallback(
|
|
151
|
+
(next: Hsv) => {
|
|
152
|
+
if (latest.current.disabled) return;
|
|
153
|
+
pendingHsv.current = next;
|
|
154
|
+
if (!frame.current) frame.current = requestAnimationFrame(flush);
|
|
155
|
+
},
|
|
156
|
+
[flush],
|
|
157
|
+
);
|
|
158
|
+
useEffect(
|
|
159
|
+
() => () => {
|
|
160
|
+
if (frame.current) cancelAnimationFrame(frame.current);
|
|
161
|
+
if (interacting.current) latest.current.onInteractionEnd?.();
|
|
162
|
+
},
|
|
163
|
+
[],
|
|
164
|
+
);
|
|
165
|
+
const field = Gesture.Pan()
|
|
166
|
+
.enabled(!membership.disabled)
|
|
167
|
+
.minDistance(0)
|
|
168
|
+
.runOnJS(true)
|
|
169
|
+
.onFinalize(() => {
|
|
170
|
+
flush();
|
|
171
|
+
interacting.current = false;
|
|
172
|
+
latest.current.onInteractionEnd?.();
|
|
173
|
+
})
|
|
174
|
+
.onBegin((event) => {
|
|
175
|
+
interacting.current = true;
|
|
176
|
+
onInteractionStart?.();
|
|
177
|
+
fieldRef.current?.focus();
|
|
178
|
+
emit({
|
|
179
|
+
...(pendingHsv.current ?? hsv),
|
|
180
|
+
s: clamp01(event.x / width),
|
|
181
|
+
v: 1 - clamp01(event.y / ((width * 2) / 3)),
|
|
182
|
+
});
|
|
183
|
+
})
|
|
184
|
+
.onUpdate((event) =>
|
|
185
|
+
emit({
|
|
186
|
+
...(pendingHsv.current ?? hsv),
|
|
187
|
+
s: clamp01(event.x / width),
|
|
188
|
+
v: 1 - clamp01(event.y / ((width * 2) / 3)),
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
191
|
+
const rail = Gesture.Pan()
|
|
192
|
+
.enabled(!membership.disabled)
|
|
193
|
+
.minDistance(0)
|
|
194
|
+
.runOnJS(true)
|
|
195
|
+
.onFinalize(() => {
|
|
196
|
+
flush();
|
|
197
|
+
interacting.current = false;
|
|
198
|
+
latest.current.onInteractionEnd?.();
|
|
199
|
+
})
|
|
200
|
+
.onBegin((event) => {
|
|
201
|
+
interacting.current = true;
|
|
202
|
+
onInteractionStart?.();
|
|
203
|
+
railRef.current?.focus();
|
|
204
|
+
emit({
|
|
205
|
+
...(pendingHsv.current ?? hsv),
|
|
206
|
+
h: Math.min(clamp01(event.x / width) * 360, 359.9),
|
|
207
|
+
});
|
|
208
|
+
})
|
|
209
|
+
.onUpdate((event) =>
|
|
210
|
+
emit({
|
|
211
|
+
...(pendingHsv.current ?? hsv),
|
|
212
|
+
h: Math.min(clamp01(event.x / width) * 360, 359.9),
|
|
213
|
+
}),
|
|
214
|
+
);
|
|
215
|
+
useTrackEvents(fieldRef, undefined, (key, shift) => {
|
|
216
|
+
const step = shift ? 0.1 : 0.02;
|
|
217
|
+
const moves: Record<string, Partial<Hsv>> = {
|
|
218
|
+
ArrowLeft: { s: clamp01((pendingHsv.current ?? hsv).s - step) },
|
|
219
|
+
ArrowRight: { s: clamp01((pendingHsv.current ?? hsv).s + step) },
|
|
220
|
+
ArrowUp: { v: clamp01((pendingHsv.current ?? hsv).v + step) },
|
|
221
|
+
ArrowDown: { v: clamp01((pendingHsv.current ?? hsv).v - step) },
|
|
222
|
+
};
|
|
223
|
+
const move = moves[key];
|
|
224
|
+
if (!move) return false;
|
|
225
|
+
emit({ ...(pendingHsv.current ?? hsv), ...move });
|
|
226
|
+
return true;
|
|
227
|
+
});
|
|
228
|
+
useTrackEvents(railRef, undefined, (key, shift) => {
|
|
229
|
+
const step = shift ? 15 : 3;
|
|
230
|
+
const delta =
|
|
231
|
+
key === 'ArrowLeft' || key === 'ArrowDown'
|
|
232
|
+
? -step
|
|
233
|
+
: key === 'ArrowRight' || key === 'ArrowUp'
|
|
234
|
+
? step
|
|
235
|
+
: null;
|
|
236
|
+
if (delta === null) return false;
|
|
237
|
+
emit({
|
|
238
|
+
...(pendingHsv.current ?? hsv),
|
|
239
|
+
h: Math.min(Math.max((pendingHsv.current ?? hsv).h + delta, 0), 359.9),
|
|
240
|
+
});
|
|
241
|
+
return true;
|
|
242
|
+
});
|
|
243
|
+
const commitHexDraft = () => {
|
|
244
|
+
if (membership.disabled) return;
|
|
245
|
+
if (frame.current) cancelAnimationFrame(frame.current);
|
|
246
|
+
frame.current = 0;
|
|
247
|
+
pendingHsv.current = undefined;
|
|
248
|
+
const parsed = hexToHsv(hexDraft);
|
|
249
|
+
if (!parsed) {
|
|
250
|
+
setHexDraft(lastEmitted);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const hex = normalizeAvatarSkinColor(hsvToHex(parsed));
|
|
254
|
+
setLastEmitted(hex);
|
|
255
|
+
setHsv(hexToHsv(hex)!);
|
|
256
|
+
setHexDraft(hex);
|
|
257
|
+
onChange(hex);
|
|
258
|
+
};
|
|
259
|
+
const hueColor = hsvToHex({ h: hsv.h, s: 1, v: 1 });
|
|
260
|
+
const current = normalizeAvatarSkinColor(hsvToHex(hsv));
|
|
261
|
+
const thumb = {
|
|
262
|
+
width: 16,
|
|
263
|
+
height: 16,
|
|
264
|
+
borderWidth: 1,
|
|
265
|
+
borderColor: '#ffffff',
|
|
266
|
+
borderRadius: 8,
|
|
267
|
+
transform: Platform.OS === 'web' ? undefined : [{ translateX: -8 }, { translateY: -8 }],
|
|
268
|
+
boxShadow: '0 2px 4px rgba(0,0,0,.18), inset 0 0 0 1px rgba(0,0,0,.06)',
|
|
269
|
+
};
|
|
270
|
+
return (
|
|
271
|
+
<StyledView
|
|
272
|
+
className={className ? `flex flex-col gap-2.5 ${className}` : 'flex flex-col gap-2.5'}
|
|
273
|
+
>
|
|
274
|
+
<GestureDetector gesture={field}>
|
|
275
|
+
<StyledView
|
|
276
|
+
ref={fieldRef}
|
|
277
|
+
onLayout={(event) => setWidth(event.nativeEvent.layout.width)}
|
|
278
|
+
role="slider"
|
|
279
|
+
tabIndex={membership.disabled ? -1 : 0}
|
|
280
|
+
aria-disabled={membership.disabled || undefined}
|
|
281
|
+
aria-invalid={membership.invalid || undefined}
|
|
282
|
+
aria-describedby={membership.describedBy}
|
|
283
|
+
accessibilityHint={membership.accessibilityHint}
|
|
284
|
+
accessibilityLabel={messages.saturationBrightness}
|
|
285
|
+
aria-valuemin={0}
|
|
286
|
+
aria-valuemax={100}
|
|
287
|
+
aria-valuenow={Math.round(hsv.v * 100)}
|
|
288
|
+
aria-valuetext={messages.saturationBrightnessValue(
|
|
289
|
+
Math.round(hsv.s * 100),
|
|
290
|
+
Math.round(hsv.v * 100),
|
|
291
|
+
)}
|
|
292
|
+
className="relative aspect-[3/2] w-full cursor-crosshair touch-none rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-border-focus-ring focus-visible:ring-offset-2"
|
|
293
|
+
accessibilityActions={[
|
|
294
|
+
{ name: 'increment', label: messages.increaseBrightness },
|
|
295
|
+
{ name: 'decrement', label: messages.decreaseBrightness },
|
|
296
|
+
]}
|
|
297
|
+
onAccessibilityAction={(event) =>
|
|
298
|
+
emit({
|
|
299
|
+
...(pendingHsv.current ?? hsv),
|
|
300
|
+
v: clamp01(
|
|
301
|
+
(pendingHsv.current ?? hsv).v +
|
|
302
|
+
(event.nativeEvent.actionName === 'increment' ? 0.02 : -0.02),
|
|
303
|
+
),
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
>
|
|
307
|
+
<SkinColorField hue={hsv.h} id={id} />
|
|
308
|
+
<StyledView
|
|
309
|
+
pointerEvents="none"
|
|
310
|
+
aria-hidden
|
|
311
|
+
className="pointer-events-none absolute inset-0 rounded-2xl shadow-[inset_0_0_0_1px_rgb(0_0_0/0.06),inset_0_1px_0_rgb(255_255_255/0.12)]"
|
|
312
|
+
/>
|
|
313
|
+
<StyledView
|
|
314
|
+
pointerEvents="none"
|
|
315
|
+
aria-hidden
|
|
316
|
+
className={THUMB}
|
|
317
|
+
style={[
|
|
318
|
+
thumb,
|
|
319
|
+
{
|
|
320
|
+
position: 'absolute',
|
|
321
|
+
left: `${hsv.s * 100}%`,
|
|
322
|
+
top: `${(1 - hsv.v) * 100}%`,
|
|
323
|
+
backgroundColor: current,
|
|
324
|
+
},
|
|
325
|
+
]}
|
|
326
|
+
/>
|
|
327
|
+
</StyledView>
|
|
328
|
+
</GestureDetector>
|
|
329
|
+
<GestureDetector gesture={rail}>
|
|
330
|
+
<StyledView
|
|
331
|
+
ref={railRef}
|
|
332
|
+
role="slider"
|
|
333
|
+
tabIndex={membership.disabled ? -1 : 0}
|
|
334
|
+
aria-disabled={membership.disabled || undefined}
|
|
335
|
+
aria-invalid={membership.invalid || undefined}
|
|
336
|
+
aria-describedby={membership.describedBy}
|
|
337
|
+
accessibilityHint={membership.accessibilityHint}
|
|
338
|
+
accessibilityLabel={messages.hue}
|
|
339
|
+
aria-valuemin={0}
|
|
340
|
+
aria-valuemax={360}
|
|
341
|
+
aria-valuenow={Math.round(hsv.h)}
|
|
342
|
+
className="relative h-3 w-full cursor-pointer touch-none rounded-full outline-none focus-visible:ring-2 focus-visible:ring-border-focus-ring focus-visible:ring-offset-2"
|
|
343
|
+
accessibilityActions={[
|
|
344
|
+
{ name: 'increment', label: messages.increaseHue },
|
|
345
|
+
{ name: 'decrement', label: messages.decreaseHue },
|
|
346
|
+
]}
|
|
347
|
+
onAccessibilityAction={(event) =>
|
|
348
|
+
emit({
|
|
349
|
+
...(pendingHsv.current ?? hsv),
|
|
350
|
+
h: Math.min(
|
|
351
|
+
Math.max(
|
|
352
|
+
(pendingHsv.current ?? hsv).h +
|
|
353
|
+
(event.nativeEvent.actionName === 'increment' ? 3 : -3),
|
|
354
|
+
0,
|
|
355
|
+
),
|
|
356
|
+
359.9,
|
|
357
|
+
),
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
>
|
|
361
|
+
<Svg
|
|
362
|
+
width="100%"
|
|
363
|
+
height={12}
|
|
364
|
+
{...svgA11yProps()}
|
|
365
|
+
style={{ position: 'absolute', left: 0, top: 0 }}
|
|
366
|
+
>
|
|
367
|
+
<Defs>
|
|
368
|
+
<LinearGradient id={`${id}hue`} x1="0" x2="1" y1="0" y2="0">
|
|
369
|
+
{['#ff0000', '#ffff00', '#00ff00', '#00ffff', '#0000ff', '#ff00ff', '#ff0000'].map(
|
|
370
|
+
(color, index) => (
|
|
371
|
+
<Stop key={color + index} offset={index / 6} stopColor={color} />
|
|
372
|
+
),
|
|
373
|
+
)}
|
|
374
|
+
</LinearGradient>
|
|
375
|
+
</Defs>
|
|
376
|
+
<Rect rx={6} width="100%" height={12} fill={`url(#${id}hue)`} />
|
|
377
|
+
</Svg>
|
|
378
|
+
<StyledView
|
|
379
|
+
pointerEvents="none"
|
|
380
|
+
aria-hidden
|
|
381
|
+
className="pointer-events-none absolute inset-0 rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0/0.06)]"
|
|
382
|
+
/>
|
|
383
|
+
<StyledView
|
|
384
|
+
pointerEvents="none"
|
|
385
|
+
aria-hidden
|
|
386
|
+
className={`${THUMB} top-1/2`}
|
|
387
|
+
style={[
|
|
388
|
+
thumb,
|
|
389
|
+
{
|
|
390
|
+
position: 'absolute',
|
|
391
|
+
left: `${(hsv.h / 360) * 100}%`,
|
|
392
|
+
top: '50%',
|
|
393
|
+
backgroundColor: hueColor,
|
|
394
|
+
},
|
|
395
|
+
]}
|
|
396
|
+
/>
|
|
397
|
+
</StyledView>
|
|
398
|
+
</GestureDetector>
|
|
399
|
+
<StyledView className="flex items-center gap-2 flex-row">
|
|
400
|
+
<StyledView
|
|
401
|
+
aria-hidden
|
|
402
|
+
className="relative size-8 shrink-0 overflow-hidden rounded-full shadow-[inset_0_0_0_1px_rgb(0_0_0/0.06)]"
|
|
403
|
+
>
|
|
404
|
+
<GlossArt center={current} edge={current} size={32} />
|
|
405
|
+
</StyledView>
|
|
406
|
+
<StyledTextInput
|
|
407
|
+
value={hexDraft}
|
|
408
|
+
onChangeText={setHexDraft}
|
|
409
|
+
autoCorrect={false}
|
|
410
|
+
autoCapitalize="none"
|
|
411
|
+
accessibilityLabel={membership.accessibilityLabel}
|
|
412
|
+
nativeID={membership.nativeID}
|
|
413
|
+
aria-describedby={membership.describedBy}
|
|
414
|
+
accessibilityHint={membership.accessibilityHint}
|
|
415
|
+
aria-invalid={membership.invalid || undefined}
|
|
416
|
+
aria-disabled={membership.disabled || undefined}
|
|
417
|
+
editable={!membership.disabled}
|
|
418
|
+
onFocus={() => setHexFocused(true)}
|
|
419
|
+
onBlur={() => {
|
|
420
|
+
setHexFocused(false);
|
|
421
|
+
commitHexDraft();
|
|
422
|
+
}}
|
|
423
|
+
onSubmitEditing={commitHexDraft}
|
|
424
|
+
className="h-8 w-full min-w-0 rounded-2lg bg-background-tertiary-default px-2.5 font-mono text-[13px] text-text-primary uppercase outline-none ring-2 ring-transparent ring-inset transition-[background-color,box-shadow] duration-150 ease placeholder:text-text-placeholder focus:bg-background-primary-default focus:ring-border-focus-ring"
|
|
425
|
+
style={[
|
|
426
|
+
{ flex: 1, direction: 'ltr' },
|
|
427
|
+
Platform.OS === 'web'
|
|
428
|
+
? undefined
|
|
429
|
+
: {
|
|
430
|
+
height: 32,
|
|
431
|
+
borderRadius: 10,
|
|
432
|
+
paddingHorizontal: 10,
|
|
433
|
+
backgroundColor: hexFocused ? colors.card : colors.backgroundTertiary,
|
|
434
|
+
color: colors.text,
|
|
435
|
+
fontFamily: 'monospace',
|
|
436
|
+
fontSize: 13,
|
|
437
|
+
},
|
|
438
|
+
]}
|
|
439
|
+
/>
|
|
440
|
+
</StyledView>
|
|
441
|
+
</StyledView>
|
|
442
|
+
);
|
|
443
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import Svg, {
|
|
3
|
+
Circle,
|
|
4
|
+
ClipPath,
|
|
5
|
+
Defs,
|
|
6
|
+
Ellipse,
|
|
7
|
+
FeGaussianBlur,
|
|
8
|
+
Filter,
|
|
9
|
+
G,
|
|
10
|
+
LinearGradient,
|
|
11
|
+
RadialGradient,
|
|
12
|
+
Rect,
|
|
13
|
+
Stop,
|
|
14
|
+
} from 'react-native-svg';
|
|
15
|
+
import { StyledImage, StyledView } from '../styles/styled-primitives';
|
|
16
|
+
import { useSvgIdPrefix } from '../styles/svg-id';
|
|
17
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
18
|
+
import { useTheme } from '../theme/use-theme';
|
|
19
|
+
import { RAINBOW_DARK, RAINBOW_LIGHT } from './rainbow-artwork';
|
|
20
|
+
import { svgA11yProps } from '../styles/svg-a11y';
|
|
21
|
+
|
|
22
|
+
/** The original four-layer glossy sphere, with the same 26px reflection geometry. */
|
|
23
|
+
export function GlossArt({
|
|
24
|
+
center = '#437EF7',
|
|
25
|
+
edge = '#004DE9',
|
|
26
|
+
rainbow = false,
|
|
27
|
+
active = false,
|
|
28
|
+
size = 26,
|
|
29
|
+
}: {
|
|
30
|
+
center?: string;
|
|
31
|
+
edge?: string;
|
|
32
|
+
rainbow?: boolean;
|
|
33
|
+
active?: boolean;
|
|
34
|
+
size?: number;
|
|
35
|
+
}) {
|
|
36
|
+
const id = useSvgIdPrefix('bloom-gloss');
|
|
37
|
+
const { isDark } = useTheme();
|
|
38
|
+
if (rainbow)
|
|
39
|
+
return (
|
|
40
|
+
<StyledView
|
|
41
|
+
aria-hidden
|
|
42
|
+
pointerEvents="none"
|
|
43
|
+
className="absolute inset-0 overflow-hidden rounded-full"
|
|
44
|
+
style={{ width: size, height: size }}
|
|
45
|
+
>
|
|
46
|
+
<StyledImage
|
|
47
|
+
source={{ uri: isDark ? RAINBOW_DARK : RAINBOW_LIGHT }}
|
|
48
|
+
className="object-cover"
|
|
49
|
+
contentFit="cover"
|
|
50
|
+
style={{ width: size, height: size }}
|
|
51
|
+
/>
|
|
52
|
+
</StyledView>
|
|
53
|
+
);
|
|
54
|
+
if (Platform.OS === 'web') {
|
|
55
|
+
const fill: WebCssStyle = {
|
|
56
|
+
backgroundImage: `radial-gradient(closest-side circle at 50% 50%, ${center} 0%, ${edge} 100%)`,
|
|
57
|
+
};
|
|
58
|
+
return (
|
|
59
|
+
<StyledView
|
|
60
|
+
pointerEvents="none"
|
|
61
|
+
aria-hidden
|
|
62
|
+
className="relative overflow-hidden rounded-full"
|
|
63
|
+
style={[{ width: size, height: size }, fill]}
|
|
64
|
+
>
|
|
65
|
+
<StyledView
|
|
66
|
+
aria-hidden
|
|
67
|
+
className="absolute inset-0 bg-linear-to-b from-[#ffffff00] to-[#ffffff4d]"
|
|
68
|
+
/>
|
|
69
|
+
<StyledView
|
|
70
|
+
aria-hidden
|
|
71
|
+
className="absolute top-0 left-[7.7%] h-[38.5%] w-[84.6%] rounded-[50%] bg-linear-to-b from-[#ffffff80] to-[#ffffff00] blur-[0.5px]"
|
|
72
|
+
/>
|
|
73
|
+
<StyledView
|
|
74
|
+
aria-hidden
|
|
75
|
+
className="absolute top-0 left-[34.6%] h-[11.5%] w-[30.8%] rounded-[50%] bg-linear-to-b from-[#ffffff80] to-[#ffffff00] blur-[1px]"
|
|
76
|
+
/>
|
|
77
|
+
<StyledView
|
|
78
|
+
aria-hidden
|
|
79
|
+
className="absolute top-[73.1%] left-[-23.1%] h-[53.8%] w-[138.5%] rounded-[50%] bg-linear-to-b from-[#ffffff00] to-[#ffffff80] blur-[0.5px]"
|
|
80
|
+
/>
|
|
81
|
+
{active && (
|
|
82
|
+
<StyledView
|
|
83
|
+
aria-hidden
|
|
84
|
+
className="pointer-events-none absolute inset-0 rounded-full shadow-[inset_0_0_0_2px_rgb(0_0_0/0.30)]"
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
</StyledView>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
return (
|
|
91
|
+
<Svg width={size} height={size} viewBox="0 0 26 26" {...svgA11yProps()}>
|
|
92
|
+
<Defs>
|
|
93
|
+
<ClipPath id={`${id}clip`}>
|
|
94
|
+
<Circle cx={13} cy={13} r={13} />
|
|
95
|
+
</ClipPath>
|
|
96
|
+
<RadialGradient id={`${id}base`} cx="50%" cy="50%" r="50%">
|
|
97
|
+
<Stop offset="0" stopColor={center} />
|
|
98
|
+
<Stop offset="1" stopColor={edge} />
|
|
99
|
+
</RadialGradient>
|
|
100
|
+
<LinearGradient id={`${id}sheen`} x1="0" y1="0" x2="0" y2="1">
|
|
101
|
+
<Stop offset="0" stopColor="#ffffff" stopOpacity={0} />
|
|
102
|
+
<Stop offset="1" stopColor="#ffffff" stopOpacity={0.3} />
|
|
103
|
+
</LinearGradient>
|
|
104
|
+
<LinearGradient id={`${id}reflection`} x1="0" y1="0" x2="0" y2="1">
|
|
105
|
+
<Stop offset="0" stopColor="#ffffff" stopOpacity={0.5} />
|
|
106
|
+
<Stop offset="1" stopColor="#ffffff" stopOpacity={0} />
|
|
107
|
+
</LinearGradient>
|
|
108
|
+
<LinearGradient id={`${id}bounce`} x1="0" y1="0" x2="0" y2="1">
|
|
109
|
+
<Stop offset="0" stopColor="#ffffff" stopOpacity={0} />
|
|
110
|
+
<Stop offset="1" stopColor="#ffffff" stopOpacity={0.5} />
|
|
111
|
+
</LinearGradient>
|
|
112
|
+
<Filter id={`${id}soft`} x="-25%" y="-25%" width="150%" height="150%">
|
|
113
|
+
<FeGaussianBlur stdDeviation={0.5} />
|
|
114
|
+
</Filter>
|
|
115
|
+
<Filter id={`${id}hotspot`} x="-50%" y="-50%" width="200%" height="200%">
|
|
116
|
+
<FeGaussianBlur stdDeviation={1} />
|
|
117
|
+
</Filter>
|
|
118
|
+
</Defs>
|
|
119
|
+
<G clipPath={`url(#${id}clip)`}>
|
|
120
|
+
<Circle cx={13} cy={13} r={13} fill={`url(#${id}base)`} />
|
|
121
|
+
<Rect width={26} height={26} fill={`url(#${id}sheen)`} />
|
|
122
|
+
<Ellipse
|
|
123
|
+
cx={13}
|
|
124
|
+
cy={5}
|
|
125
|
+
rx={11}
|
|
126
|
+
ry={5}
|
|
127
|
+
fill={`url(#${id}reflection)`}
|
|
128
|
+
filter={`url(#${id}soft)`}
|
|
129
|
+
/>
|
|
130
|
+
<Ellipse
|
|
131
|
+
cx={13}
|
|
132
|
+
cy={1.5}
|
|
133
|
+
rx={4}
|
|
134
|
+
ry={1.5}
|
|
135
|
+
fill={`url(#${id}reflection)`}
|
|
136
|
+
filter={`url(#${id}hotspot)`}
|
|
137
|
+
/>
|
|
138
|
+
<Ellipse
|
|
139
|
+
cx={12}
|
|
140
|
+
cy={26}
|
|
141
|
+
rx={18}
|
|
142
|
+
ry={7}
|
|
143
|
+
fill={`url(#${id}bounce)`}
|
|
144
|
+
filter={`url(#${id}soft)`}
|
|
145
|
+
/>
|
|
146
|
+
{active && (
|
|
147
|
+
<Circle
|
|
148
|
+
cx={13}
|
|
149
|
+
cy={13}
|
|
150
|
+
r={12}
|
|
151
|
+
fill="none"
|
|
152
|
+
stroke="#000000"
|
|
153
|
+
strokeOpacity={0.3}
|
|
154
|
+
strokeWidth={2}
|
|
155
|
+
/>
|
|
156
|
+
)}
|
|
157
|
+
</G>
|
|
158
|
+
</Svg>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
@@ -2,14 +2,15 @@ import { memo } from 'react';
|
|
|
2
2
|
import { type AvatarCharacter, resolveAvatarCharacter } from '../agent-avatar/character';
|
|
3
3
|
import { CHARACTER_COLORS } from '../agent-avatar/character-colors';
|
|
4
4
|
import { VectorStaticPortrait } from '../agent-avatar/VectorStaticPortrait';
|
|
5
|
-
import {
|
|
5
|
+
import { useStaticPortraits } from '../agent-avatar/use-static-portraits';
|
|
6
6
|
|
|
7
|
-
/** Body contours are static: browsing shapes never downloads animation clips. */
|
|
7
|
+
/** Body contours are static: browsing shapes never downloads animation clips (`use-static-portraits`). */
|
|
8
8
|
export const ShapeSilhouette = memo(function ShapeSilhouette({
|
|
9
9
|
character,
|
|
10
10
|
}: {
|
|
11
11
|
character: AvatarCharacter;
|
|
12
12
|
}) {
|
|
13
|
+
const portraits = useStaticPortraits();
|
|
13
14
|
const resolved = resolveAvatarCharacter(character);
|
|
14
15
|
const bodyColor =
|
|
15
16
|
'bodyColor' in resolved.paint
|
|
@@ -17,7 +18,7 @@ export const ShapeSilhouette = memo(function ShapeSilhouette({
|
|
|
17
18
|
: CHARACTER_COLORS[resolved.paint.color];
|
|
18
19
|
return (
|
|
19
20
|
<VectorStaticPortrait
|
|
20
|
-
frame={vectorShapePortraits[resolved.shape]
|
|
21
|
+
frame={portraits?.vectorShapePortraits[resolved.shape]}
|
|
21
22
|
size={56}
|
|
22
23
|
bodyColor={bodyColor}
|
|
23
24
|
/>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo } from 'react';
|
|
2
2
|
import { useMessages } from '../locale/messages';
|
|
3
|
+
import type * as PopoverParts from '../popover/Popover';
|
|
3
4
|
import type * as SelectParts from '../select';
|
|
4
5
|
import { AGENT_CREATOR_MESSAGES, type AgentCreatorMessages } from './messages';
|
|
5
6
|
|
|
@@ -13,6 +14,7 @@ export type AgentCreatorBindings = Pick<
|
|
|
13
14
|
| 'SelectItem'
|
|
14
15
|
| 'SelectItemText'
|
|
15
16
|
> &
|
|
17
|
+
Pick<typeof PopoverParts, 'Popover' | 'PopoverTrigger' | 'PopoverContent'> &
|
|
16
18
|
Pick<typeof import('../settings-modal/SettingsSelect'), 'SettingsSelect'> &
|
|
17
19
|
import('../screen/types').ScreenComponents;
|
|
18
20
|
export const AgentCreatorContext = createContext<AgentCreatorBindings | null>(null);
|