@planningcenter/chat-react-native 1.6.1-qa-27.0 → 1.6.1-rc.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/build/components/display/button.d.ts +2 -2
- package/build/components/display/button.d.ts.map +1 -1
- package/build/components/display/button.js +4 -4
- package/build/components/display/button.js.map +1 -1
- package/build/components/display/button_color_utils.d.ts +28 -13
- package/build/components/display/button_color_utils.d.ts.map +1 -1
- package/build/components/display/button_color_utils.js +25 -8
- package/build/components/display/button_color_utils.js.map +1 -1
- package/build/components/display/icon.d.ts +1 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/icon_button.d.ts +52 -0
- package/build/components/display/icon_button.d.ts.map +1 -0
- package/build/components/display/icon_button.js +102 -0
- package/build/components/display/icon_button.js.map +1 -0
- package/build/components/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/components/display/text_button.d.ts +3 -3
- package/build/components/display/text_button.d.ts.map +1 -1
- package/build/components/display/text_button.js +5 -5
- package/build/components/display/text_button.js.map +1 -1
- package/build/components/display/text_inline_button.d.ts +2 -2
- package/build/components/display/text_inline_button.d.ts.map +1 -1
- package/build/components/display/text_inline_button.js +4 -4
- package/build/components/display/text_inline_button.js.map +1 -1
- package/build/screens/display.d.ts.map +1 -1
- package/build/screens/display.js +27 -1
- package/build/screens/display.js.map +1 -1
- package/package.json +2 -2
- package/src/components/display/button.tsx +6 -6
- package/src/components/display/button_color_utils.ts +42 -14
- package/src/components/display/icon.tsx +1 -1
- package/src/components/display/icon_button.tsx +208 -0
- package/src/components/display/index.ts +1 -0
- package/src/components/display/text_button.tsx +8 -7
- package/src/components/display/text_inline_button.tsx +6 -6
- package/src/screens/display.tsx +139 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PressableProps, ViewStyle } from 'react-native';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ButtonAppearanceUnion } from './button_color_utils';
|
|
4
4
|
declare const SIZES: {
|
|
5
5
|
readonly sm: "sm";
|
|
6
6
|
readonly md: "md";
|
|
@@ -24,7 +24,7 @@ interface ButtonProps extends PressableProps {
|
|
|
24
24
|
/**
|
|
25
25
|
* Updates the button's colors
|
|
26
26
|
*/
|
|
27
|
-
appearance?:
|
|
27
|
+
appearance?: ButtonAppearanceUnion;
|
|
28
28
|
/**
|
|
29
29
|
* Styles the inner View that wraps the button's content
|
|
30
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/display/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAQ7D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/display/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAQ7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAMjE,QAAA,MAAM,KAAK;;;;CAID,CAAA;AAEV,KAAK,SAAS,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAYnD,QAAA,MAAM,QAAQ;;;CAGJ,CAAA;AAEV,KAAK,YAAY,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAA;AAa5D,UAAU,WAAY,SAAQ,cAAc;IAC1C;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAClC;;OAEG;IACH,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B;;OAEG;IACH,iBAAiB,CAAC,EAAE,SAAS,CAAA;IAC7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB;AAED,wBAAgB,MAAM,CAAC,EACrB,oBAA4B,EAC5B,gBAAuB,EACvB,UAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,QAAgB,EAChB,YAAY,EACZ,aAAa,EACb,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,IAAW,EACX,KAAK,EACL,OAAgB,EAChB,GAAG,KAAK,EACT,EAAE,WAAW,qBA4Db"}
|
|
@@ -6,7 +6,7 @@ import { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks
|
|
|
6
6
|
import { tokens } from '../../vendor/tapestry/tokens';
|
|
7
7
|
import { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils';
|
|
8
8
|
import { Spinner } from './spinner';
|
|
9
|
-
import { getColorKey,
|
|
9
|
+
import { getColorKey, useButtonColorOptionMap, useGradientColorMap } from './button_color_utils';
|
|
10
10
|
// =================================
|
|
11
11
|
// ====== Constants ================
|
|
12
12
|
// =================================
|
|
@@ -19,7 +19,7 @@ const VARIANTS = {
|
|
|
19
19
|
fill: 'fill',
|
|
20
20
|
outline: 'outline',
|
|
21
21
|
};
|
|
22
|
-
export function Button({ adjustsFontSizeToFit = false, allowFontScaling = true, appearance = '
|
|
22
|
+
export function Button({ adjustsFontSizeToFit = false, allowFontScaling = true, appearance = 'interaction', buttonInnerStyles, buttonOuterStyles, disabled = false, iconNameLeft, iconNameRight, loading, maxFontSizeMultiplier, minimumFontScale, size = 'md', title, variant = 'fill', ...props }) {
|
|
23
23
|
const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size, variant });
|
|
24
24
|
const gradientOptionsMap = useGradientColorMap();
|
|
25
25
|
const colorKey = getColorKey({ disabled, loading, appearance });
|
|
@@ -42,10 +42,10 @@ export function Button({ adjustsFontSizeToFit = false, allowFontScaling = true,
|
|
|
42
42
|
// =================================
|
|
43
43
|
// ====== Styles ===================
|
|
44
44
|
// =================================
|
|
45
|
-
const useStyles = ({ appearance = '
|
|
45
|
+
const useStyles = ({ appearance = 'interaction', disabled = false, loading = false, maxFontSizeMultiplier, size = 'md', variant = 'fill', }) => {
|
|
46
46
|
const { colors } = useTheme();
|
|
47
47
|
const fontScale = useFontScale({ maxFontSizeMultiplier });
|
|
48
|
-
const colorOptionMap =
|
|
48
|
+
const colorOptionMap = useButtonColorOptionMap();
|
|
49
49
|
const outlineOffsetSm = 2;
|
|
50
50
|
const outlineOffset = 4;
|
|
51
51
|
const sizeStyleMap = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/display/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EA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ACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet, Text, View } from 'react-native'\nimport type { PressableProps, ViewStyle } from 'react-native'\nimport LinearGradient from 'react-native-linear-gradient'\nimport { Icon } from './icon'\nimport { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils'\nimport { Spinner } from './spinner'\nimport { getColorKey, useColorOptionMap, useGradientColorMap } from './button_color_utils'\nimport type { AppearanceUnion } from './button_color_utils'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst SIZES = {\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n} as const\n\ntype SizeUnion = (typeof SIZES)[keyof typeof SIZES]\ntype SizeStyle = Record<\n SizeUnion,\n {\n fontSize: number\n paddingHorizontal: number\n height: number\n borderRadius: number\n gap: number\n }\n>\n\nconst VARIANTS = {\n fill: 'fill',\n outline: 'outline',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\ntype VariantColors = Record<\n VariantUnion,\n {\n backgroundColor: string\n color: string\n }\n>\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface ButtonProps extends PressableProps {\n /**\n * Specifies whether fonts should be scaled down automatically to fit given style constraints.\n */\n adjustsFontSizeToFit?: boolean\n /**\n * Specifies whether fonts should scale to respect the device's text size accessibility settings. The default is true.\n */\n allowFontScaling?: boolean\n /**\n * Updates the button's colors\n */\n appearance?: AppearanceUnion\n /**\n * Styles the inner View that wraps the button's content\n */\n buttonInnerStyles?: ViewStyle\n /**\n * Styles the outer LinearGradient that gives the button it's backgrounnd and outline color\n */\n buttonOuterStyles?: ViewStyle\n /**\n * Generates an icon to the left of the button text\n */\n iconNameLeft?: string\n /**\n * Generates an icon to the right of the button text\n */\n iconNameRight?: string\n /**\n * Disables the button and replaces its content with a spinner\n */\n loading?: boolean\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).\n */\n minimumFontScale?: number\n /**\n * Changes the overall size of the button and its contents\n */\n size?: SizeUnion\n /**\n * Renders as text within the button\n */\n title: string\n /**\n * Fill buttons are visually more propmonitent then outline buttons\n */\n variant?: VariantUnion\n}\n\nexport function Button({\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n appearance = 'primary',\n buttonInnerStyles,\n buttonOuterStyles,\n disabled = false,\n iconNameLeft,\n iconNameRight,\n loading,\n maxFontSizeMultiplier,\n minimumFontScale,\n size = 'md',\n title,\n variant = 'fill',\n ...props\n}: ButtonProps) {\n const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size, variant })\n const gradientOptionsMap = useGradientColorMap()\n const colorKey = getColorKey({ disabled, loading, appearance })\n\n const textStyles = [styles.text, disabled && styles.textDisabled, loading && styles.iconLoading]\n const iconStyles = [styles.icon, disabled && styles.iconDisabled, loading && styles.textLoading]\n\n const androidRippleColor = useCreateAndroidRippleColor({ color: gradientOptionsMap[colorKey][0] })\n\n return (\n <Pressable\n style={({ pressed }) => [styles.pressable, pressed && platformPressedOpacityStyle]}\n accessibilityRole=\"button\"\n disabled={disabled || loading}\n accessibilityState={{ busy: loading }}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n {...props}\n >\n <LinearGradient\n start={{ x: 0.1, y: 0.1 }}\n end={{ x: 0.9, y: 0.9 }}\n colors={gradientOptionsMap[colorKey]}\n style={[styles.colorWrapper, buttonOuterStyles]}\n >\n {loading && (\n <Spinner\n size={styles.spinner.fontSize}\n maxFontSizeMultiplier={maxFontSizeMultiplier || 0}\n />\n )}\n <View style={[styles.innerWrapper, buttonInnerStyles]}>\n {iconNameLeft && (\n <Icon\n name={iconNameLeft}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n <Text\n allowFontScaling={allowFontScaling}\n minimumFontScale={minimumFontScale}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n numberOfLines={1}\n style={textStyles}\n >\n {title}\n </Text>\n {iconNameRight && (\n <Icon\n name={iconNameRight}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n </View>\n </LinearGradient>\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'primary',\n disabled = false,\n loading = false,\n maxFontSizeMultiplier,\n size = 'md',\n variant = 'fill',\n}: Partial<ButtonProps>) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n const colorOptionMap = useColorOptionMap()\n\n const outlineOffsetSm = 2\n const outlineOffset = 4\n\n const sizeStyleMap: SizeStyle = {\n [SIZES.sm]: {\n fontSize: 12,\n paddingHorizontal: 12 * fontScale,\n height: 24 * fontScale - outlineOffsetSm,\n borderRadius: 24 * fontScale,\n gap: 4 * fontScale,\n },\n [SIZES.md]: {\n fontSize: 14,\n paddingHorizontal: 16 * fontScale,\n height: 32 * fontScale - outlineOffset,\n borderRadius: 32 * fontScale,\n gap: 6 * fontScale,\n },\n [SIZES.lg]: {\n fontSize: 16,\n paddingHorizontal: 24 * fontScale,\n height: 40 * fontScale - outlineOffset,\n borderRadius: 40 * fontScale,\n gap: 8 * fontScale,\n },\n }\n\n const variantOutlineColor =\n disabled || loading ? colors.fillColorNeutral090 : colors.fillColorNeutral100Inverted\n\n const variantStyleMap: VariantColors = {\n fill: {\n backgroundColor: 'transparent',\n color: tokens.colorNeutral100White,\n },\n outline: {\n backgroundColor: variantOutlineColor,\n color: colorOptionMap[appearance],\n },\n }\n\n return StyleSheet.create({\n pressable: {\n borderRadius: sizeStyleMap[size].borderRadius,\n overflow: 'hidden',\n },\n colorWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: sizeStyleMap[size].borderRadius,\n },\n innerWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n margin: size === 'sm' ? 1 : 2,\n gap: sizeStyleMap[size].gap,\n borderRadius: sizeStyleMap[size].borderRadius,\n height: sizeStyleMap[size].height,\n backgroundColor: variantStyleMap[variant].backgroundColor,\n paddingHorizontal: sizeStyleMap[size].paddingHorizontal,\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n includeFontPadding: false,\n fontWeight: platformFontWeightBold,\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n textDisabled: {\n color: colors.textColorDefaultDisabled,\n },\n textLoading: {\n opacity: 0,\n },\n icon: {\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n iconDisabled: {\n color: colors.iconColorDefaultDisabled,\n },\n iconLoading: {\n opacity: 0,\n },\n spinner: {\n fontSize: sizeStyleMap[size].fontSize,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/display/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAGhG,oCA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I,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG;YAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,YAAY;YAC7C,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM;YACjC,eAAe,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,eAAe;YACzD,iBAAiB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,iBAAiB;SACxD;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,QAAQ;YACnB,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,KAAK;YACzB,UAAU,EAAE,sBAAsB;YAClC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;YACrC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK;SACtC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;SACX;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;YACrC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK;SACtC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;SACX;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet, Text, View } from 'react-native'\nimport type { PressableProps, ViewStyle } from 'react-native'\nimport LinearGradient from 'react-native-linear-gradient'\nimport { Icon } from './icon'\nimport { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils'\nimport { Spinner } from './spinner'\nimport { getColorKey, useButtonColorOptionMap, useGradientColorMap } from './button_color_utils'\nimport type { ButtonAppearanceUnion } from './button_color_utils'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst SIZES = {\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n} as const\n\ntype SizeUnion = (typeof SIZES)[keyof typeof SIZES]\ntype SizeStyle = Record<\n SizeUnion,\n {\n fontSize: number\n paddingHorizontal: number\n height: number\n borderRadius: number\n gap: number\n }\n>\n\nconst VARIANTS = {\n fill: 'fill',\n outline: 'outline',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\ntype VariantColors = Record<\n VariantUnion,\n {\n backgroundColor: string\n color: string\n }\n>\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface ButtonProps extends PressableProps {\n /**\n * Specifies whether fonts should be scaled down automatically to fit given style constraints.\n */\n adjustsFontSizeToFit?: boolean\n /**\n * Specifies whether fonts should scale to respect the device's text size accessibility settings. The default is true.\n */\n allowFontScaling?: boolean\n /**\n * Updates the button's colors\n */\n appearance?: ButtonAppearanceUnion\n /**\n * Styles the inner View that wraps the button's content\n */\n buttonInnerStyles?: ViewStyle\n /**\n * Styles the outer LinearGradient that gives the button it's backgrounnd and outline color\n */\n buttonOuterStyles?: ViewStyle\n /**\n * Generates an icon to the left of the button text\n */\n iconNameLeft?: string\n /**\n * Generates an icon to the right of the button text\n */\n iconNameRight?: string\n /**\n * Disables the button and replaces its content with a spinner\n */\n loading?: boolean\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).\n */\n minimumFontScale?: number\n /**\n * Changes the overall size of the button and its contents\n */\n size?: SizeUnion\n /**\n * Renders as text within the button\n */\n title: string\n /**\n * Fill buttons are visually more propmonitent then outline buttons\n */\n variant?: VariantUnion\n}\n\nexport function Button({\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n appearance = 'interaction',\n buttonInnerStyles,\n buttonOuterStyles,\n disabled = false,\n iconNameLeft,\n iconNameRight,\n loading,\n maxFontSizeMultiplier,\n minimumFontScale,\n size = 'md',\n title,\n variant = 'fill',\n ...props\n}: ButtonProps) {\n const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size, variant })\n const gradientOptionsMap = useGradientColorMap()\n const colorKey = getColorKey({ disabled, loading, appearance })\n\n const textStyles = [styles.text, disabled && styles.textDisabled, loading && styles.iconLoading]\n const iconStyles = [styles.icon, disabled && styles.iconDisabled, loading && styles.textLoading]\n\n const androidRippleColor = useCreateAndroidRippleColor({ color: gradientOptionsMap[colorKey][0] })\n\n return (\n <Pressable\n style={({ pressed }) => [styles.pressable, pressed && platformPressedOpacityStyle]}\n accessibilityRole=\"button\"\n disabled={disabled || loading}\n accessibilityState={{ busy: loading }}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n {...props}\n >\n <LinearGradient\n start={{ x: 0.1, y: 0.1 }}\n end={{ x: 0.9, y: 0.9 }}\n colors={gradientOptionsMap[colorKey]}\n style={[styles.colorWrapper, buttonOuterStyles]}\n >\n {loading && (\n <Spinner\n size={styles.spinner.fontSize}\n maxFontSizeMultiplier={maxFontSizeMultiplier || 0}\n />\n )}\n <View style={[styles.innerWrapper, buttonInnerStyles]}>\n {iconNameLeft && (\n <Icon\n name={iconNameLeft}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n <Text\n allowFontScaling={allowFontScaling}\n minimumFontScale={minimumFontScale}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n numberOfLines={1}\n style={textStyles}\n >\n {title}\n </Text>\n {iconNameRight && (\n <Icon\n name={iconNameRight}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n </View>\n </LinearGradient>\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'interaction',\n disabled = false,\n loading = false,\n maxFontSizeMultiplier,\n size = 'md',\n variant = 'fill',\n}: Partial<ButtonProps>) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n const colorOptionMap = useButtonColorOptionMap()\n\n const outlineOffsetSm = 2\n const outlineOffset = 4\n\n const sizeStyleMap: SizeStyle = {\n [SIZES.sm]: {\n fontSize: 12,\n paddingHorizontal: 12 * fontScale,\n height: 24 * fontScale - outlineOffsetSm,\n borderRadius: 24 * fontScale,\n gap: 4 * fontScale,\n },\n [SIZES.md]: {\n fontSize: 14,\n paddingHorizontal: 16 * fontScale,\n height: 32 * fontScale - outlineOffset,\n borderRadius: 32 * fontScale,\n gap: 6 * fontScale,\n },\n [SIZES.lg]: {\n fontSize: 16,\n paddingHorizontal: 24 * fontScale,\n height: 40 * fontScale - outlineOffset,\n borderRadius: 40 * fontScale,\n gap: 8 * fontScale,\n },\n }\n\n const variantOutlineColor =\n disabled || loading ? colors.fillColorNeutral090 : colors.fillColorNeutral100Inverted\n\n const variantStyleMap: VariantColors = {\n fill: {\n backgroundColor: 'transparent',\n color: tokens.colorNeutral100White,\n },\n outline: {\n backgroundColor: variantOutlineColor,\n color: colorOptionMap[appearance],\n },\n }\n\n return StyleSheet.create({\n pressable: {\n borderRadius: sizeStyleMap[size].borderRadius,\n overflow: 'hidden',\n },\n colorWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: sizeStyleMap[size].borderRadius,\n },\n innerWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n margin: size === 'sm' ? 1 : 2,\n gap: sizeStyleMap[size].gap,\n borderRadius: sizeStyleMap[size].borderRadius,\n height: sizeStyleMap[size].height,\n backgroundColor: variantStyleMap[variant].backgroundColor,\n paddingHorizontal: sizeStyleMap[size].paddingHorizontal,\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n includeFontPadding: false,\n fontWeight: platformFontWeightBold,\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n textDisabled: {\n color: colors.textColorDefaultDisabled,\n },\n textLoading: {\n opacity: 0,\n },\n icon: {\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n iconDisabled: {\n color: colors.iconColorDefaultDisabled,\n },\n iconLoading: {\n opacity: 0,\n },\n spinner: {\n fontSize: sizeStyleMap[size].fontSize,\n },\n })\n}\n"]}
|
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
export { getColorKey,
|
|
2
|
-
export type {
|
|
3
|
-
declare const
|
|
4
|
-
readonly primary: "primary";
|
|
1
|
+
export { getColorKey, useButtonColorOptionMap, useGradientColorMap, useIconButtonColorOptionMap };
|
|
2
|
+
export type { ButtonAppearanceUnion, IconButtonAppearanceUnion };
|
|
3
|
+
declare const BUTTON_APPEARANCES: {
|
|
5
4
|
readonly danger: "danger";
|
|
5
|
+
readonly interaction: "interaction";
|
|
6
6
|
};
|
|
7
|
-
type
|
|
8
|
-
declare const
|
|
7
|
+
type ButtonAppearanceUnion = (typeof BUTTON_APPEARANCES)[keyof typeof BUTTON_APPEARANCES];
|
|
8
|
+
declare const ICON_BUTTON_APPEARANCES: {
|
|
9
|
+
readonly neutral: "neutral";
|
|
10
|
+
readonly danger: "danger";
|
|
11
|
+
readonly interaction: "interaction";
|
|
12
|
+
};
|
|
13
|
+
type IconButtonAppearanceUnion = (typeof ICON_BUTTON_APPEARANCES)[keyof typeof ICON_BUTTON_APPEARANCES];
|
|
14
|
+
declare const BUTTON_COLOR_OPTIONS: {
|
|
9
15
|
readonly disabled: "disabled";
|
|
10
|
-
readonly primary: "primary";
|
|
11
16
|
readonly danger: "danger";
|
|
17
|
+
readonly interaction: "interaction";
|
|
18
|
+
};
|
|
19
|
+
type ButtonColorOptionUnion = (typeof BUTTON_COLOR_OPTIONS)[keyof typeof BUTTON_COLOR_OPTIONS];
|
|
20
|
+
declare const ICON_BUTTON_COLOR_OPTIONS: {
|
|
21
|
+
readonly neutral: "neutral";
|
|
22
|
+
readonly danger: "danger";
|
|
23
|
+
readonly interaction: "interaction";
|
|
24
|
+
readonly disabled: "disabled";
|
|
12
25
|
};
|
|
13
|
-
type
|
|
14
|
-
type
|
|
15
|
-
declare function
|
|
16
|
-
type
|
|
26
|
+
type IconButtonColorOptionUnion = (typeof ICON_BUTTON_COLOR_OPTIONS)[keyof typeof ICON_BUTTON_COLOR_OPTIONS];
|
|
27
|
+
type ButtonColorOptionMap = Record<ButtonColorOptionUnion, string>;
|
|
28
|
+
declare function useButtonColorOptionMap(): ButtonColorOptionMap;
|
|
29
|
+
type IconButtonColorOptionMap = Record<IconButtonColorOptionUnion, string>;
|
|
30
|
+
declare function useIconButtonColorOptionMap(): IconButtonColorOptionMap;
|
|
31
|
+
type GradientColorMap = Record<ButtonColorOptionUnion, [string, string]>;
|
|
17
32
|
declare function useGradientColorMap(): GradientColorMap;
|
|
18
33
|
interface GetColorKeyArgs {
|
|
19
34
|
disabled: boolean | null;
|
|
20
35
|
loading?: boolean;
|
|
21
|
-
appearance:
|
|
36
|
+
appearance: ButtonAppearanceUnion | IconButtonAppearanceUnion;
|
|
22
37
|
}
|
|
23
|
-
declare function getColorKey({ disabled, loading, appearance }: GetColorKeyArgs):
|
|
38
|
+
declare function getColorKey({ disabled, loading, appearance }: GetColorKeyArgs): "danger" | "interaction" | "neutral" | "disabled";
|
|
24
39
|
//# sourceMappingURL=button_color_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button_color_utils.d.ts","sourceRoot":"","sources":["../../../src/components/display/button_color_utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"button_color_utils.d.ts","sourceRoot":"","sources":["../../../src/components/display/button_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AAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,eAAe,qDAGtE"}
|
|
@@ -2,24 +2,41 @@ import { useTheme } from '../../hooks';
|
|
|
2
2
|
// =================================
|
|
3
3
|
// ====== Exports ==================
|
|
4
4
|
// =================================
|
|
5
|
-
export { getColorKey,
|
|
5
|
+
export { getColorKey, useButtonColorOptionMap, useGradientColorMap, useIconButtonColorOptionMap };
|
|
6
6
|
// =================================
|
|
7
7
|
// ====== Constants ================
|
|
8
8
|
// =================================
|
|
9
|
-
const
|
|
10
|
-
primary: 'primary',
|
|
9
|
+
const BUTTON_APPEARANCES = {
|
|
11
10
|
danger: 'danger',
|
|
11
|
+
interaction: 'interaction',
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
...
|
|
13
|
+
const ICON_BUTTON_APPEARANCES = {
|
|
14
|
+
...BUTTON_APPEARANCES,
|
|
15
|
+
neutral: 'neutral',
|
|
16
|
+
};
|
|
17
|
+
const BUTTON_COLOR_OPTIONS = {
|
|
18
|
+
...BUTTON_APPEARANCES,
|
|
15
19
|
disabled: 'disabled',
|
|
16
20
|
};
|
|
17
|
-
|
|
21
|
+
const ICON_BUTTON_COLOR_OPTIONS = {
|
|
22
|
+
...BUTTON_COLOR_OPTIONS,
|
|
23
|
+
...ICON_BUTTON_APPEARANCES,
|
|
24
|
+
};
|
|
25
|
+
function useButtonColorOptionMap() {
|
|
26
|
+
const { colors } = useTheme();
|
|
27
|
+
return {
|
|
28
|
+
interaction: colors.interaction,
|
|
29
|
+
danger: colors.fillColorStatusErrorMedium,
|
|
30
|
+
disabled: colors.textColorDefaultDisabled,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useIconButtonColorOptionMap() {
|
|
18
34
|
const { colors } = useTheme();
|
|
19
35
|
return {
|
|
20
|
-
primary: colors.interaction,
|
|
21
36
|
danger: colors.fillColorStatusErrorMedium,
|
|
22
37
|
disabled: colors.textColorDefaultDisabled,
|
|
38
|
+
interaction: colors.interaction,
|
|
39
|
+
neutral: colors.iconColorDefaultSecondary,
|
|
23
40
|
};
|
|
24
41
|
}
|
|
25
42
|
function useGradientColorMap() {
|
|
@@ -27,7 +44,7 @@ function useGradientColorMap() {
|
|
|
27
44
|
const defaultColorStart = colors.buttonStart || colors.interaction;
|
|
28
45
|
const defaultColorEnd = colors.buttonEnd || colors.interaction;
|
|
29
46
|
return {
|
|
30
|
-
|
|
47
|
+
interaction: [defaultColorStart, defaultColorEnd],
|
|
31
48
|
danger: [colors.fillColorStatusErrorMedium, colors.fillColorStatusErrorMedium],
|
|
32
49
|
disabled: [
|
|
33
50
|
colors.fillColorButtonNeutralSolidDisabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button_color_utils.js","sourceRoot":"","sources":["../../../src/components/display/button_color_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"button_color_utils.js","sourceRoot":"","sources":["../../../src/components/display/button_color_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,CAAA;AAGjG,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,kBAAkB,GAAG;IACzB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,aAAa;CAClB,CAAA;AAIV,MAAM,uBAAuB,GAAG;IAC9B,GAAG,kBAAkB;IACrB,OAAO,EAAE,SAAS;CACV,CAAA;AAKV,MAAM,oBAAoB,GAAG;IAC3B,GAAG,kBAAkB;IACrB,QAAQ,EAAE,UAAU;CACZ,CAAA;AAIV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================================\n// ====== Exports ==================\n// =================================\n\nexport { getColorKey, useButtonColorOptionMap, useGradientColorMap, useIconButtonColorOptionMap }\nexport type { ButtonAppearanceUnion, IconButtonAppearanceUnion }\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst BUTTON_APPEARANCES = {\n danger: 'danger',\n interaction: 'interaction',\n} as const\n\ntype ButtonAppearanceUnion = (typeof BUTTON_APPEARANCES)[keyof typeof BUTTON_APPEARANCES]\n\nconst ICON_BUTTON_APPEARANCES = {\n ...BUTTON_APPEARANCES,\n neutral: 'neutral',\n} as const\n\ntype IconButtonAppearanceUnion =\n (typeof ICON_BUTTON_APPEARANCES)[keyof typeof ICON_BUTTON_APPEARANCES]\n\nconst BUTTON_COLOR_OPTIONS = {\n ...BUTTON_APPEARANCES,\n disabled: 'disabled',\n} as const\n\ntype ButtonColorOptionUnion = (typeof BUTTON_COLOR_OPTIONS)[keyof typeof BUTTON_COLOR_OPTIONS]\n\nconst ICON_BUTTON_COLOR_OPTIONS = {\n ...BUTTON_COLOR_OPTIONS,\n ...ICON_BUTTON_APPEARANCES,\n} as const\n\ntype IconButtonColorOptionUnion =\n (typeof ICON_BUTTON_COLOR_OPTIONS)[keyof typeof ICON_BUTTON_COLOR_OPTIONS]\n\n// =================================\n// ====== Hooks ====================\n// =================================\n\ntype ButtonColorOptionMap = Record<ButtonColorOptionUnion, string>\nfunction useButtonColorOptionMap(): ButtonColorOptionMap {\n const { colors } = useTheme()\n\n return {\n interaction: colors.interaction,\n danger: colors.fillColorStatusErrorMedium,\n disabled: colors.textColorDefaultDisabled,\n }\n}\n\ntype IconButtonColorOptionMap = Record<IconButtonColorOptionUnion, string>\nfunction useIconButtonColorOptionMap(): IconButtonColorOptionMap {\n const { colors } = useTheme()\n\n return {\n danger: colors.fillColorStatusErrorMedium,\n disabled: colors.textColorDefaultDisabled,\n interaction: colors.interaction,\n neutral: colors.iconColorDefaultSecondary,\n }\n}\n\ntype GradientColorMap = Record<ButtonColorOptionUnion, [string, string]>\nfunction useGradientColorMap(): GradientColorMap {\n const { colors } = useTheme()\n\n const defaultColorStart = colors.buttonStart || colors.interaction\n const defaultColorEnd = colors.buttonEnd || colors.interaction\n\n return {\n interaction: [defaultColorStart, defaultColorEnd],\n danger: [colors.fillColorStatusErrorMedium, colors.fillColorStatusErrorMedium],\n disabled: [\n colors.fillColorButtonNeutralSolidDisabled,\n colors.fillColorButtonNeutralSolidDisabled,\n ],\n }\n}\n\n// =================================\n// ====== Functions ================\n// =================================\n\ninterface GetColorKeyArgs {\n disabled: boolean | null\n loading?: boolean\n appearance: ButtonAppearanceUnion | IconButtonAppearanceUnion\n}\nfunction getColorKey({ disabled, loading, appearance }: GetColorKeyArgs) {\n if (disabled || loading) return 'disabled'\n return appearance\n}\n"]}
|
|
@@ -5,7 +5,7 @@ type IconStyle = ViewStyle & {
|
|
|
5
5
|
fontSize?: number;
|
|
6
6
|
color?: string;
|
|
7
7
|
};
|
|
8
|
-
interface IconProps extends Omit<XmlProps, 'xml' | 'fontSize'> {
|
|
8
|
+
export interface IconProps extends Omit<XmlProps, 'xml' | 'fontSize'> {
|
|
9
9
|
/**
|
|
10
10
|
* Made up of the set.iconName.
|
|
11
11
|
* Example: "general.textMessage"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AA0BhD,KAAK,SAAS,GAAG,SAAS,GAAG;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAMD,
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"m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AAG,aAAa,EAAE,CAAC,CAC5C,IAAI,KAAK,CAAC,EACV,CACH,CAAA;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CAAC,IAAa,EAAE,KAAiB,EAAE,qBAA8B,EAAE,EAAE;IAC1F,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAQ,CAAA;IAChC,MAAM,SAAS,GAAG,YAAY,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAA;IAEzD,IAAI,QAAQ;QAAE,OAAO,QAAQ,GAAG,SAAS,CAAA;IAEzC,OAAO,IAAI,IAAI,aAAa,CAAA;AAC9B,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE;IAC3C,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE3C,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;AACnC,CAAC,CAAA;AAED,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAE,EAAE;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,eAAe,EAAE,MAAM,CAAC,wBAAwB;YAChD,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE,QAAQ,GAAG,CAAC;SAC3B;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport type { StyleProp, ViewStyle } from 'react-native'\nimport { SvgXml } from 'react-native-svg'\nimport type { XmlProps } from 'react-native-svg'\nimport { useFontScale, useTheme } from '../../hooks'\nimport * as general from '@planningcenter/icons/paths/general'\nimport * as groups from '@planningcenter/icons/paths/groups'\nimport * as calendar from '@planningcenter/icons/paths/calendar'\nimport * as people from '@planningcenter/icons/paths/people'\nimport * as churchCenter from '@planningcenter/icons/paths/church-center'\nimport * as logomark from '@planningcenter/icons/paths/logomark'\nimport * as brand from '@planningcenter/icons/paths/brand'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst FALLBACK_SIZE = 12\n\nconst ICONS = {\n calendar,\n people,\n churchCenter,\n groups,\n general,\n logomark,\n brand,\n} as const\n\ntype IconStyle = ViewStyle & {\n fontSize?: number\n color?: string\n}\n\n// =================================\n// ====== Component ================\n// =================================\n\
|
|
1
|
+
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,qCAAqC,CAAA;AAC9D,OAAO,KAAK,MAAM,MAAM,oCAAoC,CAAA;AAC5D,OAAO,KAAK,QAAQ,MAAM,sCAAsC,CAAA;AAChE,OAAO,KAAK,MAAM,MAAM,oCAAoC,CAAA;AAC5D,OAAO,KAAK,YAAY,MAAM,2CAA2C,CAAA;AACzE,OAAO,KAAK,QAAQ,MAAM,sCAAsC,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,mCAAmC,CAAA;AAE1D,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,MAAM;IACN,OAAO;IACP,QAAQ;IACR,KAAK;CACG,CAAA;AAgCV,MAAM,UAAU,IAAI,C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CAAA;AAC9B,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE;IAC3C,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE3C,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;AACnC,CAAC,CAAA;AAED,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAE,EAAE;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,eAAe,EAAE,MAAM,CAAC,wBAAwB;YAChD,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE,QAAQ,GAAG,CAAC;SAC3B;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport type { StyleProp, ViewStyle } from 'react-native'\nimport { SvgXml } from 'react-native-svg'\nimport type { XmlProps } from 'react-native-svg'\nimport { useFontScale, useTheme } from '../../hooks'\nimport * as general from '@planningcenter/icons/paths/general'\nimport * as groups from '@planningcenter/icons/paths/groups'\nimport * as calendar from '@planningcenter/icons/paths/calendar'\nimport * as people from '@planningcenter/icons/paths/people'\nimport * as churchCenter from '@planningcenter/icons/paths/church-center'\nimport * as logomark from '@planningcenter/icons/paths/logomark'\nimport * as brand from '@planningcenter/icons/paths/brand'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst FALLBACK_SIZE = 12\n\nconst ICONS = {\n calendar,\n people,\n churchCenter,\n groups,\n general,\n logomark,\n brand,\n} as const\n\ntype IconStyle = ViewStyle & {\n fontSize?: number\n color?: string\n}\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface IconProps extends Omit<XmlProps, 'xml' | 'fontSize'> {\n /**\n * Made up of the set.iconName.\n * Example: \"general.textMessage\"\n */\n name: string\n /**\n * This sets a static size for the icon.\n * Providing a fontSize style will allow the icon to scale with the device's text a11y size.\n */\n size?: number\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Icon can handle ViewStyle, color, and fontSize.\n */\n style?: StyleProp<IconStyle>\n}\n\nexport function Icon({\n name,\n size,\n style,\n accessibilityElementsHidden,\n accessibilityLabel,\n maxFontSizeMultiplier,\n ...props\n}: IconProps) {\n const flattenStyles = StyleSheet.flatten(style)\n const iconSize = useGetIconSize(size, flattenStyles, maxFontSizeMultiplier)\n const path = getIconPath(name)\n const styles = useStyles({ iconSize })\n\n if (!path) {\n console.warn(`No icon available named ${name}. Remember to use the format \"set.iconName\"`)\n return <View style={styles.noIcon} />\n }\n\n return (\n <SvgXml\n accessibilityElementsHidden={accessibilityElementsHidden}\n accessibilityLabel={accessibilityLabel}\n xml={`\n <svg viewBox=\"0 0 16 16\">\n <path d=\"${path}\" fill=\"currentColor\" />\n </svg>\n `}\n height={iconSize}\n width={iconSize}\n style={{ ...styles.icon, ...flattenStyles }}\n {...props}\n />\n )\n}\n\nconst useGetIconSize = (size?: number, style?: IconStyle, maxFontSizeMultiplier?: number) => {\n const fontSize = style?.fontSize\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n if (fontSize) return fontSize * fontScale\n\n return size || FALLBACK_SIZE\n}\n\nconst getIconPath = (name: string): string => {\n const [setName, iconName] = name.split('.')\n\n return ICONS[setName]?.[iconName]\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({ iconSize }: { iconSize: number }) => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n noIcon: {\n backgroundColor: colors.iconColorDefaultDisabled,\n width: iconSize,\n height: iconSize,\n borderRadius: iconSize / 2,\n },\n icon: {\n color: colors.iconColorDefaultPrimary,\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PressableProps, ViewStyle } from 'react-native';
|
|
3
|
+
import type { IconProps } from './icon';
|
|
4
|
+
import type { IconButtonAppearanceUnion } from './button_color_utils';
|
|
5
|
+
declare const SIZES: {
|
|
6
|
+
readonly md: "md";
|
|
7
|
+
readonly lg: "lg";
|
|
8
|
+
readonly xl: "xl";
|
|
9
|
+
readonly xxl: "xxl";
|
|
10
|
+
readonly xxxl: "xxxl";
|
|
11
|
+
};
|
|
12
|
+
type SizeUnion = (typeof SIZES)[keyof typeof SIZES];
|
|
13
|
+
interface IconButtonProps extends PressableProps {
|
|
14
|
+
/**
|
|
15
|
+
* Provides context to screen readers about what the button does.
|
|
16
|
+
* This is required as Icons don't inherently provide non-visual context like text does.
|
|
17
|
+
*/
|
|
18
|
+
accessibilityLabel: string;
|
|
19
|
+
/**
|
|
20
|
+
* Updates the icon's colors. Defaults to 'neutral'.
|
|
21
|
+
*/
|
|
22
|
+
appearance?: IconButtonAppearanceUnion;
|
|
23
|
+
/**
|
|
24
|
+
* Styles the icon itself.
|
|
25
|
+
* `fontSize` allows for a custom size that also responds to the device's text scale.
|
|
26
|
+
* `color` changes the color of the icon.
|
|
27
|
+
*/
|
|
28
|
+
iconStyle?: IconProps['style'];
|
|
29
|
+
/**
|
|
30
|
+
* Disables the button and replaces its content with a spinner
|
|
31
|
+
*/
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Specifies the maximum size a font can reach when allowFontScaling is enabled.
|
|
35
|
+
*/
|
|
36
|
+
maxFontSizeMultiplier?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Generates an icon from `@planningcenter/icons`
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
/**
|
|
42
|
+
* Changes the overall size of the button and its contents
|
|
43
|
+
*/
|
|
44
|
+
size?: SizeUnion;
|
|
45
|
+
/**
|
|
46
|
+
* Styles the `Pressable` wrapper
|
|
47
|
+
*/
|
|
48
|
+
style?: ViewStyle;
|
|
49
|
+
}
|
|
50
|
+
export declare function IconButton({ accessibilityLabel, appearance, disabled, iconStyle, loading, maxFontSizeMultiplier, name, size, style, ...props }: IconButtonProps): React.JSX.Element;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=icon_button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon_button.d.ts","sourceRoot":"","sources":["../../../src/components/display/icon_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAKvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAMrE,QAAA,MAAM,KAAK;;;;;;CAMD,CAAA;AAEV,KAAK,SAAS,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAmBnD,UAAU,eAAgB,SAAQ,cAAc;IAC9C;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,yBAAyB,CAAA;IACtC;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,wBAAgB,UAAU,CAAC,EACzB,kBAAkB,EAClB,UAAsB,EACtB,QAAgB,EAChB,SAAS,EACT,OAAO,EACP,qBAAqB,EACrB,IAAI,EACJ,IAAW,EACX,KAAK,EACL,GAAG,KAAK,EACT,EAAE,eAAe,qBAuDjB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native';
|
|
3
|
+
import { Icon } from './icon';
|
|
4
|
+
import { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks';
|
|
5
|
+
import { platformPressedOpacityStyle } from '../../utils';
|
|
6
|
+
import { Spinner } from './spinner';
|
|
7
|
+
import { getColorKey, useIconButtonColorOptionMap } from './button_color_utils';
|
|
8
|
+
// =================================
|
|
9
|
+
// ====== Constants ================
|
|
10
|
+
// =================================
|
|
11
|
+
const SIZES = {
|
|
12
|
+
md: 'md',
|
|
13
|
+
lg: 'lg',
|
|
14
|
+
xl: 'xl',
|
|
15
|
+
xxl: 'xxl',
|
|
16
|
+
xxxl: 'xxxl',
|
|
17
|
+
};
|
|
18
|
+
export function IconButton({ accessibilityLabel, appearance = 'neutral', disabled = false, iconStyle, loading, maxFontSizeMultiplier, name, size = 'md', style, ...props }) {
|
|
19
|
+
const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size });
|
|
20
|
+
const colorOptionMap = useIconButtonColorOptionMap();
|
|
21
|
+
const colorKey = getColorKey({ disabled, loading, appearance });
|
|
22
|
+
const { color = colorOptionMap[colorKey] } = StyleSheet.flatten(iconStyle || {});
|
|
23
|
+
const androidRippleColor = useCreateAndroidRippleColor({ color: color });
|
|
24
|
+
const androidRadiusSizeMap = {
|
|
25
|
+
[SIZES.md]: {
|
|
26
|
+
radius: 16,
|
|
27
|
+
},
|
|
28
|
+
[SIZES.lg]: {
|
|
29
|
+
radius: 18,
|
|
30
|
+
},
|
|
31
|
+
[SIZES.xl]: {
|
|
32
|
+
radius: 20,
|
|
33
|
+
},
|
|
34
|
+
[SIZES.xxl]: {
|
|
35
|
+
radius: 26,
|
|
36
|
+
},
|
|
37
|
+
[SIZES.xxxl]: {
|
|
38
|
+
radius: 32,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
return (<Pressable style={({ pressed }) => [styles.pressable, style, pressed && platformPressedOpacityStyle]} accessibilityRole="button" disabled={disabled || loading} accessibilityState={{ busy: loading }} accessibilityLabel={accessibilityLabel} hitSlop={10} android_ripple={{
|
|
42
|
+
color: androidRippleColor,
|
|
43
|
+
borderless: true,
|
|
44
|
+
foreground: true,
|
|
45
|
+
radius: androidRadiusSizeMap[size].radius,
|
|
46
|
+
}} {...props}>
|
|
47
|
+
{loading && (<Spinner size={styles.spinner.fontSize} maxFontSizeMultiplier={maxFontSizeMultiplier || 0}/>)}
|
|
48
|
+
<Icon name={name} style={[styles.icon, iconStyle, disabled && styles.disabled, loading && styles.loading]} maxFontSizeMultiplier={maxFontSizeMultiplier}/>
|
|
49
|
+
</Pressable>);
|
|
50
|
+
}
|
|
51
|
+
// =================================
|
|
52
|
+
// ====== Styles ===================
|
|
53
|
+
// =================================
|
|
54
|
+
const useStyles = ({ appearance = 'neutral', disabled = false, loading = false, maxFontSizeMultiplier, size = 'md', }) => {
|
|
55
|
+
const { colors } = useTheme();
|
|
56
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier });
|
|
57
|
+
const colorOptionMap = useIconButtonColorOptionMap();
|
|
58
|
+
const colorKey = getColorKey({ disabled, loading, appearance });
|
|
59
|
+
const sizeStyleMap = {
|
|
60
|
+
[SIZES.md]: {
|
|
61
|
+
fontSize: 16,
|
|
62
|
+
height: 16 * fontScale,
|
|
63
|
+
},
|
|
64
|
+
[SIZES.lg]: {
|
|
65
|
+
fontSize: 20,
|
|
66
|
+
height: 20 * fontScale,
|
|
67
|
+
},
|
|
68
|
+
[SIZES.xl]: {
|
|
69
|
+
fontSize: 24,
|
|
70
|
+
height: 24 * fontScale,
|
|
71
|
+
},
|
|
72
|
+
[SIZES.xxl]: {
|
|
73
|
+
fontSize: 32,
|
|
74
|
+
height: 32 * fontScale,
|
|
75
|
+
},
|
|
76
|
+
[SIZES.xxxl]: {
|
|
77
|
+
fontSize: 40,
|
|
78
|
+
height: 40 * fontScale,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
return StyleSheet.create({
|
|
82
|
+
pressable: {
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
justifyContent: 'center',
|
|
85
|
+
height: sizeStyleMap[size].height,
|
|
86
|
+
},
|
|
87
|
+
icon: {
|
|
88
|
+
fontSize: sizeStyleMap[size].fontSize,
|
|
89
|
+
color: colorOptionMap[colorKey],
|
|
90
|
+
},
|
|
91
|
+
disabled: {
|
|
92
|
+
color: colors.iconColorDefaultDisabled,
|
|
93
|
+
},
|
|
94
|
+
loading: {
|
|
95
|
+
opacity: 0,
|
|
96
|
+
},
|
|
97
|
+
spinner: {
|
|
98
|
+
fontSize: sizeStyleMap[size].fontSize,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=icon_button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon_button.js","sourceRoot":"","sources":["../../../src/components/display/icon_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAG/E,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,KAAK,GAAG;IACZ,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AI,CAAC,CAAC,QAAQ;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet } from 'react-native'\nimport type { PressableProps, ViewStyle } from 'react-native'\nimport { Icon } from './icon'\nimport type { IconProps } from './icon'\nimport { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'\nimport { platformPressedOpacityStyle } from '../../utils'\nimport { Spinner } from './spinner'\nimport { getColorKey, useIconButtonColorOptionMap } from './button_color_utils'\nimport type { IconButtonAppearanceUnion } from './button_color_utils'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst SIZES = {\n md: 'md',\n lg: 'lg',\n xl: 'xl',\n xxl: 'xxl',\n xxxl: 'xxxl',\n} as const\n\ntype SizeUnion = (typeof SIZES)[keyof typeof SIZES]\ntype SizeStyle = Record<\n SizeUnion,\n {\n fontSize: number\n height: number\n }\n>\ntype AndroidRadiusSize = Record<\n SizeUnion,\n {\n radius: number\n }\n>\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface IconButtonProps extends PressableProps {\n /**\n * Provides context to screen readers about what the button does.\n * This is required as Icons don't inherently provide non-visual context like text does.\n */\n accessibilityLabel: string\n /**\n * Updates the icon's colors. Defaults to 'neutral'.\n */\n appearance?: IconButtonAppearanceUnion\n /**\n * Styles the icon itself.\n * `fontSize` allows for a custom size that also responds to the device's text scale.\n * `color` changes the color of the icon.\n */\n iconStyle?: IconProps['style']\n /**\n * Disables the button and replaces its content with a spinner\n */\n loading?: boolean\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Generates an icon from `@planningcenter/icons`\n */\n name: string\n /**\n * Changes the overall size of the button and its contents\n */\n size?: SizeUnion\n /**\n * Styles the `Pressable` wrapper\n */\n style?: ViewStyle\n}\n\nexport function IconButton({\n accessibilityLabel,\n appearance = 'neutral',\n disabled = false,\n iconStyle,\n loading,\n maxFontSizeMultiplier,\n name,\n size = 'md',\n style,\n ...props\n}: IconButtonProps) {\n const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size })\n const colorOptionMap = useIconButtonColorOptionMap()\n const colorKey = getColorKey({ disabled, loading, appearance })\n\n const { color = colorOptionMap[colorKey] } = StyleSheet.flatten(iconStyle || {})\n const androidRippleColor = useCreateAndroidRippleColor({ color: color })\n\n const androidRadiusSizeMap: AndroidRadiusSize = {\n [SIZES.md]: {\n radius: 16,\n },\n [SIZES.lg]: {\n radius: 18,\n },\n [SIZES.xl]: {\n radius: 20,\n },\n [SIZES.xxl]: {\n radius: 26,\n },\n [SIZES.xxxl]: {\n radius: 32,\n },\n }\n\n return (\n <Pressable\n style={({ pressed }) => [styles.pressable, style, pressed && platformPressedOpacityStyle]}\n accessibilityRole=\"button\"\n disabled={disabled || loading}\n accessibilityState={{ busy: loading }}\n accessibilityLabel={accessibilityLabel}\n hitSlop={10}\n android_ripple={{\n color: androidRippleColor,\n borderless: true,\n foreground: true,\n radius: androidRadiusSizeMap[size].radius,\n }}\n {...props}\n >\n {loading && (\n <Spinner\n size={styles.spinner.fontSize}\n maxFontSizeMultiplier={maxFontSizeMultiplier || 0}\n />\n )}\n <Icon\n name={name}\n style={[styles.icon, iconStyle, disabled && styles.disabled, loading && styles.loading]}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'neutral',\n disabled = false,\n loading = false,\n maxFontSizeMultiplier,\n size = 'md',\n}: Partial<IconButtonProps>) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n const colorOptionMap = useIconButtonColorOptionMap()\n const colorKey = getColorKey({ disabled, loading, appearance })\n\n const sizeStyleMap: SizeStyle = {\n [SIZES.md]: {\n fontSize: 16,\n height: 16 * fontScale,\n },\n [SIZES.lg]: {\n fontSize: 20,\n height: 20 * fontScale,\n },\n [SIZES.xl]: {\n fontSize: 24,\n height: 24 * fontScale,\n },\n [SIZES.xxl]: {\n fontSize: 32,\n height: 32 * fontScale,\n },\n [SIZES.xxxl]: {\n fontSize: 40,\n height: 40 * fontScale,\n },\n }\n\n return StyleSheet.create({\n pressable: {\n alignItems: 'center',\n justifyContent: 'center',\n height: sizeStyleMap[size].height,\n },\n icon: {\n fontSize: sizeStyleMap[size].fontSize,\n color: colorOptionMap[colorKey],\n },\n disabled: {\n color: colors.iconColorDefaultDisabled,\n },\n loading: {\n opacity: 0,\n },\n spinner: {\n fontSize: sizeStyleMap[size].fontSize,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './avatar'\nexport * from './avatar_group'\nexport * from './button'\nexport * from './heading'\nexport * from './icon'\nexport * from './image'\nexport * from './spinner'\nexport * from './text'\nexport * from './text_button'\nexport * from './text_inline_button'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './avatar'\nexport * from './avatar_group'\nexport * from './button'\nexport * from './heading'\nexport * from './icon'\nexport * from './icon_button'\nexport * from './image'\nexport * from './spinner'\nexport * from './text'\nexport * from './text_button'\nexport * from './text_inline_button'\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PressableProps } from 'react-native';
|
|
3
3
|
import type { TextProps } from './text';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ButtonAppearanceUnion } from './button_color_utils';
|
|
5
5
|
interface TextButtonProps extends PressableProps {
|
|
6
6
|
/**
|
|
7
7
|
* Specifies whether fonts should be scaled down automatically to fit given style constraints.
|
|
@@ -14,7 +14,7 @@ interface TextButtonProps extends PressableProps {
|
|
|
14
14
|
/**
|
|
15
15
|
* Updates the button's colors
|
|
16
16
|
*/
|
|
17
|
-
appearance?:
|
|
17
|
+
appearance?: ButtonAppearanceUnion;
|
|
18
18
|
/**
|
|
19
19
|
* Renders text within a `Text`
|
|
20
20
|
*/
|
|
@@ -28,7 +28,7 @@ interface TextButtonProps extends PressableProps {
|
|
|
28
28
|
*/
|
|
29
29
|
minimumFontScale?: number;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Changes the styles and size of the text.
|
|
32
32
|
*/
|
|
33
33
|
variant?: TextProps['variant'];
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text_button.d.ts","sourceRoot":"","sources":["../../../src/components/display/text_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"text_button.d.ts","sourceRoot":"","sources":["../../../src/components/display/text_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAMjE,UAAU,eAAgB,SAAQ,cAAc;IAC9C;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;IAChC;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC/B;AAED,wBAAgB,UAAU,CAAC,EACzB,oBAA4B,EAC5B,gBAAuB,EACvB,UAA0B,EAC1B,QAAgB,EAChB,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,EAChB,OAAiB,EACjB,GAAG,KAAK,EACT,EAAE,eAAe,qBAwBjB"}
|
|
@@ -3,11 +3,11 @@ import { Pressable, StyleSheet } from 'react-native';
|
|
|
3
3
|
import { useTheme } from '../../hooks';
|
|
4
4
|
import { platformFontWeightMedium } from '../../utils';
|
|
5
5
|
import { Text } from './text';
|
|
6
|
-
import { getColorKey,
|
|
7
|
-
export function TextButton({ adjustsFontSizeToFit = false, allowFontScaling = true, appearance = '
|
|
6
|
+
import { getColorKey, useButtonColorOptionMap } from './button_color_utils';
|
|
7
|
+
export function TextButton({ adjustsFontSizeToFit = false, allowFontScaling = true, appearance = 'interaction', disabled = false, children, maxFontSizeMultiplier, minimumFontScale, variant = 'plain', ...props }) {
|
|
8
8
|
const styles = useStyles({ appearance, disabled });
|
|
9
9
|
return (<Pressable accessibilityRole="button" disabled={disabled} style={({ pressed }) => pressed && styles.pressed} // Android & iOS intentionally get the same pressed style
|
|
10
|
-
{...props}>
|
|
10
|
+
hitSlop={10} {...props}>
|
|
11
11
|
<Text adjustsFontSizeToFit={adjustsFontSizeToFit} allowFontScaling={allowFontScaling} maxFontSizeMultiplier={maxFontSizeMultiplier} minimumFontScale={minimumFontScale} numberOfLines={1} style={[styles.text, disabled && styles.disabled]} variant={variant}>
|
|
12
12
|
{children}
|
|
13
13
|
</Text>
|
|
@@ -16,10 +16,10 @@ export function TextButton({ adjustsFontSizeToFit = false, allowFontScaling = tr
|
|
|
16
16
|
// =================================
|
|
17
17
|
// ====== Styles ===================
|
|
18
18
|
// =================================
|
|
19
|
-
const useStyles = ({ appearance = '
|
|
19
|
+
const useStyles = ({ appearance = 'interaction', disabled = false }) => {
|
|
20
20
|
const { colors } = useTheme();
|
|
21
21
|
const colorKey = getColorKey({ disabled, appearance });
|
|
22
|
-
const colorOptionMap =
|
|
22
|
+
const colorOptionMap = useButtonColorOptionMap();
|
|
23
23
|
return StyleSheet.create({
|
|
24
24
|
text: {
|
|
25
25
|
fontWeight: platformFontWeightMedium,
|