forked from keep-starknet-strange/joyboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat toast view (keep-starknet-strange#175)
* added toast view used state names for toast views, added 2 icons needed. * Refactor toast --------- Co-authored-by: Uğur Eren <[email protected]>
- Loading branch information
1 parent
af77838
commit 4d10802
Showing
4 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {View} from 'react-native'; | ||
|
||
import {ErrorIcon, InfoIcon, SuccessIcon} from '../../assets/icons'; | ||
import {useStyles, useTheme} from '../../hooks'; | ||
import {Text} from '../Text'; | ||
import stylesheet from './styles'; | ||
|
||
export type ToastProps = { | ||
type: 'success' | 'info' | 'error'; | ||
title: string; | ||
}; | ||
|
||
export const Toast: React.FC<ToastProps> = ({type, title}) => { | ||
const theme = useTheme(); | ||
const styles = useStyles(stylesheet, type); | ||
|
||
const color = ( | ||
{ | ||
success: 'successDark', | ||
info: 'infoDark', | ||
error: 'errorDark', | ||
} as const | ||
)[type]; | ||
|
||
const Icon = ( | ||
{ | ||
success: SuccessIcon, | ||
info: InfoIcon, | ||
error: ErrorIcon, | ||
} as const | ||
)[type]; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Icon width={20} height={20} color={theme.colors[color]} /> | ||
|
||
<Text weight="semiBold" color={color} fontSize={14} style={styles.text}> | ||
{title} | ||
</Text> | ||
</View> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Spacing, ThemedStyleSheet} from '../../styles'; | ||
|
||
export default ThemedStyleSheet((theme, type: 'success' | 'info' | 'error') => ({ | ||
container: { | ||
width: '100%', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
gap: Spacing.xsmall, | ||
paddingVertical: Spacing.medium, | ||
paddingHorizontal: Spacing.medium, | ||
borderRadius: 8, | ||
|
||
...(type === 'success' && { | ||
backgroundColor: theme.colors.successLight, | ||
}), | ||
|
||
...(type === 'info' && { | ||
backgroundColor: theme.colors.infoLight, | ||
}), | ||
|
||
...(type === 'error' && { | ||
backgroundColor: theme.colors.errorLight, | ||
}), | ||
}, | ||
text: { | ||
flex: 1, | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters