@artsy/palette-mobile 11.2.15 → 11.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ # v11.2.17 (Fri Aug 04 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - feat(Popover): add Popover element [#137](https://github.com/artsy/palette-mobile/pull/137) ([@araujobarret](https://github.com/araujobarret) [@damassi](https://github.com/damassi))
6
+
7
+ #### Authors: 2
8
+
9
+ - Carlos Alberto de Araujo Barreto ([@araujobarret](https://github.com/araujobarret))
10
+ - Christopher Pappas ([@damassi](https://github.com/damassi))
11
+
12
+ ---
13
+
14
+ # v11.2.16 (Wed Aug 02 2023)
15
+
16
+ #### 🐛 Bug Fix
17
+
18
+ - fix(Pill): animate moti using worklet [#135](https://github.com/artsy/palette-mobile/pull/135) ([@araujobarret](https://github.com/araujobarret))
19
+
20
+ #### Authors: 1
21
+
22
+ - Carlos Alberto de Araujo Barreto ([@araujobarret](https://github.com/araujobarret))
23
+
24
+ ---
25
+
1
26
  # v11.2.15 (Wed Aug 02 2023)
2
27
 
3
28
  #### 🐛 Bug Fix
@@ -30,6 +30,7 @@ exports.Pill = exports.PILL_VARIANT_NAMES = void 0;
30
30
  const jsx_runtime_1 = require("react/jsx-runtime");
31
31
  const theme_get_1 = __importDefault(require("@styled-system/theme-get"));
32
32
  const interactions_1 = require("moti/interactions");
33
+ const react_1 = require("react");
33
34
  const styled_components_1 = __importStar(require("styled-components"));
34
35
  const svgs_1 = require("../../svgs");
35
36
  const Flex_1 = require("../Flex");
@@ -39,7 +40,12 @@ exports.PILL_VARIANT_NAMES = ["default", "search", "filter", "artist", "badge"];
39
40
  const Pill = ({ variant = "default", src, selected, disabled, Icon, children, onPress, ...rest }) => {
40
41
  const stateString = selected ? "selected" : disabled ? "disabled" : "default";
41
42
  const color = TEXT_COLOR[variant][stateString];
42
- return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { ...rest, children: (0, jsx_runtime_1.jsxs)(Container, { variant: variant, selected: selected, disabled: disabled, onPress: onPress, children: [variant === "artist" && ((0, jsx_runtime_1.jsx)(Thumbnail, { src: src, height: 30, width: 30, style: { overflow: "hidden" } })), Icon && (0, jsx_runtime_1.jsx)(Icon, { fill: color, ml: -0.5, mr: 0.5 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: color, children: children }), ((variant === "filter" && !disabled) || (variant === "artist" && selected)) && ((0, jsx_runtime_1.jsx)(svgs_1.CloseIcon, { fill: color, ml: 0.5, width: 15, height: 15 }))] }) }));
43
+ return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { ...rest, children: (0, jsx_runtime_1.jsxs)(Container, { variant: variant, selected: selected, disabled: disabled, onPress: onPress, animate: (0, react_1.useMemo)(() => ({ hovered, pressed }) => {
44
+ "worklet";
45
+ return {
46
+ opacity: hovered || pressed ? 0.5 : 1,
47
+ };
48
+ }, []), children: [variant === "artist" && ((0, jsx_runtime_1.jsx)(Thumbnail, { src: src, height: 30, width: 30, style: { overflow: "hidden" } })), Icon && (0, jsx_runtime_1.jsx)(Icon, { fill: color, ml: -0.5, mr: 0.5 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: color, children: children }), ((variant === "filter" && !disabled) || (variant === "artist" && selected)) && ((0, jsx_runtime_1.jsx)(svgs_1.CloseIcon, { fill: color, ml: 0.5, width: 15, height: 15 }))] }) }));
43
49
  };
44
50
  exports.Pill = Pill;
45
51
  const Container = (0, styled_components_1.default)(interactions_1.MotiPressable) `
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import { Color } from "@artsy/palette-tokens";
3
+ import { ViewStyle } from "react-native";
4
+ import RNPopover from "react-native-popover-view";
5
+ interface PopoverProps {
6
+ children?: React.ReactElement;
7
+ variant?: PopoverVariant;
8
+ title?: React.ReactElement;
9
+ content?: React.ReactElement;
10
+ onPressOutside?: () => void;
11
+ onDismiss?: () => void;
12
+ onCloseComplete?: RNPopover["props"]["onCloseComplete"];
13
+ placement?: "top" | "bottom" | "left" | "right";
14
+ noCloseIcon?: boolean;
15
+ visible?: boolean;
16
+ }
17
+ export declare const Popover: ({ variant, children, visible, onPressOutside, onDismiss, onCloseComplete, placement, title, content, noCloseIcon, }: PopoverProps) => JSX.Element;
18
+ export declare const POPOVER_VARIANTS: Record<"light" | "dark", {
19
+ backgroundColor: string;
20
+ fill: Color;
21
+ shadow?: ViewStyle;
22
+ }>;
23
+ export type PopoverVariant = keyof typeof POPOVER_VARIANTS;
24
+ export {};
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.POPOVER_VARIANTS = exports.Popover = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const palette_tokens_1 = require("@artsy/palette-tokens");
9
+ const react_native_popover_view_1 = __importDefault(require("react-native-popover-view"));
10
+ const react_native_reanimated_1 = require("react-native-reanimated");
11
+ const styled_components_1 = __importDefault(require("styled-components"));
12
+ const svgs_1 = require("../../svgs");
13
+ const Flex_1 = require("../Flex");
14
+ const Touchable_1 = require("../Touchable");
15
+ const Popover = ({ variant = "dark", children, visible, onPressOutside, onDismiss, onCloseComplete, placement = "top", title, content, noCloseIcon, }) => {
16
+ const style = exports.POPOVER_VARIANTS[variant];
17
+ return ((0, jsx_runtime_1.jsx)(react_native_popover_view_1.default, { backgroundStyle: { opacity: 1, backgroundColor: "transparent" }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible, onCloseComplete: onCloseComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
18
+ duration: 400,
19
+ easing: react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.exp),
20
+ }, children: (0, jsx_runtime_1.jsxs)(Container, { variant: variant, p: 1, children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : (0, jsx_runtime_1.jsx)(Flex_1.Flex, {}), !noCloseIcon && ((0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { onPress: onDismiss, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { ml: 0.5, children: (0, jsx_runtime_1.jsx)(svgs_1.CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) }));
21
+ };
22
+ exports.Popover = Popover;
23
+ const Container = (0, styled_components_1.default)(Flex_1.Flex) `
24
+ background-color: ${({ variant }) => exports.POPOVER_VARIANTS[variant].backgroundColor};
25
+ `;
26
+ const DROP_SHADOW = {
27
+ shadowColor: palette_tokens_1.THEME.colors["black100"],
28
+ shadowOffset: {
29
+ width: 0,
30
+ height: 2,
31
+ },
32
+ shadowOpacity: 0.23,
33
+ shadowRadius: 2.62,
34
+ elevation: 4,
35
+ };
36
+ exports.POPOVER_VARIANTS = {
37
+ light: {
38
+ backgroundColor: palette_tokens_1.THEME.colors["white100"],
39
+ fill: "black100",
40
+ shadow: DROP_SHADOW,
41
+ },
42
+ dark: {
43
+ backgroundColor: palette_tokens_1.THEME.colors["black100"],
44
+ fill: "white100",
45
+ },
46
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_native_1 = require("@storybook/react-native");
5
+ const react_1 = require("react");
6
+ const Popover_1 = require("./Popover");
7
+ const Button_1 = require("../Button");
8
+ const Flex_1 = require("../Flex");
9
+ const Text_1 = require("../Text");
10
+ (0, react_native_1.storiesOf)("Popover", module)
11
+ .add("Variants", () => {
12
+ const [visible, setVisible] = (0, react_1.useState)(null);
13
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, alignSelf: "center", mt: 12, alignItems: "center", flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "top-dark", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "white100", variant: "xs", children: "Popover Top Dark" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("top-dark"), children: "Top Dark" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "bottom-dark", placement: "bottom", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "white100", variant: "xs", children: "Popover Bottom Dark" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("bottom-dark"), children: "Bottom Dark" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "top-light", placement: "top", variant: "light", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: "Popover Top Light" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("top-light"), children: "Top Light" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "bottom-light", placement: "bottom", variant: "light", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: "Popover Bottom Light" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("bottom-light"), children: "Bottom Light" }) })] }));
14
+ })
15
+ .add("With title and/or content", () => {
16
+ const [visible, setVisible] = (0, react_1.useState)(null);
17
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, alignSelf: "center", mt: 12, alignItems: "center", flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "title", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { weight: "medium", color: "white100", children: "Popover title" }), content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { color: "white100", children: "Popover descriptive text with some not so long long long body" }), (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "white100", children: "And some line break" })] }), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("title"), children: "Some title and description" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "buttons", placement: "bottom", variant: "light", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { weight: "medium", mb: 1, children: "Popover title" }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { height: 80, backgroundColor: "black30", mb: 1 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { mb: 1, children: "Popover descriptive text" }), (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", justifyContent: "flex-end", children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", variant: "outlineGray", children: "Learn more" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", ml: 1, onPress: () => setVisible(null), children: "Got it" })] })] }), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("buttons"), children: "Buttons and more content" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "no-close", placement: "bottom", noCloseIcon: true, variant: "light", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { weight: "medium", mb: 1, children: "Popover title?" }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { height: 80, backgroundColor: "black30", mb: 1 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { mb: 1, children: "Popover descriptive text" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", onPress: () => setVisible(null), children: "Got it" })] }), onDismiss: () => setVisible(null), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: () => setVisible("no-close"), children: "Content without close icon" }) })] }));
18
+ })
19
+ .add("Edge positions", () => {
20
+ const [topVisible, setTopVisible] = (0, react_1.useState)(true);
21
+ const [bottomVisible, setBottomVisible] = (0, react_1.useState)(false);
22
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, backgroundColor: "black30", justifyContent: "space-between", px: 1, children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "white100", width: 80, px: 1, children: (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: topVisible, placement: "bottom", onDismiss: () => setTopVisible(false), onCloseComplete: () => setBottomVisible(true), title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "white100", variant: "xs", children: "Top-Left" }), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Top-left" }) }) }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "white100", width: 120, mb: 6, alignSelf: "flex-end", px: 1, children: (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: bottomVisible, onDismiss: () => setBottomVisible(false), title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "white100", variant: "xs", children: "Bottom-Right" }), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Bottom-right" }) }) })] }));
23
+ });
@@ -0,0 +1 @@
1
+ export * from "./Popover";
@@ -0,0 +1,17 @@
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("./Popover"), exports);
@@ -26,6 +26,7 @@ export * from "./MeasuredView";
26
26
  export * from "./MenuItem";
27
27
  export * from "./Pill";
28
28
  export * from "./PopIn";
29
+ export * from "./Popover";
29
30
  export * from "./ProgressBar";
30
31
  export * from "./Radio";
31
32
  export * from "./SearchInput";
@@ -42,6 +42,7 @@ __exportStar(require("./MeasuredView"), exports);
42
42
  __exportStar(require("./MenuItem"), exports);
43
43
  __exportStar(require("./Pill"), exports);
44
44
  __exportStar(require("./PopIn"), exports);
45
+ __exportStar(require("./Popover"), exports);
45
46
  __exportStar(require("./ProgressBar"), exports);
46
47
  __exportStar(require("./Radio"), exports);
47
48
  __exportStar(require("./SearchInput"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "11.2.15",
3
+ "version": "11.2.17",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "react-native run-android",
@@ -43,6 +43,7 @@
43
43
  "react-native-collapsible-tab-view": "^6.1.4",
44
44
  "react-native-fast-image": "^8.6.3",
45
45
  "react-native-pager-view": "^6.2.0",
46
+ "react-native-popover-view": "^5.1.7",
46
47
  "react-spring": "8.0.23",
47
48
  "styled-system": "^5.1.5"
48
49
  },