@artsy/palette-mobile 3.1.0 → 3.2.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/dist/Theme.d.ts CHANGED
@@ -13,7 +13,6 @@ export declare const useTheme: () => {
13
13
  color: ColorFuncOverload;
14
14
  space: (spaceName: SpacingUnit) => number;
15
15
  };
16
- export declare const isThemeV3: (theme: AllThemesType) => boolean;
17
16
  /**
18
17
  * Only use this if it's are absolutely neccessary, and only in tests.
19
18
  */
package/dist/Theme.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._test_THEMES = exports.isThemeV3 = exports.useTheme = exports.Theme = void 0;
3
+ exports._test_THEMES = exports.useTheme = exports.Theme = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const remeda_1 = require("remeda");
@@ -37,7 +37,7 @@ const useTheme = () => {
37
37
  console.error("You are trying to use the `Theme` but you have not wrapped your component/screen with `<Theme>`. Please wrap and try again.");
38
38
  throw new Error("ThemeContext is not defined. Wrap your component with `<Theme>` and try again.");
39
39
  }
40
- const themeIfUnwrapped = tokens_1.THEMES.v3;
40
+ const themeIfUnwrapped = tokens_1.THEMES.v5light;
41
41
  return {
42
42
  theme: theme ?? themeIfUnwrapped,
43
43
  color: color(theme ?? themeIfUnwrapped),
@@ -45,8 +45,6 @@ const useTheme = () => {
45
45
  };
46
46
  };
47
47
  exports.useTheme = useTheme;
48
- const isThemeV3 = (theme) => theme.id === "v3";
49
- exports.isThemeV3 = isThemeV3;
50
48
  /**
51
49
  * Only use this if it's are absolutely neccessary, and only in tests.
52
50
  */
@@ -1,14 +1,12 @@
1
1
  import { ImgHTMLAttributes } from "react";
2
+ declare type AvatarSize = "xxs" | "xs" | "sm" | "md";
2
3
  export interface AvatarProps extends ImgHTMLAttributes<any> {
3
4
  src?: string;
4
5
  /** If an image is missing, show initials instead */
5
6
  initials?: string;
6
7
  /** The size of the Avatar */
7
- size?: "xxs" | "xs" | "sm" | "md";
8
+ size?: AvatarSize;
8
9
  }
9
10
  /** A circular Avatar component containing an image or initials */
10
11
  export declare const Avatar: ({ src, initials, size }: AvatarProps) => JSX.Element;
11
- export declare const InitialsHolder: import("styled-components").StyledComponent<{
12
- ({ backgroundColor, ...restProps }: import("../../atoms").BoxProps): JSX.Element;
13
- displayName: string;
14
- }, any, {}, never>;
12
+ export {};
@@ -1,40 +1,34 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InitialsHolder = exports.Avatar = void 0;
3
+ exports.Avatar = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const theme_get_1 = require("@styled-system/theme-get");
9
5
  const react_native_1 = require("react-native");
10
- const native_1 = __importDefault(require("styled-components/native"));
11
- const styled_system_1 = require("styled-system");
12
6
  const atoms_1 = require("../../atoms");
13
7
  const hooks_1 = require("../../hooks");
14
8
  const Text_1 = require("../Text");
15
9
  const DEFAULT_SIZE = "md";
16
- const SIZES = {
10
+ const VARIANTS = {
17
11
  xxs: {
18
12
  diameter: 30,
19
- typeSize: "13",
13
+ textSize: "xs",
20
14
  },
21
15
  xs: {
22
16
  diameter: 45,
23
- typeSize: "13",
17
+ textSize: "sm-display",
24
18
  },
25
19
  sm: {
26
20
  diameter: 70,
27
- typeSize: "16",
21
+ textSize: "md",
28
22
  },
29
23
  md: {
30
24
  diameter: 100,
31
- typeSize: "24",
25
+ textSize: "lg-display",
32
26
  },
33
27
  };
34
28
  /** A circular Avatar component containing an image or initials */
35
29
  const Avatar = ({ src, initials, size = DEFAULT_SIZE }) => {
36
30
  const color = (0, hooks_1.useColor)();
37
- const { diameter, typeSize } = SIZES[size];
31
+ const { diameter, textSize } = VARIANTS[size];
38
32
  if (src) {
39
33
  return ((0, jsx_runtime_1.jsx)(react_native_1.Image, { resizeMode: "cover", style: {
40
34
  width: diameter,
@@ -42,16 +36,8 @@ const Avatar = ({ src, initials, size = DEFAULT_SIZE }) => {
42
36
  borderRadius: diameter / 2,
43
37
  borderColor: color("white100"),
44
38
  borderWidth: 1,
45
- }, source: {
46
- uri: src,
47
- } }));
39
+ }, source: { uri: src } }));
48
40
  }
49
- return ((0, jsx_runtime_1.jsx)(exports.InitialsHolder, { width: diameter, height: diameter, justifyContent: "center", alignItems: "center", borderRadius: diameter, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { fontSize: typeSize, lineHeight: diameter, children: initials }) }));
41
+ return ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { width: diameter, height: diameter, borderColor: "black10", borderWidth: 1, borderRadius: diameter, overflow: "hidden", alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: textSize, children: initials }) }));
50
42
  };
51
43
  exports.Avatar = Avatar;
52
- exports.InitialsHolder = (0, native_1.default)(atoms_1.Flex) `
53
- border: ${(0, theme_get_1.themeGet)("colors.black10")};
54
- text-align: center;
55
- overflow: hidden;
56
- ${styled_system_1.borderRadius}
57
- `;
@@ -0,0 +1,7 @@
1
+ import { AvatarProps } from "./Avatar";
2
+ declare const _default: {
3
+ title: string;
4
+ component: ({ src, initials, size }: AvatarProps) => JSX.Element;
5
+ };
6
+ export default _default;
7
+ export declare function Variants(): JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Variants = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const storybookHelpers_1 = require("../../storybookHelpers");
6
+ const Avatar_1 = require("./Avatar");
7
+ exports.default = {
8
+ title: "Avatar",
9
+ component: Avatar_1.Avatar,
10
+ };
11
+ const sizes = ["md", "sm", "xs", "xxs"];
12
+ function Variants() {
13
+ return ((0, jsx_runtime_1.jsxs)(storybookHelpers_1.List, { children: [(0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: sizes.map((s) => ((0, jsx_runtime_1.jsx)(Avatar_1.Avatar, { initials: "A", size: s }, s))) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: sizes.map((s) => ((0, jsx_runtime_1.jsx)(Avatar_1.Avatar, { initials: "AA", size: s }, s))) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: sizes.map((s) => ((0, jsx_runtime_1.jsx)(Avatar_1.Avatar, { src: "https://placekitten.com/300/300", size: s }, s))) })] }));
14
+ }
15
+ exports.Variants = Variants;
@@ -1,15 +1,15 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="styled-components-react-native" />
3
- import { TouchableWithoutFeedbackProps } from "react-native";
4
- import { FlexProps } from "../../atoms";
5
- export interface CheckboxProps extends TouchableWithoutFeedbackProps, FlexProps {
2
+ import { TouchableProps } from "../../elements";
3
+ declare type DisplayState = "unpressed" | "pressed";
4
+ export interface CheckboxProps {
6
5
  checked?: boolean;
7
6
  disabled?: boolean;
8
7
  error?: boolean;
9
8
  text?: React.ReactElement | string;
10
9
  subtitle?: React.ReactElement | string;
11
- children?: React.ReactElement | string;
10
+ onPress?: TouchableProps["onPress"];
11
+ /** Used only for tests and stories */
12
+ testOnly_state?: DisplayState;
12
13
  }
13
- export declare const Checkbox: ({ checked: checkedProp, disabled, error, onPress, style, text, subtitle, children, ...restProps }: CheckboxProps) => JSX.Element;
14
- export declare const CheckMark: import("styled-components").StyledComponent<typeof import("react-native").View, import("styled-components").DefaultTheme, {}, never>;
15
- export declare const DisabledMark: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof JSX.IntrinsicElements, any, {}, never>;
14
+ export declare const Checkbox: ({ checked: checkedProp, disabled, error, onPress, text, subtitle, testOnly_state, }: CheckboxProps) => JSX.Element;
15
+ export {};
@@ -1,96 +1,105 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DisabledMark = exports.CheckMark = exports.Checkbox = void 0;
26
+ exports.Checkbox = void 0;
7
27
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const theme_get_1 = require("@styled-system/theme-get");
28
+ const elements_1 = require("../../elements");
9
29
  const react_1 = require("react");
10
30
  const react_native_1 = require("react-native");
11
- const native_1 = __importDefault(require("styled-components/native"));
12
- const animation_1 = require("../../animation");
13
31
  const atoms_1 = require("../../atoms");
32
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
14
33
  const Theme_1 = require("../../Theme");
15
34
  const Text_1 = require("../Text");
16
- const CHECKBOX_SIZE = 20;
17
- const DURATION = 250;
18
- const Checkbox = ({ checked: checkedProp, disabled, error, onPress, style, text, subtitle, children, ...restProps }) => {
35
+ const hooks_1 = require("../../hooks");
36
+ const CHECKBOX_SIZEx1 = 20;
37
+ const ANIMATION_DURATION = 250;
38
+ const Checkbox = ({ checked: checkedProp, disabled, error, onPress, text, subtitle, testOnly_state, }) => {
19
39
  const { color, space } = (0, Theme_1.useTheme)();
20
40
  const fontScale = react_native_1.PixelRatio.getFontScale();
21
- const checkboxSize = CHECKBOX_SIZE * fontScale;
22
- const [checked, setChecked] = (0, react_1.useState)(checkedProp);
23
- const isChecked = checkedProp ?? checked;
24
- const defaultCheckboxStyle = {
25
- backgroundColor: color("white100"),
26
- borderColor: color("black60"),
27
- };
28
- const checkedCheckboxStyle = {
29
- backgroundColor: color("black100"),
30
- borderColor: color("black100"),
31
- };
32
- const disabledCheckboxStyle = {
33
- backgroundColor: color("black5"),
34
- borderColor: color("black10"),
41
+ const checkboxSize = CHECKBOX_SIZEx1 * fontScale;
42
+ const [checked, setChecked] = (0, react_1.useState)(checkedProp ?? false);
43
+ const [displayState, setDisplayState] = (0, react_1.useState)(testOnly_state ?? "unpressed");
44
+ const containerColor = {
45
+ unchecked: { border: color("black100"), background: color("white100") },
46
+ error: { border: color("red100"), background: color("white100") },
47
+ checked: { border: color("black100"), background: color("black100") },
48
+ disabled: { border: color("black30"), background: color("black30") },
35
49
  };
36
- const checkboxStyles = {
37
- default: {
38
- unchecked: defaultCheckboxStyle,
39
- checked: checkedCheckboxStyle,
40
- },
41
- error: {
42
- unchecked: { backgroundColor: color("white100"), borderColor: color("red100") },
43
- checked: checkedCheckboxStyle,
44
- },
45
- };
46
- const checkboxStyle = disabled
47
- ? disabledCheckboxStyle
48
- : checkboxStyles[error ? "error" : "default"][isChecked ? "checked" : "unchecked"];
49
- const textColor = error ? color("red100") : disabled ? color("black30") : color("black100");
50
- const subtitleColor = error ? color("red100") : color("black30");
51
- return ((0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { onPress: (event) => {
52
- if (disabled) {
50
+ const toggleProgress = (0, react_native_reanimated_1.useDerivedValue)(() => (0, react_native_reanimated_1.withTiming)(checked ? 1 : 0, { duration: ANIMATION_DURATION }));
51
+ const toggleAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
52
+ backgroundColor: (0, react_native_reanimated_1.interpolateColor)(toggleProgress.value, [0, 1], [
53
+ containerColor.unchecked.background,
54
+ disabled ? containerColor.disabled.background : containerColor.checked.background,
55
+ ]),
56
+ borderColor: (0, react_native_reanimated_1.interpolateColor)(toggleProgress.value, [0, 1], [
57
+ error
58
+ ? containerColor.error.border
59
+ : disabled
60
+ ? containerColor.disabled.border
61
+ : containerColor.unchecked.border,
62
+ disabled ? containerColor.disabled.border : containerColor.checked.border,
63
+ ]),
64
+ }), [toggleProgress]);
65
+ const pressedStateProgress = (0, react_native_reanimated_1.useDerivedValue)(() => (0, react_native_reanimated_1.withTiming)(displayState === "pressed" ? 1 : 0, { duration: ANIMATION_DURATION }));
66
+ const textColor = color(error ? "red100" : disabled ? "onBackgroundLow" : "onBackgroundHigh");
67
+ const pressedTextColor = color("brand");
68
+ const pressAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
69
+ color: (0, react_native_reanimated_1.interpolateColor)(pressedStateProgress.value, [0, 1], [textColor, pressedTextColor]),
70
+ }), [pressedStateProgress]);
71
+ const subtitleColor = error
72
+ ? "red100"
73
+ : disabled
74
+ ? "onBackgroundLow"
75
+ : "onBackgroundMedium";
76
+ return ((0, jsx_runtime_1.jsx)(elements_1.Touchable, { noFeedback: true, disabled: disabled, onPressIn: () => setDisplayState("pressed"), onPressOut: () => setDisplayState("unpressed"), onPress: (event) => {
77
+ if (disabled)
53
78
  return;
54
- }
55
79
  setChecked(!checked);
56
80
  onPress?.(event);
57
- }, children: (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { flex: 1, ...restProps, children: [(0, jsx_runtime_1.jsxs)(atoms_1.Flex, { flexDirection: "row", children: [(0, jsx_runtime_1.jsx)(atoms_1.Flex, { mt: "2px", children: (0, jsx_runtime_1.jsx)(animation_1.CssTransition, { style: [
58
- styles(fontScale).container,
59
- text || subtitle || children ? { marginRight: space("1") * fontScale } : {},
60
- checkboxStyle,
61
- ], animate: ["backgroundColor", "borderColor"], duration: DURATION, children: !!isChecked &&
62
- (!!disabled ? ((0, jsx_runtime_1.jsx)(exports.DisabledMark, { size: checkboxSize })) : ((0, jsx_runtime_1.jsx)(exports.CheckMark, { size: checkboxSize }))) }) }), (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { justifyContent: "center", flex: 1, children: [!!text && ((0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "md", color: textColor, children: text })), children] })] }), !!subtitle && ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { ml: (CHECKBOX_SIZE + space("1")) * fontScale, mt: "6px", children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: subtitleColor, children: subtitle }) }))] }) }));
81
+ }, children: (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { flex: 1, children: [(0, jsx_runtime_1.jsxs)(atoms_1.Flex, { flexDirection: "row", children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [
82
+ {
83
+ width: checkboxSize,
84
+ height: checkboxSize,
85
+ alignItems: "center",
86
+ justifyContent: "center",
87
+ borderWidth: 1,
88
+ },
89
+ toggleAnim,
90
+ ], children: checked && (0, jsx_runtime_1.jsx)(Checkmark, { size: checkboxSize }) }), (0, jsx_runtime_1.jsx)(atoms_1.Flex, { ml: "1", flex: 1, children: !!text && ((0, jsx_runtime_1.jsxs)(AText, { variant: "sm-display", color: textColor, numberOfLines: 2, underline: displayState === "pressed", style: pressAnim, children: [text, " ", displayState] })) })] }), !!subtitle && ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { ml: (checkboxSize + space("1")) * fontScale, mt: "0.5", children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: subtitleColor, children: subtitle }) }))] }) }));
63
91
  };
64
92
  exports.Checkbox = Checkbox;
65
- // styled-component does not have support for Animated.View
66
- const styles = (fontScale) => react_native_1.StyleSheet.create({
67
- container: {
68
- display: "flex",
69
- justifyContent: "center",
70
- alignItems: "center",
71
- borderWidth: 1,
72
- borderStyle: "solid",
73
- width: CHECKBOX_SIZE * fontScale,
74
- height: CHECKBOX_SIZE * fontScale,
75
- },
76
- });
77
- // This component represents the √ mark in CSS. We are not using styled-system since it's easier to specify raw CSS
78
- // properties with styled-component.
79
- exports.CheckMark = native_1.default.View.attrs({}) `
80
- transform: rotate(-45deg);
81
- top: -12%;
82
- width: ${(props) =>
83
- // @ts-expect-error
84
- props.size * 0.625};
85
- height: ${(props) =>
86
- // @ts-expect-error
87
- props.size * 0.3125};
88
- border-bottom-color: white;
89
- border-bottom-width: 2px;
90
- border-left-color: white;
91
- border-left-width: 2px;
92
- `;
93
- exports.DisabledMark = (0, native_1.default)(exports.CheckMark) `
94
- border-bottom-color: ${(0, theme_get_1.themeGet)("colors.black30")};
95
- border-left-color: ${(0, theme_get_1.themeGet)("colors.black30")};
96
- `;
93
+ const AText = react_native_reanimated_1.default.createAnimatedComponent(Text_1.Text);
94
+ function Checkmark({ size }) {
95
+ const color = (0, hooks_1.useColor)();
96
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
97
+ width: size * 0.625,
98
+ height: size * 0.3125,
99
+ borderColor: color("white100"),
100
+ borderBottomWidth: 2,
101
+ borderLeftWidth: 2,
102
+ transform: [{ rotate: "-45deg" }],
103
+ top: -2,
104
+ } }));
105
+ }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: ({ checked: checkedProp, disabled, error, onPress, text, subtitle, testOnly_state, }: import("./Checkbox").CheckboxProps) => JSX.Element;
4
+ };
5
+ export default _default;
6
+ export declare function Variants(): JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Variants = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const storybookHelpers_1 = require("../../storybookHelpers");
6
+ const Checkbox_1 = require("./Checkbox");
7
+ exports.default = {
8
+ title: "Checkbox",
9
+ component: Checkbox_1.Checkbox,
10
+ };
11
+ function Variants() {
12
+ return ((0, jsx_runtime_1.jsxs)(storybookHelpers_1.List, { style: { marginLeft: 20 }, children: [(0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Default" }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Pressed", testOnly_state: "pressed" }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Checked", checked: true }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Disabled", disabled: true }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Checked and disabled", checked: true, disabled: true }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Error", error: true }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: `Default with multiline
13
+ text` }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: "Disabled", subtitle: "With subtitle", disabled: true }) }), (0, jsx_runtime_1.jsx)(storybookHelpers_1.Row, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { text: `Error with multiline
14
+ text`, subtitle: "With subtitle", error: true }) })] }));
15
+ }
16
+ exports.Variants = Variants;
@@ -1,2 +1 @@
1
1
  export * from "./Checkbox";
2
- export * from "./Check";
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Checkbox"), exports);
18
- __exportStar(require("./Check"), exports);
@@ -11,20 +11,16 @@ const native_1 = __importDefault(require("styled-components/native"));
11
11
  const styled_system_1 = require("styled-system");
12
12
  const Theme_1 = require("../../Theme");
13
13
  const helpers_1 = require("./helpers");
14
- exports.Text = (0, react_1.forwardRef)(({ variant = "sm", italic = false, color = "onBackgroundHigh", caps, weight = "regular", underline = false, style, children, ...rest }, ref) => {
14
+ exports.Text = (0, react_1.forwardRef)(({ variant = "sm", italic = false, color = "onBackgroundHigh", caps, weight = "regular", underline = false, style, children, ...restProps }, ref) => {
15
15
  const { theme } = (0, Theme_1.useTheme)();
16
16
  const fontFamily = (0, helpers_1.useFontFamilyFor)({ italic, weight });
17
- if (!(0, Theme_1.isThemeV3)(theme)) {
18
- console.warn("Text is missing because null is returned. Wrap your Text with ThemeV3.");
19
- return null;
20
- }
21
17
  const nativeTextStyle = [caps ? { textTransform: "uppercase" } : {}];
22
18
  return ((0, jsx_runtime_1.jsx)(InnerStyledText, { ref: ref, style: [
23
19
  ...nativeTextStyle,
24
20
  { textAlignVertical: "center" },
25
21
  { textDecorationLine: !!underline ? "underline" : "none" },
26
22
  style, // keep last so we can override
27
- ], fontFamily: fontFamily, ...theme.textTreatments[variant], children: children, color: color, ...rest }));
23
+ ], fontFamily: fontFamily, ...theme.textTreatments[variant], children: children, color: color, ...restProps }));
28
24
  });
29
25
  const InnerStyledText = (0, native_1.default)(react_native_1.Text) `
30
26
  ${styled_system_1.color}
@@ -4,9 +4,6 @@ exports.useTextStyleForPalette = exports.useFontFamilyFor = void 0;
4
4
  const Theme_1 = require("../../Theme");
5
5
  const useFontFamilyFor = ({ italic, weight, }) => {
6
6
  const { theme } = (0, Theme_1.useTheme)();
7
- if (!(0, Theme_1.isThemeV3)(theme)) {
8
- return "no-font";
9
- }
10
7
  const { fonts } = theme;
11
8
  if (italic && weight === "medium") {
12
9
  return fonts.sans.mediumItalic;
@@ -6,7 +6,6 @@ export * from "./Button";
6
6
  export * from "./Checkbox";
7
7
  export * from "./Collapse";
8
8
  export * from "./CollapsibleMenuItem";
9
- export * from "./Dialog";
10
9
  export * from "./EntityHeader";
11
10
  export * from "./Header";
12
11
  export * from "./Histogram";
@@ -22,7 +22,6 @@ __exportStar(require("./Button"), exports);
22
22
  __exportStar(require("./Checkbox"), exports);
23
23
  __exportStar(require("./Collapse"), exports);
24
24
  __exportStar(require("./CollapsibleMenuItem"), exports);
25
- __exportStar(require("./Dialog"), exports);
26
25
  __exportStar(require("./EntityHeader"), exports);
27
26
  __exportStar(require("./Header"), exports);
28
27
  __exportStar(require("./Histogram"), exports);
@@ -8,6 +8,6 @@ const hooks_1 = require("../hooks");
8
8
  const svgs_1 = require("../svgs");
9
9
  const MenuItem = ({ title, text, value, onPress, disabled = false, chevron = (0, jsx_runtime_1.jsx)(svgs_1.ChevronIcon, { direction: "right", fill: "black60" }), }) => {
10
10
  const color = (0, hooks_1.useColor)();
11
- return ((0, jsx_runtime_1.jsx)(elements_1.Touchable, { onPress: onPress, underlayColor: color("black5"), disabled: disabled, children: (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", py: "2", px: "2", pr: "15px", children: [(0, jsx_runtime_1.jsx)(atoms_1.Flex, { flexDirection: "row", mr: "2", children: (0, jsx_runtime_1.jsx)(elements_1.Text, { variant: "md", children: title }) }), !!value && ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { flex: 1, children: (0, jsx_runtime_1.jsx)(elements_1.Text, { variant: "md", color: "black60", numberOfLines: 1, textAlign: "right", children: value }) })), !!(onPress && chevron) && (0, jsx_runtime_1.jsx)(atoms_1.Flex, { ml: "1", children: chevron }), !!text && ((0, jsx_runtime_1.jsx)(elements_1.Text, { variant: "md", color: color("black60"), children: text }))] }) }));
11
+ return ((0, jsx_runtime_1.jsx)(elements_1.Touchable, { onPress: onPress, underlayColor: color("black5"), disabled: disabled, children: (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", py: "2", px: "2", pr: "15px", children: [(0, jsx_runtime_1.jsx)(atoms_1.Flex, { flexDirection: "row", mr: "2", children: (0, jsx_runtime_1.jsx)(elements_1.Text, { variant: "md", color: "onBackgroundHigh", children: title }) }), !!value && ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { flex: 1, children: (0, jsx_runtime_1.jsx)(elements_1.Text, { variant: "md", color: "black60", numberOfLines: 1, textAlign: "right", children: value }) })), !!(onPress && chevron) && (0, jsx_runtime_1.jsx)(atoms_1.Flex, { ml: "1", children: chevron }), !!text && ((0, jsx_runtime_1.jsx)(elements_1.Text, { variant: "md", color: color("black60"), children: text }))] }) }));
12
12
  };
13
13
  exports.MenuItem = MenuItem;
@@ -24,5 +24,5 @@ const List = ({ children, contentContainerStyle, style, horizontal, }) => ((0, j
24
24
  contentContainerStyle,
25
25
  ], style: style }));
26
26
  exports.List = List;
27
- const Row = ({ children }) => ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { width: "100%", flexDirection: "row", justifyContent: "space-evenly", children: children }));
27
+ const Row = ({ children }) => ((0, jsx_runtime_1.jsx)(atoms_1.Flex, { width: "100%", flexDirection: "row", justifyContent: "space-evenly", alignItems: "center", children: children }));
28
28
  exports.Row = Row;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "install:all": "yarn install && yarn bundle-install && yarn pod-install",
@@ -13,7 +13,7 @@
13
13
  "bundle-install": "bundle install",
14
14
  "pod-install": "cd ios && bundle exec pod install && cd ..",
15
15
  "test": "jest",
16
- "build-lib": "tsc -p tsconfig.lib.json",
16
+ "build-lib": "tsc",
17
17
  "build-lib:clean": "rimraf dist && yarn build-lib",
18
18
  "release": "auto shipit",
19
19
  "release:canary": "auto canary",
@@ -25,13 +25,13 @@
25
25
  "FOR DEPS NEEDED FOR THE STORYBOOK APP, ADD THEM AS DEV DEPS BELOW."
26
26
  ],
27
27
  "dependencies": {
28
- "@artsy/palette-tokens": "^4.0.0",
28
+ "@artsy/palette-tokens": "^4.0.1",
29
29
  "@styled-system/core": "^5.1.2",
30
30
  "@styled-system/theme-get": "^5.1.2",
31
31
  "events": "^3.3.0",
32
32
  "react-nanny": "^2.15.0",
33
33
  "react-spring": "8.0.22",
34
- "remeda": "^1.1.0",
34
+ "remeda": "^1.2.0",
35
35
  "styled-components": "^5.3.6",
36
36
  "styled-system": "^5.1.5"
37
37
  },
@@ -43,6 +43,7 @@
43
43
  "react-native": "*",
44
44
  "react-native-haptic-feedback": "*",
45
45
  "react-native-linear-gradient": "*",
46
+ "react-native-reanimated": "*",
46
47
  "react-native-svg": "*"
47
48
  },
48
49
  "devDependencies": {
@@ -79,6 +80,7 @@
79
80
  "react-native": "0.69.5",
80
81
  "react-native-haptic-feedback": "^1.14.0",
81
82
  "react-native-linear-gradient": "^2.6.2",
83
+ "react-native-reanimated": "^2.12.0",
82
84
  "react-native-safe-area-context": "^4.4.1",
83
85
  "react-native-svg": "^13.4.0",
84
86
  "react-test-renderer": "^18.2.0",
@@ -1,8 +0,0 @@
1
- export declare const CHECK_SIZE = 22;
2
- export interface CheckProps {
3
- disabled?: boolean;
4
- error?: boolean;
5
- hover?: boolean;
6
- selected?: boolean;
7
- }
8
- export declare const Check: ({ disabled, selected, ...restProps }: CheckProps) => JSX.Element;
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Check = exports.CHECK_SIZE = void 0;
27
- const jsx_runtime_1 = require("react/jsx-runtime");
28
- const theme_get_1 = require("@styled-system/theme-get");
29
- const native_1 = __importStar(require("styled-components/native"));
30
- const atoms_1 = require("../../atoms");
31
- const CheckIcon_1 = require("../../svgs/CheckIcon");
32
- exports.CHECK_SIZE = 22;
33
- const CHECK_MODES = {
34
- default: {
35
- resting: (0, native_1.css) `
36
- background-color: ${(0, theme_get_1.themeGet)("colors.white100")};
37
- border-color: ${(0, theme_get_1.themeGet)("colors.black10")};
38
- `,
39
- selected: (0, native_1.css) `
40
- background-color: ${(0, theme_get_1.themeGet)("colors.black100")};
41
- border-color: ${(0, theme_get_1.themeGet)("colors.black100")};
42
- `,
43
- },
44
- disabled: {
45
- resting: (0, native_1.css) `
46
- background-color: ${(0, theme_get_1.themeGet)("colors.black5")};
47
- border-color: ${(0, theme_get_1.themeGet)("colors.black10")};
48
- `,
49
- selected: (0, native_1.css) `
50
- background-color: ${(0, theme_get_1.themeGet)("colors.black30")};
51
- border-color: ${(0, theme_get_1.themeGet)("colors.black30")};
52
- `,
53
- },
54
- error: {
55
- resting: (0, native_1.css) `
56
- background-color: ${(0, theme_get_1.themeGet)("colors.white100")};
57
- border-color: ${(0, theme_get_1.themeGet)("colors.red100")};
58
- `,
59
- selected: (0, native_1.css) `
60
- background-color: ${(0, theme_get_1.themeGet)("colors.black100")};
61
- border-color: ${(0, theme_get_1.themeGet)("colors.black100")};
62
- `,
63
- },
64
- };
65
- const Check = ({ disabled, selected, ...restProps }) => ((0, jsx_runtime_1.jsx)(Container, { disabled: disabled, selected: selected, ...restProps, children: !!selected && (0, jsx_runtime_1.jsx)(CheckIcon_1.CheckIcon, { fill: "white100" }) }));
66
- exports.Check = Check;
67
- const Container = (0, native_1.default)(atoms_1.Box) `
68
- width: ${exports.CHECK_SIZE}px;
69
- height: ${exports.CHECK_SIZE}px;
70
- display: flex;
71
- align-items: center;
72
- justify-content: center;
73
- border: 2px solid;
74
- border-radius: 1px;
75
-
76
- ${(props) => {
77
- const mode = (() => {
78
- switch (true) {
79
- case props.error:
80
- return CHECK_MODES.error;
81
- case props.disabled:
82
- return CHECK_MODES.disabled;
83
- default:
84
- return CHECK_MODES.default;
85
- }
86
- })();
87
- return props.selected ? mode.selected : mode.resting;
88
- }};
89
- `;
@@ -1,14 +0,0 @@
1
- interface DialogAction {
2
- text: string;
3
- onPress: () => void;
4
- }
5
- export interface DialogProps {
6
- isVisible: boolean;
7
- title: string;
8
- detail?: string;
9
- primaryCta: DialogAction;
10
- secondaryCta?: DialogAction;
11
- onBackgroundPress?: () => void;
12
- }
13
- export declare const Dialog: (props: DialogProps) => JSX.Element;
14
- export {};
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Dialog = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const react_native_1 = require("react-native");
7
- const react_native_safe_area_context_1 = require("react-native-safe-area-context");
8
- const atoms_1 = require("../../atoms");
9
- const Theme_1 = require("../../Theme");
10
- const Button_1 = require("../Button");
11
- const Text_1 = require("../Text");
12
- const Dialog = (props) => {
13
- const { isVisible, title, detail, primaryCta, secondaryCta, onBackgroundPress, ...other } = props;
14
- const [visible, setVisible] = (0, react_1.useState)(isVisible);
15
- const { space, color } = (0, Theme_1.useTheme)();
16
- const value = (0, react_1.useRef)(new react_native_1.Animated.Value(Number(isVisible))).current;
17
- const fadeIn = () => {
18
- return new Promise((resolve) => {
19
- react_native_1.Animated.timing(value, {
20
- toValue: 1,
21
- useNativeDriver: true,
22
- duration: 180,
23
- }).start(resolve);
24
- });
25
- };
26
- const fadeOut = () => {
27
- return new Promise((resolve) => {
28
- react_native_1.Animated.timing(value, {
29
- toValue: 0,
30
- useNativeDriver: true,
31
- duration: 150,
32
- }).start(resolve);
33
- });
34
- };
35
- (0, react_1.useEffect)(() => {
36
- if (isVisible) {
37
- setVisible(true);
38
- fadeIn();
39
- }
40
- else {
41
- fadeOut().then(() => {
42
- setVisible(false);
43
- });
44
- }
45
- }, [isVisible]);
46
- const backdrop = ((0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { style: [
47
- react_native_1.StyleSheet.absoluteFillObject,
48
- { opacity: value, backgroundColor: "rgba(194,194,194,0.5)" },
49
- ] }));
50
- return ((0, jsx_runtime_1.jsxs)(react_native_1.Modal, { ...other, visible: visible, statusBarTranslucent: true, transparent: true, animationType: "none", children: [!!onBackgroundPress ? ((0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { testID: "dialog-backdrop", onPress: onBackgroundPress, children: backdrop })) : (backdrop), (0, jsx_runtime_1.jsx)(react_native_safe_area_context_1.SafeAreaView, { pointerEvents: "box-none", style: {
51
- flex: 1,
52
- justifyContent: "center",
53
- alignItems: "center",
54
- padding: space(2),
55
- backgroundColor: "transparent",
56
- }, children: (0, jsx_runtime_1.jsxs)(react_native_1.Animated.View, { style: {
57
- width: "100%",
58
- maxHeight: "100%",
59
- opacity: value,
60
- backgroundColor: color("white100"),
61
- borderWidth: 1,
62
- borderColor: color("black5"),
63
- shadowColor: "rgba(0, 0, 0, 0.06)",
64
- shadowOffset: {
65
- height: 2,
66
- width: 0,
67
- },
68
- shadowOpacity: 1,
69
- shadowRadius: 10,
70
- }, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { testID: "dialog-title", variant: "md", mb: 0.5, mt: 2, mx: 2, children: title }), !!detail && ((0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { alwaysBounceVertical: false, contentContainerStyle: { paddingHorizontal: space(2) }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { testID: "dialog-detail", variant: "sm", color: "black60", children: detail }) })), (0, jsx_runtime_1.jsxs)(atoms_1.Flex, { mt: 2, mb: 2, mx: 2, flexDirection: "row", justifyContent: "flex-end", children: [!!secondaryCta && ((0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", testID: "dialog-secondary-action-button", variant: "text", onPress: secondaryCta.onPress, children: secondaryCta.text })), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", variant: "fillDark", testID: "dialog-primary-action-button", ml: 2, onPress: primaryCta.onPress, children: primaryCta.text })] })] }) })] }));
71
- };
72
- exports.Dialog = Dialog;
@@ -1 +0,0 @@
1
- export * from "./Dialog";
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Dialog"), exports);