@artsy/palette-mobile 3.0.0 → 3.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.
|
@@ -2,15 +2,15 @@ import { TouchableHighlightProps } from "react-native";
|
|
|
2
2
|
import { HapticFeedbackTypes } from "react-native-haptic-feedback";
|
|
3
3
|
interface ExtraTouchableProps {
|
|
4
4
|
flex?: number;
|
|
5
|
+
/**
|
|
6
|
+
* `haptic` can be used like:
|
|
7
|
+
* <Touchable haptic />
|
|
8
|
+
* or
|
|
9
|
+
* <Touchable haptic="impactHeavy" />
|
|
10
|
+
*/
|
|
5
11
|
haptic?: HapticFeedbackTypes | true;
|
|
6
12
|
noFeedback?: boolean;
|
|
7
13
|
}
|
|
8
14
|
export declare type TouchableProps = TouchableHighlightProps & ExtraTouchableProps;
|
|
9
|
-
/**
|
|
10
|
-
* `haptic` can be used like:
|
|
11
|
-
* <Touchable haptic />
|
|
12
|
-
* or
|
|
13
|
-
* <Touchable haptic="impactHeavy" />
|
|
14
|
-
*/
|
|
15
15
|
export declare const Touchable: ({ children, flex, haptic, noFeedback, onPress, ...restProps }: TouchableProps) => JSX.Element;
|
|
16
16
|
export {};
|
|
@@ -10,24 +10,17 @@ const react_native_1 = require("react-native");
|
|
|
10
10
|
const react_native_haptic_feedback_1 = __importDefault(require("react-native-haptic-feedback"));
|
|
11
11
|
const atoms_1 = require("../../atoms");
|
|
12
12
|
const hooks_1 = require("../../hooks");
|
|
13
|
-
|
|
14
|
-
* `haptic` can be used like:
|
|
15
|
-
* <Touchable haptic />
|
|
16
|
-
* or
|
|
17
|
-
* <Touchable haptic="impactHeavy" />
|
|
18
|
-
*/
|
|
19
|
-
const Touchable = ({ children, flex, haptic, noFeedback, onPress, ...restProps }) => {
|
|
13
|
+
const Touchable = ({ children, flex, haptic, noFeedback = false, onPress, ...restProps }) => {
|
|
20
14
|
const color = (0, hooks_1.useColor)();
|
|
21
15
|
const inner = react_1.Children.count(children) === 1 ? children : (0, jsx_runtime_1.jsx)(atoms_1.Flex, { flex: flex, children: children });
|
|
22
16
|
const onPressWrapped = (evt) => {
|
|
23
|
-
if (onPress === undefined)
|
|
17
|
+
if (onPress === undefined)
|
|
24
18
|
return;
|
|
25
|
-
}
|
|
26
19
|
if (haptic !== undefined) {
|
|
27
20
|
react_native_haptic_feedback_1.default.trigger(haptic === true ? "impactLight" : haptic);
|
|
28
21
|
}
|
|
29
22
|
onPress(evt);
|
|
30
23
|
};
|
|
31
|
-
return noFeedback ? ((0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { ...restProps, onPress: onPressWrapped, children: inner })) : ((0, jsx_runtime_1.jsx)(react_native_1.TouchableHighlight, {
|
|
24
|
+
return noFeedback ? ((0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { ...restProps, onPress: onPressWrapped, children: inner })) : ((0, jsx_runtime_1.jsx)(react_native_1.TouchableHighlight, { activeOpacity: 0.8, ...restProps, underlayColor: color("background"), onPress: onPressWrapped, children: inner }));
|
|
32
25
|
};
|
|
33
26
|
exports.Touchable = Touchable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Examples = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const atoms_1 = require("../../atoms");
|
|
6
|
+
const storybookHelpers_1 = require("../../storybookHelpers");
|
|
7
|
+
const svgs_1 = require("../../svgs");
|
|
8
|
+
const Text_1 = require("../Text");
|
|
9
|
+
const Touchable_1 = require("./Touchable");
|
|
10
|
+
exports.default = {
|
|
11
|
+
title: "Touchable",
|
|
12
|
+
component: Touchable_1.Touchable,
|
|
13
|
+
};
|
|
14
|
+
const Examples = () => ((0, jsx_runtime_1.jsxs)(storybookHelpers_1.List, { children: [(0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "This is a text wrapped in a `Touchable`." }) }), (0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { children: (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { width: 200, alignItems: "center", borderColor: "red", borderWidth: 1, children: [(0, jsx_runtime_1.jsx)(svgs_1.TrashIcon, {}), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "This is a cell with an icon and a text, wrapped in a `Touchable`." })] }) })] }));
|
|
15
|
+
exports.Examples = Examples;
|