Skip to content
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

feat: mobile textbox comp #926

Merged
merged 16 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/mobile/app/(app)/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native';
const HomePage = () => {
return (
<View style={styles.container}>
<Text style={styles.title}>Home Page</Text>
<Text style={styles.title}>Hello</Text>
</View>
);
};
Expand Down
5 changes: 5 additions & 0 deletions frontend/mobile/app/(design-system)/assets/svg/Error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const StandardButton: React.FC<
}) => {
return (
<BaseButton
backgroundColor={disabled ? 'disabled' : color}
backgroundColor={disabled ? 'gray' : color}
disabled={disabled}
onPress={disabled ? undefined : onPress}
{...styles.standardButton}
Expand Down Expand Up @@ -83,7 +83,7 @@ const IconButton: React.FC<

return (
<BaseButton
backgroundColor={disabled ? 'disabled' : color}
backgroundColor={disabled ? 'gray' : color}
justifyContent={justify}
disabled={disabled}
onPress={disabled ? undefined : onPress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,25 @@ const Texts = {
fontFamily: 'DMSans-Medium',
fontSize: 24,
fontStyle: 'normal',
fontWeight: '500',
lineHeight: 'normal',
color: '#000'
fontWeight: '500'
},
'body-1': {
fontFamily: 'DMSans-Regular',
fontSize: 16,
fontStyle: 'normal',
fontWeight: '400',
lineHeight: 'normal'
fontWeight: '400'
},
'caption-1': {
fontFamily: 'DMSans-Regular',
fontSize: 12,
fontStyle: 'normal',
fontWeight: '400',
lineHeight: 'normal'
fontWeight: '200'
},
'caption-2': {
fontFamily: 'DMSans-Regular',
fontSize: 10,
fontStyle: 'normal',
fontWeight: '400',
lineHeight: 'normal'
fontWeight: '200'
}
} as const;

Expand Down
80 changes: 80 additions & 0 deletions frontend/mobile/app/(design-system)/components/Textbox/Textbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React from 'react';
import { TextInput } from 'react-native';

import { BoxProps, createBox } from '@shopify/restyle';

import ErrorIcon from '@/app/(design-system)/assets/svg/Error.svg';
import { Box } from '@/app/(design-system)/components/Box/Box';
import { Text } from '@/app/(design-system)/components/Text/Text';
import { TextVariants } from '@/app/(design-system)/components/Text/TextVariants';
import { Theme, createStyles } from '@/app/(design-system)/theme';

type TextboxProps = {
title?: string;
placeholder?: string;
helperText?: string;
error?: string;
autoFocus?: boolean;
readOnly?: boolean;
inputMode?: 'text' | 'numeric' | 'tel' | 'search' | 'email';
onChangeText?: () => void;
value?: string;
maxLength?: number;
secureTextEntry?: boolean;
children?: React.ReactNode;
} & BoxProps<Theme>;

const BaseTextInput = createBox<Theme, TextboxProps>(TextInput);

export const TextBox: React.FC<TextboxProps> = ({
title,
placeholder,
helperText = ' ',
error,
autoFocus = false,
readOnly = false,
inputMode = 'text',
onChangeText,
value,
maxLength,
secureTextEntry = false
}) => {
return (
<Box>
<Text color="black" variant="body-1">
{title}
</Text>
<BaseTextInput
placeholder={placeholder}
autoFocus={autoFocus}
readOnly={readOnly}
inputMode={inputMode}
onChangeText={onChangeText}
value={value}
maxLength={maxLength}
secureTextEntry={secureTextEntry}
{...styles.textInput}
borderColor={error ? 'darkRed' : 'gray'}
/>
<Box gap="xxs" flexDirection="row" alignItems="center">
{error && <ErrorIcon />}
<Text color={error ? 'darkRed' : 'black'} variant="caption-1">
{error ?? helperText}
</Text>
</Box>
</Box>
);
};

const styles = createStyles({
textInput: {
borderWidth: 1,
borderRadius: 'base',
backgroundColor: 'white',
padding: 'm',
marginBottom: 'xs',
marginTop: 'xs',
minWidth: '100%',
...TextVariants['body-1']
}
});
4 changes: 2 additions & 2 deletions frontend/mobile/app/(design-system)/shared/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Colors = {
yellow: '#FFB626',
white: '#FFFFFF',
black: '#000000',
disabled: '#BDBDBD'
gray: '#C3C9D0'
};

export type SACColors = keyof typeof Colors;
Expand Down Expand Up @@ -69,5 +69,5 @@ export const textColorVariants = {
yellow: 'white',
white: 'black',
black: 'white',
disabled: 'white'
gray: 'white'
} as const;
Loading