-
Notifications
You must be signed in to change notification settings - Fork 50
Design system #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+48
−5
Merged
Design system #174
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1ebf8b0
feat(mobile): add themed atomic ui components for design system
blegodwin 3345c67
feat(mobile): build hidden component sandbox with typography button a…
blegodwin 2d16fdf
fix(mobile): improve disabled outlined button text contrast
blegodwin 163aa25
Merge branch 'main' into design-system
blegodwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,10 +1,52 @@ | ||
| import { Text, View } from "react-native" | ||
| import { ScrollView, View } from "react-native" | ||
| import { Button, Card, Input, Typography } from "../../src/components" | ||
| import { colors, spacing } from "../../src/theme/tokens" | ||
|
|
||
| export default function SandboxScreen() { | ||
| return ( | ||
| <View style={{ flex: 1, alignItems: "center", justifyContent: "center", padding: 24 }}> | ||
| <Text style={{ fontSize: 24, fontWeight: "700" }}>Component Sandbox</Text> | ||
| <Text style={{ marginTop: 8 }}>Typography, Button, Input, and Card previews will live here.</Text> | ||
| </View> | ||
| <ScrollView | ||
| contentContainerStyle={{ | ||
| padding: spacing.lg, | ||
| paddingBottom: spacing.xl, | ||
| backgroundColor: colors.background, | ||
| gap: spacing.lg, | ||
| }} | ||
| > | ||
| <Typography variant="h1">Component Sandbox</Typography> | ||
|
|
||
| <Card> | ||
| <View style={{ gap: spacing.sm }}> | ||
| <Typography variant="h2">Typography</Typography> | ||
| <Typography variant="h1">H1 Discoverly</Typography> | ||
| <Typography variant="h2">H2 Taste the Match</Typography> | ||
| <Typography variant="h3">H3 Fresh picks nearby</Typography> | ||
| <Typography variant="body">Body copy for content and supporting descriptions.</Typography> | ||
| <Typography variant="caption" color={colors.muted}> | ||
| Caption and helper content | ||
| </Typography> | ||
| </View> | ||
| </Card> | ||
|
|
||
| <Card> | ||
| <View style={{ gap: spacing.sm }}> | ||
| <Typography variant="h2">Buttons</Typography> | ||
| <Button label="Primary Button" /> | ||
| <Button label="Secondary Button" variant="secondary" /> | ||
| <Button label="Outlined Button" variant="outlined" /> | ||
| <Button label="Loading Button" loading /> | ||
| <Button label="Disabled Button" disabled /> | ||
| </View> | ||
| </Card> | ||
|
|
||
| <Card> | ||
| <View style={{ gap: spacing.sm }}> | ||
| <Typography variant="h2">Inputs</Typography> | ||
| <Input label="Empty Input" placeholder="Enter email" /> | ||
| <Input label="Focused Input" placeholder="Focused state" forceFocused /> | ||
| <Input label="Filled Input" value="hello@discoverly.app" editable={false} /> | ||
| <Input label="Error Input" placeholder="name@domain.com" error="Invalid email address" /> | ||
| </View> | ||
| </Card> | ||
| </ScrollView> | ||
| ) | ||
| } |
This file contains hidden or 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,98 @@ | ||
| import type { ReactNode } from "react" | ||
| import { ActivityIndicator, Pressable, type ViewStyle } from "react-native" | ||
| import { colors, radius, spacing } from "../theme/tokens" | ||
| import { Typography } from "./Typography" | ||
|
|
||
| type ButtonVariant = "primary" | "secondary" | "outlined" | ||
|
|
||
| type ButtonProps = { | ||
| label: string | ||
| onPress?: () => void | ||
| variant?: ButtonVariant | ||
| loading?: boolean | ||
| disabled?: boolean | ||
| leftIcon?: ReactNode | ||
| style?: ViewStyle | ||
| } | ||
|
|
||
| function getContainerStyle(variant: ButtonVariant, disabled: boolean): ViewStyle { | ||
| if (variant === "outlined") { | ||
| return { | ||
| backgroundColor: colors.surface, | ||
| borderColor: disabled ? colors.disabled : colors.crypto, | ||
| borderWidth: 1.5, | ||
| } | ||
| } | ||
|
|
||
| if (variant === "secondary") { | ||
| return { | ||
| backgroundColor: disabled ? colors.disabled : colors.crypto, | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| backgroundColor: disabled ? colors.disabled : colors.primary, | ||
| } | ||
| } | ||
|
|
||
| function getLabelColor(variant: ButtonVariant, disabled: boolean): string { | ||
| if (disabled) { | ||
| return colors.surface | ||
| } | ||
|
|
||
| if (variant === "outlined") { | ||
| return colors.crypto | ||
| } | ||
|
|
||
| if (variant === "secondary") { | ||
| return colors.onCrypto | ||
| } | ||
|
|
||
| return colors.onPrimary | ||
| } | ||
|
|
||
| export function Button({ | ||
| label, | ||
| onPress, | ||
| variant = "primary", | ||
| loading = false, | ||
| disabled = false, | ||
| leftIcon, | ||
| style, | ||
| }: ButtonProps) { | ||
| const isDisabled = disabled || loading | ||
| const labelColor = getLabelColor(variant, isDisabled) | ||
|
|
||
| return ( | ||
| <Pressable | ||
| onPress={onPress} | ||
| disabled={isDisabled} | ||
| style={({ pressed }) => [ | ||
| { | ||
| minHeight: 52, | ||
| borderRadius: radius.md, | ||
| paddingHorizontal: spacing.lg, | ||
| paddingVertical: spacing.md, | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| flexDirection: "row", | ||
| gap: spacing.sm, | ||
| opacity: pressed ? 0.9 : 1, | ||
| }, | ||
| getContainerStyle(variant, isDisabled), | ||
| style, | ||
| ]} | ||
| > | ||
| {loading ? ( | ||
| <ActivityIndicator color={labelColor} /> | ||
| ) : ( | ||
| <> | ||
| {leftIcon} | ||
| <Typography variant="body" color={labelColor} style={{ fontWeight: "700" }}> | ||
| {label} | ||
| </Typography> | ||
| </> | ||
| )} | ||
| </Pressable> | ||
| ) | ||
| } | ||
This file contains hidden or 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 type { ReactNode } from "react" | ||
| import { View, type ViewStyle } from "react-native" | ||
| import { colors, radius, shadows, spacing } from "../theme/tokens" | ||
|
|
||
| type CardProps = { | ||
| children: ReactNode | ||
| style?: ViewStyle | ||
| } | ||
|
|
||
| export function Card({ children, style }: CardProps) { | ||
| return ( | ||
| <View | ||
| style={[ | ||
| { | ||
| borderRadius: radius.md, | ||
| backgroundColor: colors.surface, | ||
| borderWidth: 1, | ||
| borderColor: colors.border, | ||
| padding: spacing.md, | ||
| ...shadows.soft, | ||
| }, | ||
| style, | ||
| ]} | ||
| > | ||
| {children} | ||
| </View> | ||
| ) | ||
| } |
This file contains hidden or 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,49 @@ | ||
| import { useState } from "react" | ||
| import { TextInput, View, type TextInputProps, type ViewStyle } from "react-native" | ||
| import { colors, radius, spacing } from "../theme/tokens" | ||
| import { Typography } from "./Typography" | ||
|
|
||
| type InputProps = TextInputProps & { | ||
| label?: string | ||
| error?: string | ||
| forceFocused?: boolean | ||
| containerStyle?: ViewStyle | ||
| } | ||
|
|
||
| export function Input({ label, error, forceFocused = false, containerStyle, onFocus, onBlur, ...props }: InputProps) { | ||
| const [isFocused, setIsFocused] = useState(false) | ||
| const focused = forceFocused || isFocused | ||
|
|
||
| return ( | ||
| <View style={[{ width: "100%", gap: spacing.xs }, containerStyle]}> | ||
| {label ? <Typography variant="caption">{label}</Typography> : null} | ||
| <TextInput | ||
| placeholderTextColor={colors.muted} | ||
| onFocus={(event) => { | ||
| setIsFocused(true) | ||
| onFocus?.(event) | ||
| }} | ||
| onBlur={(event) => { | ||
| setIsFocused(false) | ||
| onBlur?.(event) | ||
| }} | ||
| style={{ | ||
| minHeight: 52, | ||
| borderRadius: radius.md, | ||
| borderWidth: 1.5, | ||
| borderColor: error ? colors.error : focused ? colors.crypto : colors.border, | ||
| backgroundColor: colors.surface, | ||
| color: colors.text, | ||
| paddingHorizontal: spacing.md, | ||
| paddingVertical: spacing.sm, | ||
| }} | ||
| {...props} | ||
| /> | ||
| {error ? ( | ||
| <Typography variant="caption" color={colors.error}> | ||
| {error} | ||
| </Typography> | ||
| ) : null} | ||
| </View> | ||
| ) | ||
| } |
This file contains hidden or 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,16 @@ | ||
| import type { ReactNode } from "react" | ||
| import { Text, type TextStyle } from "react-native" | ||
| import { colors, typography } from "../theme/tokens" | ||
|
|
||
| type TypographyVariant = keyof typeof typography | ||
|
|
||
| type TypographyProps = { | ||
| children: ReactNode | ||
| variant?: TypographyVariant | ||
| color?: string | ||
| style?: TextStyle | ||
| } | ||
|
|
||
| export function Typography({ children, variant = "body", color = colors.text, style }: TypographyProps) { | ||
| return <Text style={[typography[variant], { color }, style]}>{children}</Text> | ||
| } |
This file contains hidden or 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,4 @@ | ||
| export * from "./Button" | ||
| export * from "./Card" | ||
| export * from "./Input" | ||
| export * from "./Typography" |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.