@planningcenter/chat-react-native 2.2.0-rc.1 → 2.2.0-rc.3
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 +28 -25
- package/build/components/conversations.js.map +1 -1
- package/build/components/display/banner.d.ts +6 -2
- package/build/components/display/banner.d.ts.map +1 -1
- package/build/components/display/banner.js +11 -1
- package/build/components/display/banner.js.map +1 -1
- package/build/components/display/banner_collapsible.d.ts +11 -0
- package/build/components/display/banner_collapsible.d.ts.map +1 -0
- package/build/components/display/banner_collapsible.js +46 -0
- package/build/components/display/banner_collapsible.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/primitive/banner_primitive.d.ts +7 -1
- package/build/components/primitive/banner_primitive.d.ts.map +1 -1
- package/build/components/primitive/banner_primitive.js +20 -4
- package/build/components/primitive/banner_primitive.js.map +1 -1
- package/build/screens/design_system_screen.d.ts.map +1 -1
- package/build/screens/design_system_screen.js +37 -1
- package/build/screens/design_system_screen.js.map +1 -1
- package/package.json +3 -2
- package/src/components/conversations.tsx +57 -54
- package/src/components/display/banner.tsx +16 -7
- package/src/components/display/banner_collapsible.tsx +71 -0
- package/src/components/display/index.ts +1 -0
- package/src/components/primitive/banner_primitive.tsx +48 -4
- package/src/screens/design_system_screen.tsx +49 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/components/conversations.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/components/conversations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,eAAO,MAAM,aAAa,yBAoEzB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useNavigation } from '@react-navigation/native';
|
|
2
|
+
import { FlashList } from '@shopify/flash-list';
|
|
2
3
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
+
import { Pressable, StyleSheet, View } from 'react-native';
|
|
4
5
|
import { useTheme } from '../hooks';
|
|
5
6
|
import { useConversationsJoltEvents } from '../hooks/use_conversation_jolt_events';
|
|
6
7
|
import { useConversations } from '../hooks/use_conversations';
|
|
@@ -13,32 +14,34 @@ export const Conversations = () => {
|
|
|
13
14
|
const nonEmptyConversations = conversations.filter(c => c.lastMessageTextPreview) || [];
|
|
14
15
|
const navigation = useNavigation();
|
|
15
16
|
useConversationsJoltEvents();
|
|
16
|
-
return (<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return (<View style={styles.container}>
|
|
18
|
+
<FlashList data={nonEmptyConversations} estimatedItemSize={97} contentContainerStyle={styles.contentContainer} onRefresh={refetch} refreshing={isRefetching} ListHeaderComponent={<View style={styles.header}>
|
|
19
|
+
<Heading numberOfLines={1} variant="h2">
|
|
20
|
+
Conversations
|
|
21
|
+
</Heading>
|
|
22
|
+
<TextButton>Mark all read</TextButton>
|
|
23
|
+
</View>} ListEmptyComponent={<Text>No conversations found</Text>} renderItem={({ item }) => (<Pressable style={styles.conversation} onPress={() => navigation.navigate('Conversation', {
|
|
22
24
|
conversation_id: item.id,
|
|
23
25
|
chat_group_graph_id: item.id,
|
|
24
26
|
})}>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
<AvatarGroup size="lg" sourceUris={item.previewAvatarUrls || []}/>
|
|
28
|
+
<View style={styles.conversationBody}>
|
|
29
|
+
<Heading numberOfLines={1} variant="h3" style={styles.conversationTitle}>
|
|
30
|
+
{item.title}
|
|
31
|
+
</Heading>
|
|
32
|
+
<Text style={styles.listItem} numberOfLines={2}>
|
|
33
|
+
{item.lastMessageAuthorName}: {item.lastMessageTextPreview}
|
|
34
|
+
</Text>
|
|
35
|
+
<View style={styles.conversationBadges}>
|
|
36
|
+
{item.badges?.map(badge => (<Badge key={badge.text} variant="meta" productLogoName={badge.appName} label={badge.pcoResourceType} metaLabel={badge.text || ''}/>))}
|
|
37
|
+
</View>
|
|
38
|
+
</View>
|
|
39
|
+
<View style={styles.conversationExtra}>
|
|
40
|
+
<Text variant="secondary">{formatDatePreview(item.lastMessageCreatedAt)}</Text>
|
|
41
|
+
<UnreadCountBadge count={item.unreadCount}/>
|
|
35
42
|
</View>
|
|
36
|
-
</
|
|
37
|
-
|
|
38
|
-
<Text variant="secondary">{formatDatePreview(item.lastMessageCreatedAt)}</Text>
|
|
39
|
-
<UnreadCountBadge count={item.unreadCount}/>
|
|
40
|
-
</View>
|
|
41
|
-
</Pressable>)} onEndReached={() => fetchNextPage()}/>);
|
|
43
|
+
</Pressable>)} onEndReached={() => fetchNextPage()}/>
|
|
44
|
+
</View>);
|
|
42
45
|
};
|
|
43
46
|
const UnreadCountBadge = ({ count }) => {
|
|
44
47
|
const styles = useStyles();
|
|
@@ -59,8 +62,8 @@ const useStyles = () => {
|
|
|
59
62
|
paddingBottom: 8,
|
|
60
63
|
paddingHorizontal: 16,
|
|
61
64
|
},
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
container: { flex: 1 },
|
|
66
|
+
contentContainer: { paddingVertical: 16 },
|
|
64
67
|
listItem: { color: colors.fillColorNeutral020 },
|
|
65
68
|
conversation: {
|
|
66
69
|
flexDirection: 'row',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/components/conversations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"conversations.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C,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport { FlashList } from '@shopify/flash-list'\nimport React from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport { useTheme } from '../hooks'\nimport { useConversationsJoltEvents } from '../hooks/use_conversation_jolt_events'\nimport { useConversations } from '../hooks/use_conversations'\nimport { formatDatePreview } from '../utils/date'\nimport { AvatarGroup, Badge, Heading, Text, TextButton } from './display'\n\nexport const Conversations = () => {\n const styles = useStyles()\n\n const { conversations, fetchNextPage, refetch, isRefetching } = useConversations()\n\n // TODO: Filter using the API\n const nonEmptyConversations = conversations.filter(c => c.lastMessageTextPreview) || []\n const navigation = useNavigation()\n\n useConversationsJoltEvents()\n\n return (\n <View style={styles.container}>\n <FlashList\n data={nonEmptyConversations}\n estimatedItemSize={97}\n contentContainerStyle={styles.contentContainer}\n onRefresh={refetch}\n refreshing={isRefetching}\n ListHeaderComponent={\n <View style={styles.header}>\n <Heading numberOfLines={1} variant=\"h2\">\n Conversations\n </Heading>\n <TextButton>Mark all read</TextButton>\n </View>\n }\n ListEmptyComponent={<Text>No conversations found</Text>}\n renderItem={({ item }) => (\n <Pressable\n style={styles.conversation}\n onPress={() =>\n navigation.navigate('Conversation', {\n conversation_id: item.id,\n chat_group_graph_id: item.id,\n })\n }\n >\n <AvatarGroup size=\"lg\" sourceUris={item.previewAvatarUrls || []} />\n <View style={styles.conversationBody}>\n <Heading numberOfLines={1} variant=\"h3\" style={styles.conversationTitle}>\n {item.title}\n </Heading>\n <Text style={styles.listItem} numberOfLines={2}>\n {item.lastMessageAuthorName}: {item.lastMessageTextPreview}\n </Text>\n <View style={styles.conversationBadges}>\n {item.badges?.map(badge => (\n <Badge\n key={badge.text}\n variant=\"meta\"\n productLogoName={badge.appName}\n label={badge.pcoResourceType}\n metaLabel={badge.text || ''}\n />\n ))}\n </View>\n </View>\n <View style={styles.conversationExtra}>\n <Text variant=\"secondary\">{formatDatePreview(item.lastMessageCreatedAt)}</Text>\n <UnreadCountBadge count={item.unreadCount} />\n </View>\n </Pressable>\n )}\n onEndReached={() => fetchNextPage()}\n />\n </View>\n )\n}\n\nconst UnreadCountBadge = ({ count }: { count: number }) => {\n const styles = useStyles()\n const displayCount = count > 99 ? '99+' : count\n\n if (count === 0) return null\n\n return (\n <Text variant=\"tertiary\" style={styles.unreadCountBadge}>\n {displayCount}\n </Text>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n header: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n paddingTop: 8,\n paddingBottom: 8,\n paddingHorizontal: 16,\n },\n container: { flex: 1 },\n contentContainer: { paddingVertical: 16 },\n listItem: { color: colors.fillColorNeutral020 },\n conversation: {\n flexDirection: 'row',\n gap: 8,\n borderBottomWidth: 1,\n borderBottomColor: colors.fillColorNeutral060,\n paddingTop: 4,\n paddingBottom: 12,\n paddingHorizontal: 16,\n },\n conversationTitle: {},\n conversationBody: {\n flex: 1,\n rowGap: 2,\n },\n conversationExtra: {\n rowGap: 2,\n },\n conversationBadges: {\n marginTop: 4,\n alignItems: 'flex-start',\n },\n unreadCountBadge: {\n alignSelf: 'flex-end',\n backgroundColor: colors.interaction,\n paddingVertical: 0,\n paddingHorizontal: 10,\n borderRadius: 24,\n color: 'white',\n },\n })\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
2
|
import { type BannerStatusIconProps, type BannerRootProps } from '../primitive/banner_primitive';
|
|
3
|
-
|
|
3
|
+
type descriptionUnion = string | ReactElement | undefined;
|
|
4
|
+
export interface BannerProps {
|
|
4
5
|
/**
|
|
5
6
|
* Changes the status color for the background, text, and icon.
|
|
6
7
|
* Sets a preset status icon.
|
|
@@ -10,7 +11,7 @@ interface BannerProps {
|
|
|
10
11
|
* Renders the banner's main text.
|
|
11
12
|
* If some of the text is interactive it can also take `BannerPrimitive.Link` wrapped in `BannerPrimitive.Text`.
|
|
12
13
|
*/
|
|
13
|
-
description
|
|
14
|
+
description?: descriptionUnion;
|
|
14
15
|
/**
|
|
15
16
|
* Renders the banner's heading text.
|
|
16
17
|
*/
|
|
@@ -25,5 +26,8 @@ interface BannerProps {
|
|
|
25
26
|
showIcon?: boolean;
|
|
26
27
|
}
|
|
27
28
|
export declare function Banner({ appearance, description, heading, iconName, showIcon, }: BannerProps): React.JSX.Element | null;
|
|
29
|
+
export declare function ConditionalDescription({ description }: {
|
|
30
|
+
description: descriptionUnion;
|
|
31
|
+
}): React.JSX.Element | null;
|
|
28
32
|
export {};
|
|
29
33
|
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../src/components/display/banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAkB,YAAY,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAwB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAA;AAEtC,
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../src/components/display/banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAkB,YAAY,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAwB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAA;AAEtC,KAAK,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,CAAA;AAEzD,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAA;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,MAAM,CAAC,EACrB,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAe,GAChB,EAAE,WAAW,4BAcb;AAED,wBAAgB,sBAAsB,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,gBAAgB,CAAA;CAAE,4BASxF"}
|
|
@@ -8,9 +8,19 @@ export function Banner({ appearance, description, heading, iconName, showIcon =
|
|
|
8
8
|
{showIcon && <BannerPrimitive.StatusIcon iconName={iconName}/>}
|
|
9
9
|
<BannerPrimitive.Content>
|
|
10
10
|
{Boolean(heading) && <BannerPrimitive.Heading>{heading}</BannerPrimitive.Heading>}
|
|
11
|
-
|
|
11
|
+
<ConditionalDescription description={description}/>
|
|
12
12
|
</BannerPrimitive.Content>
|
|
13
13
|
</BannerPrimitive.StaticLayout>
|
|
14
14
|
</BannerPrimitive.Root>);
|
|
15
15
|
}
|
|
16
|
+
export function ConditionalDescription({ description }) {
|
|
17
|
+
switch (true) {
|
|
18
|
+
case description === undefined:
|
|
19
|
+
return null;
|
|
20
|
+
case isValidElement(description):
|
|
21
|
+
return description;
|
|
22
|
+
default:
|
|
23
|
+
return <BannerPrimitive.Text>{description}</BannerPrimitive.Text>;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
16
26
|
//# sourceMappingURL=banner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../src/components/display/banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAgB,MAAM,OAAO,CAAA;AAC3D,OAAO,eAGN,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../src/components/display/banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAgB,MAAM,OAAO,CAAA;AAC3D,OAAO,eAGN,MAAM,+BAA+B,CAAA;AA6BtC,MAAM,UAAU,MAAM,CAAC,EACrB,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAQ,GAAG,IAAI,GACH;IACZ,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAEzC,OAAO,CACL,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAC3C;MAAA,CAAC,eAAe,CAAC,YAAY,CAC3B;QAAA,CAAC,QAAQ,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAG,CAC/D;QAAA,CAAC,eAAe,CAAC,OAAO,CACtB;UAAA,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CACjF;UAAA,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,EACnD;QAAA,EAAE,eAAe,CAAC,OAAO,CAC3B;MAAA,EAAE,eAAe,CAAC,YAAY,CAChC;IAAA,EAAE,eAAe,CAAC,IAAI,CAAC,CACxB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EAAE,WAAW,EAAqC;IACvF,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW,KAAK,SAAS;YAC5B,OAAO,IAAI,CAAA;QACb,KAAK,cAAc,CAAC,WAAW,CAAC;YAC9B,OAAO,WAAW,CAAA;QACpB;YACE,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;IACrE,CAAC;AACH,CAAC","sourcesContent":["import React, { isValidElement, ReactElement } from 'react'\nimport BannerPrimitive, {\n type BannerStatusIconProps,\n type BannerRootProps,\n} from '../primitive/banner_primitive'\n\ntype descriptionUnion = string | ReactElement | undefined\n\nexport interface BannerProps {\n /**\n * Changes the status color for the background, text, and icon.\n * Sets a preset status icon.\n */\n appearance?: BannerRootProps['appearance']\n /**\n * Renders the banner's main text.\n * If some of the text is interactive it can also take `BannerPrimitive.Link` wrapped in `BannerPrimitive.Text`.\n */\n description?: descriptionUnion\n /**\n * Renders the banner's heading text.\n */\n heading?: string\n /**\n * Overrides the preset status icon.\n */\n iconName?: BannerStatusIconProps['iconName']\n /**\n * Hides the status icon. By default, the status icon is shown.\n */\n showIcon?: boolean\n}\n\nexport function Banner({\n appearance,\n description,\n heading,\n iconName,\n showIcon = true,\n}: BannerProps) {\n if (!description && !heading) return null\n\n return (\n <BannerPrimitive.Root appearance={appearance}>\n <BannerPrimitive.StaticLayout>\n {showIcon && <BannerPrimitive.StatusIcon iconName={iconName} />}\n <BannerPrimitive.Content>\n {Boolean(heading) && <BannerPrimitive.Heading>{heading}</BannerPrimitive.Heading>}\n <ConditionalDescription description={description} />\n </BannerPrimitive.Content>\n </BannerPrimitive.StaticLayout>\n </BannerPrimitive.Root>\n )\n}\n\nexport function ConditionalDescription({ description }: { description: descriptionUnion }) {\n switch (true) {\n case description === undefined:\n return null\n case isValidElement(description):\n return description\n default:\n return <BannerPrimitive.Text>{description}</BannerPrimitive.Text>\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { BannerProps } from './banner';
|
|
3
|
+
interface BannerCollapsibleProps extends BannerProps {
|
|
4
|
+
/**
|
|
5
|
+
* Hidden by default and shown when the banner is expanded.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function BannerCollapsible({ appearance, children, description, heading, iconName, showIcon, }: BannerCollapsibleProps): React.JSX.Element | null;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=banner_collapsible.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner_collapsible.d.ts","sourceRoot":"","sources":["../../../src/components/display/banner_collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,WAAW,EAA0B,MAAM,UAAU,CAAA;AAiC9D,UAAU,sBAAuB,SAAQ,WAAW;IAClD;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAe,GAChB,EAAE,sBAAsB,4BAsBxB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConditionalDescription } from './banner';
|
|
3
|
+
import BannerPrimitive from '../primitive/banner_primitive';
|
|
4
|
+
import { LayoutAnimation } from 'react-native';
|
|
5
|
+
// =================================
|
|
6
|
+
// ====== Constants ================
|
|
7
|
+
// =================================
|
|
8
|
+
const OPACITY_DURATION = 100; // Ensures the content fades before the height rolls up
|
|
9
|
+
const collapsibleAnimationConfig = {
|
|
10
|
+
duration: 300,
|
|
11
|
+
create: {
|
|
12
|
+
type: LayoutAnimation.Types.easeInEaseOut,
|
|
13
|
+
property: LayoutAnimation.Properties.opacity,
|
|
14
|
+
duration: OPACITY_DURATION,
|
|
15
|
+
},
|
|
16
|
+
update: {
|
|
17
|
+
type: LayoutAnimation.Types.easeInEaseOut,
|
|
18
|
+
property: LayoutAnimation.Properties.opacity,
|
|
19
|
+
duration: OPACITY_DURATION,
|
|
20
|
+
},
|
|
21
|
+
delete: {
|
|
22
|
+
type: LayoutAnimation.Types.easeInEaseOut,
|
|
23
|
+
property: LayoutAnimation.Properties.opacity,
|
|
24
|
+
duration: OPACITY_DURATION,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export function BannerCollapsible({ appearance, children, description, heading, iconName, showIcon = true, }) {
|
|
28
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
29
|
+
const toggleCollapsible = () => {
|
|
30
|
+
LayoutAnimation.configureNext(collapsibleAnimationConfig);
|
|
31
|
+
setExpanded(prev => !prev);
|
|
32
|
+
};
|
|
33
|
+
if (!description && !heading)
|
|
34
|
+
return null;
|
|
35
|
+
return (<BannerPrimitive.Root appearance={appearance}>
|
|
36
|
+
<BannerPrimitive.CollapsibleLayout onPress={toggleCollapsible} expanded={expanded}>
|
|
37
|
+
{showIcon && <BannerPrimitive.StatusIcon iconName={iconName}/>}
|
|
38
|
+
<BannerPrimitive.Content>
|
|
39
|
+
{Boolean(heading) && <BannerPrimitive.Heading>{heading}</BannerPrimitive.Heading>}
|
|
40
|
+
<ConditionalDescription description={description}/>
|
|
41
|
+
{expanded ? children : null}
|
|
42
|
+
</BannerPrimitive.Content>
|
|
43
|
+
</BannerPrimitive.CollapsibleLayout>
|
|
44
|
+
</BannerPrimitive.Root>);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=banner_collapsible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner_collapsible.js","sourceRoot":"","sources":["../../../src/components/display/banner_collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EAAe,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,gBAAgB,GAAG,GAAG,CAAA,CAAC,uDAAuD;AAEpF,MAAM,0BAA0B,GAAG;IACjC,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE;QACN,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,aAAa;QACzC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,OAAO;QAC5C,QAAQ,EAAE,gBAAgB;KAC3B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,eAAe,CA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AW,CAAC,EACjD;UAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAC7B;QAAA,EAAE,eAAe,CAAC,OAAO,CAC3B;MAAA,EAAE,eAAe,CAAC,iBAAiB,CACrC;IAAA,EAAE,eAAe,CAAC,IAAI,CAAC,CACxB,CAAA;AACH,CAAC","sourcesContent":["import React, { ReactNode } from 'react'\nimport { BannerProps, ConditionalDescription } from './banner'\nimport BannerPrimitive from '../primitive/banner_primitive'\nimport { LayoutAnimation } from 'react-native'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst OPACITY_DURATION = 100 // Ensures the content fades before the height rolls up\n\nconst collapsibleAnimationConfig = {\n duration: 300,\n create: {\n type: LayoutAnimation.Types.easeInEaseOut,\n property: LayoutAnimation.Properties.opacity,\n duration: OPACITY_DURATION,\n },\n update: {\n type: LayoutAnimation.Types.easeInEaseOut,\n property: LayoutAnimation.Properties.opacity,\n duration: OPACITY_DURATION,\n },\n delete: {\n type: LayoutAnimation.Types.easeInEaseOut,\n property: LayoutAnimation.Properties.opacity,\n duration: OPACITY_DURATION,\n },\n}\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface BannerCollapsibleProps extends BannerProps {\n /**\n * Hidden by default and shown when the banner is expanded.\n */\n children?: ReactNode\n}\n\nexport function BannerCollapsible({\n appearance,\n children,\n description,\n heading,\n iconName,\n showIcon = true,\n}: BannerCollapsibleProps) {\n const [expanded, setExpanded] = React.useState(false)\n\n const toggleCollapsible = () => {\n LayoutAnimation.configureNext(collapsibleAnimationConfig)\n setExpanded(prev => !prev)\n }\n\n if (!description && !heading) return null\n\n return (\n <BannerPrimitive.Root appearance={appearance}>\n <BannerPrimitive.CollapsibleLayout onPress={toggleCollapsible} expanded={expanded}>\n {showIcon && <BannerPrimitive.StatusIcon iconName={iconName} />}\n <BannerPrimitive.Content>\n {Boolean(heading) && <BannerPrimitive.Heading>{heading}</BannerPrimitive.Heading>}\n <ConditionalDescription description={description} />\n {expanded ? children : null}\n </BannerPrimitive.Content>\n </BannerPrimitive.CollapsibleLayout>\n </BannerPrimitive.Root>\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,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,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,UAAU,CAAA;AACxB,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,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,sBAAsB,CAAA;AACpC,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,UAAU,CAAA;AACxB,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,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,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,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './avatar'\nexport * from './avatar_group'\nexport * from './badge'\nexport * from './banner'\nexport * from './button'\nexport * from './heading'\nexport * from './icon'\nexport * from './icon_button'\nexport * from './image'\nexport * from './spinner'\nexport * from './switch'\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,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,sBAAsB,CAAA;AACpC,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,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './avatar'\nexport * from './avatar_group'\nexport * from './badge'\nexport * from './banner'\nexport * from './banner_collapsible'\nexport * from './button'\nexport * from './heading'\nexport * from './icon'\nexport * from './icon_button'\nexport * from './image'\nexport * from './spinner'\nexport * from './switch'\nexport * from './text'\nexport * from './text_button'\nexport * from './text_inline_button'\n"]}
|
|
@@ -3,6 +3,7 @@ import { type StatusAppearanceUnion } from '../display/utils/status_colors';
|
|
|
3
3
|
type BannerComponents = {
|
|
4
4
|
Root: FC<BannerRootProps>;
|
|
5
5
|
StaticLayout: FC<BannerStaticLayoutProps>;
|
|
6
|
+
CollapsibleLayout: FC<BannerCollapsibleLayoutProps>;
|
|
6
7
|
Content: FC<BannerContentProps>;
|
|
7
8
|
StatusIcon: FC<BannerStatusIconProps>;
|
|
8
9
|
Heading: FC<BannerHeadingProps>;
|
|
@@ -11,7 +12,7 @@ type BannerComponents = {
|
|
|
11
12
|
};
|
|
12
13
|
declare const _default: BannerComponents;
|
|
13
14
|
export default _default;
|
|
14
|
-
export type { BannerRootProps, BannerStaticLayoutProps, BannerContentProps, BannerStatusIconProps, BannerHeadingProps, BannerTextProps, BannerLinkProps, };
|
|
15
|
+
export type { BannerRootProps, BannerStaticLayoutProps, BannerCollapsibleLayoutProps, BannerContentProps, BannerStatusIconProps, BannerHeadingProps, BannerTextProps, BannerLinkProps, };
|
|
15
16
|
interface BannerRootProps {
|
|
16
17
|
children: ReactNode;
|
|
17
18
|
appearance?: StatusAppearanceUnion;
|
|
@@ -19,6 +20,11 @@ interface BannerRootProps {
|
|
|
19
20
|
interface BannerStaticLayoutProps {
|
|
20
21
|
children: ReactNode;
|
|
21
22
|
}
|
|
23
|
+
interface BannerCollapsibleLayoutProps {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
expanded?: boolean;
|
|
26
|
+
onPress?: () => void;
|
|
27
|
+
}
|
|
22
28
|
interface BannerContentProps {
|
|
23
29
|
children: ReactNode;
|
|
24
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner_primitive.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/banner_primitive.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAiB,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAA;AAEvE,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"banner_primitive.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/banner_primitive.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAiB,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,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QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React, { createContext, useContext } from 'react';
|
|
2
|
-
import { StyleSheet, View } from 'react-native';
|
|
2
|
+
import { Pressable, StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useStatusColorAppearanceMap, } from '../display/utils/status_colors';
|
|
4
|
-
import { MAX_FONT_SIZE_MULTIPLIER, platformFontWeightMedium, space } from '../../utils';
|
|
4
|
+
import { MAX_FONT_SIZE_MULTIPLIER, platformFontWeightMedium, platformPressedOpacityStyle, space, } from '../../utils';
|
|
5
5
|
import { tokens } from '../../vendor/tapestry/tokens';
|
|
6
6
|
import { Heading, Icon, Text, TextInlineButton } from '../display';
|
|
7
|
-
import { useFontScale } from '../../hooks';
|
|
7
|
+
import { useCreateAndroidRippleColor, useFontScale } from '../../hooks';
|
|
8
8
|
// ========================================
|
|
9
9
|
// ====== Exports =========================
|
|
10
10
|
// ========================================
|
|
11
11
|
const Banner = {
|
|
12
12
|
Root: BannerRoot,
|
|
13
13
|
StaticLayout: BannerStaticLayout,
|
|
14
|
+
CollapsibleLayout: BannerCollapsibleLayout,
|
|
14
15
|
Content: BannerContent,
|
|
15
16
|
StatusIcon: BannerStatusIcon,
|
|
16
17
|
Heading: BannerHeading,
|
|
@@ -36,6 +37,20 @@ function BannerStaticLayout({ children }) {
|
|
|
36
37
|
return <View style={styles.staticLayout}>{children}</View>;
|
|
37
38
|
}
|
|
38
39
|
BannerStaticLayout.displayName = 'Banner.StaticLayout';
|
|
40
|
+
function BannerCollapsibleLayout({ children, expanded, onPress }) {
|
|
41
|
+
const { appearance = 'neutral' } = useBannerContext();
|
|
42
|
+
const styles = useStyles({ appearance });
|
|
43
|
+
const iconName = expanded ? 'general.upCaret' : 'general.downCaret';
|
|
44
|
+
const statusColorMap = useStatusColorAppearanceMap();
|
|
45
|
+
const androidRippleColor = useCreateAndroidRippleColor({
|
|
46
|
+
color: statusColorMap[appearance].background,
|
|
47
|
+
});
|
|
48
|
+
return (<Pressable onPress={onPress} style={({ pressed }) => [styles.staticLayout, pressed && platformPressedOpacityStyle]} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }} accessibilityState={{ expanded }} accessibilityRole="button">
|
|
49
|
+
{children}
|
|
50
|
+
<Icon name={iconName} style={styles.icon} maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}/>
|
|
51
|
+
</Pressable>);
|
|
52
|
+
}
|
|
53
|
+
BannerCollapsibleLayout.displayName = 'Banner.CollapsibleLayout';
|
|
39
54
|
function BannerContent({ children }) {
|
|
40
55
|
const styles = useStyles();
|
|
41
56
|
return <View style={styles.content}>{children}</View>;
|
|
@@ -81,6 +96,7 @@ BannerLink.displayName = 'Banner.Link';
|
|
|
81
96
|
const useStyles = ({ appearance = 'neutral' } = {}) => {
|
|
82
97
|
const statusColorMap = useStatusColorAppearanceMap();
|
|
83
98
|
const fontScale = useFontScale();
|
|
99
|
+
const LINE_HEIGHT_OFFSET = 1;
|
|
84
100
|
return StyleSheet.create({
|
|
85
101
|
staticLayout: {
|
|
86
102
|
flexDirection: 'row',
|
|
@@ -97,7 +113,7 @@ const useStyles = ({ appearance = 'neutral' } = {}) => {
|
|
|
97
113
|
icon: {
|
|
98
114
|
color: statusColorMap[appearance].icon,
|
|
99
115
|
fontSize: tokens.fontSizeMd,
|
|
100
|
-
marginTop: space(0.5) * fontScale,
|
|
116
|
+
marginTop: space(0.5) - LINE_HEIGHT_OFFSET * fontScale,
|
|
101
117
|
},
|
|
102
118
|
heading: {
|
|
103
119
|
color: statusColorMap[appearance].text,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner_primitive.js","sourceRoot":"","sources":["../../../src/components/primitive/banner_primitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAiB,UAAU,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,E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EAAE,UAAU,GAAG,SAAS,KAAa,EAAE,EAAE,EAAE;IAC5D,MAAM,cAAc,GAAG,2BAA2B,EAAE,CAAA;IACpD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,YAAY,EAAE;YACZ,aAAa,EAAE,KAAK;YACpB,eAAe,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,UAAU;YACtD,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC;YACnB,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACb,YAAY,EAAE,MAAM,CAAC,cAAc;YACnC,IAAI,EAAE,CAAC;SACR;QACD,OAAO,EAAE;YACP,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC;YACf,IAAI,EAAE,CAAC;SACR;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI;YACtC,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS;SAClC;QACD,OAAO,EAAE;YACP,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI;YACtC,UAAU,EAAE,wBAAwB;YACpC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI;SACvC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { createContext, FC, ReactNode, useContext } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport {\n useStatusColorAppearanceMap,\n type StatusAppearanceUnion,\n} from '../display/utils/status_colors'\nimport { MAX_FONT_SIZE_MULTIPLIER, platformFontWeightMedium, space } from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Heading, Icon, Text, TextInlineButton } from '../display'\nimport { useFontScale } from '../../hooks'\n\n// ========================================\n// ====== Exports =========================\n// ========================================\n\nconst Banner = {\n Root: BannerRoot,\n StaticLayout: BannerStaticLayout,\n Content: BannerContent,\n StatusIcon: BannerStatusIcon,\n Heading: BannerHeading,\n Text: BannerText,\n Link: BannerLink,\n} as const\n\ntype BannerComponents = {\n Root: FC<BannerRootProps>\n StaticLayout: FC<BannerStaticLayoutProps>\n Content: FC<BannerContentProps>\n StatusIcon: FC<BannerStatusIconProps>\n Heading: FC<BannerHeadingProps>\n Text: FC<BannerTextProps>\n Link: FC<BannerLinkProps>\n}\n\nexport default Banner as BannerComponents\nexport type {\n BannerRootProps,\n BannerStaticLayoutProps,\n BannerContentProps,\n BannerStatusIconProps,\n BannerHeadingProps,\n BannerTextProps,\n BannerLinkProps,\n}\n\n// ========================================\n// ====== Context =========================\n// ========================================\n\ninterface BannerContextType {\n appearance?: StatusAppearanceUnion\n}\n\nconst BannerContext = createContext<BannerContextType | null>(null)\n\nfunction useBannerContext() {\n const context = useContext(BannerContext)\n if (!context) {\n throw new Error('Banner components must be used within Banner.Root')\n }\n return context\n}\n\n// ========================================\n// ====== BannerRoot ======================\n// ========================================\n\ninterface BannerRootProps {\n children: ReactNode\n appearance?: StatusAppearanceUnion\n}\n\nfunction BannerRoot({ children, appearance = 'neutral' }: BannerRootProps) {\n return <BannerContext.Provider value={{ appearance }}>{children}</BannerContext.Provider>\n}\n\nBannerRoot.displayName = 'Banner.Root'\n\n// ========================================\n// ====== BannerStaticLayout ==============\n// ========================================\n\ninterface BannerStaticLayoutProps {\n children: ReactNode\n}\n\nfunction BannerStaticLayout({ children }: BannerStaticLayoutProps) {\n const { appearance } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return <View style={styles.staticLayout}>{children}</View>\n}\n\nBannerStaticLayout.displayName = 'Banner.StaticLayout'\n\n// ========================================\n// ====== BannerContent ===================\n// ========================================\n\ninterface BannerContentProps {\n children: ReactNode\n}\n\nfunction BannerContent({ children }: BannerContentProps) {\n const styles = useStyles()\n\n return <View style={styles.content}>{children}</View>\n}\n\nBannerContent.displayName = 'Banner.Content'\n\n// ========================================\n// ====== BannerStatusIcon ================\n// ========================================\n\ninterface BannerStatusIconProps {\n iconName?: string\n}\n\nfunction BannerStatusIcon({ iconName }: BannerStatusIconProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n const iconNameMap = {\n error: 'general.exclamationTriangle',\n info: 'general.outlinedInfoCircle',\n neutral: 'general.outlinedInfoCircle',\n success: 'general.check',\n warning: 'general.exclamationTriangle',\n } as const\n\n return (\n <Icon\n name={iconName || iconNameMap[appearance]}\n style={styles.icon}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}\n />\n )\n}\n\nBannerStatusIcon.displayName = 'Banner.StatusIcon'\n\n// ========================================\n// ====== BannerHeading ===================\n// ========================================\n\ninterface BannerHeadingProps {\n children: ReactNode\n}\n\nfunction BannerHeading({ children }: BannerHeadingProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return (\n <Heading variant=\"h3\" style={styles.heading}>\n {children}\n </Heading>\n )\n}\n\nBannerHeading.displayName = 'Banner.Heading'\n\n// ========================================\n// ====== BannerText ======================\n// ========================================\n\ninterface BannerTextProps {\n children: ReactNode\n}\n\nfunction BannerText({ children }: BannerTextProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return (\n <Text variant=\"tertiary\" style={styles.text}>\n {children}\n </Text>\n )\n}\n\nBannerText.displayName = 'Banner.Text'\n\n// ========================================\n// ====== BannerLink ======================\n// ========================================\n\ninterface BannerLinkProps {\n children: ReactNode\n onPress?: () => void\n}\n\nfunction BannerLink({ children, onPress }: BannerLinkProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return (\n <TextInlineButton variant=\"tertiary\" style={styles.text} onPress={onPress}>\n {children}\n </TextInlineButton>\n )\n}\n\nBannerLink.displayName = 'Banner.Link'\n\n// ========================================\n// ====== Styles ==========================\n// ========================================\n\ninterface Styles {\n appearance?: StatusAppearanceUnion\n}\n\nconst useStyles = ({ appearance = 'neutral' }: Styles = {}) => {\n const statusColorMap = useStatusColorAppearanceMap()\n const fontScale = useFontScale()\n\n return StyleSheet.create({\n staticLayout: {\n flexDirection: 'row',\n backgroundColor: statusColorMap[appearance].background,\n padding: space(1.5),\n gap: space(1),\n borderRadius: tokens.borderRadiusMd,\n flex: 1,\n },\n content: {\n gap: space(0.5),\n flex: 1,\n },\n icon: {\n color: statusColorMap[appearance].icon,\n fontSize: tokens.fontSizeMd,\n marginTop: space(0.5) * fontScale,\n },\n heading: {\n color: statusColorMap[appearance].text,\n fontWeight: platformFontWeightMedium,\n fontSize: tokens.fontSizeMd,\n },\n text: {\n color: statusColorMap[appearance].text,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"banner_primitive.js","sourceRoot":"","sources":["../../../src/components/primitive/banner_primitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAiB,UAAU,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EACL,2BAA2B,GAE5B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,KAAK,GACN,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvE,2CAA2C;AAC3C,2CAA2C;AAC3C,2CAA2C;AAE3C,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,kBAAkB;IAChC,iBAAiB,EAAE,uBAAuB;IAC1C,OAAO,EAA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C,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,kBAAkB,GAAG,SAAS;SACvD;QACD,OAAO,EAAE;YACP,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI;YACtC,UAAU,EAAE,wBAAwB;YACpC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI;SACvC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { createContext, FC, ReactNode, useContext } from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport {\n useStatusColorAppearanceMap,\n type StatusAppearanceUnion,\n} from '../display/utils/status_colors'\nimport {\n MAX_FONT_SIZE_MULTIPLIER,\n platformFontWeightMedium,\n platformPressedOpacityStyle,\n space,\n} from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Heading, Icon, Text, TextInlineButton } from '../display'\nimport { useCreateAndroidRippleColor, useFontScale } from '../../hooks'\n\n// ========================================\n// ====== Exports =========================\n// ========================================\n\nconst Banner = {\n Root: BannerRoot,\n StaticLayout: BannerStaticLayout,\n CollapsibleLayout: BannerCollapsibleLayout,\n Content: BannerContent,\n StatusIcon: BannerStatusIcon,\n Heading: BannerHeading,\n Text: BannerText,\n Link: BannerLink,\n} as const\n\ntype BannerComponents = {\n Root: FC<BannerRootProps>\n StaticLayout: FC<BannerStaticLayoutProps>\n CollapsibleLayout: FC<BannerCollapsibleLayoutProps>\n Content: FC<BannerContentProps>\n StatusIcon: FC<BannerStatusIconProps>\n Heading: FC<BannerHeadingProps>\n Text: FC<BannerTextProps>\n Link: FC<BannerLinkProps>\n}\n\nexport default Banner as BannerComponents\nexport type {\n BannerRootProps,\n BannerStaticLayoutProps,\n BannerCollapsibleLayoutProps,\n BannerContentProps,\n BannerStatusIconProps,\n BannerHeadingProps,\n BannerTextProps,\n BannerLinkProps,\n}\n\n// ========================================\n// ====== Context =========================\n// ========================================\n\ninterface BannerContextType {\n appearance?: StatusAppearanceUnion\n}\n\nconst BannerContext = createContext<BannerContextType | null>(null)\n\nfunction useBannerContext() {\n const context = useContext(BannerContext)\n if (!context) {\n throw new Error('Banner components must be used within Banner.Root')\n }\n return context\n}\n\n// ========================================\n// ====== BannerRoot ======================\n// ========================================\n\ninterface BannerRootProps {\n children: ReactNode\n appearance?: StatusAppearanceUnion\n}\n\nfunction BannerRoot({ children, appearance = 'neutral' }: BannerRootProps) {\n return <BannerContext.Provider value={{ appearance }}>{children}</BannerContext.Provider>\n}\n\nBannerRoot.displayName = 'Banner.Root'\n\n// ========================================\n// ====== BannerStaticLayout ==============\n// ========================================\n\ninterface BannerStaticLayoutProps {\n children: ReactNode\n}\n\nfunction BannerStaticLayout({ children }: BannerStaticLayoutProps) {\n const { appearance } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return <View style={styles.staticLayout}>{children}</View>\n}\n\nBannerStaticLayout.displayName = 'Banner.StaticLayout'\n\n// ========================================\n// ====== BannerCollapsibleLayout =========\n// ========================================\n\ninterface BannerCollapsibleLayoutProps {\n children: ReactNode\n expanded?: boolean\n onPress?: () => void\n}\n\nfunction BannerCollapsibleLayout({ children, expanded, onPress }: BannerCollapsibleLayoutProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n const iconName = expanded ? 'general.upCaret' : 'general.downCaret'\n const statusColorMap = useStatusColorAppearanceMap()\n const androidRippleColor = useCreateAndroidRippleColor({\n color: statusColorMap[appearance].background,\n })\n\n return (\n <Pressable\n onPress={onPress}\n style={({ pressed }) => [styles.staticLayout, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n accessibilityState={{ expanded }}\n accessibilityRole=\"button\"\n >\n {children}\n <Icon name={iconName} style={styles.icon} maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER} />\n </Pressable>\n )\n}\n\nBannerCollapsibleLayout.displayName = 'Banner.CollapsibleLayout'\n\n// ========================================\n// ====== BannerContent ===================\n// ========================================\n\ninterface BannerContentProps {\n children: ReactNode\n}\n\nfunction BannerContent({ children }: BannerContentProps) {\n const styles = useStyles()\n\n return <View style={styles.content}>{children}</View>\n}\n\nBannerContent.displayName = 'Banner.Content'\n\n// ========================================\n// ====== BannerStatusIcon ================\n// ========================================\n\ninterface BannerStatusIconProps {\n iconName?: string\n}\n\nfunction BannerStatusIcon({ iconName }: BannerStatusIconProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n const iconNameMap = {\n error: 'general.exclamationTriangle',\n info: 'general.outlinedInfoCircle',\n neutral: 'general.outlinedInfoCircle',\n success: 'general.check',\n warning: 'general.exclamationTriangle',\n } as const\n\n return (\n <Icon\n name={iconName || iconNameMap[appearance]}\n style={styles.icon}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}\n />\n )\n}\n\nBannerStatusIcon.displayName = 'Banner.StatusIcon'\n\n// ========================================\n// ====== BannerHeading ===================\n// ========================================\n\ninterface BannerHeadingProps {\n children: ReactNode\n}\n\nfunction BannerHeading({ children }: BannerHeadingProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return (\n <Heading variant=\"h3\" style={styles.heading}>\n {children}\n </Heading>\n )\n}\n\nBannerHeading.displayName = 'Banner.Heading'\n\n// ========================================\n// ====== BannerText ======================\n// ========================================\n\ninterface BannerTextProps {\n children: ReactNode\n}\n\nfunction BannerText({ children }: BannerTextProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return (\n <Text variant=\"tertiary\" style={styles.text}>\n {children}\n </Text>\n )\n}\n\nBannerText.displayName = 'Banner.Text'\n\n// ========================================\n// ====== BannerLink ======================\n// ========================================\n\ninterface BannerLinkProps {\n children: ReactNode\n onPress?: () => void\n}\n\nfunction BannerLink({ children, onPress }: BannerLinkProps) {\n const { appearance = 'neutral' } = useBannerContext()\n const styles = useStyles({ appearance })\n\n return (\n <TextInlineButton variant=\"tertiary\" style={styles.text} onPress={onPress}>\n {children}\n </TextInlineButton>\n )\n}\n\nBannerLink.displayName = 'Banner.Link'\n\n// ========================================\n// ====== Styles ==========================\n// ========================================\n\ninterface Styles {\n appearance?: StatusAppearanceUnion\n}\n\nconst useStyles = ({ appearance = 'neutral' }: Styles = {}) => {\n const statusColorMap = useStatusColorAppearanceMap()\n const fontScale = useFontScale()\n const LINE_HEIGHT_OFFSET = 1\n\n return StyleSheet.create({\n staticLayout: {\n flexDirection: 'row',\n backgroundColor: statusColorMap[appearance].background,\n padding: space(1.5),\n gap: space(1),\n borderRadius: tokens.borderRadiusMd,\n flex: 1,\n },\n content: {\n gap: space(0.5),\n flex: 1,\n },\n icon: {\n color: statusColorMap[appearance].icon,\n fontSize: tokens.fontSizeMd,\n marginTop: space(0.5) - LINE_HEIGHT_OFFSET * fontScale,\n },\n heading: {\n color: statusColorMap[appearance].text,\n fontWeight: platformFontWeightMedium,\n fontSize: tokens.fontSizeMd,\n },\n text: {\n color: statusColorMap[appearance].text,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design_system_screen.d.ts","sourceRoot":"","sources":["../../src/screens/design_system_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"design_system_screen.d.ts","sourceRoot":"","sources":["../../src/screens/design_system_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AA0DvC,wBAAgB,kBAAkB,sBAgBjC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { Alert, Pressable, ScrollView, StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useTheme } from '../hooks';
|
|
4
|
-
import { Avatar, AvatarGroup, Badge, Banner, Button, Heading, Icon, IconButton, Image, Spinner, Switch, Text, TextButton, TextInlineButton, } from '../components/display';
|
|
4
|
+
import { Avatar, AvatarGroup, Badge, Banner, BannerCollapsible, Button, Heading, Icon, IconButton, Image, Spinner, Switch, Text, TextButton, TextInlineButton, } from '../components/display';
|
|
5
5
|
import { space, MAX_FONT_SIZE_MULTIPLIER, platformPressedOpacityStyle, platformFontWeightMedium, } from '../utils';
|
|
6
6
|
import BannerPrimitive from '../components/primitive/banner_primitive';
|
|
7
7
|
// =================================
|
|
@@ -446,6 +446,42 @@ function StatusComponentsSection({ isLast }) {
|
|
|
446
446
|
<Banner appearance="error" heading="Banner heading" description="Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt."/>
|
|
447
447
|
</Column>
|
|
448
448
|
</Group>
|
|
449
|
+
<Group title="BannerCollapsible" description="Same as `Banner` but takes children that can be hidden/revealed on a tap.">
|
|
450
|
+
<Column>
|
|
451
|
+
<BannerCollapsible appearance="neutral" showIcon={false} heading="Banner heading">
|
|
452
|
+
<BannerPrimitive.Text>
|
|
453
|
+
Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt.
|
|
454
|
+
</BannerPrimitive.Text>
|
|
455
|
+
</BannerCollapsible>
|
|
456
|
+
<BannerCollapsible appearance="info" heading="Banner heading">
|
|
457
|
+
<BannerPrimitive.Text>
|
|
458
|
+
Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt.
|
|
459
|
+
</BannerPrimitive.Text>
|
|
460
|
+
</BannerCollapsible>
|
|
461
|
+
<BannerCollapsible appearance="success" heading="Banner heading">
|
|
462
|
+
<BannerPrimitive.Text>
|
|
463
|
+
Et sint Quis non excepturi{' '}
|
|
464
|
+
<BannerPrimitive.Link onPress={buttonPress}>
|
|
465
|
+
enim et conseq atur porro est
|
|
466
|
+
</BannerPrimitive.Link>{' '}
|
|
467
|
+
galisum labore ea volupt.
|
|
468
|
+
</BannerPrimitive.Text>
|
|
469
|
+
</BannerCollapsible>
|
|
470
|
+
<BannerCollapsible appearance="warning" iconName="general.shieldExclamation" heading="13 members under age 13" description="Et sint Quis non excepturi enim et conse.">
|
|
471
|
+
<BannerPrimitive.Text>
|
|
472
|
+
More hdden content that can be revealed on a tap. Lorem ipsum dolor sit amet,
|
|
473
|
+
consectetur
|
|
474
|
+
</BannerPrimitive.Text>
|
|
475
|
+
</BannerCollapsible>
|
|
476
|
+
<BannerCollapsible appearance="error" heading="Banner heading" description="Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt.">
|
|
477
|
+
<BannerPrimitive.Text>
|
|
478
|
+
Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt. Et
|
|
479
|
+
sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt. Et
|
|
480
|
+
sint Quis non excepturi enim et .
|
|
481
|
+
</BannerPrimitive.Text>
|
|
482
|
+
</BannerCollapsible>
|
|
483
|
+
</Column>
|
|
484
|
+
</Group>
|
|
449
485
|
</CollapsableSection>);
|
|
450
486
|
}
|
|
451
487
|
function CollapsableSection({ children, title, isLast = false }) {
|