@artsy/palette-mobile 13.0.27 → 13.0.28

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,15 @@
1
+ # v13.0.28 (Fri Jan 12 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - feat: Update Banner Component [#172](https://github.com/artsy/palette-mobile/pull/172) ([@MrSltun](https://github.com/MrSltun))
6
+
7
+ #### Authors: 1
8
+
9
+ - Sultan Al-Maari ([@MrSltun](https://github.com/MrSltun))
10
+
11
+ ---
12
+
1
13
  # v13.0.27 (Mon Dec 11 2023)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -1,13 +1,33 @@
1
1
  /// <reference types="react" />
2
- import { TextProps } from "react-native";
3
2
  import { FlexProps } from "styled-system";
4
- export interface BannerProps {
5
- title: string;
3
+ export type BannerVariant = keyof typeof BANNER_VARIANTS;
4
+ export interface BannerProps extends FlexProps {
6
5
  text: string;
7
6
  onClose?: () => void;
8
- showCloseButton?: boolean;
9
- containerStyle?: FlexProps;
10
- titleStyle?: TextProps;
11
- bodyTextStyle?: TextProps;
7
+ dismissable?: boolean;
8
+ variant?: BannerVariant;
12
9
  }
13
- export declare const Banner: ({ title, text, onClose, showCloseButton, containerStyle, titleStyle, bodyTextStyle, }: BannerProps) => JSX.Element;
10
+ export declare const Banner: ({ text, onClose, dismissable, variant, ...restProps }: BannerProps) => JSX.Element;
11
+ declare const BANNER_VARIANTS: {
12
+ defaultLight: {
13
+ backgroundColor: string;
14
+ color: string;
15
+ };
16
+ defaultDark: {
17
+ backgroundColor: string;
18
+ color: string;
19
+ };
20
+ success: {
21
+ backgroundColor: string;
22
+ color: string;
23
+ };
24
+ error: {
25
+ backgroundColor: string;
26
+ color: string;
27
+ };
28
+ brand: {
29
+ backgroundColor: string;
30
+ color: string;
31
+ };
32
+ };
33
+ export {};
@@ -4,12 +4,11 @@ exports.Banner = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_native_1 = require("react-native");
7
+ const constants_1 = require("../../constants");
7
8
  const svgs_1 = require("../../svgs");
8
- const hooks_1 = require("../../utils/hooks");
9
9
  const Flex_1 = require("../Flex");
10
10
  const Text_1 = require("../Text");
11
- const Banner = ({ title, text, onClose, showCloseButton = false, containerStyle, titleStyle, bodyTextStyle, }) => {
12
- const color = (0, hooks_1.useColor)();
11
+ const Banner = ({ text, onClose, dismissable = false, variant = "defaultLight", ...restProps }) => {
13
12
  const [tempHeight, setTempHeight] = (0, react_1.useState)(undefined);
14
13
  const scaleYAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
15
14
  const handleClose = () => {
@@ -33,6 +32,28 @@ const Banner = ({ title, text, onClose, showCloseButton = false, containerStyle,
33
32
  }),
34
33
  },
35
34
  ],
36
- }, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: color("blue10"), ...containerStyle, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { px: 2, py: 1, flexDirection: "row", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { fontSize: "13px", color: color("blue100"), ...titleStyle, children: title }), (0, jsx_runtime_1.jsx)(Text_1.Text, { fontSize: "13px", color: color("black100"), ...bodyTextStyle, children: text })] }), !!showCloseButton && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: { marginTop: 2 }, children: (0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { testID: "banner-close-button", onPress: handleClose, hitSlop: { bottom: 40, right: 40, left: 40, top: 40 }, children: (0, jsx_runtime_1.jsx)(svgs_1.QuestionCircleIcon, {}) }) }))] }) }) }));
35
+ }, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: BANNER_VARIANTS[variant].backgroundColor, ...restProps, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { px: 2, py: 1, flexDirection: "row", alignItems: "center", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, alignItems: "center", children: (0, jsx_runtime_1.jsx)(Text_1.Text, { textAlign: "center", variant: "xs", color: BANNER_VARIANTS[variant].color, children: text }) }), !!dismissable && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { children: (0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { testID: "banner-close-button", onPress: handleClose, hitSlop: constants_1.DEFAULT_HIT_SLOP, children: (0, jsx_runtime_1.jsx)(svgs_1.CloseIcon, { fill: BANNER_VARIANTS[variant].color }) }) }))] }) }) }));
37
36
  };
38
37
  exports.Banner = Banner;
38
+ const BANNER_VARIANTS = {
39
+ defaultLight: {
40
+ backgroundColor: "black10",
41
+ color: "black100",
42
+ },
43
+ defaultDark: {
44
+ backgroundColor: "black100",
45
+ color: "white100",
46
+ },
47
+ success: {
48
+ backgroundColor: "green100",
49
+ color: "white100",
50
+ },
51
+ error: {
52
+ backgroundColor: "red100",
53
+ color: "white100",
54
+ },
55
+ brand: {
56
+ backgroundColor: "brand",
57
+ color: "white100",
58
+ },
59
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ component: ({ text, onClose, dismissable, variant, ...restProps }: import("./Banner").BannerProps) => JSX.Element;
5
+ };
6
+ export default _default;
7
+ export declare const States: () => JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.States = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const Banner_1 = require("./Banner");
6
+ const helpers_1 = require("../../storybook/helpers");
7
+ exports.default = {
8
+ title: "Banner",
9
+ component: Banner_1.Banner,
10
+ };
11
+ const States = () => {
12
+ return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { contentContainerStyle: { alignItems: undefined }, children: [(0, jsx_runtime_1.jsx)(Banner_1.Banner, { text: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Reiciendis quae\n natus assumenda distinctio, voluptatum magni. autem sunt." }), (0, jsx_runtime_1.jsx)(Banner_1.Banner, { dismissable: true, text: "Default Light", variant: "defaultLight" }), (0, jsx_runtime_1.jsx)(Banner_1.Banner, { dismissable: true, text: "Default Dark", variant: "defaultDark" }), (0, jsx_runtime_1.jsx)(Banner_1.Banner, { dismissable: true, text: "Success", variant: "success" }), (0, jsx_runtime_1.jsx)(Banner_1.Banner, { dismissable: true, text: "Error", variant: "error" }), (0, jsx_runtime_1.jsx)(Banner_1.Banner, { dismissable: true, text: "Brand", variant: "brand" })] }));
13
+ };
14
+ exports.States = States;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "13.0.27",
3
+ "version": "13.0.28",
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",