@planningcenter/chat-react-native 1.5.0 → 1.6.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/conversations.d.ts.map +1 -1
- package/build/components/conversations.js +29 -8
- package/build/components/conversations.js.map +1 -1
- package/build/components/display/button.d.ts +71 -0
- package/build/components/display/button.d.ts.map +1 -0
- package/build/components/display/button.js +136 -0
- package/build/components/display/button.js.map +1 -0
- package/build/components/display/button_color_utils.d.ts +24 -0
- package/build/components/display/button_color_utils.d.ts.map +1 -0
- package/build/components/display/button_color_utils.js +43 -0
- package/build/components/display/button_color_utils.js.map +1 -0
- package/build/components/display/heading.d.ts +4 -0
- package/build/components/display/heading.d.ts.map +1 -1
- package/build/components/display/heading.js +3 -0
- package/build/components/display/heading.js.map +1 -1
- package/build/components/display/icon.d.ts +8 -4
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +21 -13
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/image.d.ts +7 -2
- package/build/components/display/image.d.ts.map +1 -1
- package/build/components/display/image.js +5 -5
- package/build/components/display/image.js.map +1 -1
- package/build/components/display/index.d.ts +10 -7
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +10 -7
- package/build/components/display/index.js.map +1 -1
- package/build/components/display/spinner.d.ts +5 -1
- package/build/components/display/spinner.d.ts.map +1 -1
- package/build/components/display/spinner.js +19 -13
- package/build/components/display/spinner.js.map +1 -1
- package/build/components/display/text.d.ts +13 -3
- package/build/components/display/text.d.ts.map +1 -1
- package/build/components/display/text.js +17 -5
- package/build/components/display/text.js.map +1 -1
- package/build/components/display/text_button.d.ts +37 -0
- package/build/components/display/text_button.d.ts.map +1 -0
- package/build/components/display/text_button.js +36 -0
- package/build/components/display/text_button.js.map +1 -0
- package/build/components/display/text_inline_button.d.ts +12 -0
- package/build/components/display/text_inline_button.d.ts.map +1 -0
- package/build/components/display/text_inline_button.js +53 -0
- package/build/components/display/text_inline_button.js.map +1 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +1 -0
- package/build/components/index.js.map +1 -1
- package/build/components/primitive/avatar_primitive.d.ts +1 -1
- package/build/components/primitive/avatar_primitive.d.ts.map +1 -1
- package/build/components/primitive/avatar_primitive.js +6 -9
- package/build/components/primitive/avatar_primitive.js.map +1 -1
- package/build/contexts/api_provider.d.ts +4 -6
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +13 -20
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +7 -5
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +40 -4
- package/build/contexts/chat_context.js.map +1 -1
- package/build/hooks/index.d.ts +4 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +4 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_create_android_ripple_color.d.ts +4 -0
- package/build/hooks/use_create_android_ripple_color.d.ts.map +1 -0
- package/build/hooks/use_create_android_ripple_color.js +15 -0
- package/build/hooks/use_create_android_ripple_color.js.map +1 -0
- package/build/hooks/use_current_person.d.ts +3 -0
- package/build/hooks/use_current_person.d.ts.map +1 -0
- package/build/hooks/use_current_person.js +13 -0
- package/build/hooks/use_current_person.js.map +1 -0
- package/build/hooks/use_font_scale.d.ts +4 -0
- package/build/hooks/use_font_scale.d.ts.map +1 -0
- package/build/hooks/use_font_scale.js +8 -0
- package/build/hooks/use_font_scale.js.map +1 -0
- package/build/hooks/use_suspense_api.d.ts +61 -0
- package/build/hooks/use_suspense_api.d.ts.map +1 -0
- package/build/hooks/use_suspense_api.js +39 -0
- package/build/hooks/use_suspense_api.js.map +1 -0
- package/build/navigation/index.d.ts +1 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +7 -4
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +59 -6
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/display.d.ts.map +1 -1
- package/build/screens/display.js +277 -51
- package/build/screens/display.js.map +1 -1
- package/build/screens/not_found.js +1 -1
- package/build/screens/not_found.js.map +1 -1
- package/build/types/api_primitives.d.ts +23 -0
- package/build/types/api_primitives.d.ts.map +1 -0
- package/build/types/api_primitives.js +2 -0
- package/build/types/api_primitives.js.map +1 -0
- package/build/types/index.d.ts +4 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +4 -0
- package/build/types/index.js.map +1 -0
- package/build/types/resources/conversation.d.ts +15 -0
- package/build/types/resources/conversation.d.ts.map +1 -0
- package/build/types/resources/conversation.js +2 -0
- package/build/types/resources/conversation.js.map +1 -0
- package/build/types/resources/index.d.ts +5 -0
- package/build/types/resources/index.d.ts.map +1 -0
- package/build/types/resources/index.js +5 -0
- package/build/types/resources/index.js.map +1 -0
- package/build/types/resources/message.d.ts +16 -0
- package/build/types/resources/message.d.ts.map +1 -0
- package/build/types/resources/message.js +2 -0
- package/build/types/resources/message.js.map +1 -0
- package/build/types/resources/oauth_token.d.ts +9 -0
- package/build/types/resources/oauth_token.d.ts.map +1 -0
- package/build/types/resources/oauth_token.js +2 -0
- package/build/types/resources/oauth_token.js.map +1 -0
- package/build/types/resources/person.d.ts +9 -0
- package/build/types/resources/person.d.ts.map +1 -0
- package/build/types/resources/person.js +2 -0
- package/build/types/resources/person.js.map +1 -0
- package/build/types/resources/reaction.d.ts +10 -0
- package/build/types/resources/reaction.d.ts.map +1 -0
- package/build/types/resources/reaction.js +2 -0
- package/build/types/resources/reaction.js.map +1 -0
- package/build/types/utils/index.d.ts +4 -0
- package/build/types/utils/index.d.ts.map +1 -0
- package/build/types/utils/index.js +4 -0
- package/build/types/utils/index.js.map +1 -0
- package/build/utils/client/client.d.ts +21 -12
- package/build/utils/client/client.d.ts.map +1 -1
- package/build/utils/client/client.js +24 -22
- package/build/utils/client/client.js.map +1 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/session.d.ts +0 -5
- package/build/utils/session.d.ts.map +1 -1
- package/build/utils/session.js +0 -10
- package/build/utils/session.js.map +1 -1
- package/build/utils/styles.d.ts +5 -0
- package/build/utils/styles.d.ts.map +1 -1
- package/build/utils/styles.js +9 -0
- package/build/utils/styles.js.map +1 -1
- package/build/utils/theme.d.ts +3 -1
- package/build/utils/theme.d.ts.map +1 -1
- package/build/utils/theme.js +6 -2
- package/build/utils/theme.js.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts +8 -0
- package/build/vendor/tapestry/alias_tokens_color_map.d.ts.map +1 -1
- package/build/vendor/tapestry/alias_tokens_color_map.js +8 -0
- package/build/vendor/tapestry/alias_tokens_color_map.js.map +1 -1
- package/build/vendor/tapestry/tokens.d.ts +21 -0
- package/build/vendor/tapestry/tokens.d.ts.map +1 -1
- package/build/vendor/tapestry/tokens.js +21 -0
- package/build/vendor/tapestry/tokens.js.map +1 -1
- package/package.json +4 -3
- package/src/__tests__/client.ts +72 -19
- package/src/__tests__/session.ts +0 -11
- package/src/__utils__/handlers.ts +1 -1
- package/src/components/conversations.tsx +33 -11
- package/src/components/display/button.tsx +293 -0
- package/src/components/display/button_color_utils.ts +72 -0
- package/src/components/display/heading.tsx +12 -0
- package/src/components/display/icon.tsx +35 -16
- package/src/components/display/image.tsx +29 -7
- package/src/components/display/index.ts +10 -7
- package/src/components/display/spinner.tsx +42 -13
- package/src/components/display/text.tsx +34 -13
- package/src/components/display/text_button.tsx +102 -0
- package/src/components/display/text_inline_button.tsx +91 -0
- package/src/components/index.tsx +1 -0
- package/src/components/primitive/avatar_primitive.tsx +12 -6
- package/src/contexts/api_provider.tsx +18 -26
- package/src/contexts/chat_context.tsx +61 -7
- package/src/hooks/index.ts +4 -0
- package/src/hooks/use_create_android_ripple_color.ts +18 -0
- package/src/hooks/use_current_person.ts +15 -0
- package/src/hooks/use_font_scale.ts +9 -0
- package/src/hooks/use_suspense_api.ts +60 -0
- package/src/navigation/index.tsx +14 -4
- package/src/screens/conversation_screen.tsx +83 -7
- package/src/screens/display.tsx +447 -51
- package/src/screens/not_found.tsx +1 -1
- package/src/types/api_primitives.ts +24 -0
- package/src/types/index.ts +3 -0
- package/src/types/resources/conversation.ts +15 -0
- package/src/types/resources/index.ts +4 -0
- package/src/types/resources/message.ts +18 -0
- package/src/types/resources/oauth_token.ts +8 -0
- package/src/types/resources/person.ts +9 -0
- package/src/types/resources/reaction.ts +9 -0
- package/src/types/utils/index.ts +6 -0
- package/src/utils/client/client.ts +41 -34
- package/src/utils/client/types.d.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/session.ts +0 -13
- package/src/utils/styles.ts +12 -0
- package/src/utils/theme.ts +9 -3
- package/src/vendor/tapestry/alias_tokens_color_map.ts +12 -0
- package/src/vendor/tapestry/tokens.ts +21 -0
- package/build/utils/api.d.ts +0 -9
- package/build/utils/api.d.ts.map +0 -1
- package/build/utils/api.js +0 -36
- package/build/utils/api.js.map +0 -1
- package/src/types.d.ts +0 -35
- package/src/utils/api.ts +0 -47
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/components/display/image.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,EAIL,UAAU,IAAI,qBAAqB,EAGnC,SAAS,EACV,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/components/display/image.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,EAIL,UAAU,IAAI,qBAAqB,EAGnC,SAAS,EACV,MAAM,cAAc,CAAA;AAQrB,MAAM,WAAW,UAAW,SAAQ,qBAAqB;IACvD;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,uBAAuB,CAAC,EAAE,SAAS,CAAA;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAA;CACzB;AAED,wBAAgB,KAAK,CAAC,EACpB,MAAM,EACN,MAAa,EACb,cAAqB,EACrB,cAAqB,EACrB,UAAe,EACf,uBAAuB,EACvB,KAAU,EACV,YAAiB,EACjB,GAAG,EACH,GAAG,KAAK,EACT,EAAE,UAAU,qBAiCZ"}
|
|
@@ -3,23 +3,23 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import { Image as ReactNativeImage, StyleSheet, View, } from 'react-native';
|
|
4
4
|
import { useTheme } from '../../hooks';
|
|
5
5
|
import { Spinner } from './spinner';
|
|
6
|
-
export function Image({ source, onLoad = noop, defaultLoading = true, loadingEnabled = true, loaderSize = 24, loadingBackgroundStyles, style = {}, wrapperStyle = {}, ...props }) {
|
|
6
|
+
export function Image({ source, onLoad = noop, defaultLoading = true, loadingEnabled = true, loaderSize = 24, loadingBackgroundStyles, style = {}, wrapperStyle = {}, alt, ...props }) {
|
|
7
7
|
const [loading, setLoading] = useState(defaultLoading);
|
|
8
8
|
const imageStyles = StyleSheet.flatten(style);
|
|
9
9
|
const { width = '100%', height = '100%', borderRadius = 0 } = imageStyles || {};
|
|
10
|
-
const styles = useStyles(width, height, borderRadius);
|
|
10
|
+
const styles = useStyles({ width, height, borderRadius });
|
|
11
11
|
const handleOnLoad = (event) => {
|
|
12
12
|
setLoading(false);
|
|
13
13
|
onLoad?.(event);
|
|
14
14
|
};
|
|
15
|
-
return (<View style={wrapperStyle}>
|
|
16
|
-
<ReactNativeImage style={[styles.image, imageStyles]} onLoad={handleOnLoad} source={source} {...props}/>
|
|
15
|
+
return (<View style={wrapperStyle} accessible={Boolean(alt)} accessibilityRole="image" accessibilityState={{ busy: loading }}>
|
|
16
|
+
<ReactNativeImage style={[styles.image, imageStyles]} onLoad={handleOnLoad} source={source} alt={loading ? '' : alt} {...props}/>
|
|
17
17
|
{loading && loadingEnabled && (<View style={[styles.loadingBackground, loadingBackgroundStyles]}>
|
|
18
18
|
<Spinner size={loaderSize}/>
|
|
19
19
|
</View>)}
|
|
20
20
|
</View>);
|
|
21
21
|
}
|
|
22
|
-
const useStyles = (width, height, borderRadius) => {
|
|
22
|
+
const useStyles = ({ width, height, borderRadius }) => {
|
|
23
23
|
const { colors } = useTheme();
|
|
24
24
|
return StyleSheet.create({
|
|
25
25
|
loadingBackground: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/components/display/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAGL,KAAK,IAAI,gBAAgB,EAEzB,UAAU,EACV,IAAI,GAEL,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/components/display/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAGL,KAAK,IAAI,gBAAgB,EAEzB,UAAU,EACV,IAAI,GAEL,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkCnC,MAAM,UAAU,KAAK,CAAC,EACpB,MAAM,EAC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AI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC,CAC/D;UAAA,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAC5B;QAAA,EAAE,IAAI,CAAC,CACR,CACH;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAYD,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAU,EAAE,EAAE;IAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,iBAAiB,EAAE;YACjB,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,CAAC;YACP,eAAe,EAAE,MAAM,CAAC,mBAAmB;YAC3C,YAAY;YACZ,KAAK;YACL,MAAM;SACP;QACD,KAAK,EAAE;YACL,eAAe,EAAE,MAAM,CAAC,mBAAmB;YAC3C,KAAK;YACL,MAAM;SACP;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { noop } from 'lodash'\nimport React, { useState } from 'react'\nimport {\n AnimatableNumericValue,\n DimensionValue,\n Image as ReactNativeImage,\n ImageProps as ReactNativeImageProps,\n StyleSheet,\n View,\n ViewStyle,\n} from 'react-native'\nimport { useTheme } from '../../hooks'\nimport { Spinner } from './spinner'\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface ImageProps extends ReactNativeImageProps {\n /**\n * Describes the image to screen-readers and marks the image as `accessible`.\n * Passing an empty string will hide the image from screen-readers.\n */\n alt: string\n /**\n * Shows the image's loading spinner right away. Enabled by default.\n */\n defaultLoading?: boolean\n /**\n * Turn on or off loading spinner.\n */\n loadingEnabled?: boolean\n /**\n * Size of the loading spinner.\n */\n loaderSize?: number\n /**\n * Style object for the preload background.\n */\n loadingBackgroundStyles?: ViewStyle\n /**\n * Style the outer View of the image.\n */\n wrapperStyle?: ViewStyle\n}\n\nexport function Image({\n source,\n onLoad = noop,\n defaultLoading = true,\n loadingEnabled = true,\n loaderSize = 24,\n loadingBackgroundStyles,\n style = {},\n wrapperStyle = {},\n alt,\n ...props\n}: ImageProps) {\n const [loading, setLoading] = useState(defaultLoading)\n\n const imageStyles = StyleSheet.flatten(style)\n const { width = '100%', height = '100%', borderRadius = 0 } = imageStyles || {}\n const styles = useStyles({ width, height, borderRadius })\n\n const handleOnLoad = (event: any) => {\n setLoading(false)\n onLoad?.(event)\n }\n\n return (\n <View\n style={wrapperStyle}\n accessible={Boolean(alt)}\n accessibilityRole=\"image\"\n accessibilityState={{ busy: loading }}\n >\n <ReactNativeImage\n style={[styles.image, imageStyles]}\n onLoad={handleOnLoad}\n source={source}\n alt={loading ? '' : alt}\n {...props}\n />\n {loading && loadingEnabled && (\n <View style={[styles.loadingBackground, loadingBackgroundStyles]}>\n <Spinner size={loaderSize} />\n </View>\n )}\n </View>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\ninterface Styles {\n width: DimensionValue\n height: DimensionValue\n borderRadius: AnimatableNumericValue | string\n}\n\nconst useStyles = ({ width, height, borderRadius }: Styles) => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n loadingBackground: {\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: colors.fillColorNeutral070,\n borderRadius,\n width,\n height,\n },\n image: {\n backgroundColor: colors.fillColorNeutral070,\n width,\n height,\n },\n })\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
export * from './avatar';
|
|
2
|
+
export * from './avatar_group';
|
|
3
|
+
export * from './button';
|
|
4
|
+
export * from './heading';
|
|
5
|
+
export * from './icon';
|
|
6
|
+
export * from './image';
|
|
7
|
+
export * from './spinner';
|
|
8
|
+
export * from './text';
|
|
9
|
+
export * from './text_button';
|
|
10
|
+
export * from './text_inline_button';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,
|
|
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,8 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
export * from './avatar';
|
|
2
|
+
export * from './avatar_group';
|
|
3
|
+
export * from './button';
|
|
4
|
+
export * from './heading';
|
|
5
|
+
export * from './icon';
|
|
6
|
+
export * from './image';
|
|
7
|
+
export * from './spinner';
|
|
8
|
+
export * from './text';
|
|
9
|
+
export * from './text_button';
|
|
10
|
+
export * from './text_inline_button';
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,
|
|
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"]}
|
|
@@ -4,7 +4,11 @@ interface SpinnerProps {
|
|
|
4
4
|
* Size of the spinner in px
|
|
5
5
|
* */
|
|
6
6
|
size?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Specifies the maximum size spinner can scale to if the device's font-size is increased.
|
|
9
|
+
*/
|
|
10
|
+
maxFontSizeMultiplier?: number;
|
|
7
11
|
}
|
|
8
|
-
export declare function Spinner({ size }: SpinnerProps): React.JSX.Element;
|
|
12
|
+
export declare function Spinner({ size, maxFontSizeMultiplier, }: SpinnerProps): React.JSX.Element;
|
|
9
13
|
export {};
|
|
10
14
|
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/display/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/display/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAchD,UAAU,YAAY;IACpB;;SAEK;IACL,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,wBAAgB,OAAO,CAAC,EACtB,IAAS,EACT,qBAA+C,GAChD,EAAE,YAAY,qBAoCd"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { Animated, Easing, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { useTheme } from '../../hooks';
|
|
4
|
-
|
|
3
|
+
import { useFontScale, useTheme } from '../../hooks';
|
|
4
|
+
// =================================
|
|
5
|
+
// ====== Constants ================
|
|
6
|
+
// =================================
|
|
7
|
+
const PREVENT_SCALING_DEFAULT = 1;
|
|
8
|
+
export function Spinner({ size = 20, maxFontSizeMultiplier = PREVENT_SCALING_DEFAULT, }) {
|
|
5
9
|
const rotation = useRef(new Animated.Value(0)).current;
|
|
6
10
|
const animation = Animated.loop(Animated.timing(rotation, {
|
|
7
11
|
toValue: 1,
|
|
@@ -13,7 +17,7 @@ export function Spinner({ size = 20 }) {
|
|
|
13
17
|
inputRange: [0, 1],
|
|
14
18
|
outputRange: ['0deg', '360deg'],
|
|
15
19
|
});
|
|
16
|
-
const styles = useStyles(rotateValue, size);
|
|
20
|
+
const styles = useStyles({ maxFontSizeMultiplier, rotateValue, size });
|
|
17
21
|
useEffect(() => {
|
|
18
22
|
animation.start();
|
|
19
23
|
return () => animation.stop();
|
|
@@ -28,8 +32,10 @@ export function Spinner({ size = 20 }) {
|
|
|
28
32
|
</Animated.View>
|
|
29
33
|
</View>);
|
|
30
34
|
}
|
|
31
|
-
const useStyles = (
|
|
35
|
+
const useStyles = ({ maxFontSizeMultiplier, rotateValue, size }) => {
|
|
32
36
|
const { colors } = useTheme();
|
|
37
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier });
|
|
38
|
+
const scalableSize = size * fontScale;
|
|
33
39
|
return StyleSheet.create({
|
|
34
40
|
container: {
|
|
35
41
|
width: '100%',
|
|
@@ -43,15 +49,15 @@ const useStyles = (rotate, size) => {
|
|
|
43
49
|
opacity: 0.7,
|
|
44
50
|
},
|
|
45
51
|
animatedContainer: {
|
|
46
|
-
width:
|
|
47
|
-
height:
|
|
48
|
-
borderRadius:
|
|
49
|
-
transform: [{ rotate }],
|
|
52
|
+
width: scalableSize,
|
|
53
|
+
height: scalableSize,
|
|
54
|
+
borderRadius: scalableSize / 2,
|
|
55
|
+
transform: [{ rotate: rotateValue }],
|
|
50
56
|
},
|
|
51
57
|
circle: {
|
|
52
|
-
width:
|
|
53
|
-
height:
|
|
54
|
-
borderRadius:
|
|
58
|
+
width: scalableSize,
|
|
59
|
+
height: scalableSize,
|
|
60
|
+
borderRadius: scalableSize / 2,
|
|
55
61
|
borderStyle: 'solid',
|
|
56
62
|
borderWidth: 3,
|
|
57
63
|
},
|
|
@@ -68,8 +74,8 @@ const useStyles = (rotate, size) => {
|
|
|
68
74
|
position: 'absolute',
|
|
69
75
|
top: 0,
|
|
70
76
|
left: 0,
|
|
71
|
-
width:
|
|
72
|
-
height:
|
|
77
|
+
width: scalableSize / 2,
|
|
78
|
+
height: scalableSize / 2,
|
|
73
79
|
overflow: 'hidden',
|
|
74
80
|
zIndex: 200,
|
|
75
81
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../../src/components/display/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../../src/components/display/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEpD,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAiBjC,MAAM,UAAU,OAAO,CAAC,EACtB,IAAI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AE,MAAM,CAAC,mBAAmB;SACxC;QACD,KAAK,EAAE;YACL,WAAW,EAAE,MAAM,CAAC,uBAAuB;SAC5C;QACD,QAAQ,EAAE;YACR,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,YAAY,GAAG,CAAC;YACvB,MAAM,EAAE,YAAY,GAAG,CAAC;YACxB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,GAAG;SACZ;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport { Animated, Easing, StyleSheet, View } from 'react-native'\nimport { useFontScale, useTheme } from '../../hooks'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst PREVENT_SCALING_DEFAULT = 1\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface SpinnerProps {\n /**\n * Size of the spinner in px\n * */\n size?: number\n /**\n * Specifies the maximum size spinner can scale to if the device's font-size is increased.\n */\n maxFontSizeMultiplier?: number\n}\n\nexport function Spinner({\n size = 20,\n maxFontSizeMultiplier = PREVENT_SCALING_DEFAULT,\n}: SpinnerProps) {\n const rotation = useRef(new Animated.Value(0)).current\n\n const animation = Animated.loop(\n Animated.timing(rotation, {\n toValue: 1,\n duration: 1000,\n easing: Easing.linear,\n useNativeDriver: true,\n })\n )\n\n const rotateValue = rotation.interpolate({\n inputRange: [0, 1],\n outputRange: ['0deg', '360deg'],\n })\n\n const styles = useStyles({ maxFontSizeMultiplier, rotateValue, size })\n\n useEffect(() => {\n animation.start()\n return () => animation.stop()\n }, [animation])\n\n useEffect(() => () => rotation.setValue(0), [rotation])\n\n return (\n <View style={styles.container}>\n <Animated.View style={styles.animatedContainer}>\n <View style={styles.clipping}>\n <View style={[styles.circle, styles.spinner]} />\n </View>\n <View style={[styles.circle, styles.track]} />\n </Animated.View>\n </View>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\ninterface Styles {\n maxFontSizeMultiplier: number | undefined\n rotateValue: Animated.AnimatedInterpolation<string | number>\n size: number\n}\n\nconst useStyles = ({ maxFontSizeMultiplier, rotateValue, size }: Styles) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n const scalableSize = size * fontScale\n\n return StyleSheet.create({\n container: {\n width: '100%',\n height: '100%',\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 200,\n justifyContent: 'center',\n alignItems: 'center',\n opacity: 0.7,\n },\n animatedContainer: {\n width: scalableSize,\n height: scalableSize,\n borderRadius: scalableSize / 2,\n transform: [{ rotate: rotateValue }],\n },\n circle: {\n width: scalableSize,\n height: scalableSize,\n borderRadius: scalableSize / 2,\n borderStyle: 'solid',\n borderWidth: 3,\n },\n spinner: {\n position: 'absolute',\n top: 0,\n left: 0,\n borderColor: colors.fillColorNeutral020,\n },\n track: {\n borderColor: colors.fillColorNeutral050Base,\n },\n clipping: {\n position: 'absolute',\n top: 0,\n left: 0,\n width: scalableSize / 2,\n height: scalableSize / 2,\n overflow: 'hidden',\n zIndex: 200,\n },\n })\n}\n"]}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TextProps as ReactNativeTextProps } from 'react-native';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { TextProps as ReactNativeTextProps } from 'react-native';
|
|
3
|
+
declare const VARIANTS: {
|
|
4
|
+
readonly plain: "plain";
|
|
5
|
+
readonly secondary: "secondary";
|
|
6
|
+
readonly tertiary: "tertiary";
|
|
7
|
+
readonly footnote: "footnote";
|
|
8
|
+
};
|
|
9
|
+
type VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS];
|
|
10
|
+
export interface TextProps extends ReactNativeTextProps {
|
|
11
|
+
/**
|
|
12
|
+
* Changes the styles and size of the text.
|
|
13
|
+
*/
|
|
14
|
+
variant?: VariantUnion;
|
|
5
15
|
}
|
|
6
16
|
export declare function Text({ style, variant, children, ...props }: TextProps): React.JSX.Element;
|
|
7
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/components/display/text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/components/display/text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAa,SAAS,IAAI,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAOhF,QAAA,MAAM,QAAQ;;;;;CAKJ,CAAA;AAEV,KAAK,YAAY,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAA;AAO5D,MAAM,WAAW,SAAU,SAAQ,oBAAoB;IACrD;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB;AAED,wBAAgB,IAAI,CAAC,EAAE,KAAK,EAAE,OAAiB,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,qBAc/E"}
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { useTheme } from '../../hooks';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Platform, StyleSheet, Text as ReactNativeText
|
|
3
|
+
import { Platform, StyleSheet, Text as ReactNativeText } from 'react-native';
|
|
4
4
|
import { tokens } from '../../vendor/tapestry/tokens';
|
|
5
|
+
// =================================
|
|
6
|
+
// ====== Constants ================
|
|
7
|
+
// =================================
|
|
8
|
+
const VARIANTS = {
|
|
9
|
+
plain: 'plain',
|
|
10
|
+
secondary: 'secondary',
|
|
11
|
+
tertiary: 'tertiary',
|
|
12
|
+
footnote: 'footnote',
|
|
13
|
+
};
|
|
5
14
|
export function Text({ style, variant = 'plain', children, ...props }) {
|
|
6
15
|
const styles = useStyles();
|
|
7
16
|
const variantStyleMap = {
|
|
8
|
-
plain: styles.plain,
|
|
9
|
-
secondary: styles.secondary,
|
|
10
|
-
tertiary: styles.tertiary,
|
|
11
|
-
footnote: styles.footnote,
|
|
17
|
+
[VARIANTS.plain]: styles.plain,
|
|
18
|
+
[VARIANTS.secondary]: styles.secondary,
|
|
19
|
+
[VARIANTS.tertiary]: styles.tertiary,
|
|
20
|
+
[VARIANTS.footnote]: styles.footnote,
|
|
12
21
|
};
|
|
13
22
|
return (<ReactNativeText style={[styles.global, variantStyleMap[variant], style]} {...props}>
|
|
14
23
|
{children}
|
|
15
24
|
</ReactNativeText>);
|
|
16
25
|
}
|
|
26
|
+
// =================================
|
|
27
|
+
// ====== Styles ===================
|
|
28
|
+
// =================================
|
|
17
29
|
const useStyles = () => {
|
|
18
30
|
const { colors } = useTheme();
|
|
19
31
|
return StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/components/display/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/components/display/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAErD,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,QAAQ,GAAG;IACf,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACZ,CAAA;AAgBV,MAAM,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,QAAQ,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B,UAAU,EAAE,EAAE;SACf;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM,CAAC,yBAAyB;YACvC,QAAQ,EAAE,EAAE,EAAE,uCAAuC;YACrD,UAAU,EAAE,EAAE;SACf;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useTheme } from '../../hooks'\nimport React from 'react'\nimport { Platform, StyleSheet, Text as ReactNativeText } from 'react-native'\nimport type { TextStyle, TextProps as ReactNativeTextProps } from 'react-native'\nimport { tokens } from '../../vendor/tapestry/tokens'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst VARIANTS = {\n plain: 'plain',\n secondary: 'secondary',\n tertiary: 'tertiary',\n footnote: 'footnote',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\ntype VariantStyles = Record<VariantUnion, TextStyle>\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface TextProps extends ReactNativeTextProps {\n /**\n * Changes the styles and size of the text.\n */\n variant?: VariantUnion\n}\n\nexport function Text({ style, variant = 'plain', children, ...props }: TextProps) {\n const styles = useStyles()\n const variantStyleMap: VariantStyles = {\n [VARIANTS.plain]: styles.plain,\n [VARIANTS.secondary]: styles.secondary,\n [VARIANTS.tertiary]: styles.tertiary,\n [VARIANTS.footnote]: styles.footnote,\n }\n\n return (\n <ReactNativeText style={[styles.global, variantStyleMap[variant], style]} {...props}>\n {children}\n </ReactNativeText>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n global: {\n fontFamily: Platform.select({\n ios: 'System',\n android: 'normal',\n }),\n },\n plain: {\n color: colors.textColorDefaultPrimary,\n fontSize: tokens.fontSizeMd,\n lineHeight: 24,\n },\n secondary: {\n color: colors.textColorDefaultPrimary,\n fontSize: 15, // TODO: Check with UX on correct token\n lineHeight: 22,\n },\n tertiary: {\n color: colors.textColorDefaultPrimary,\n fontSize: tokens.fontSizeSm,\n lineHeight: 20,\n },\n footnote: {\n color: colors.textColorDefaultSecondary,\n fontSize: 13, // TODO: Check with UX on correct token\n lineHeight: 16,\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PressableProps } from 'react-native';
|
|
3
|
+
import type { TextProps } from './text';
|
|
4
|
+
import type { AppearanceUnion } from './button_color_utils';
|
|
5
|
+
interface TextButtonProps extends PressableProps {
|
|
6
|
+
/**
|
|
7
|
+
* Specifies whether fonts should be scaled down automatically to fit given style constraints.
|
|
8
|
+
*/
|
|
9
|
+
adjustsFontSizeToFit?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Specifies whether fonts should scale to respect the device's text size accessibility settings. The default is true.
|
|
12
|
+
*/
|
|
13
|
+
allowFontScaling?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Updates the button's colors
|
|
16
|
+
*/
|
|
17
|
+
appearance?: AppearanceUnion;
|
|
18
|
+
/**
|
|
19
|
+
* Renders text within a `Text`
|
|
20
|
+
*/
|
|
21
|
+
children?: TextProps['children'];
|
|
22
|
+
/**
|
|
23
|
+
* Specifies the maximum size a font can reach when allowFontScaling is enabled.
|
|
24
|
+
*/
|
|
25
|
+
maxFontSizeMultiplier?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
|
|
28
|
+
*/
|
|
29
|
+
minimumFontScale?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Fill buttons are visually more propmonitent then outline buttons
|
|
32
|
+
*/
|
|
33
|
+
variant?: TextProps['variant'];
|
|
34
|
+
}
|
|
35
|
+
export declare function TextButton({ adjustsFontSizeToFit, allowFontScaling, appearance, disabled, children, maxFontSizeMultiplier, minimumFontScale, variant, ...props }: TextButtonProps): React.JSX.Element;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=text_button.d.ts.map
|
|
@@ -0,0 +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,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAM3D,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,eAAe,CAAA;IAC5B;;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,UAAsB,EACtB,QAAgB,EAChB,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,EAChB,OAAiB,EACjB,GAAG,KAAK,EACT,EAAE,eAAe,qBAuBjB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native';
|
|
3
|
+
import { useTheme } from '../../hooks';
|
|
4
|
+
import { platformFontWeightMedium } from '../../utils';
|
|
5
|
+
import { Text } from './text';
|
|
6
|
+
import { getColorKey, useColorOptionMap } from './button_color_utils';
|
|
7
|
+
export function TextButton({ adjustsFontSizeToFit = false, allowFontScaling = true, appearance = 'primary', disabled = false, children, maxFontSizeMultiplier, minimumFontScale, variant = 'plain', ...props }) {
|
|
8
|
+
const styles = useStyles({ appearance, disabled });
|
|
9
|
+
return (<Pressable accessibilityRole="button" disabled={disabled} style={({ pressed }) => pressed && styles.pressed} // Android & iOS intentionally get the same pressed style
|
|
10
|
+
{...props}>
|
|
11
|
+
<Text adjustsFontSizeToFit={adjustsFontSizeToFit} allowFontScaling={allowFontScaling} maxFontSizeMultiplier={maxFontSizeMultiplier} minimumFontScale={minimumFontScale} numberOfLines={1} style={[styles.text, disabled && styles.disabled]} variant={variant}>
|
|
12
|
+
{children}
|
|
13
|
+
</Text>
|
|
14
|
+
</Pressable>);
|
|
15
|
+
}
|
|
16
|
+
// =================================
|
|
17
|
+
// ====== Styles ===================
|
|
18
|
+
// =================================
|
|
19
|
+
const useStyles = ({ appearance = 'primary', disabled = false }) => {
|
|
20
|
+
const { colors } = useTheme();
|
|
21
|
+
const colorKey = getColorKey({ disabled, appearance });
|
|
22
|
+
const colorOptionMap = useColorOptionMap();
|
|
23
|
+
return StyleSheet.create({
|
|
24
|
+
text: {
|
|
25
|
+
fontWeight: platformFontWeightMedium,
|
|
26
|
+
color: colorOptionMap[colorKey],
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
color: colors.textColorDefaultDisabled,
|
|
30
|
+
},
|
|
31
|
+
pressed: {
|
|
32
|
+
opacity: 0.5,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=text_button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text_button.js","sourceRoot":"","sources":["../../../src/components/display/text_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,IAAI,E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;IAC3F,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IACtD,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAA;IAE1C,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE;YACJ,UAAU,EAAE,wBAAwB;YACpC,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC;SAChC;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,OAAO,EAAE;YACP,OAAO,EAAE,GAAG;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet } from 'react-native'\nimport type { PressableProps } from 'react-native'\nimport { useTheme } from '../../hooks'\nimport { platformFontWeightMedium } from '../../utils'\nimport { Text } from './text'\nimport type { TextProps } from './text'\nimport { getColorKey, useColorOptionMap } from './button_color_utils'\nimport type { AppearanceUnion } from './button_color_utils'\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface TextButtonProps 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 * Renders text within a `Text`\n */\n children?: TextProps['children']\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 * Fill buttons are visually more propmonitent then outline buttons\n */\n variant?: TextProps['variant']\n}\n\nexport function TextButton({\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n appearance = 'primary',\n disabled = false,\n children,\n maxFontSizeMultiplier,\n minimumFontScale,\n variant = 'plain',\n ...props\n}: TextButtonProps) {\n const styles = useStyles({ appearance, disabled })\n\n return (\n <Pressable\n accessibilityRole=\"button\"\n disabled={disabled}\n style={({ pressed }) => pressed && styles.pressed} // Android & iOS intentionally get the same pressed style\n {...props}\n >\n <Text\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n allowFontScaling={allowFontScaling}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n minimumFontScale={minimumFontScale}\n numberOfLines={1}\n style={[styles.text, disabled && styles.disabled]}\n variant={variant}\n >\n {children}\n </Text>\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({ appearance = 'primary', disabled = false }: Partial<TextButtonProps>) => {\n const { colors } = useTheme()\n const colorKey = getColorKey({ disabled, appearance })\n const colorOptionMap = useColorOptionMap()\n\n return StyleSheet.create({\n text: {\n fontWeight: platformFontWeightMedium,\n color: colorOptionMap[colorKey],\n },\n disabled: {\n color: colors.textColorDefaultDisabled,\n },\n pressed: {\n opacity: 0.5,\n },\n })\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TextProps } from './text';
|
|
3
|
+
import type { AppearanceUnion } from './button_color_utils';
|
|
4
|
+
interface TextInlineButtonProps extends TextProps {
|
|
5
|
+
/**
|
|
6
|
+
* Updates the button's colors
|
|
7
|
+
*/
|
|
8
|
+
appearance?: AppearanceUnion;
|
|
9
|
+
}
|
|
10
|
+
export declare function TextInlineButton({ appearance, children, disabled, onPress, ...props }: TextInlineButtonProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=text_inline_button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text_inline_button.d.ts","sourceRoot":"","sources":["../../../src/components/display/text_inline_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAIvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAM3D,UAAU,qBAAsB,SAAQ,SAAS;IAC/C;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAA;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,UAAsB,EACtB,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,GAAG,KAAK,EACT,EAAE,qBAAqB,qBA2BvB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import { useTheme } from '../../hooks';
|
|
4
|
+
import { Text } from './text';
|
|
5
|
+
import { platformFontWeightMedium } from '../../utils';
|
|
6
|
+
import colorFunction from 'color';
|
|
7
|
+
import { getColorKey, useColorOptionMap } from './button_color_utils';
|
|
8
|
+
export function TextInlineButton({ appearance = 'primary', children, disabled = false, onPress, ...props }) {
|
|
9
|
+
const styles = useStyles({ appearance, disabled });
|
|
10
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
11
|
+
const platformPressedStyle = Platform.select({
|
|
12
|
+
ios: null,
|
|
13
|
+
android: styles.pressedAndroid,
|
|
14
|
+
});
|
|
15
|
+
return (<Text accessibilityRole="button" numberOfLines={1} style={[
|
|
16
|
+
styles.text,
|
|
17
|
+
styles.underline,
|
|
18
|
+
disabled && styles.disabled,
|
|
19
|
+
isPressed && platformPressedStyle,
|
|
20
|
+
]} onPress={!disabled ? onPress : undefined} onPressIn={() => setIsPressed(true)} onPressOut={() => setIsPressed(false)} {...props}>
|
|
21
|
+
{children}
|
|
22
|
+
</Text>);
|
|
23
|
+
}
|
|
24
|
+
// =================================
|
|
25
|
+
// ====== Styles ===================
|
|
26
|
+
// =================================
|
|
27
|
+
const useStyles = ({ appearance = 'primary', disabled = false, }) => {
|
|
28
|
+
const { colors } = useTheme();
|
|
29
|
+
const colorKey = getColorKey({ disabled, appearance });
|
|
30
|
+
const colorOptionMap = useColorOptionMap();
|
|
31
|
+
// Android doesn't show a "pressed" state and so we need to simulate it.
|
|
32
|
+
// Lowering the Text's opacity doesn't work as it inherits it's parent's Text's opacity.
|
|
33
|
+
// We can simulate the effect by changing the color's opacity instead.
|
|
34
|
+
const pressedColor = colorFunction(colorOptionMap[colorKey]).alpha(0.5).string();
|
|
35
|
+
return StyleSheet.create({
|
|
36
|
+
text: {
|
|
37
|
+
fontWeight: platformFontWeightMedium,
|
|
38
|
+
color: colorOptionMap[colorKey],
|
|
39
|
+
},
|
|
40
|
+
underline: {
|
|
41
|
+
textDecorationLine: 'underline',
|
|
42
|
+
textDecorationColor: colorOptionMap[colorKey],
|
|
43
|
+
textDecorationStyle: 'solid',
|
|
44
|
+
},
|
|
45
|
+
disabled: {
|
|
46
|
+
color: colors.textColorDefaultDisabled,
|
|
47
|
+
},
|
|
48
|
+
pressedAndroid: {
|
|
49
|
+
color: pressedColor,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=text_inline_button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text_inline_button.js","sourceRoot":"","sources":["../../../src/components/display/text_inline_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAcrE,MAAM,UAAU,gBAAgB,CAAC,EAC/B,UAAU,G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AAM,cAAc,GAAG,iBAAiB,EAAE,CAAA;IAE1C,wEAAwE;IACxE,wFAAwF;IACxF,sEAAsE;IACtE,MAAM,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;IAEhF,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE;YACJ,UAAU,EAAE,wBAAwB;YACpC,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC;SAChC;QACD,SAAS,EAAE;YACT,kBAAkB,EAAE,WAAW;YAC/B,mBAAmB,EAAE,cAAc,CAAC,QAAQ,CAAC;YAC7C,mBAAmB,EAAE,OAAO;SAC7B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,cAAc,EAAE;YACd,KAAK,EAAE,YAAY;SACpB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useState } from 'react'\nimport { Platform, StyleSheet } from 'react-native'\nimport { useTheme } from '../../hooks'\nimport { Text } from './text'\nimport type { TextProps } from './text'\nimport { platformFontWeightMedium } from '../../utils'\nimport colorFunction from 'color'\nimport { getColorKey, useColorOptionMap } from './button_color_utils'\nimport type { AppearanceUnion } from './button_color_utils'\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface TextInlineButtonProps extends TextProps {\n /**\n * Updates the button's colors\n */\n appearance?: AppearanceUnion\n}\n\nexport function TextInlineButton({\n appearance = 'primary',\n children,\n disabled = false,\n onPress,\n ...props\n}: TextInlineButtonProps) {\n const styles = useStyles({ appearance, disabled })\n const [isPressed, setIsPressed] = useState(false)\n\n const platformPressedStyle = Platform.select({\n ios: null,\n android: styles.pressedAndroid,\n })\n\n return (\n <Text\n accessibilityRole=\"button\"\n numberOfLines={1}\n style={[\n styles.text,\n styles.underline,\n disabled && styles.disabled,\n isPressed && platformPressedStyle,\n ]}\n onPress={!disabled ? onPress : undefined}\n onPressIn={() => setIsPressed(true)}\n onPressOut={() => setIsPressed(false)}\n {...props}\n >\n {children}\n </Text>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'primary',\n disabled = false,\n}: Partial<TextInlineButtonProps>) => {\n const { colors } = useTheme()\n const colorKey = getColorKey({ disabled, appearance })\n const colorOptionMap = useColorOptionMap()\n\n // Android doesn't show a \"pressed\" state and so we need to simulate it.\n // Lowering the Text's opacity doesn't work as it inherits it's parent's Text's opacity.\n // We can simulate the effect by changing the color's opacity instead.\n const pressedColor = colorFunction(colorOptionMap[colorKey]).alpha(0.5).string()\n\n return StyleSheet.create({\n text: {\n fontWeight: platformFontWeightMedium,\n color: colorOptionMap[colorKey],\n },\n underline: {\n textDecorationLine: 'underline',\n textDecorationColor: colorOptionMap[colorKey],\n textDecorationStyle: 'solid',\n },\n disabled: {\n color: colors.textColorDefaultDisabled,\n },\n pressedAndroid: {\n color: pressedColor,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './conversations'\nexport * from './error_boundary'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA","sourcesContent":["export * from './conversations'\nexport * from './error_boundary'\nexport * from './display'\n"]}
|
|
@@ -27,7 +27,7 @@ interface AvatarRootProps {
|
|
|
27
27
|
size?: AvatarSize;
|
|
28
28
|
}
|
|
29
29
|
type AvatarMaskProps = ViewProps;
|
|
30
|
-
interface AvatarImageProps extends Omit<ImageProps, 'source'> {
|
|
30
|
+
interface AvatarImageProps extends Omit<ImageProps, 'source' | 'alt'> {
|
|
31
31
|
sourceUri: string;
|
|
32
32
|
}
|
|
33
33
|
interface AvatarGroupProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar_primitive.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/avatar_primitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAE1D,OAAO,EAAS,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAgBpD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,CAAA;IAC/B,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAA;IACjC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAA;IACvC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAA;IACjC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;IAC5C,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,CAAA;CAChC,CAAA;wBAEwB,gBAAgB;AAAzC,wBAAyC;AACzC,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,CAAA;AAMD,QAAA,MAAM,YAAY;;;CAG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,CAAA;AAMD,QAAA,MAAM,YAAY;;;CAGR,CAAA;AAEV,QAAA,MAAM,qBAAqB;;;CAGjB,CAAA;AAGV,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAA;AAClE,KAAK,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAA;AAoC5F,UAAU,eAAe;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAmBD,KAAK,eAAe,GAAG,SAAS,CAAA;AAkBhC,UAAU,gBAAiB,SAAQ,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,KAAK,CAAC;IACnE,SAAS,EAAE,MAAM,CAAA;CAClB;AAgCD,UAAU,gBAAgB;IACxB,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAsID,UAAU,mBAAoB,SAAQ,SAAS;IAC7C,QAAQ,EAAE,kBAAkB,CAAA;CAC7B"}
|
|
@@ -44,7 +44,7 @@ function useAvatarContext() {
|
|
|
44
44
|
}
|
|
45
45
|
function AvatarRoot({ children, size = 'md' }) {
|
|
46
46
|
const [allImagesLoaded, setAllImagesLoaded] = useState(false);
|
|
47
|
-
const styles = useStyles(size);
|
|
47
|
+
const styles = useStyles({ size });
|
|
48
48
|
return (<AvatarContext.Provider value={{ size, allImagesLoaded, setAllImagesLoaded }}>
|
|
49
49
|
<View style={styles.rootContainer}>{children}</View>
|
|
50
50
|
</AvatarContext.Provider>);
|
|
@@ -59,11 +59,11 @@ function AvatarMask({ children, ...props }) {
|
|
|
59
59
|
AvatarMask.displayName = 'Avatar.Mask';
|
|
60
60
|
function AvatarImage({ sourceUri, ...props }) {
|
|
61
61
|
const { size } = useAvatarContext();
|
|
62
|
-
return <Image source={{ uri: sourceUri }} loaderSize={AVATAR_PX[size]} {...props}/>;
|
|
62
|
+
return <Image source={{ uri: sourceUri }} loaderSize={AVATAR_PX[size]} {...props} alt=""/>;
|
|
63
63
|
}
|
|
64
64
|
AvatarImage.displayName = 'Avatar.Image';
|
|
65
65
|
function AvatarGroupImage({ sourceUri, style, onLoad }) {
|
|
66
|
-
return (<Image source={{ uri: sourceUri }} loadingEnabled={false} wrapperStyle={style} onLoad={onLoad}/>);
|
|
66
|
+
return (<Image source={{ uri: sourceUri }} loadingEnabled={false} wrapperStyle={style} onLoad={onLoad} alt=""/>);
|
|
67
67
|
}
|
|
68
68
|
function AvatarGroup({ sourceUris }) {
|
|
69
69
|
const styles = useStyles();
|
|
@@ -126,7 +126,7 @@ AvatarGroup.displayName = 'Avatar.Group';
|
|
|
126
126
|
// =================================
|
|
127
127
|
function AvatarGroupLoader() {
|
|
128
128
|
const { size, allImagesLoaded } = useAvatarContext();
|
|
129
|
-
const styles = useStyles(size);
|
|
129
|
+
const styles = useStyles({ size });
|
|
130
130
|
if (allImagesLoaded)
|
|
131
131
|
return null;
|
|
132
132
|
return (<View style={styles.groupLoader}>
|
|
@@ -136,14 +136,11 @@ function AvatarGroupLoader() {
|
|
|
136
136
|
AvatarGroupLoader.displayName = 'Avatar.GroupLoader';
|
|
137
137
|
function AvatarPresence({ presence, ...props }) {
|
|
138
138
|
const { size } = useAvatarContext();
|
|
139
|
-
const styles = useStyles(size, presence);
|
|
139
|
+
const styles = useStyles({ size, presence });
|
|
140
140
|
return <View style={styles.presence} {...props}/>;
|
|
141
141
|
}
|
|
142
142
|
AvatarPresence.displayName = 'Avatar.Presence';
|
|
143
|
-
|
|
144
|
-
// ====== Styles ===================
|
|
145
|
-
// =================================
|
|
146
|
-
const useStyles = (size = 'md', presence = 'offline') => {
|
|
143
|
+
const useStyles = ({ size = 'md', presence = 'offline' } = {}) => {
|
|
147
144
|
const { colors } = useTheme();
|
|
148
145
|
const PRESENCE_COLOR = {
|
|
149
146
|
online: colors.fillColorInteractionOnlineDefault,
|