diff options
author | jim <310223+jimmylee@users.noreply.github.com> | 2025-07-29 22:51:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-29 22:51:16 -0700 |
commit | 658dd448d560c569b5dd986dabeda28d306a1371 (patch) | |
tree | 020f7df26ad31c48e5caef8998f13b7413b3c5f2 /src/view/screens | |
parent | 0a00e02c701aee2151b8f708e9b53af81a41d44e (diff) | |
parent | 34ea6e8f3499eeeb1013dfbf7c4dcd3bdcf149a3 (diff) | |
download | voidsky-658dd448d560c569b5dd986dabeda28d306a1371.tar.zst |
Merge pull request #8734 from internet-development/@APiligrim/update-toast
[APP-1345] Update Toast UI on the web and add to storybook
Diffstat (limited to 'src/view/screens')
-rw-r--r-- | src/view/screens/Storybook/Toasts.tsx | 100 | ||||
-rw-r--r-- | src/view/screens/Storybook/index.tsx | 2 |
2 files changed, 102 insertions, 0 deletions
diff --git a/src/view/screens/Storybook/Toasts.tsx b/src/view/screens/Storybook/Toasts.tsx new file mode 100644 index 000000000..5197ec2f4 --- /dev/null +++ b/src/view/screens/Storybook/Toasts.tsx @@ -0,0 +1,100 @@ +import {View, Pressable} from 'react-native' + +import {atoms as a, useTheme} from '#/alf' +import {Text, H1} from '#/components/Typography' +import { + type ToastType, + TOAST_TYPE_TO_ICON, + getToastTypeStyles, +} from '#/view/com/util/Toast.style' +import * as Toast from '#/view/com/util/Toast' + +function ToastPreview({message, type}: {message: string; type: ToastType}) { + const t = useTheme() + const toastStyles = getToastTypeStyles(t) + const colors = toastStyles[type] + const IconComponent = TOAST_TYPE_TO_ICON[type] + + return ( + <Pressable + onPress={() => Toast.show(message, type)} + style={[ + {backgroundColor: colors.backgroundColor}, + a.shadow_sm, + {borderColor: colors.borderColor}, + a.rounded_sm, + a.border, + a.px_sm, + a.py_sm, + a.flex_row, + a.gap_sm, + a.align_center, + ]}> + <View + style={[ + a.flex_shrink_0, + a.rounded_full, + {width: 24, height: 24}, + a.align_center, + a.justify_center, + { + backgroundColor: colors.backgroundColor, + }, + ]}> + <IconComponent fill={colors.iconColor} size="xs" /> + </View> + <View style={[a.flex_1]}> + <Text + style={[ + a.text_sm, + a.font_bold, + a.leading_snug, + {color: colors.textColor}, + ]} + emoji> + {message} + </Text> + </View> + </Pressable> + ) +} + +export function Toasts() { + return ( + <View style={[a.gap_md]}> + <H1>Toast Examples</H1> + + <View style={[a.gap_md]}> + <View style={[a.gap_xs]}> + <ToastPreview message="Default Toast" type="default" /> + </View> + + <View style={[a.gap_xs]}> + <ToastPreview + message="Operation completed successfully!" + type="success" + /> + </View> + + <View style={[a.gap_xs]}> + <ToastPreview message="Something went wrong!" type="error" /> + </View> + + <View style={[a.gap_xs]}> + <ToastPreview message="Please check your input" type="warning" /> + </View> + + <View style={[a.gap_xs]}> + <ToastPreview message="Here's some helpful information" type="info" /> + </View> + + <View style={[a.gap_xs]}> + <ToastPreview + message="This is a longer message to test how the toast handles multiple lines of text content." + type="info" + /> + </View> + </View> + </View> + ) +} diff --git a/src/view/screens/Storybook/index.tsx b/src/view/screens/Storybook/index.tsx index a6c2ecdde..afcc1c4e7 100644 --- a/src/view/screens/Storybook/index.tsx +++ b/src/view/screens/Storybook/index.tsx @@ -20,6 +20,7 @@ import {Settings} from './Settings' import {Shadows} from './Shadows' import {Spacing} from './Spacing' import {Theming} from './Theming' +import {Toasts} from './Toasts' import {Typography} from './Typography' export function Storybook() { @@ -122,6 +123,7 @@ function StorybookInner() { <Breakpoints /> <Dialogs /> <Admonitions /> + <Toasts /> <Settings /> <Button |