@artsy/palette-mobile 11.2.16 → 12.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ # v12.0.0 (Mon Aug 07 2023)
2
+
3
+ #### 💥 Breaking Change
4
+
5
+ - chore(palette-tokens): bump palette-tokens to v5 [#136](https://github.com/artsy/palette-mobile/pull/136) ([@araujobarret](https://github.com/araujobarret))
6
+
7
+ #### Authors: 1
8
+
9
+ - Carlos Alberto de Araujo Barreto ([@araujobarret](https://github.com/araujobarret))
10
+
11
+ ---
12
+
13
+ # v11.2.17 (Fri Aug 04 2023)
14
+
15
+ #### 🐛 Bug Fix
16
+
17
+ - feat(Popover): add Popover element [#137](https://github.com/artsy/palette-mobile/pull/137) ([@araujobarret](https://github.com/araujobarret) [@damassi](https://github.com/damassi))
18
+
19
+ #### Authors: 2
20
+
21
+ - Carlos Alberto de Araujo Barreto ([@araujobarret](https://github.com/araujobarret))
22
+ - Christopher Pappas ([@damassi](https://github.com/damassi))
23
+
24
+ ---
25
+
1
26
  # v11.2.16 (Wed Aug 02 2023)
2
27
 
3
28
  #### 🐛 Bug Fix
@@ -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/dist/tokens.js CHANGED
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.THEMES = exports.COLOR_LAYER_ROLE = exports.COLOR_LAYER_NAME = void 0;
9
9
  const palette_tokens_1 = require("@artsy/palette-tokens");
10
10
  const webTokensToMobile_1 = require("./utils/webTokensToMobile");
11
- const { textVariants, space, colors, fonts } = palette_tokens_1.THEME_V3;
11
+ const { textVariants, space, colors } = palette_tokens_1.THEME;
12
12
  exports.COLOR_LAYER_NAME = {
13
13
  ...colors,
14
14
  /** Adding this here for dev usage. Avoid using it for actual components. */
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SpacingUnit as BaseSpacingUnit } from "@artsy/palette-tokens/dist/themes/v3";
1
+ import { SpacingUnit as BaseSpacingUnit } from "@artsy/palette-tokens";
2
2
  import { COLOR_LAYER_ROLE, COLOR_LAYER_NAME } from "./tokens";
3
3
  import { Neg } from "./utils/types";
4
4
  export type SpacingUnitDSValueNumber = BaseSpacingUnit;
@@ -10,8 +10,8 @@ type SpaceFn = (spaceName: SpacingUnit) => number;
10
10
  declare const space: (theme: AllThemesType) => SpaceFn;
11
11
  export interface ColorFn {
12
12
  (colorNumber: undefined): undefined;
13
- (colorNumber: ColorDSValue): string;
14
- (colorNumber: Color | undefined): string | undefined;
13
+ (colorNumber: ColorDSValue | Color): string;
14
+ (colorNumber: ColorDSValue | Color | undefined): string | undefined;
15
15
  }
16
16
  declare const color: (theme: AllThemesType) => ColorFn;
17
17
  export {};
@@ -1,4 +1,4 @@
1
- import { THEME_V3 } from "@artsy/palette-tokens";
1
+ import { THEME } from "@artsy/palette-tokens";
2
2
  import { SpacingUnit } from "@artsy/palette-tokens/dist/themes/v3";
3
3
  import { TextTreatment, TextVariant } from "@artsy/palette-tokens/dist/typography/v3";
4
4
  import { SpacingUnitPixelValue } from "../types";
@@ -12,7 +12,7 @@ export type TextTreatmentWithoutUnits = {
12
12
  * from a string `"120px"` to a number `120`, and the key values from a number
13
13
  * `0.5` to a string `"0.5"`.
14
14
  */
15
- export declare const convertWebSpacingUnitsToMobile: (withUnits: typeof THEME_V3.space) => Record<SpacingUnit, SpacingUnitPixelValue>;
15
+ export declare const convertWebSpacingUnitsToMobile: (withUnits: typeof THEME.space) => Record<SpacingUnit, SpacingUnitPixelValue>;
16
16
  /**
17
17
  * This function is removing the `px` and `em` suffix and making the values
18
18
  * into numbers. letterspacing, fontSize, and lineHeight all take numbers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "11.2.16",
3
+ "version": "12.0.0",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "react-native run-android",
@@ -33,7 +33,7 @@
33
33
  "FOR DEPS NEEDED FOR THE STORYBOOK APP, ADD THEM AS DEV DEPS BELOW."
34
34
  ],
35
35
  "dependencies": {
36
- "@artsy/palette-tokens": "^4.0.1",
36
+ "@artsy/palette-tokens": "^5.0.0",
37
37
  "@styled-system/core": "^5.1.2",
38
38
  "@styled-system/theme-get": "^5.1.2",
39
39
  "events": "^3.3.0",
@@ -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
  },