@artsy/palette-mobile 14.0.28 → 14.0.30

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.
@@ -1,12 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { Color } from "@artsy/palette-tokens";
3
- import { ViewStyle } from "react-native";
4
2
  import RNPopover from "react-native-popover-view";
5
3
  interface PopoverProps {
6
4
  children?: React.ReactElement;
7
5
  variant?: PopoverVariant;
8
6
  title?: React.ReactElement;
9
7
  content?: React.ReactElement;
8
+ onOpenComplete?: () => void;
10
9
  onPressOutside?: () => void;
11
10
  onDismiss?: () => void;
12
11
  onCloseComplete?: RNPopover["props"]["onCloseComplete"];
@@ -14,11 +13,6 @@ interface PopoverProps {
14
13
  noCloseIcon?: boolean;
15
14
  visible?: boolean;
16
15
  }
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;
16
+ export declare const Popover: ({ variant, children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement, title, content, noCloseIcon, }: PopoverProps) => JSX.Element;
17
+ export type PopoverVariant = "light" | "dark";
24
18
  export {};
@@ -1,42 +1,39 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { THEME } from "@artsy/palette-tokens";
3
2
  import { Platform, StatusBar } from "react-native";
4
3
  import RNPopover from "react-native-popover-view";
5
4
  import { Easing } from "react-native-reanimated";
6
- import styled from "styled-components";
7
5
  import { CloseIcon } from "../../svgs";
6
+ import { useColor } from "../../utils/hooks";
8
7
  import { Flex } from "../Flex";
9
8
  import { Touchable } from "../Touchable";
10
- export const Popover = ({ variant = "dark", children, visible, onPressOutside, onDismiss, onCloseComplete, placement = "top", title, content, noCloseIcon, }) => {
9
+ export const Popover = ({ variant = "dark", children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement = "top", title, content, noCloseIcon, }) => {
10
+ const color = useColor();
11
+ const DROP_SHADOW = {
12
+ shadowColor: color("black100"),
13
+ shadowOffset: {
14
+ width: 0,
15
+ height: 2,
16
+ },
17
+ shadowOpacity: 0.23,
18
+ shadowRadius: 2.62,
19
+ elevation: 4,
20
+ };
21
+ const POPOVER_VARIANTS = {
22
+ light: {
23
+ backgroundColor: color("white100"),
24
+ fill: "black100",
25
+ shadow: DROP_SHADOW,
26
+ },
27
+ dark: {
28
+ backgroundColor: color("black100"),
29
+ fill: "white100",
30
+ },
31
+ };
11
32
  const style = POPOVER_VARIANTS[variant];
12
- return (_jsx(RNPopover, { backgroundStyle: { opacity: 0.5, backgroundColor: THEME.colors.black100 }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible,
33
+ return (_jsx(RNPopover, { backgroundStyle: { opacity: 0.5, backgroundColor: color("black100") }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible,
13
34
  // this is required to make sure that the popover is positioned correctly on android
14
- verticalOffset: Platform.OS === "android" ? -(StatusBar.currentHeight ?? 0) : 0, onCloseComplete: onCloseComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
35
+ verticalOffset: Platform.OS === "android" ? -(StatusBar.currentHeight ?? 0) : 0, onCloseComplete: onCloseComplete, onOpenComplete: onOpenComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
15
36
  duration: 400,
16
37
  easing: Easing.out(Easing.exp),
17
- }, children: _jsxs(Container, { variant: variant, p: 1, children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : _jsx(Flex, {}), !noCloseIcon && (_jsx(Touchable, { onPress: onDismiss, accessibilityRole: "button", "aria-label": "Dismiss popover", children: _jsx(Flex, { ml: 0.5, children: _jsx(CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) }));
18
- };
19
- const Container = styled(Flex) `
20
- background-color: ${({ variant }) => POPOVER_VARIANTS[variant].backgroundColor};
21
- `;
22
- const DROP_SHADOW = {
23
- shadowColor: THEME.colors.black100,
24
- shadowOffset: {
25
- width: 0,
26
- height: 2,
27
- },
28
- shadowOpacity: 0.23,
29
- shadowRadius: 2.62,
30
- elevation: 4,
31
- };
32
- export const POPOVER_VARIANTS = {
33
- light: {
34
- backgroundColor: THEME.colors.white100,
35
- fill: "black100",
36
- shadow: DROP_SHADOW,
37
- },
38
- dark: {
39
- backgroundColor: THEME.colors.black100,
40
- fill: "white100",
41
- },
38
+ }, children: _jsxs(Flex, { backgroundColor: POPOVER_VARIANTS[variant].backgroundColor, p: 1, children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : _jsx(Flex, {}), !noCloseIcon && (_jsx(Touchable, { onPress: onDismiss, accessibilityRole: "button", "aria-label": "Dismiss popover", children: _jsx(Flex, { ml: 0.5, children: _jsx(CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) }));
42
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "14.0.28",
3
+ "version": "14.0.30",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "RCT_METRO_PORT=8082 react-native run-android --port 8082 --terminal terminal",