@oxy.so/bloom 23.5.0 → 23.6.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/bloom-language-modifiers.mdx +1 -1
- package/docs/task-catalog.json +1 -1
- package/docs/task-catalog.mdx +1 -1
- package/lib/commonjs/subtle-hover/SubtleHover.js +94 -31
- package/lib/commonjs/subtle-hover/SubtleHover.js.map +1 -1
- package/lib/commonjs/subtle-hover/index.js +7 -0
- package/lib/commonjs/subtle-hover/index.js.map +1 -1
- package/lib/commonjs/subtle-hover/use-press-highlight.js +95 -0
- package/lib/commonjs/subtle-hover/use-press-highlight.js.map +1 -0
- package/lib/module/subtle-hover/SubtleHover.js +95 -32
- package/lib/module/subtle-hover/SubtleHover.js.map +1 -1
- package/lib/module/subtle-hover/index.js +1 -0
- package/lib/module/subtle-hover/index.js.map +1 -1
- package/lib/module/subtle-hover/use-press-highlight.js +92 -0
- package/lib/module/subtle-hover/use-press-highlight.js.map +1 -0
- package/lib/typescript/commonjs/subtle-hover/SubtleHover.d.ts +4 -1
- package/lib/typescript/commonjs/subtle-hover/SubtleHover.d.ts.map +1 -1
- package/lib/typescript/commonjs/subtle-hover/index.d.ts +1 -0
- package/lib/typescript/commonjs/subtle-hover/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/subtle-hover/types.d.ts +6 -0
- package/lib/typescript/commonjs/subtle-hover/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/subtle-hover/use-press-highlight.d.ts +42 -0
- package/lib/typescript/commonjs/subtle-hover/use-press-highlight.d.ts.map +1 -0
- package/lib/typescript/module/subtle-hover/SubtleHover.d.ts +4 -1
- package/lib/typescript/module/subtle-hover/SubtleHover.d.ts.map +1 -1
- package/lib/typescript/module/subtle-hover/index.d.ts +1 -0
- package/lib/typescript/module/subtle-hover/index.d.ts.map +1 -1
- package/lib/typescript/module/subtle-hover/types.d.ts +6 -0
- package/lib/typescript/module/subtle-hover/types.d.ts.map +1 -1
- package/lib/typescript/module/subtle-hover/use-press-highlight.d.ts +42 -0
- package/lib/typescript/module/subtle-hover/use-press-highlight.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/subtle-hover/SubtleHover.tsx +33 -2
- package/src/subtle-hover/index.ts +5 -0
- package/src/subtle-hover/types.ts +6 -0
- package/src/subtle-hover/use-press-highlight.ts +93 -0
|
@@ -659,7 +659,7 @@ The side of the view it opens on, and its alignment along that side.
|
|
|
659
659
|
|
|
660
660
|
### `hoverGroup`
|
|
661
661
|
|
|
662
|
-
Web: the pointer over this view is what `group-hover:` styles inside it answer (Bloom `SubtleHover`).
|
|
662
|
+
Web: the pointer over this view is what `group-hover:` styles inside it answer (Bloom `SubtleHover`). Android and iOS: a press on the view lights it with Bloom's press highlight (`usePressHighlight`), Android's ripple or iOS's wash; a child that takes its own press, or a scroll, does not.
|
|
663
663
|
|
|
664
664
|
- Parameters: none
|
|
665
665
|
- Signature: `.hoverGroup()`
|
package/docs/task-catalog.json
CHANGED
package/docs/task-catalog.mdx
CHANGED
|
@@ -8,7 +8,7 @@ order: 1
|
|
|
8
8
|
|
|
9
9
|
# Choose an API by task
|
|
10
10
|
|
|
11
|
-
This guide belongs to **@oxy.so/bloom 23.
|
|
11
|
+
This guide belongs to **@oxy.so/bloom 23.6.0**. Read it from the installed package alongside [the structured index](./task-catalog.json). A source build version is not a registry-publication receipt. Use the containing package’s manifest for exact peer ranges.
|
|
12
12
|
|
|
13
13
|
Start under the application’s BloomProvider and follow [getting started](./getting-started.mdx) for CSS, fonts and platform setup. These examples accept domain content/actions and require a bounded host. They do not add a provider per route. For document scrolling, follow [the host contract](./compose-layouts.mdx); Expo’s bounded reset must not silently prevent document overflow.
|
|
14
14
|
|
|
@@ -44,53 +44,80 @@ const FADE = _reactNativeReanimated.Easing.bezier(0.4, 0, 0.2, 1);
|
|
|
44
44
|
* can light up together (e.g. every post of a thread), cross-fading over
|
|
45
45
|
* 150ms. Web always; native only when `native` is set.
|
|
46
46
|
*
|
|
47
|
+
* Either way, on native a `pressed` value (`usePressHighlight`, iOS) adds the
|
|
48
|
+
* row's press wash on top, at the full fill.
|
|
49
|
+
*
|
|
47
50
|
* The wash color comes from the theme's `contrast50` token so it tracks the
|
|
48
51
|
* active preset and light/dark mode.
|
|
49
52
|
*/
|
|
50
53
|
function SubtleHover(t0) {
|
|
51
|
-
const $ = (0, _compilerRuntime.c)(
|
|
54
|
+
const $ = (0, _compilerRuntime.c)(10);
|
|
52
55
|
const {
|
|
53
56
|
active,
|
|
57
|
+
pressed,
|
|
54
58
|
style,
|
|
55
59
|
native: t1
|
|
56
60
|
} = t0;
|
|
57
61
|
const native = t1 === undefined ? false : t1;
|
|
58
|
-
|
|
59
|
-
if (active
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
$[0] = style;
|
|
69
|
-
$[1] = t2;
|
|
70
|
-
} else {
|
|
71
|
-
t2 = $[1];
|
|
72
|
-
}
|
|
73
|
-
return t2;
|
|
62
|
+
let t2;
|
|
63
|
+
if ($[0] !== active || $[1] !== native || $[2] !== style) {
|
|
64
|
+
t2 = washFor(active, native, style);
|
|
65
|
+
$[0] = active;
|
|
66
|
+
$[1] = native;
|
|
67
|
+
$[2] = style;
|
|
68
|
+
$[3] = t2;
|
|
69
|
+
} else {
|
|
70
|
+
t2 = $[3];
|
|
74
71
|
}
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
const wash = t2;
|
|
73
|
+
if (pressed === undefined || _reactNative.Platform.OS === "web") {
|
|
74
|
+
return wash;
|
|
77
75
|
}
|
|
78
|
-
let
|
|
79
|
-
if ($[
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
style: style
|
|
83
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeActiveWash, {
|
|
84
|
-
active: active,
|
|
76
|
+
let t3;
|
|
77
|
+
if ($[4] !== pressed || $[5] !== style) {
|
|
78
|
+
t3 = /*#__PURE__*/(0, _jsxRuntime.jsx)(PressedWash, {
|
|
79
|
+
pressed: pressed,
|
|
85
80
|
style: style
|
|
86
81
|
});
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
82
|
+
$[4] = pressed;
|
|
83
|
+
$[5] = style;
|
|
84
|
+
$[6] = t3;
|
|
90
85
|
} else {
|
|
91
|
-
|
|
86
|
+
t3 = $[6];
|
|
92
87
|
}
|
|
93
|
-
|
|
88
|
+
let t4;
|
|
89
|
+
if ($[7] !== t3 || $[8] !== wash) {
|
|
90
|
+
t4 = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
91
|
+
children: [wash, t3]
|
|
92
|
+
});
|
|
93
|
+
$[7] = t3;
|
|
94
|
+
$[8] = wash;
|
|
95
|
+
$[9] = t4;
|
|
96
|
+
} else {
|
|
97
|
+
t4 = $[9];
|
|
98
|
+
}
|
|
99
|
+
return t4;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The hover or coordinated wash, drawn in place (no component of its own). */
|
|
103
|
+
function washFor(active, native, style) {
|
|
104
|
+
const isWeb = _reactNative.Platform.OS === 'web';
|
|
105
|
+
if (active === undefined) {
|
|
106
|
+
// A web pointer affordance. Native has no hover, and neither does touch web.
|
|
107
|
+
if (!isWeb || _pointer.IS_WEB_TOUCH_DEVICE) return null;
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HoverWash, {
|
|
109
|
+
style: style
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// JS-driven coordinated mode: web always; native only when opted in.
|
|
113
|
+
if (!isWeb && !native) return null;
|
|
114
|
+
return isWeb ? /*#__PURE__*/(0, _jsxRuntime.jsx)(WebActiveWash, {
|
|
115
|
+
active: active,
|
|
116
|
+
style: style
|
|
117
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeActiveWash, {
|
|
118
|
+
active: active,
|
|
119
|
+
style: style
|
|
120
|
+
});
|
|
94
121
|
}
|
|
95
122
|
SubtleHover.displayName = 'SubtleHover';
|
|
96
123
|
function HoverWash(t0) {
|
|
@@ -234,6 +261,42 @@ function NativeActiveWash(t0) {
|
|
|
234
261
|
}
|
|
235
262
|
return t4;
|
|
236
263
|
}
|
|
264
|
+
|
|
265
|
+
/** A press's wash: the full fill, its opacity the press highlight's value, on the UI thread. */
|
|
266
|
+
function PressedWash(t0) {
|
|
267
|
+
const $ = (0, _compilerRuntime.c)(6);
|
|
268
|
+
const {
|
|
269
|
+
pressed,
|
|
270
|
+
style
|
|
271
|
+
} = t0;
|
|
272
|
+
const theme = (0, _theme.useTheme)();
|
|
273
|
+
const fade = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
274
|
+
opacity: pressed.value
|
|
275
|
+
}), [pressed]);
|
|
276
|
+
let t1;
|
|
277
|
+
if ($[0] !== theme.colors.contrast50) {
|
|
278
|
+
t1 = {
|
|
279
|
+
backgroundColor: theme.colors.contrast50
|
|
280
|
+
};
|
|
281
|
+
$[0] = theme.colors.contrast50;
|
|
282
|
+
$[1] = t1;
|
|
283
|
+
} else {
|
|
284
|
+
t1 = $[1];
|
|
285
|
+
}
|
|
286
|
+
let t2;
|
|
287
|
+
if ($[2] !== fade || $[3] !== style || $[4] !== t1) {
|
|
288
|
+
t2 = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
289
|
+
style: [styles.overlay, t1, fade, style]
|
|
290
|
+
});
|
|
291
|
+
$[2] = fade;
|
|
292
|
+
$[3] = style;
|
|
293
|
+
$[4] = t1;
|
|
294
|
+
$[5] = t2;
|
|
295
|
+
} else {
|
|
296
|
+
t2 = $[5];
|
|
297
|
+
}
|
|
298
|
+
return t2;
|
|
299
|
+
}
|
|
237
300
|
const styles = _reactNative.StyleSheet.create({
|
|
238
301
|
overlay: {
|
|
239
302
|
position: 'absolute',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_theme","_adoptStyleSheet","_pointer","_webData","_jsxRuntime","cache","e","t","__esModule","r","c","a","Object","defineProperty","n","__proto__","default","WeakMap","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","hoverGroupProps","exports","webDataSet","bloomHoverGroup","STYLE_ID","CSS","FADE_MS","FADE","Easing","bezier","SubtleHover","t0","$","_compilerRuntime","active","style","native","t1","undefined","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_interopRequireWildcard","_theme","_adoptStyleSheet","_pointer","_webData","_jsxRuntime","cache","e","t","__esModule","r","c","a","Object","defineProperty","n","__proto__","default","WeakMap","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","hoverGroupProps","exports","webDataSet","bloomHoverGroup","STYLE_ID","CSS","FADE_MS","FADE","Easing","bezier","SubtleHover","t0","$","_compilerRuntime","active","pressed","style","native","t1","undefined","t2","washFor","wash","Platform","OS","t3","jsx","PressedWash","t4","jsxs","Fragment","children","isWeb","IS_WEB_TOUCH_DEVICE","HoverWash","WebActiveWash","NativeActiveWash","displayName","theme","useTheme","Symbol","for","adoptStyleSheet","useEffect","bloomSubtleHover","colors","contrast50","backgroundColor","t5","View","styles","overlay","isDark","opacity","webFade","target","useSharedValue","value","withTiming","duration","easing","fade","useAnimatedStyle","StyleSheet","create","position","top","left","right","bottom","pointerEvents","transitionProperty","transitionDuration","transitionTimingFunction"],"sourceRoot":"../../../src","sources":["subtle-hover/SubtleHover.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAC,uBAAA,CAAAH,OAAA;AAQA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAAgD,IAAA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A;IAAAjD,CAAA,MAAAI,KAAA;IAAAJ,CAAA,MAAAM,EAAA;IAAAN,CAAA,MAAAQ,EAAA;EAAA;IAAAA,EAAA,GAAAR,CAAA;EAAA;EAAA,OAFFQ,EAEE;AAAA;AAIN,MAAM8B,MAAM,GAAGa,uBAAU,CAACC,MAAM,CAAC;EAC/Bb,OAAO,EAAE;IACPc,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,aAAa,EAAE;EACjB,CAAC;EACDhB,OAAO,EAAE;IACPiB,kBAAkB,EAAE,SAAS;IAC7BC,kBAAkB,EAAE,OAAO;IAC3BC,wBAAwB,EAAE;EAC5B;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -15,5 +15,12 @@ Object.defineProperty(exports, "hoverGroupProps", {
|
|
|
15
15
|
return _SubtleHover.hoverGroupProps;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "usePressHighlight", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _usePressHighlight.usePressHighlight;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
var _SubtleHover = require("./SubtleHover.js");
|
|
25
|
+
var _usePressHighlight = require("./use-press-highlight.js");
|
|
19
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_SubtleHover","require"],"sourceRoot":"../../../src","sources":["subtle-hover/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_SubtleHover","require","_usePressHighlight"],"sourceRoot":"../../../src","sources":["subtle-hover/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePressHighlight = void 0;
|
|
7
|
+
var _compilerRuntime = require("react/compiler-runtime");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
11
|
+
var _theme = require("../theme");
|
|
12
|
+
/** The props a row's pressable host spreads for its press highlight. */
|
|
13
|
+
|
|
14
|
+
/** The release's fade, as `SubtleHover`'s cross-fade. */
|
|
15
|
+
const FADE_OUT = {
|
|
16
|
+
duration: 150,
|
|
17
|
+
easing: _reactNativeReanimated.Easing.bezier(0.4, 0, 0.2, 1)
|
|
18
|
+
};
|
|
19
|
+
const NONE = Object.freeze({
|
|
20
|
+
hostProps: Object.freeze({}),
|
|
21
|
+
pressed: undefined
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Android: the ripple React Native draws for a `Pressable` (`android_ripple`).
|
|
26
|
+
* The press reaches the view as a command, without a React render, and the
|
|
27
|
+
* ripple animates on the render thread.
|
|
28
|
+
*/
|
|
29
|
+
function useRipple() {
|
|
30
|
+
const $ = (0, _compilerRuntime.c)(2);
|
|
31
|
+
const color = (0, _theme.useTheme)().colors.contrast50;
|
|
32
|
+
let t0;
|
|
33
|
+
if ($[0] !== color) {
|
|
34
|
+
t0 = {
|
|
35
|
+
hostProps: {
|
|
36
|
+
android_ripple: {
|
|
37
|
+
color,
|
|
38
|
+
borderless: false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
pressed: undefined
|
|
42
|
+
};
|
|
43
|
+
$[0] = color;
|
|
44
|
+
$[1] = t0;
|
|
45
|
+
} else {
|
|
46
|
+
t0 = $[1];
|
|
47
|
+
}
|
|
48
|
+
return t0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* iOS: a wash the press lights at once and the release fades, as a table
|
|
53
|
+
* cell's highlight. Press in and out only set a shared value: no React render,
|
|
54
|
+
* and the wash's opacity follows it on the UI thread.
|
|
55
|
+
*/
|
|
56
|
+
function useWash() {
|
|
57
|
+
const pressed = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
58
|
+
return (0, _react.useMemo)(() => ({
|
|
59
|
+
hostProps: {
|
|
60
|
+
onPressIn: () => {
|
|
61
|
+
pressed.value = 1;
|
|
62
|
+
},
|
|
63
|
+
onPressOut: () => {
|
|
64
|
+
pressed.value = (0, _reactNativeReanimated.withTiming)(0, FADE_OUT);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
pressed
|
|
68
|
+
}), [pressed]);
|
|
69
|
+
}
|
|
70
|
+
function useNone() {
|
|
71
|
+
return NONE;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A pressable row's pressed state on native, in the wash `SubtleHover` paints:
|
|
76
|
+
* the theme's `contrast50`, the fill an unfilled Bloom control takes while
|
|
77
|
+
* held. Android draws its ripple; iOS lights the row's `SubtleHover`. The web
|
|
78
|
+
* has the pointer's hover wash and gets nothing here.
|
|
79
|
+
*
|
|
80
|
+
* Spread `hostProps` only on a row that takes a press: a `Pressable` without
|
|
81
|
+
* `onPress` still answers a touch.
|
|
82
|
+
*
|
|
83
|
+
* ```tsx
|
|
84
|
+
* const highlight = usePressHighlight();
|
|
85
|
+
* <Pressable onPress={open} {...highlight.hostProps}>
|
|
86
|
+
* <SubtleHover pressed={highlight.pressed} />
|
|
87
|
+
* …
|
|
88
|
+
* </Pressable>
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* A child that takes its own press (a button, a link) holds the touch, so the
|
|
92
|
+
* row does not light; a scroll that takes the touch releases it.
|
|
93
|
+
*/
|
|
94
|
+
const usePressHighlight = exports.usePressHighlight = _reactNative.Platform.OS === 'android' ? useRipple : _reactNative.Platform.OS === 'ios' ? useWash : useNone;
|
|
95
|
+
//# sourceMappingURL=use-press-highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeReanimated","_theme","FADE_OUT","duration","easing","Easing","bezier","NONE","Object","freeze","hostProps","pressed","undefined","useRipple","$","_compilerRuntime","c","color","useTheme","colors","contrast50","t0","android_ripple","borderless","useWash","useSharedValue","useMemo","onPressIn","value","onPressOut","withTiming","useNone","usePressHighlight","exports","Platform","OS"],"sourceRoot":"../../../src","sources":["subtle-hover/use-press-highlight.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAEA;;AAoBA;AACA,MAAMI,QAAQ,GAAG;EAAEC,QAAQ,EAAE,GAAG;EAAEC,MAAM,EAAEC,6BAAM,CAACC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAAE,CAAC;AAEzE,MAAMC,IAAoB,GAAGC,MAAM,CAACC,MAAM,CAAC;EAAEC,SAAS,EAAEF,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;EAAEE,OAAO,EAAEC;AAAU,CAAC,CAAC;;AAEhG;AACA;AACA;AACA;AACA;AACA,SAAAC,UAAA;EAAA,MAAAC,CAAA,OAAAC,gBAAA,CAAAC,CAAA;EACE,MAAAC,KAAA,GAAc,IAAAC,eAAQ,EAAC,CAAC,CAAAC,MAAO,CAAAC,UAAW;EAAC,IAAAC,EAAA;EAAA,IAAAP,CAAA,QAAAG,KAAA;IAElCI,EAAA;MAAAX,SAAA,EAAa;QAAAY,cAAA,EAAkB;UAAAL,KAAA;UAAAM,UAAA,EAAqB;QAAM;MAAE,CAAC;MAAAZ,OAAA,EAAWC;IAAU,CAAC;IAAAE,CAAA,MAAAG,KAAA;IAAAH,CAAA,MAAAO,EAAA;EAAA;IAAAA,EAAA,GAAAP,CAAA;EAAA;EAAA,OAAnFO,EAAmF;AAAA;;AAK9F;AACA;AACA;AACA;AACA;AACA,SAASG,OAAOA,CAAA,EAAmB;EACjC,MAAMb,OAAO,GAAG,IAAAc,qCAAc,EAAC,CAAC,CAAC;EACjC,OAAO,IAAAC,cAAO,EACZ,OAAO;IACLhB,SAAS,EAAE;MACTiB,SAAS,EAAEA,CAAA,KAAM;QACfhB,OAAO,CAACiB,KAAK,GAAG,CAAC;MACnB,CAAC;MACDC,UAAU,EAAEA,CAAA,KAAM;QAChBlB,OAAO,CAACiB,KAAK,GAAG,IAAAE,iCAAU,EAAC,CAAC,EAAE5B,QAAQ,CAAC;MACzC;IACF,CAAC;IACDS;EACF,CAAC,CAAC,EACF,CAACA,OAAO,CACV,CAAC;AACH;AAEA,SAASoB,OAAOA,CAAA,EAAmB;EACjC,OAAOxB,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMyB,iBAAuC,GAAAC,OAAA,CAAAD,iBAAA,GAClDE,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGtB,SAAS,GAAGqB,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGX,OAAO,GAAGO,OAAO","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ import { useTheme } from '../theme';
|
|
|
8
8
|
import { adoptStyleSheet } from "../styles/adopt-style-sheet.js";
|
|
9
9
|
import { IS_WEB_TOUCH_DEVICE } from "../styles/pointer.js";
|
|
10
10
|
import { webDataSet } from "../styles/web-data.js";
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
/**
|
|
13
13
|
* The marker a `SubtleHover`'s hover group carries: spread it on the element
|
|
14
14
|
* whose hover lights the wash (`<Pressable {...hoverGroupProps}>`). A web
|
|
@@ -37,53 +37,80 @@ const FADE = Easing.bezier(0.4, 0, 0.2, 1);
|
|
|
37
37
|
* can light up together (e.g. every post of a thread), cross-fading over
|
|
38
38
|
* 150ms. Web always; native only when `native` is set.
|
|
39
39
|
*
|
|
40
|
+
* Either way, on native a `pressed` value (`usePressHighlight`, iOS) adds the
|
|
41
|
+
* row's press wash on top, at the full fill.
|
|
42
|
+
*
|
|
40
43
|
* The wash color comes from the theme's `contrast50` token so it tracks the
|
|
41
44
|
* active preset and light/dark mode.
|
|
42
45
|
*/
|
|
43
46
|
export function SubtleHover(t0) {
|
|
44
|
-
const $ = _c(
|
|
47
|
+
const $ = _c(10);
|
|
45
48
|
const {
|
|
46
49
|
active,
|
|
50
|
+
pressed,
|
|
47
51
|
style,
|
|
48
52
|
native: t1
|
|
49
53
|
} = t0;
|
|
50
54
|
const native = t1 === undefined ? false : t1;
|
|
51
|
-
|
|
52
|
-
if (active
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
$[0] = style;
|
|
62
|
-
$[1] = t2;
|
|
63
|
-
} else {
|
|
64
|
-
t2 = $[1];
|
|
65
|
-
}
|
|
66
|
-
return t2;
|
|
55
|
+
let t2;
|
|
56
|
+
if ($[0] !== active || $[1] !== native || $[2] !== style) {
|
|
57
|
+
t2 = washFor(active, native, style);
|
|
58
|
+
$[0] = active;
|
|
59
|
+
$[1] = native;
|
|
60
|
+
$[2] = style;
|
|
61
|
+
$[3] = t2;
|
|
62
|
+
} else {
|
|
63
|
+
t2 = $[3];
|
|
67
64
|
}
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const wash = t2;
|
|
66
|
+
if (pressed === undefined || Platform.OS === "web") {
|
|
67
|
+
return wash;
|
|
70
68
|
}
|
|
71
|
-
let
|
|
72
|
-
if ($[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
style: style
|
|
76
|
-
}) : /*#__PURE__*/_jsx(NativeActiveWash, {
|
|
77
|
-
active: active,
|
|
69
|
+
let t3;
|
|
70
|
+
if ($[4] !== pressed || $[5] !== style) {
|
|
71
|
+
t3 = /*#__PURE__*/_jsx(PressedWash, {
|
|
72
|
+
pressed: pressed,
|
|
78
73
|
style: style
|
|
79
74
|
});
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
75
|
+
$[4] = pressed;
|
|
76
|
+
$[5] = style;
|
|
77
|
+
$[6] = t3;
|
|
83
78
|
} else {
|
|
84
|
-
|
|
79
|
+
t3 = $[6];
|
|
85
80
|
}
|
|
86
|
-
|
|
81
|
+
let t4;
|
|
82
|
+
if ($[7] !== t3 || $[8] !== wash) {
|
|
83
|
+
t4 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
84
|
+
children: [wash, t3]
|
|
85
|
+
});
|
|
86
|
+
$[7] = t3;
|
|
87
|
+
$[8] = wash;
|
|
88
|
+
$[9] = t4;
|
|
89
|
+
} else {
|
|
90
|
+
t4 = $[9];
|
|
91
|
+
}
|
|
92
|
+
return t4;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The hover or coordinated wash, drawn in place (no component of its own). */
|
|
96
|
+
function washFor(active, native, style) {
|
|
97
|
+
const isWeb = Platform.OS === 'web';
|
|
98
|
+
if (active === undefined) {
|
|
99
|
+
// A web pointer affordance. Native has no hover, and neither does touch web.
|
|
100
|
+
if (!isWeb || IS_WEB_TOUCH_DEVICE) return null;
|
|
101
|
+
return /*#__PURE__*/_jsx(HoverWash, {
|
|
102
|
+
style: style
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// JS-driven coordinated mode: web always; native only when opted in.
|
|
106
|
+
if (!isWeb && !native) return null;
|
|
107
|
+
return isWeb ? /*#__PURE__*/_jsx(WebActiveWash, {
|
|
108
|
+
active: active,
|
|
109
|
+
style: style
|
|
110
|
+
}) : /*#__PURE__*/_jsx(NativeActiveWash, {
|
|
111
|
+
active: active,
|
|
112
|
+
style: style
|
|
113
|
+
});
|
|
87
114
|
}
|
|
88
115
|
SubtleHover.displayName = 'SubtleHover';
|
|
89
116
|
function HoverWash(t0) {
|
|
@@ -227,6 +254,42 @@ function NativeActiveWash(t0) {
|
|
|
227
254
|
}
|
|
228
255
|
return t4;
|
|
229
256
|
}
|
|
257
|
+
|
|
258
|
+
/** A press's wash: the full fill, its opacity the press highlight's value, on the UI thread. */
|
|
259
|
+
function PressedWash(t0) {
|
|
260
|
+
const $ = _c(6);
|
|
261
|
+
const {
|
|
262
|
+
pressed,
|
|
263
|
+
style
|
|
264
|
+
} = t0;
|
|
265
|
+
const theme = useTheme();
|
|
266
|
+
const fade = useAnimatedStyle(() => ({
|
|
267
|
+
opacity: pressed.value
|
|
268
|
+
}), [pressed]);
|
|
269
|
+
let t1;
|
|
270
|
+
if ($[0] !== theme.colors.contrast50) {
|
|
271
|
+
t1 = {
|
|
272
|
+
backgroundColor: theme.colors.contrast50
|
|
273
|
+
};
|
|
274
|
+
$[0] = theme.colors.contrast50;
|
|
275
|
+
$[1] = t1;
|
|
276
|
+
} else {
|
|
277
|
+
t1 = $[1];
|
|
278
|
+
}
|
|
279
|
+
let t2;
|
|
280
|
+
if ($[2] !== fade || $[3] !== style || $[4] !== t1) {
|
|
281
|
+
t2 = /*#__PURE__*/_jsx(Animated.View, {
|
|
282
|
+
style: [styles.overlay, t1, fade, style]
|
|
283
|
+
});
|
|
284
|
+
$[2] = fade;
|
|
285
|
+
$[3] = style;
|
|
286
|
+
$[4] = t1;
|
|
287
|
+
$[5] = t2;
|
|
288
|
+
} else {
|
|
289
|
+
t2 = $[5];
|
|
290
|
+
}
|
|
291
|
+
return t2;
|
|
292
|
+
}
|
|
230
293
|
const styles = StyleSheet.create({
|
|
231
294
|
overlay: {
|
|
232
295
|
position: 'absolute',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","Platform","StyleSheet","View","Animated","Easing","useAnimatedStyle","useSharedValue","withTiming","useTheme","adoptStyleSheet","IS_WEB_TOUCH_DEVICE","webDataSet","jsx","_jsx","hoverGroupProps","bloomHoverGroup","STYLE_ID","CSS","FADE_MS","FADE","bezier","SubtleHover","t0","$","_c","active","style","native","t1","undefined","
|
|
1
|
+
{"version":3,"names":["useEffect","Platform","StyleSheet","View","Animated","Easing","useAnimatedStyle","useSharedValue","withTiming","useTheme","adoptStyleSheet","IS_WEB_TOUCH_DEVICE","webDataSet","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","hoverGroupProps","bloomHoverGroup","STYLE_ID","CSS","FADE_MS","FADE","bezier","SubtleHover","t0","$","_c","active","pressed","style","native","t1","undefined","t2","washFor","wash","OS","t3","PressedWash","t4","children","isWeb","HoverWash","WebActiveWash","NativeActiveWash","displayName","theme","Symbol","for","bloomSubtleHover","colors","contrast50","backgroundColor","t5","styles","overlay","isDark","opacity","webFade","target","value","duration","easing","fade","create","position","top","left","right","bottom","pointerEvents","transitionProperty","transitionDuration","transitionTimingFunction"],"sourceRoot":"../../../src","sources":["subtle-hover/SubtleHover.tsx"],"mappings":";;;AAAA,SAA4BA,SAAS,QAAQ,OAAO;AACpD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACzD,OAAOC,QAAQ,IACbC,MAAM,EAENC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,QAAQ,QAAQ,UAAU;AACnC,SAASC,eAAe,QAAQ,gCAA6B;AAC7D,SAASC,mBAAmB,QAAQ,sBAAmB;AACvD,SAASC,UAAU,QAAQ,uBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAGhD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAwC,GAAGP,UAAU,CAAC;EAAEQ,eAAe,EAAE;AAAG,CAAC,CAAC;AAE3F,MAAMC,QAAQ,GAAG,oBAAoB;AACrC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EAC/BT,OAAO,EAAE;IACPU,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,aAAa,EAAE;EACjB,CAAC;EACDZ,OAAO,EAAE;IACPa,kBAAkB,EAAE,SAAS;IAC7BC,kBAAkB,EAAE,OAAO;IAC3BC,wBAAwB,EAAE;EAC5B;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hoverGroupProps","SubtleHover"],"sourceRoot":"../../../src","sources":["subtle-hover/index.ts"],"mappings":";;AAAA,SAASA,eAAe,EAAEC,WAAW,QAAQ,kBAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["hoverGroupProps","SubtleHover","usePressHighlight"],"sourceRoot":"../../../src","sources":["subtle-hover/index.ts"],"mappings":";;AAAA,SAASA,eAAe,EAAEC,WAAW,QAAQ,kBAAe;AAE5D,SAGEC,iBAAiB,QACZ,0BAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
import { Easing, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
7
|
+
import { useTheme } from '../theme';
|
|
8
|
+
|
|
9
|
+
/** The props a row's pressable host spreads for its press highlight. */
|
|
10
|
+
|
|
11
|
+
/** The release's fade, as `SubtleHover`'s cross-fade. */
|
|
12
|
+
const FADE_OUT = {
|
|
13
|
+
duration: 150,
|
|
14
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1)
|
|
15
|
+
};
|
|
16
|
+
const NONE = Object.freeze({
|
|
17
|
+
hostProps: Object.freeze({}),
|
|
18
|
+
pressed: undefined
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Android: the ripple React Native draws for a `Pressable` (`android_ripple`).
|
|
23
|
+
* The press reaches the view as a command, without a React render, and the
|
|
24
|
+
* ripple animates on the render thread.
|
|
25
|
+
*/
|
|
26
|
+
function useRipple() {
|
|
27
|
+
const $ = _c(2);
|
|
28
|
+
const color = useTheme().colors.contrast50;
|
|
29
|
+
let t0;
|
|
30
|
+
if ($[0] !== color) {
|
|
31
|
+
t0 = {
|
|
32
|
+
hostProps: {
|
|
33
|
+
android_ripple: {
|
|
34
|
+
color,
|
|
35
|
+
borderless: false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
pressed: undefined
|
|
39
|
+
};
|
|
40
|
+
$[0] = color;
|
|
41
|
+
$[1] = t0;
|
|
42
|
+
} else {
|
|
43
|
+
t0 = $[1];
|
|
44
|
+
}
|
|
45
|
+
return t0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* iOS: a wash the press lights at once and the release fades, as a table
|
|
50
|
+
* cell's highlight. Press in and out only set a shared value: no React render,
|
|
51
|
+
* and the wash's opacity follows it on the UI thread.
|
|
52
|
+
*/
|
|
53
|
+
function useWash() {
|
|
54
|
+
const pressed = useSharedValue(0);
|
|
55
|
+
return useMemo(() => ({
|
|
56
|
+
hostProps: {
|
|
57
|
+
onPressIn: () => {
|
|
58
|
+
pressed.value = 1;
|
|
59
|
+
},
|
|
60
|
+
onPressOut: () => {
|
|
61
|
+
pressed.value = withTiming(0, FADE_OUT);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
pressed
|
|
65
|
+
}), [pressed]);
|
|
66
|
+
}
|
|
67
|
+
function useNone() {
|
|
68
|
+
return NONE;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A pressable row's pressed state on native, in the wash `SubtleHover` paints:
|
|
73
|
+
* the theme's `contrast50`, the fill an unfilled Bloom control takes while
|
|
74
|
+
* held. Android draws its ripple; iOS lights the row's `SubtleHover`. The web
|
|
75
|
+
* has the pointer's hover wash and gets nothing here.
|
|
76
|
+
*
|
|
77
|
+
* Spread `hostProps` only on a row that takes a press: a `Pressable` without
|
|
78
|
+
* `onPress` still answers a touch.
|
|
79
|
+
*
|
|
80
|
+
* ```tsx
|
|
81
|
+
* const highlight = usePressHighlight();
|
|
82
|
+
* <Pressable onPress={open} {...highlight.hostProps}>
|
|
83
|
+
* <SubtleHover pressed={highlight.pressed} />
|
|
84
|
+
* …
|
|
85
|
+
* </Pressable>
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* A child that takes its own press (a button, a link) holds the touch, so the
|
|
89
|
+
* row does not light; a scroll that takes the touch releases it.
|
|
90
|
+
*/
|
|
91
|
+
export const usePressHighlight = Platform.OS === 'android' ? useRipple : Platform.OS === 'ios' ? useWash : useNone;
|
|
92
|
+
//# sourceMappingURL=use-press-highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","Platform","Easing","useSharedValue","withTiming","useTheme","FADE_OUT","duration","easing","bezier","NONE","Object","freeze","hostProps","pressed","undefined","useRipple","$","_c","color","colors","contrast50","t0","android_ripple","borderless","useWash","onPressIn","value","onPressOut","useNone","usePressHighlight","OS"],"sourceRoot":"../../../src","sources":["subtle-hover/use-press-highlight.ts"],"mappings":";;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,QAAQ,QAA6B,cAAc;AAC5D,SAASC,MAAM,EAAoBC,cAAc,EAAEC,UAAU,QAAQ,yBAAyB;AAE9F,SAASC,QAAQ,QAAQ,UAAU;;AAEnC;;AAoBA;AACA,MAAMC,QAAQ,GAAG;EAAEC,QAAQ,EAAE,GAAG;EAAEC,MAAM,EAAEN,MAAM,CAACO,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAAE,CAAC;AAEzE,MAAMC,IAAoB,GAAGC,MAAM,CAACC,MAAM,CAAC;EAAEC,SAAS,EAAEF,MAA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GAAGN,OAAO,GAAGI,OAAO","ignoreList":[]}
|
|
@@ -15,10 +15,13 @@ export declare const hoverGroupProps: Record<string, unknown>;
|
|
|
15
15
|
* can light up together (e.g. every post of a thread), cross-fading over
|
|
16
16
|
* 150ms. Web always; native only when `native` is set.
|
|
17
17
|
*
|
|
18
|
+
* Either way, on native a `pressed` value (`usePressHighlight`, iOS) adds the
|
|
19
|
+
* row's press wash on top, at the full fill.
|
|
20
|
+
*
|
|
18
21
|
* The wash color comes from the theme's `contrast50` token so it tracks the
|
|
19
22
|
* active preset and light/dark mode.
|
|
20
23
|
*/
|
|
21
|
-
export declare function SubtleHover({ active, style, native }: SubtleHoverProps): import("react").JSX.Element | null;
|
|
24
|
+
export declare function SubtleHover({ active, pressed, style, native }: SubtleHoverProps): import("react").JSX.Element | null;
|
|
22
25
|
export declare namespace SubtleHover {
|
|
23
26
|
var displayName: string;
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubtleHover.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/SubtleHover.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubtleHover.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/SubtleHover.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAuC,CAAC;AAY5F;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE,gBAAgB,sCASvF;yBATe,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,iBAAiB,GAClB,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
3
|
export interface SubtleHoverProps {
|
|
3
4
|
/**
|
|
4
5
|
* JS-driven visibility for a coordinated highlight — e.g. every post of one
|
|
@@ -7,6 +8,11 @@ export interface SubtleHoverProps {
|
|
|
7
8
|
* element spreads `hoverGroupProps`.
|
|
8
9
|
*/
|
|
9
10
|
active?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The row's press, from `usePressHighlight()` (iOS): the wash lights while
|
|
13
|
+
* the row is held, at the full fill, on the UI thread. Ignored on the web.
|
|
14
|
+
*/
|
|
15
|
+
pressed?: SharedValue<number>;
|
|
10
16
|
/** Extra style merged last — e.g. `borderRadius` to match the parent. */
|
|
11
17
|
style?: StyleProp<ViewStyle>;
|
|
12
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type PressableProps } from 'react-native';
|
|
2
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
3
|
+
/** The props a row's pressable host spreads for its press highlight. */
|
|
4
|
+
export interface PressHighlightHostProps {
|
|
5
|
+
/** Android: the platform ripple, bounded by the row. */
|
|
6
|
+
android_ripple?: PressableProps['android_ripple'];
|
|
7
|
+
/** iOS: lights `pressed`. Call it from the host's own `onPressIn` if it has one. */
|
|
8
|
+
onPressIn?: () => void;
|
|
9
|
+
/** iOS: fades `pressed` out. Call it from the host's own `onPressOut` if it has one. */
|
|
10
|
+
onPressOut?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface PressHighlight {
|
|
13
|
+
/** Spread on the row's `Pressable`; nothing on the web. */
|
|
14
|
+
hostProps: PressHighlightHostProps;
|
|
15
|
+
/**
|
|
16
|
+
* iOS: hand it to the row's `SubtleHover` (`<SubtleHover pressed={…} />`),
|
|
17
|
+
* whose wash it drives on the UI thread. `undefined` elsewhere.
|
|
18
|
+
*/
|
|
19
|
+
pressed: SharedValue<number> | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A pressable row's pressed state on native, in the wash `SubtleHover` paints:
|
|
23
|
+
* the theme's `contrast50`, the fill an unfilled Bloom control takes while
|
|
24
|
+
* held. Android draws its ripple; iOS lights the row's `SubtleHover`. The web
|
|
25
|
+
* has the pointer's hover wash and gets nothing here.
|
|
26
|
+
*
|
|
27
|
+
* Spread `hostProps` only on a row that takes a press: a `Pressable` without
|
|
28
|
+
* `onPress` still answers a touch.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const highlight = usePressHighlight();
|
|
32
|
+
* <Pressable onPress={open} {...highlight.hostProps}>
|
|
33
|
+
* <SubtleHover pressed={highlight.pressed} />
|
|
34
|
+
* …
|
|
35
|
+
* </Pressable>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* A child that takes its own press (a button, a link) holds the touch, so the
|
|
39
|
+
* row does not light; a scroll that takes the touch releases it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const usePressHighlight: () => PressHighlight;
|
|
42
|
+
//# sourceMappingURL=use-press-highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-press-highlight.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/use-press-highlight.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAU,KAAK,WAAW,EAA8B,MAAM,yBAAyB,CAAC;AAI/F,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,wDAAwD;IACxD,cAAc,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAClD,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,SAAS,EAAE,uBAAuB,CAAC;IACnC;;;OAGG;IACH,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CAC1C;AA+CD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,cAC6C,CAAC"}
|
|
@@ -15,10 +15,13 @@ export declare const hoverGroupProps: Record<string, unknown>;
|
|
|
15
15
|
* can light up together (e.g. every post of a thread), cross-fading over
|
|
16
16
|
* 150ms. Web always; native only when `native` is set.
|
|
17
17
|
*
|
|
18
|
+
* Either way, on native a `pressed` value (`usePressHighlight`, iOS) adds the
|
|
19
|
+
* row's press wash on top, at the full fill.
|
|
20
|
+
*
|
|
18
21
|
* The wash color comes from the theme's `contrast50` token so it tracks the
|
|
19
22
|
* active preset and light/dark mode.
|
|
20
23
|
*/
|
|
21
|
-
export declare function SubtleHover({ active, style, native }: SubtleHoverProps): import("react").JSX.Element | null;
|
|
24
|
+
export declare function SubtleHover({ active, pressed, style, native }: SubtleHoverProps): import("react").JSX.Element | null;
|
|
22
25
|
export declare namespace SubtleHover {
|
|
23
26
|
var displayName: string;
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubtleHover.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/SubtleHover.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubtleHover.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/SubtleHover.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAS,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAuC,CAAC;AAY5F;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE,gBAAgB,sCASvF;yBATe,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAS,CAAC;AAChD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,iBAAiB,GAClB,MAAM,0BAAuB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
3
|
export interface SubtleHoverProps {
|
|
3
4
|
/**
|
|
4
5
|
* JS-driven visibility for a coordinated highlight — e.g. every post of one
|
|
@@ -7,6 +8,11 @@ export interface SubtleHoverProps {
|
|
|
7
8
|
* element spreads `hoverGroupProps`.
|
|
8
9
|
*/
|
|
9
10
|
active?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The row's press, from `usePressHighlight()` (iOS): the wash lights while
|
|
13
|
+
* the row is held, at the full fill, on the UI thread. Ignored on the web.
|
|
14
|
+
*/
|
|
15
|
+
pressed?: SharedValue<number>;
|
|
10
16
|
/** Extra style merged last — e.g. `borderRadius` to match the parent. */
|
|
11
17
|
style?: StyleProp<ViewStyle>;
|
|
12
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type PressableProps } from 'react-native';
|
|
2
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
3
|
+
/** The props a row's pressable host spreads for its press highlight. */
|
|
4
|
+
export interface PressHighlightHostProps {
|
|
5
|
+
/** Android: the platform ripple, bounded by the row. */
|
|
6
|
+
android_ripple?: PressableProps['android_ripple'];
|
|
7
|
+
/** iOS: lights `pressed`. Call it from the host's own `onPressIn` if it has one. */
|
|
8
|
+
onPressIn?: () => void;
|
|
9
|
+
/** iOS: fades `pressed` out. Call it from the host's own `onPressOut` if it has one. */
|
|
10
|
+
onPressOut?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface PressHighlight {
|
|
13
|
+
/** Spread on the row's `Pressable`; nothing on the web. */
|
|
14
|
+
hostProps: PressHighlightHostProps;
|
|
15
|
+
/**
|
|
16
|
+
* iOS: hand it to the row's `SubtleHover` (`<SubtleHover pressed={…} />`),
|
|
17
|
+
* whose wash it drives on the UI thread. `undefined` elsewhere.
|
|
18
|
+
*/
|
|
19
|
+
pressed: SharedValue<number> | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A pressable row's pressed state on native, in the wash `SubtleHover` paints:
|
|
23
|
+
* the theme's `contrast50`, the fill an unfilled Bloom control takes while
|
|
24
|
+
* held. Android draws its ripple; iOS lights the row's `SubtleHover`. The web
|
|
25
|
+
* has the pointer's hover wash and gets nothing here.
|
|
26
|
+
*
|
|
27
|
+
* Spread `hostProps` only on a row that takes a press: a `Pressable` without
|
|
28
|
+
* `onPress` still answers a touch.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const highlight = usePressHighlight();
|
|
32
|
+
* <Pressable onPress={open} {...highlight.hostProps}>
|
|
33
|
+
* <SubtleHover pressed={highlight.pressed} />
|
|
34
|
+
* …
|
|
35
|
+
* </Pressable>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* A child that takes its own press (a button, a link) holds the touch, so the
|
|
39
|
+
* row does not light; a scroll that takes the touch releases it.
|
|
40
|
+
*/
|
|
41
|
+
export declare const usePressHighlight: () => PressHighlight;
|
|
42
|
+
//# sourceMappingURL=use-press-highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-press-highlight.d.ts","sourceRoot":"","sources":["../../../../src/subtle-hover/use-press-highlight.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAU,KAAK,WAAW,EAA8B,MAAM,yBAAyB,CAAC;AAI/F,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,wDAAwD;IACxD,cAAc,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAClD,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,SAAS,EAAE,uBAAuB,CAAC;IACnC;;;OAGG;IACH,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CAC1C;AA+CD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,cAC6C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
1
|
+
import { type ReactElement, useEffect } from 'react';
|
|
2
2
|
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
3
|
import Animated, {
|
|
4
4
|
Easing,
|
|
5
|
+
type SharedValue,
|
|
5
6
|
useAnimatedStyle,
|
|
6
7
|
useSharedValue,
|
|
7
8
|
withTiming,
|
|
@@ -40,10 +41,29 @@ const FADE = Easing.bezier(0.4, 0, 0.2, 1);
|
|
|
40
41
|
* can light up together (e.g. every post of a thread), cross-fading over
|
|
41
42
|
* 150ms. Web always; native only when `native` is set.
|
|
42
43
|
*
|
|
44
|
+
* Either way, on native a `pressed` value (`usePressHighlight`, iOS) adds the
|
|
45
|
+
* row's press wash on top, at the full fill.
|
|
46
|
+
*
|
|
43
47
|
* The wash color comes from the theme's `contrast50` token so it tracks the
|
|
44
48
|
* active preset and light/dark mode.
|
|
45
49
|
*/
|
|
46
|
-
export function SubtleHover({ active, style, native = false }: SubtleHoverProps) {
|
|
50
|
+
export function SubtleHover({ active, pressed, style, native = false }: SubtleHoverProps) {
|
|
51
|
+
const wash = washFor(active, native, style);
|
|
52
|
+
if (pressed === undefined || Platform.OS === 'web') return wash;
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
{wash}
|
|
56
|
+
<PressedWash pressed={pressed} style={style} />
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The hover or coordinated wash, drawn in place (no component of its own). */
|
|
62
|
+
function washFor(
|
|
63
|
+
active: boolean | undefined,
|
|
64
|
+
native: boolean,
|
|
65
|
+
style: SubtleHoverProps['style'],
|
|
66
|
+
): ReactElement | null {
|
|
47
67
|
const isWeb = Platform.OS === 'web';
|
|
48
68
|
if (active === undefined) {
|
|
49
69
|
// A web pointer affordance. Native has no hover, and neither does touch web.
|
|
@@ -108,6 +128,17 @@ function NativeActiveWash({ active, style }: WashProps & { active: boolean }) {
|
|
|
108
128
|
);
|
|
109
129
|
}
|
|
110
130
|
|
|
131
|
+
/** A press's wash: the full fill, its opacity the press highlight's value, on the UI thread. */
|
|
132
|
+
function PressedWash({ pressed, style }: WashProps & { pressed: SharedValue<number> }) {
|
|
133
|
+
const theme = useTheme();
|
|
134
|
+
const fade = useAnimatedStyle(() => ({ opacity: pressed.value }), [pressed]);
|
|
135
|
+
return (
|
|
136
|
+
<Animated.View
|
|
137
|
+
style={[styles.overlay, { backgroundColor: theme.colors.contrast50 }, fade, style]}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
111
142
|
const styles = StyleSheet.create({
|
|
112
143
|
overlay: {
|
|
113
144
|
position: 'absolute',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
3
4
|
|
|
4
5
|
export interface SubtleHoverProps {
|
|
5
6
|
/**
|
|
@@ -9,6 +10,11 @@ export interface SubtleHoverProps {
|
|
|
9
10
|
* element spreads `hoverGroupProps`.
|
|
10
11
|
*/
|
|
11
12
|
active?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The row's press, from `usePressHighlight()` (iOS): the wash lights while
|
|
15
|
+
* the row is held, at the full fill, on the UI thread. Ignored on the web.
|
|
16
|
+
*/
|
|
17
|
+
pressed?: SharedValue<number>;
|
|
12
18
|
/** Extra style merged last — e.g. `borderRadius` to match the parent. */
|
|
13
19
|
style?: StyleProp<ViewStyle>;
|
|
14
20
|
/**
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { Platform, type PressableProps } from 'react-native';
|
|
3
|
+
import { Easing, type SharedValue, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '../theme';
|
|
6
|
+
|
|
7
|
+
/** The props a row's pressable host spreads for its press highlight. */
|
|
8
|
+
export interface PressHighlightHostProps {
|
|
9
|
+
/** Android: the platform ripple, bounded by the row. */
|
|
10
|
+
android_ripple?: PressableProps['android_ripple'];
|
|
11
|
+
/** iOS: lights `pressed`. Call it from the host's own `onPressIn` if it has one. */
|
|
12
|
+
onPressIn?: () => void;
|
|
13
|
+
/** iOS: fades `pressed` out. Call it from the host's own `onPressOut` if it has one. */
|
|
14
|
+
onPressOut?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PressHighlight {
|
|
18
|
+
/** Spread on the row's `Pressable`; nothing on the web. */
|
|
19
|
+
hostProps: PressHighlightHostProps;
|
|
20
|
+
/**
|
|
21
|
+
* iOS: hand it to the row's `SubtleHover` (`<SubtleHover pressed={…} />`),
|
|
22
|
+
* whose wash it drives on the UI thread. `undefined` elsewhere.
|
|
23
|
+
*/
|
|
24
|
+
pressed: SharedValue<number> | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The release's fade, as `SubtleHover`'s cross-fade. */
|
|
28
|
+
const FADE_OUT = { duration: 150, easing: Easing.bezier(0.4, 0, 0.2, 1) };
|
|
29
|
+
|
|
30
|
+
const NONE: PressHighlight = Object.freeze({ hostProps: Object.freeze({}), pressed: undefined });
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Android: the ripple React Native draws for a `Pressable` (`android_ripple`).
|
|
34
|
+
* The press reaches the view as a command, without a React render, and the
|
|
35
|
+
* ripple animates on the render thread.
|
|
36
|
+
*/
|
|
37
|
+
function useRipple(): PressHighlight {
|
|
38
|
+
const color = useTheme().colors.contrast50;
|
|
39
|
+
return useMemo(
|
|
40
|
+
() => ({ hostProps: { android_ripple: { color, borderless: false } }, pressed: undefined }),
|
|
41
|
+
[color],
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* iOS: a wash the press lights at once and the release fades, as a table
|
|
47
|
+
* cell's highlight. Press in and out only set a shared value: no React render,
|
|
48
|
+
* and the wash's opacity follows it on the UI thread.
|
|
49
|
+
*/
|
|
50
|
+
function useWash(): PressHighlight {
|
|
51
|
+
const pressed = useSharedValue(0);
|
|
52
|
+
return useMemo(
|
|
53
|
+
() => ({
|
|
54
|
+
hostProps: {
|
|
55
|
+
onPressIn: () => {
|
|
56
|
+
pressed.value = 1;
|
|
57
|
+
},
|
|
58
|
+
onPressOut: () => {
|
|
59
|
+
pressed.value = withTiming(0, FADE_OUT);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
pressed,
|
|
63
|
+
}),
|
|
64
|
+
[pressed],
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function useNone(): PressHighlight {
|
|
69
|
+
return NONE;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A pressable row's pressed state on native, in the wash `SubtleHover` paints:
|
|
74
|
+
* the theme's `contrast50`, the fill an unfilled Bloom control takes while
|
|
75
|
+
* held. Android draws its ripple; iOS lights the row's `SubtleHover`. The web
|
|
76
|
+
* has the pointer's hover wash and gets nothing here.
|
|
77
|
+
*
|
|
78
|
+
* Spread `hostProps` only on a row that takes a press: a `Pressable` without
|
|
79
|
+
* `onPress` still answers a touch.
|
|
80
|
+
*
|
|
81
|
+
* ```tsx
|
|
82
|
+
* const highlight = usePressHighlight();
|
|
83
|
+
* <Pressable onPress={open} {...highlight.hostProps}>
|
|
84
|
+
* <SubtleHover pressed={highlight.pressed} />
|
|
85
|
+
* …
|
|
86
|
+
* </Pressable>
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* A child that takes its own press (a button, a link) holds the touch, so the
|
|
90
|
+
* row does not light; a scroll that takes the touch releases it.
|
|
91
|
+
*/
|
|
92
|
+
export const usePressHighlight: () => PressHighlight =
|
|
93
|
+
Platform.OS === 'android' ? useRipple : Platform.OS === 'ios' ? useWash : useNone;
|