-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unistyles lib, update chip component
- Loading branch information
Showing
8 changed files
with
108 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
import { TouchableOpacity, ViewStyle } from "react-native" | ||
import { TouchableOpacity, type ViewStyle } from "react-native" | ||
import { color, fontScale, spacing } from "../../theme" | ||
import { StyleSheet } from "react-native-unistyles" | ||
|
||
const CHIP_WRAPPER: ViewStyle = { | ||
paddingHorizontal: spacing[3] * fontScale, | ||
paddingVertical: spacing[0] + 1 * fontScale, | ||
flexDirection: "row", | ||
alignItems: "center", | ||
borderRadius: 30, | ||
} | ||
|
||
const COLORS = { | ||
const CHIP_VARIANTS = { | ||
success: color.success, | ||
primary: color.primary, | ||
} | ||
transparent: "transparent", | ||
} as const | ||
|
||
interface ChipProps { | ||
children: React.ReactNode | ||
color: keyof typeof COLORS | ||
variant: keyof typeof CHIP_VARIANTS | ||
onPress: () => void | ||
icon?: React.ReactNode | ||
style?: ViewStyle | ||
} | ||
|
||
export function Chip({ children, color, onPress, style }: ChipProps) { | ||
export function Chip({ children, variant, onPress, style }: ChipProps) { | ||
return ( | ||
<TouchableOpacity style={[CHIP_WRAPPER, { backgroundColor: COLORS[color] }, style]} onPress={onPress}> | ||
<TouchableOpacity style={[stylesheet.chipWrapper(variant), style]} onPress={onPress}> | ||
{children} | ||
</TouchableOpacity> | ||
) | ||
} | ||
|
||
const stylesheet = StyleSheet.create({ | ||
chipWrapper: (variant: keyof typeof CHIP_VARIANTS) => ({ | ||
paddingHorizontal: spacing[3] * fontScale, | ||
paddingVertical: spacing[0] + 1 * fontScale, | ||
flexDirection: "row", | ||
alignItems: "center", | ||
borderRadius: 30, | ||
borderWidth: 1, | ||
borderColor: variant === "transparent" ? color.separator : undefined, | ||
}), | ||
}) |
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
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
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
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