ferns-ui 0.39.5 → 0.39.6
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/Badge.d.ts +1 -1
- package/dist/Badge.js +23 -24
- package/dist/Badge.js.map +1 -1
- package/dist/Banner.d.ts +1 -1
- package/dist/Banner.js +34 -18
- package/dist/Banner.js.map +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +7 -6
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +15 -7
- package/dist/IconButton.js +28 -3
- package/dist/IconButton.js.map +1 -1
- package/dist/Text.js +1 -0
- package/dist/Text.js.map +1 -1
- package/package.json +1 -1
- package/src/Badge.tsx +48 -30
- package/src/Banner.tsx +50 -31
- package/src/Button.tsx +7 -5
- package/src/Common.ts +16 -8
- package/src/IconButton.tsx +49 -10
- package/src/Text.tsx +1 -0
package/dist/Badge.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BadgeProps } from "./Common";
|
|
3
|
-
export declare function Badge({ title, position, type, color, }: BadgeProps): React.ReactElement;
|
|
3
|
+
export declare function Badge({ title, position, type, color, size, iconProps, fontColor, fontWeight, rounding, }: BadgeProps): React.ReactElement;
|
package/dist/Badge.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "./Box";
|
|
3
|
+
import { Icon } from "./Icon";
|
|
4
|
+
import { Text } from "./Text";
|
|
5
|
+
export function Badge({ title, position = "middle", type = "info", color, size = "xs", iconProps, fontColor = "white", fontWeight = "bold", rounding = "pill", }) {
|
|
6
6
|
if (color && type !== "custom") {
|
|
7
7
|
console.warn('Badge color only supported when `type` is set to "custom".');
|
|
8
8
|
}
|
|
9
9
|
const badgeColor = type === "custom" ? color : type;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
React.createElement(Text, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} }, title)));
|
|
10
|
+
function renderIcon() {
|
|
11
|
+
if (iconProps && iconProps.name) {
|
|
12
|
+
return (React.createElement(Box, { marginRight: title ? 1 : 0 },
|
|
13
|
+
React.createElement(Icon, Object.assign({ color: (iconProps === null || iconProps === void 0 ? void 0 : iconProps.color) ? iconProps.color : fontColor }, iconProps, { size: size }))));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function renderLabel() {
|
|
20
|
+
if (!title) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return (React.createElement(Text, { color: fontColor, size: size, weight: fontWeight }, title));
|
|
24
|
+
}
|
|
25
|
+
return (React.createElement(Box, { alignItems: "baseline", alignSelf: position === "middle" ? "center" : position === "bottom" ? "end" : "start", color: badgeColor, direction: "row", height: "min-content", justifyContent: "center", marginLeft: 1, marginTop: position === "top" ? -1 : 0, paddingX: (typeof rounding === "number" && rounding >= 4) || rounding === "pill" ? 2 : 1, paddingY: 1, rounding: rounding, width: "max-content" },
|
|
26
|
+
renderIcon(),
|
|
27
|
+
renderLabel()));
|
|
29
28
|
}
|
|
30
29
|
//# sourceMappingURL=Badge.js.map
|
package/dist/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../src/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../src/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAA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D,KAAK,CACD,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,GAAG,IACF,UAAU,EAAC,UAAU,EACrB,SAAS,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EACrF,KAAK,EAAE,UAAU,EACjB,SAAS,EAAC,KAAK,EACf,MAAM,EAAC,aAAa,EACpB,cAAc,EAAC,QAAQ,EACvB,UAAU,EAAE,CAAC,EACb,SAAS,EAAE,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACtC,QAAQ,EAAE,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,CAAC,CAAC,IAAI,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACxF,QAAQ,EAAE,CAAC,EACX,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAC,aAAa;QAElB,UAAU,EAAE;QACZ,WAAW,EAAE,CACV,CACP,CAAC;AACJ,CAAC"}
|
package/dist/Banner.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BannerProps } from "./Common";
|
|
3
3
|
export declare const hideBanner: (id: string) => Promise<void>;
|
|
4
|
-
export declare const Banner: ({ id, text, subtext, color, iconName, textColor, negativeXMargin, width, shape, type, onClick, }: BannerProps) => React.ReactElement | null;
|
|
4
|
+
export declare const Banner: ({ id, customButtonProps, text, subtext, color, iconName, textColor, negativeXMargin, width, shape, type, onClick, }: BannerProps) => React.ReactElement | null;
|
package/dist/Banner.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { Box } from "./Box";
|
|
3
|
+
import { Button } from "./Button";
|
|
3
4
|
import { Icon } from "./Icon";
|
|
4
5
|
import { IconButton } from "./IconButton";
|
|
5
6
|
import { Text } from "./Text";
|
|
@@ -11,39 +12,54 @@ export const hideBanner = (id) => {
|
|
|
11
12
|
console.debug(`[banner] Hiding ${getKey(id)} `);
|
|
12
13
|
return Unifier.storage.setItem(getKey(id), "true");
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const BannerType = {
|
|
16
|
+
ACTION: "action",
|
|
17
|
+
DISMISS: "dismiss",
|
|
18
|
+
PERMANENT: "permanent", // deprecated in favor of default behavior
|
|
19
|
+
CUSTOM_BUTTON: "customButton",
|
|
20
|
+
};
|
|
21
|
+
export const Banner = ({ id, customButtonProps, text, subtext, color = "secondaryDark", iconName, textColor = "white", negativeXMargin = 0, width, shape, type, onClick, }) => {
|
|
22
|
+
// If the banner is not type dismiss, show it immediately.
|
|
23
|
+
const { ACTION, DISMISS, CUSTOM_BUTTON } = BannerType;
|
|
24
|
+
const [show, setShow] = useState(type !== DISMISS);
|
|
17
25
|
// Load seen from async storage.
|
|
18
26
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
if (type === DISMISS) {
|
|
28
|
+
void Unifier.storage.getItem(getKey(id)).then((isSeen) => {
|
|
29
|
+
console.debug(`[banner] ${getKey(id)} seen? ${isSeen}`);
|
|
30
|
+
setShow(!isSeen);
|
|
31
|
+
});
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
console.debug(`[banner] ${getKey(id)} seen? ${isSeen}`);
|
|
25
|
-
setShow(!isSeen);
|
|
26
|
-
});
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
34
|
}, [id, type]);
|
|
28
35
|
const dismiss = async () => {
|
|
29
|
-
if (type
|
|
36
|
+
if (type !== DISMISS) {
|
|
30
37
|
return;
|
|
31
38
|
}
|
|
32
39
|
await hideBanner(id);
|
|
33
40
|
setShow(false);
|
|
34
41
|
};
|
|
35
42
|
const renderButton = () => {
|
|
36
|
-
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
if (type === CUSTOM_BUTTON) {
|
|
45
|
+
return (React.createElement(Button, Object.assign({}, customButtonProps, { color: (_a = customButtonProps === null || customButtonProps === void 0 ? void 0 : customButtonProps.color) !== null && _a !== void 0 ? _a : "primary", size: (_b = customButtonProps === null || customButtonProps === void 0 ? void 0 : customButtonProps.size) !== null && _b !== void 0 ? _b : "sm", text: (_c = customButtonProps === null || customButtonProps === void 0 ? void 0 : customButtonProps.text) !== null && _c !== void 0 ? _c : "", onClick: onClick })));
|
|
46
|
+
}
|
|
47
|
+
else if (type === ACTION) {
|
|
48
|
+
return (React.createElement(Box, { alignItems: "center", display: "block", justifyContent: "center", width: 40 },
|
|
49
|
+
React.createElement(IconButton, { accessibilityLabel: "", icon: "arrow-right", iconColor: textColor, prefix: "fas", onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick() })));
|
|
50
|
+
}
|
|
51
|
+
else if (type === DISMISS) {
|
|
52
|
+
return (React.createElement(Box, { alignItems: "center", display: "block", justifyContent: "center", width: 40 },
|
|
53
|
+
React.createElement(IconButton, { accessibilityLabel: "", icon: "times-circle", iconColor: textColor, prefix: "fas", onClick: dismiss })));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
37
56
|
return null;
|
|
38
57
|
}
|
|
39
|
-
return (React.createElement(Box, { alignItems: "center", display: "block", justifyContent: "center", width: 40 },
|
|
40
|
-
type === "dismiss" && (React.createElement(IconButton, { accessibilityLabel: "", icon: "times-circle", iconColor: textColor, prefix: "fas", onClick: dismiss })),
|
|
41
|
-
type === "action" && (React.createElement(IconButton, { accessibilityLabel: "", icon: "arrow-right", iconColor: textColor, prefix: "fas", onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick() }))));
|
|
42
58
|
};
|
|
43
59
|
if (!show) {
|
|
44
60
|
return null;
|
|
45
61
|
}
|
|
46
|
-
if (type ===
|
|
62
|
+
if ((type === ACTION && !onClick) || (type === CUSTOM_BUTTON && !onClick)) {
|
|
47
63
|
console.warn("Banners with type action require an onClick property.");
|
|
48
64
|
}
|
|
49
65
|
const negativeMargin = negativeXMargin * -4;
|
|
@@ -52,8 +68,8 @@ export const Banner = ({ id, text, subtext, color = "secondaryDark", iconName, t
|
|
|
52
68
|
marginLeft: negativeMargin,
|
|
53
69
|
marginRight: negativeMargin,
|
|
54
70
|
},
|
|
55
|
-
}, direction: "row", justifyContent: "between", paddingX: 3, paddingY: 2, rounding: shape, shadow: true, width: width || Unifier.utils.dimensions().width || "100%", onClick: type ===
|
|
56
|
-
iconName && (React.createElement(Box, { justifyContent: "center",
|
|
71
|
+
}, direction: "row", justifyContent: "between", paddingX: 3, paddingY: 2, rounding: shape, shadow: true, width: width || Unifier.utils.dimensions().width || "100%", onClick: type === DISMISS ? dismiss : undefined },
|
|
72
|
+
iconName && (React.createElement(Box, { justifyContent: "center", width: 32 },
|
|
57
73
|
React.createElement(Icon, { color: textColor, name: iconName, size: "lg" }))),
|
|
58
74
|
React.createElement(Box, { alignItems: "center", direction: "column", flex: "shrink", justifyContent: "center" },
|
|
59
75
|
React.createElement(Box, { paddingY: 1 },
|
package/dist/Banner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../src/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../src/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,EA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,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAE9C,QAAQ,IAAI,CACX,oBAAC,GAAG,IAAC,cAAc,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE;YACpC,oBAAC,IAAI,IAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,IAAI,GAAG,CAChD,CACP;QACD,oBAAC,GAAG,IAAC,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAC,QAAQ,EAAC,IAAI,EAAC,QAAQ,EAAC,cAAc,EAAC,QAAQ;YAC/E,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;gBACd,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,IACjD,IAAI,CACA,CACH;YACL,OAAO,IAAI,CACV,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;gBACd,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,KAAK,EAAE,SAAS,IAClC,OAAO,CACH,CACH,CACP,CACG;QACL,YAAY,EAAE,CACX,CACP,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/Button.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ButtonProps } from "./Common";
|
|
3
|
-
export declare function Button({ disabled, type, loading: propsLoading, children, text, inline, icon, iconPrefix, size, onClick, color, withConfirmation, confirmationText, confirmationHeading, shape, testID, tooltip, }: ButtonProps): React.JSX.Element;
|
|
3
|
+
export declare function Button({ alignSelf, disabled, type, loading: propsLoading, children, text, inline, icon, iconPrefix, size, onClick, color, withConfirmation, confirmationText, confirmationHeading, shape, testID, tooltip, }: ButtonProps): React.JSX.Element;
|
package/dist/Button.js
CHANGED
|
@@ -23,11 +23,12 @@ const buttonTextColor = {
|
|
|
23
23
|
google: "white",
|
|
24
24
|
};
|
|
25
25
|
const HEIGHTS = {
|
|
26
|
+
xs: 30,
|
|
26
27
|
sm: 36,
|
|
27
28
|
md: 40,
|
|
28
29
|
lg: 48,
|
|
29
30
|
};
|
|
30
|
-
export function Button({ disabled = false, type = "solid", loading: propsLoading, children, text, inline = false, icon, iconPrefix, size = "md", onClick, color = "gray", withConfirmation = false, confirmationText = "Are you sure you want to continue?", confirmationHeading = "Confirm", shape = "rounded", testID, tooltip, }) {
|
|
31
|
+
export function Button({ alignSelf, disabled = false, type = "solid", loading: propsLoading, children, text, inline = false, icon, iconPrefix, size = "md", onClick, color = "gray", withConfirmation = false, confirmationText = "Are you sure you want to continue?", confirmationHeading = "Confirm", shape = "rounded", testID, tooltip, }) {
|
|
31
32
|
const [loading, setLoading] = useState(propsLoading);
|
|
32
33
|
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
33
34
|
const { theme } = useContext(ThemeContext);
|
|
@@ -71,7 +72,7 @@ export function Button({ disabled = false, type = "solid", loading: propsLoading
|
|
|
71
72
|
React.createElement(Text, null, confirmationText)));
|
|
72
73
|
};
|
|
73
74
|
const renderButton = () => {
|
|
74
|
-
return (React.createElement(View,
|
|
75
|
+
return (React.createElement(View, { style: { alignSelf: inline === true ? undefined : alignSelf } },
|
|
75
76
|
React.createElement(Pressable, { disabled: disabled || loading, style: {
|
|
76
77
|
alignSelf: inline === true ? undefined : "stretch",
|
|
77
78
|
height: HEIGHTS[size || "md"],
|
|
@@ -86,7 +87,7 @@ export function Button({ disabled = false, type = "solid", loading: propsLoading
|
|
|
86
87
|
borderWidth: type === "outline" ? 2 : 0,
|
|
87
88
|
opacity: disabled ? 0.4 : 1,
|
|
88
89
|
flexDirection: "row",
|
|
89
|
-
paddingHorizontal: 8 * 2,
|
|
90
|
+
paddingHorizontal: size === "xs" ? 6 : size === "sm" ? 12 : 8 * 2,
|
|
90
91
|
}, testID: testID, onPress: debounce(async () => {
|
|
91
92
|
await Unifier.utils.haptic();
|
|
92
93
|
setLoading(true);
|
|
@@ -104,10 +105,10 @@ export function Button({ disabled = false, type = "solid", loading: propsLoading
|
|
|
104
105
|
}
|
|
105
106
|
setLoading(false);
|
|
106
107
|
}, 500, { leading: true }) },
|
|
107
|
-
icon !== undefined && (React.createElement(Box, {
|
|
108
|
-
React.createElement(Icon, { color: getTextColor(color), name: icon, prefix: iconPrefix || "far", size: size }))),
|
|
108
|
+
icon !== undefined && (React.createElement(Box, { marginRight: 2 },
|
|
109
|
+
React.createElement(Icon, { color: getTextColor(color), name: icon, prefix: iconPrefix || "far", size: size === "xs" ? "sm" : size }))),
|
|
109
110
|
Boolean(children) && children,
|
|
110
|
-
Boolean(text) && (React.createElement(Text, { align: "center", color: getTextColor(color), font: "button", inline: inline, size: size, skipLinking: true, weight: "bold" }, text)),
|
|
111
|
+
Boolean(text) && (React.createElement(Text, { align: "center", color: getTextColor(color), font: "button", inline: inline, size: size === "xs" ? "sm" : size, skipLinking: true, weight: "bold" }, text)),
|
|
111
112
|
Boolean(loading) && (React.createElement(Box, { marginLeft: 2 },
|
|
112
113
|
React.createElement(ActivityIndicator, { color: getTextColor(color), size: "small" })))),
|
|
113
114
|
Boolean(withConfirmation) && renderConfirmation()));
|
package/dist/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,EAAE,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;A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
|
import { SaveFormat } from "expo-image-manipulator";
|
|
2
2
|
import React, { ReactElement, ReactNode, SyntheticEvent } from "react";
|
|
3
3
|
import { ListRenderItemInfo, StyleProp, ViewStyle } from "react-native";
|
|
4
|
-
import { DimensionValue } from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
4
|
+
import { DimensionValue, FlexStyle } from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
5
5
|
import { Styles } from "react-native-google-places-autocomplete";
|
|
6
6
|
import { SelectListOptions } from "./SelectList";
|
|
7
7
|
export interface BaseProfile {
|
|
@@ -114,7 +114,7 @@ export declare const SPACING = 4;
|
|
|
114
114
|
export type TextFieldType = "date" | "datetime" | "decimal" | "decimalRange" | "email" | "height" | "password" | "phoneNumber" | "number" | "numberRange" | "search" | "text" | "time" | "url" | "username";
|
|
115
115
|
export type IconSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
116
116
|
export declare const iconSizeToNumber: (size?: IconSize) => number;
|
|
117
|
-
export type TextSize = "sm" | "md" | "lg";
|
|
117
|
+
export type TextSize = "xs" | "sm" | "md" | "lg";
|
|
118
118
|
export type TextColor = "blue" | "darkGray" | "eggplant" | "gray" | "green" | "lightGray" | "maroon" | "midnight" | "navy" | "olive" | "orange" | "orchid" | "pine" | "purple" | "red" | "watermelon" | "white";
|
|
119
119
|
export type ButtonColor = "blue" | "gray" | "red" | "white" | "primary" | "secondary" | "accent" | "tertiary";
|
|
120
120
|
export type IconPrefix = "far" | "fas";
|
|
@@ -851,13 +851,19 @@ export interface AvatarProps {
|
|
|
851
851
|
shouldShowEditIconIfNoImage?: boolean;
|
|
852
852
|
}
|
|
853
853
|
export interface BadgeProps {
|
|
854
|
-
title: string;
|
|
855
|
-
position?: "top" | "middle";
|
|
856
|
-
type?: "info" | "error" | "warning" | "success" | "neutral" | "custom";
|
|
857
854
|
color?: AllColors;
|
|
855
|
+
fontColor?: AllColors;
|
|
856
|
+
fontWeight?: TextProps["weight"];
|
|
857
|
+
iconProps?: IconProps;
|
|
858
|
+
title?: string;
|
|
859
|
+
position?: "bottom" | "top" | "middle";
|
|
860
|
+
rounding?: Rounding;
|
|
861
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
862
|
+
type?: "info" | "error" | "warning" | "success" | "neutral" | "custom";
|
|
858
863
|
}
|
|
859
864
|
export interface BannerProps {
|
|
860
865
|
id: string;
|
|
866
|
+
customButtonProps?: Partial<ButtonProps>;
|
|
861
867
|
color?: BoxColor;
|
|
862
868
|
dismissible?: boolean;
|
|
863
869
|
iconName?: IconName;
|
|
@@ -867,7 +873,7 @@ export interface BannerProps {
|
|
|
867
873
|
subtext?: string;
|
|
868
874
|
text: string;
|
|
869
875
|
textColor?: TextColor;
|
|
870
|
-
type?: "dismiss" | "action" | "permanent";
|
|
876
|
+
type?: "dismiss" | "action" | "permanent" | "customButton";
|
|
871
877
|
width?: number | string;
|
|
872
878
|
}
|
|
873
879
|
export interface BodyProps {
|
|
@@ -879,12 +885,13 @@ export interface BodyProps {
|
|
|
879
885
|
children?: ReactNode;
|
|
880
886
|
}
|
|
881
887
|
export interface ButtonProps {
|
|
888
|
+
alignSelf?: FlexStyle["alignSelf"];
|
|
882
889
|
children?: React.ReactElement;
|
|
883
890
|
text: string;
|
|
884
891
|
color?: ButtonColor | Color;
|
|
885
892
|
disabled?: boolean;
|
|
886
893
|
inline?: boolean;
|
|
887
|
-
size?: "sm" | "md" | "lg";
|
|
894
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
888
895
|
type?: "solid" | "ghost" | "outline";
|
|
889
896
|
loading?: boolean;
|
|
890
897
|
onClick: any;
|
|
@@ -993,6 +1000,7 @@ export interface IconButtonProps {
|
|
|
993
1000
|
idealDirection?: TooltipDirection;
|
|
994
1001
|
};
|
|
995
1002
|
indicator?: boolean;
|
|
1003
|
+
indicatorNumber?: number;
|
|
996
1004
|
indicatorStyle?: {
|
|
997
1005
|
position: IndicatorDirection;
|
|
998
1006
|
color: AllColors;
|
package/dist/IconButton.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef, useContext, useState } from "react";
|
|
2
2
|
import { Platform, Pressable, View } from "react-native";
|
|
3
|
+
import { Box } from "./Box";
|
|
3
4
|
import { iconSizeToNumber } from "./Common";
|
|
4
5
|
import { Icon } from "./Icon";
|
|
5
6
|
import { Modal } from "./Modal";
|
|
@@ -8,7 +9,7 @@ import { ThemeContext } from "./Theme";
|
|
|
8
9
|
import { Tooltip } from "./Tooltip";
|
|
9
10
|
import { Unifier } from "./Unifier";
|
|
10
11
|
// eslint-disable-next-line react/display-name
|
|
11
|
-
export const IconButton = forwardRef(({ prefix, icon, iconColor, onClick, size, bgColor = "transparent", withConfirmation = false, confirmationText = "Are you sure you want to continue?", confirmationHeading = "Confirm", tooltip, indicator, indicatorStyle = { position: "bottomRight", color: "primary" }, testID, }, ref) => {
|
|
12
|
+
export const IconButton = forwardRef(({ prefix, icon, iconColor, onClick, size, bgColor = "transparent", withConfirmation = false, confirmationText = "Are you sure you want to continue?", confirmationHeading = "Confirm", tooltip, indicator, indicatorNumber, indicatorStyle = { position: "bottomRight", color: "primary" }, testID, }, ref) => {
|
|
12
13
|
const { theme } = useContext(ThemeContext);
|
|
13
14
|
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
14
15
|
const opacity = 1;
|
|
@@ -29,6 +30,31 @@ export const IconButton = forwardRef(({ prefix, icon, iconColor, onClick, size,
|
|
|
29
30
|
topLeft: { top: "20%", left: "20%" },
|
|
30
31
|
};
|
|
31
32
|
const indicatorPosition = Object.assign({ position: "absolute" }, IndicatorPosition[indicatorStyle.position]);
|
|
33
|
+
const IndicatorNumPosition = {
|
|
34
|
+
bottomRight: { bottom: "18%", right: "12%" },
|
|
35
|
+
bottomLeft: { bottom: "10%", left: "10%" },
|
|
36
|
+
topRight: { top: "-5%", right: "-5%" },
|
|
37
|
+
topLeft: { top: "10%", left: "10%" },
|
|
38
|
+
};
|
|
39
|
+
const numberIndicatorProps = Object.assign({ position: "absolute" }, IndicatorNumPosition[indicatorStyle.position]);
|
|
40
|
+
function renderIndicator() {
|
|
41
|
+
if (indicator && indicatorNumber && indicatorNumber > 0) {
|
|
42
|
+
return (React.createElement(View, { style: numberIndicatorProps },
|
|
43
|
+
React.createElement(Box, { alignItems: "center", color: indicatorStyle.color, dangerouslySetInlineStyle: {
|
|
44
|
+
__style: {
|
|
45
|
+
padding: indicatorNumber && indicatorNumber > 9 ? 2 : 0,
|
|
46
|
+
},
|
|
47
|
+
}, justifyContent: "center", minHeight: 15, minWidth: 15, rounding: "pill" },
|
|
48
|
+
React.createElement(Text, { color: "white", size: "sm", weight: "bold" }, indicatorNumber))));
|
|
49
|
+
}
|
|
50
|
+
else if (indicator) {
|
|
51
|
+
return (React.createElement(View, { style: indicatorPosition },
|
|
52
|
+
React.createElement(Icon, { color: indicatorStyle.color, name: "circle", prefix: prefix || "fas", size: "sm" })));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
32
58
|
const renderConfirmation = () => {
|
|
33
59
|
return (React.createElement(Modal, { heading: confirmationHeading, primaryButtonOnClick: () => {
|
|
34
60
|
onClick();
|
|
@@ -63,8 +89,7 @@ export const IconButton = forwardRef(({ prefix, icon, iconColor, onClick, size,
|
|
|
63
89
|
}
|
|
64
90
|
} },
|
|
65
91
|
React.createElement(Icon, { color: iconColor, name: icon, prefix: prefix || "fas", size: size }),
|
|
66
|
-
|
|
67
|
-
React.createElement(Icon, { color: indicatorStyle.color, name: "circle", prefix: prefix || "fas", size: "sm" })))),
|
|
92
|
+
renderIndicator()),
|
|
68
93
|
Boolean(withConfirmation) && renderConfirmation()));
|
|
69
94
|
}
|
|
70
95
|
// Only add for web. This doesn't make much sense for mobile,
|
package/dist/IconButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../src/IconButton.tsx"],"names":[],"mappings":"AA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,OAAO,IACtF,QAAQ,CACE,CACd,CAAC;IACF,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;SAAM,CAAC;QACN,OAAO,CACL,oBAAC,SAAS,IAAC,WAAW,QAAC,SAAS,EAAE,EAAC,kBAAkB,EAAE,WAAW,EAAC,IAChE,KAAK,CACI,CACb,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/Badge.tsx
CHANGED
|
@@ -1,48 +1,66 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {Text, View} from "react-native";
|
|
1
|
+
import React from "react";
|
|
3
2
|
|
|
3
|
+
import {Box} from "./Box";
|
|
4
4
|
import {BadgeProps} from "./Common";
|
|
5
|
-
import {
|
|
5
|
+
import {Icon} from "./Icon";
|
|
6
|
+
import {Text} from "./Text";
|
|
6
7
|
|
|
7
8
|
export function Badge({
|
|
8
9
|
title,
|
|
9
10
|
position = "middle",
|
|
10
11
|
type = "info",
|
|
11
12
|
color,
|
|
13
|
+
size = "xs",
|
|
14
|
+
iconProps,
|
|
15
|
+
fontColor = "white",
|
|
16
|
+
fontWeight = "bold",
|
|
17
|
+
rounding = "pill",
|
|
12
18
|
}: BadgeProps): React.ReactElement {
|
|
13
|
-
const {theme} = useContext(ThemeContext);
|
|
14
|
-
|
|
15
19
|
if (color && type !== "custom") {
|
|
16
20
|
console.warn('Badge color only supported when `type` is set to "custom".');
|
|
17
21
|
}
|
|
18
22
|
const badgeColor = type === "custom" ? color! : type;
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fontSize: 10,
|
|
39
|
-
flexWrap: "nowrap",
|
|
40
|
-
color: "white",
|
|
41
|
-
fontWeight: "bold",
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
24
|
+
function renderIcon(): React.ReactElement | null {
|
|
25
|
+
if (iconProps && iconProps.name) {
|
|
26
|
+
return (
|
|
27
|
+
<Box marginRight={title ? 1 : 0}>
|
|
28
|
+
<Icon color={iconProps?.color ? iconProps.color : fontColor} {...iconProps} size={size} />
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function renderLabel(): React.ReactElement | null {
|
|
37
|
+
if (!title) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return (
|
|
41
|
+
<Text color={fontColor} size={size} weight={fontWeight}>
|
|
44
42
|
{title}
|
|
45
43
|
</Text>
|
|
46
|
-
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Box
|
|
49
|
+
alignItems="baseline"
|
|
50
|
+
alignSelf={position === "middle" ? "center" : position === "bottom" ? "end" : "start"}
|
|
51
|
+
color={badgeColor}
|
|
52
|
+
direction="row"
|
|
53
|
+
height="min-content"
|
|
54
|
+
justifyContent="center"
|
|
55
|
+
marginLeft={1}
|
|
56
|
+
marginTop={position === "top" ? -1 : 0}
|
|
57
|
+
paddingX={(typeof rounding === "number" && rounding >= 4) || rounding === "pill" ? 2 : 1}
|
|
58
|
+
paddingY={1}
|
|
59
|
+
rounding={rounding}
|
|
60
|
+
width="max-content"
|
|
61
|
+
>
|
|
62
|
+
{renderIcon()}
|
|
63
|
+
{renderLabel()}
|
|
64
|
+
</Box>
|
|
47
65
|
);
|
|
48
66
|
}
|
package/src/Banner.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {useEffect, useState} from "react";
|
|
2
2
|
|
|
3
3
|
import {Box} from "./Box";
|
|
4
|
+
import {Button} from "./Button";
|
|
4
5
|
import {BannerProps, ButtonColor} from "./Common";
|
|
5
6
|
import {Icon} from "./Icon";
|
|
6
7
|
import {IconButton} from "./IconButton";
|
|
@@ -16,8 +17,16 @@ export const hideBanner = (id: string): Promise<void> => {
|
|
|
16
17
|
return Unifier.storage.setItem(getKey(id), "true");
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
const BannerType = {
|
|
21
|
+
ACTION: "action",
|
|
22
|
+
DISMISS: "dismiss",
|
|
23
|
+
PERMANENT: "permanent", // deprecated in favor of default behavior
|
|
24
|
+
CUSTOM_BUTTON: "customButton",
|
|
25
|
+
};
|
|
26
|
+
|
|
19
27
|
export const Banner = ({
|
|
20
28
|
id,
|
|
29
|
+
customButtonProps,
|
|
21
30
|
text,
|
|
22
31
|
subtext,
|
|
23
32
|
color = "secondaryDark",
|
|
@@ -26,27 +35,25 @@ export const Banner = ({
|
|
|
26
35
|
negativeXMargin = 0,
|
|
27
36
|
width,
|
|
28
37
|
shape,
|
|
29
|
-
type
|
|
38
|
+
type,
|
|
30
39
|
onClick,
|
|
31
40
|
}: BannerProps): React.ReactElement | null => {
|
|
32
|
-
// If the banner is
|
|
33
|
-
const
|
|
34
|
-
|
|
41
|
+
// If the banner is not type dismiss, show it immediately.
|
|
42
|
+
const {ACTION, DISMISS, CUSTOM_BUTTON} = BannerType;
|
|
43
|
+
const [show, setShow] = useState(type !== DISMISS);
|
|
35
44
|
// Load seen from async storage.
|
|
36
45
|
useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
if (type === DISMISS) {
|
|
47
|
+
void Unifier.storage.getItem(getKey(id)).then((isSeen) => {
|
|
48
|
+
console.debug(`[banner] ${getKey(id)} seen? ${isSeen}`);
|
|
49
|
+
setShow(!isSeen);
|
|
50
|
+
});
|
|
40
51
|
}
|
|
41
|
-
|
|
42
|
-
void Unifier.storage.getItem(getKey(id)).then((isSeen) => {
|
|
43
|
-
console.debug(`[banner] ${getKey(id)} seen? ${isSeen}`);
|
|
44
|
-
setShow(!isSeen);
|
|
45
|
-
});
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
53
|
}, [id, type]);
|
|
47
54
|
|
|
48
55
|
const dismiss = async (): Promise<void> => {
|
|
49
|
-
if (type
|
|
56
|
+
if (type !== DISMISS) {
|
|
50
57
|
return;
|
|
51
58
|
}
|
|
52
59
|
await hideBanner(id);
|
|
@@ -54,38 +61,50 @@ export const Banner = ({
|
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
const renderButton = (): React.ReactElement | null => {
|
|
57
|
-
if (type ===
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
if (type === CUSTOM_BUTTON) {
|
|
65
|
+
return (
|
|
66
|
+
<Button
|
|
67
|
+
{...customButtonProps}
|
|
68
|
+
color={customButtonProps?.color ?? "primary"}
|
|
69
|
+
size={customButtonProps?.size ?? "sm"}
|
|
70
|
+
text={customButtonProps?.text ?? ""}
|
|
71
|
+
onClick={onClick}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
} else if (type === ACTION) {
|
|
75
|
+
return (
|
|
76
|
+
<Box alignItems="center" display="block" justifyContent="center" width={40}>
|
|
63
77
|
<IconButton
|
|
64
78
|
accessibilityLabel=""
|
|
65
|
-
icon="
|
|
79
|
+
icon="arrow-right"
|
|
66
80
|
iconColor={textColor as ButtonColor}
|
|
67
81
|
prefix="fas"
|
|
68
|
-
onClick={
|
|
82
|
+
onClick={(): void => onClick?.()}
|
|
69
83
|
/>
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
</Box>
|
|
85
|
+
);
|
|
86
|
+
} else if (type === DISMISS) {
|
|
87
|
+
return (
|
|
88
|
+
<Box alignItems="center" display="block" justifyContent="center" width={40}>
|
|
72
89
|
<IconButton
|
|
73
90
|
accessibilityLabel=""
|
|
74
|
-
icon="
|
|
91
|
+
icon="times-circle"
|
|
75
92
|
iconColor={textColor as ButtonColor}
|
|
76
93
|
prefix="fas"
|
|
77
|
-
onClick={
|
|
94
|
+
onClick={dismiss}
|
|
78
95
|
/>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
</Box>
|
|
97
|
+
);
|
|
98
|
+
} else {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
82
101
|
};
|
|
83
102
|
|
|
84
103
|
if (!show) {
|
|
85
104
|
return null;
|
|
86
105
|
}
|
|
87
106
|
|
|
88
|
-
if (type ===
|
|
107
|
+
if ((type === ACTION && !onClick) || (type === CUSTOM_BUTTON && !onClick)) {
|
|
89
108
|
console.warn("Banners with type action require an onClick property.");
|
|
90
109
|
}
|
|
91
110
|
|
|
@@ -107,10 +126,10 @@ export const Banner = ({
|
|
|
107
126
|
rounding={shape}
|
|
108
127
|
shadow
|
|
109
128
|
width={width || Unifier.utils.dimensions().width || "100%"}
|
|
110
|
-
onClick={type ===
|
|
129
|
+
onClick={type === DISMISS ? dismiss : undefined}
|
|
111
130
|
>
|
|
112
131
|
{iconName && (
|
|
113
|
-
<Box justifyContent="center"
|
|
132
|
+
<Box justifyContent="center" width={32}>
|
|
114
133
|
<Icon color={textColor} name={iconName} size="lg" />
|
|
115
134
|
</Box>
|
|
116
135
|
)}
|
package/src/Button.tsx
CHANGED
|
@@ -27,12 +27,14 @@ const buttonTextColor: {[buttonColor: string]: "white" | "darkGray"} = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const HEIGHTS = {
|
|
30
|
+
xs: 30,
|
|
30
31
|
sm: 36,
|
|
31
32
|
md: 40,
|
|
32
33
|
lg: 48,
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export function Button({
|
|
37
|
+
alignSelf,
|
|
36
38
|
disabled = false,
|
|
37
39
|
type = "solid",
|
|
38
40
|
loading: propsLoading,
|
|
@@ -109,7 +111,7 @@ export function Button({
|
|
|
109
111
|
|
|
110
112
|
const renderButton = () => {
|
|
111
113
|
return (
|
|
112
|
-
<View>
|
|
114
|
+
<View style={{alignSelf: inline === true ? undefined : alignSelf}}>
|
|
113
115
|
<Pressable
|
|
114
116
|
disabled={disabled || loading}
|
|
115
117
|
style={{
|
|
@@ -126,7 +128,7 @@ export function Button({
|
|
|
126
128
|
borderWidth: type === "outline" ? 2 : 0,
|
|
127
129
|
opacity: disabled ? 0.4 : 1,
|
|
128
130
|
flexDirection: "row",
|
|
129
|
-
paddingHorizontal: 8 * 2,
|
|
131
|
+
paddingHorizontal: size === "xs" ? 6 : size === "sm" ? 12 : 8 * 2,
|
|
130
132
|
}}
|
|
131
133
|
testID={testID}
|
|
132
134
|
onPress={debounce(
|
|
@@ -150,12 +152,12 @@ export function Button({
|
|
|
150
152
|
)}
|
|
151
153
|
>
|
|
152
154
|
{icon !== undefined && (
|
|
153
|
-
<Box
|
|
155
|
+
<Box marginRight={2}>
|
|
154
156
|
<Icon
|
|
155
157
|
color={getTextColor(color as Color)}
|
|
156
158
|
name={icon}
|
|
157
159
|
prefix={iconPrefix || "far"}
|
|
158
|
-
size={size}
|
|
160
|
+
size={size === "xs" ? "sm" : size}
|
|
159
161
|
/>
|
|
160
162
|
</Box>
|
|
161
163
|
)}
|
|
@@ -166,7 +168,7 @@ export function Button({
|
|
|
166
168
|
color={getTextColor(color as Color)}
|
|
167
169
|
font="button"
|
|
168
170
|
inline={inline}
|
|
169
|
-
size={size}
|
|
171
|
+
size={size === "xs" ? "sm" : size}
|
|
170
172
|
skipLinking
|
|
171
173
|
weight="bold"
|
|
172
174
|
>
|
package/src/Common.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {SaveFormat} from "expo-image-manipulator";
|
|
2
2
|
import React, {ReactElement, ReactNode, SyntheticEvent} from "react";
|
|
3
3
|
import {ListRenderItemInfo, StyleProp, ViewStyle} from "react-native";
|
|
4
|
-
import {DimensionValue} from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
4
|
+
import {DimensionValue, FlexStyle} from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
5
5
|
import {Styles} from "react-native-google-places-autocomplete";
|
|
6
6
|
|
|
7
7
|
import {SelectListOptions} from "./SelectList";
|
|
@@ -1706,7 +1706,7 @@ export const iconSizeToNumber = (size?: IconSize) => {
|
|
|
1706
1706
|
}[size || "md"];
|
|
1707
1707
|
};
|
|
1708
1708
|
|
|
1709
|
-
export type TextSize = "sm" | "md" | "lg";
|
|
1709
|
+
export type TextSize = "xs" | "sm" | "md" | "lg";
|
|
1710
1710
|
export type TextColor =
|
|
1711
1711
|
| "blue"
|
|
1712
1712
|
| "darkGray"
|
|
@@ -2585,19 +2585,25 @@ export interface AvatarProps {
|
|
|
2585
2585
|
}
|
|
2586
2586
|
|
|
2587
2587
|
export interface BadgeProps {
|
|
2588
|
+
// If `type` is set to "custom", a custom theme color should be provided.
|
|
2589
|
+
color?: AllColors;
|
|
2590
|
+
fontColor?: AllColors; // default "white"
|
|
2591
|
+
fontWeight?: TextProps["weight"]; // default "bold"
|
|
2592
|
+
iconProps?: IconProps;
|
|
2588
2593
|
// The text to display inside the badge.
|
|
2589
|
-
title
|
|
2594
|
+
title?: string;
|
|
2590
2595
|
// Position relative to the text. Top should only be used with headings.
|
|
2591
|
-
position?: "top" | "middle"; // default "middle"
|
|
2596
|
+
position?: "bottom" | "top" | "middle"; // default "middle"
|
|
2597
|
+
rounding?: Rounding;
|
|
2598
|
+
size?: "xs" | "sm" | "md" | "lg"; // default "xs'
|
|
2592
2599
|
// Some default badge types. Occasionally, a custom badge might be required for different color
|
|
2593
2600
|
// schemes.
|
|
2594
2601
|
type?: "info" | "error" | "warning" | "success" | "neutral" | "custom"; // default "info
|
|
2595
|
-
// If `type` is set to "custom", a custom theme color should be provided.
|
|
2596
|
-
color?: AllColors;
|
|
2597
2602
|
}
|
|
2598
2603
|
|
|
2599
2604
|
export interface BannerProps {
|
|
2600
2605
|
id: string;
|
|
2606
|
+
customButtonProps?: Partial<ButtonProps>;
|
|
2601
2607
|
color?: BoxColor;
|
|
2602
2608
|
dismissible?: boolean;
|
|
2603
2609
|
iconName?: IconName;
|
|
@@ -2607,7 +2613,7 @@ export interface BannerProps {
|
|
|
2607
2613
|
subtext?: string;
|
|
2608
2614
|
text: string;
|
|
2609
2615
|
textColor?: TextColor;
|
|
2610
|
-
type?: "dismiss" | "action" | "permanent";
|
|
2616
|
+
type?: "dismiss" | "action" | "permanent" /* deprectiated */ | "customButton";
|
|
2611
2617
|
width?: number | string;
|
|
2612
2618
|
}
|
|
2613
2619
|
|
|
@@ -2621,6 +2627,7 @@ export interface BodyProps {
|
|
|
2621
2627
|
}
|
|
2622
2628
|
|
|
2623
2629
|
export interface ButtonProps {
|
|
2630
|
+
alignSelf?: FlexStyle["alignSelf"];
|
|
2624
2631
|
children?: React.ReactElement;
|
|
2625
2632
|
text: string;
|
|
2626
2633
|
// TODO make this work for all colors
|
|
@@ -2628,7 +2635,7 @@ export interface ButtonProps {
|
|
|
2628
2635
|
// default gray
|
|
2629
2636
|
disabled?: boolean; // default false
|
|
2630
2637
|
inline?: boolean; // default false
|
|
2631
|
-
size?: "sm" | "md" | "lg"; // default md
|
|
2638
|
+
size?: "xs" | "sm" | "md" | "lg"; // default md
|
|
2632
2639
|
type?: "solid" | "ghost" | "outline"; // default solid
|
|
2633
2640
|
loading?: boolean;
|
|
2634
2641
|
onClick: any;
|
|
@@ -2769,6 +2776,7 @@ export interface IconButtonProps {
|
|
|
2769
2776
|
idealDirection?: TooltipDirection;
|
|
2770
2777
|
};
|
|
2771
2778
|
indicator?: boolean;
|
|
2779
|
+
indicatorNumber?: number;
|
|
2772
2780
|
indicatorStyle?: {position: IndicatorDirection; color: AllColors};
|
|
2773
2781
|
testID?: string;
|
|
2774
2782
|
}
|
package/src/IconButton.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {forwardRef, useContext, useState} from "react";
|
|
2
2
|
import {Platform, Pressable, View, ViewStyle} from "react-native";
|
|
3
3
|
|
|
4
|
+
import {Box} from "./Box";
|
|
4
5
|
import {IconButtonProps, iconSizeToNumber} from "./Common";
|
|
5
6
|
import {Icon} from "./Icon";
|
|
6
7
|
import {Modal} from "./Modal";
|
|
@@ -24,6 +25,7 @@ export const IconButton = forwardRef(
|
|
|
24
25
|
confirmationHeading = "Confirm",
|
|
25
26
|
tooltip,
|
|
26
27
|
indicator,
|
|
28
|
+
indicatorNumber,
|
|
27
29
|
indicatorStyle = {position: "bottomRight", color: "primary"},
|
|
28
30
|
testID,
|
|
29
31
|
}: IconButtonProps,
|
|
@@ -51,6 +53,52 @@ export const IconButton = forwardRef(
|
|
|
51
53
|
|
|
52
54
|
const indicatorPosition = {position: "absolute", ...IndicatorPosition[indicatorStyle.position]};
|
|
53
55
|
|
|
56
|
+
const IndicatorNumPosition = {
|
|
57
|
+
bottomRight: {bottom: "18%", right: "12%"},
|
|
58
|
+
bottomLeft: {bottom: "10%", left: "10%"},
|
|
59
|
+
topRight: {top: "-5%", right: "-5%"},
|
|
60
|
+
topLeft: {top: "10%", left: "10%"},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const numberIndicatorProps = {
|
|
64
|
+
position: "absolute",
|
|
65
|
+
...IndicatorNumPosition[indicatorStyle.position],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function renderIndicator(): React.ReactElement | null {
|
|
69
|
+
if (indicator && indicatorNumber && indicatorNumber > 0) {
|
|
70
|
+
return (
|
|
71
|
+
<View style={numberIndicatorProps as ViewStyle}>
|
|
72
|
+
<Box
|
|
73
|
+
alignItems="center"
|
|
74
|
+
color={indicatorStyle.color}
|
|
75
|
+
dangerouslySetInlineStyle={{
|
|
76
|
+
__style: {
|
|
77
|
+
padding: indicatorNumber && indicatorNumber > 9 ? 2 : 0,
|
|
78
|
+
},
|
|
79
|
+
}}
|
|
80
|
+
justifyContent="center"
|
|
81
|
+
minHeight={15}
|
|
82
|
+
minWidth={15}
|
|
83
|
+
rounding="pill"
|
|
84
|
+
>
|
|
85
|
+
<Text color="white" size="sm" weight="bold">
|
|
86
|
+
{indicatorNumber}
|
|
87
|
+
</Text>
|
|
88
|
+
</Box>
|
|
89
|
+
</View>
|
|
90
|
+
);
|
|
91
|
+
} else if (indicator) {
|
|
92
|
+
return (
|
|
93
|
+
<View style={indicatorPosition as ViewStyle}>
|
|
94
|
+
<Icon color={indicatorStyle.color} name="circle" prefix={prefix || "fas"} size="sm" />
|
|
95
|
+
</View>
|
|
96
|
+
);
|
|
97
|
+
} else {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
54
102
|
const renderConfirmation = () => {
|
|
55
103
|
return (
|
|
56
104
|
<Modal
|
|
@@ -104,16 +152,7 @@ export const IconButton = forwardRef(
|
|
|
104
152
|
}}
|
|
105
153
|
>
|
|
106
154
|
<Icon color={iconColor} name={icon} prefix={prefix || "fas"} size={size} />
|
|
107
|
-
{
|
|
108
|
-
<View style={indicatorPosition as ViewStyle}>
|
|
109
|
-
<Icon
|
|
110
|
-
color={indicatorStyle.color}
|
|
111
|
-
name="circle"
|
|
112
|
-
prefix={prefix || "fas"}
|
|
113
|
-
size="sm"
|
|
114
|
-
/>
|
|
115
|
-
</View>
|
|
116
|
-
)}
|
|
155
|
+
{renderIndicator()}
|
|
117
156
|
</Pressable>
|
|
118
157
|
|
|
119
158
|
{Boolean(withConfirmation) && renderConfirmation()}
|