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

SC 2776: UI component input component phone #37

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
342d339
Add slots into Input component
DmytroLaikov Oct 24, 2023
4f4db36
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 25, 2023
cede0bc
Fix change requests from @medreres
DmytroLaikov Oct 25, 2023
26e2cce
Fix change requests from @dmytroipatov and @bnwebdev
DmytroLaikov Oct 25, 2023
fd80977
Remove unneeded package
DmytroLaikov Oct 25, 2023
d972fdd
Fix change requests from @anhromovyi
DmytroLaikov Oct 26, 2023
0b31860
Fix change requests from @anhromovyi
DmytroLaikov Oct 27, 2023
679f84b
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 27, 2023
c6f8469
Run yarn set version berry
DmytroLaikov Oct 27, 2023
00a6ac5
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 27, 2023
86ed4a2
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 27, 2023
8d7fd94
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 27, 2023
22d6858
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 27, 2023
c0c7b53
Add isPasswordVisible toggler to input component
DmytroLaikov Oct 29, 2023
1e7d5f6
Add KeyboardAwareScrollView UI component
DmytroLaikov Oct 29, 2023
a721d19
Fix ts errors
DmytroLaikov Oct 29, 2023
cf5c6b0
Fix eslint changes
DmytroLaikov Oct 29, 2023
4f49d63
Revert eslint changes
DmytroLaikov Oct 29, 2023
148386a
Add theme config for UI components:
DmytroLaikov Oct 29, 2023
ca839d1
Fix eslint changes
DmytroLaikov Oct 29, 2023
b8f3ce7
Fix Helper text size
DmytroLaikov Oct 29, 2023
84d1bd7
Fix Text Props
DmytroLaikov Oct 29, 2023
3a18e64
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 30, 2023
a6421d3
Fix change requests from @AndrewZinko and @dmytroipatov
DmytroLaikov Oct 30, 2023
8202f47
Add theme styles for Text
DmytroLaikov Oct 30, 2023
e3d5dea
Fix Input Title props
DmytroLaikov Oct 30, 2023
922d986
Fix Input props
DmytroLaikov Oct 30, 2023
e32f7a1
Fix InputTitle
DmytroLaikov Oct 30, 2023
89eaf73
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 31, 2023
d51ffe1
Move styled components
DmytroLaikov Oct 31, 2023
f85db49
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 31, 2023
a741f76
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Oct 31, 2023
c36fc26
Fix change requests
DmytroLaikov Oct 31, 2023
9f0a9f4
Merge branch 'dev' into dmytrolaikov/sc-2776/ui-component-input-compo…
DmytroLaikov Nov 1, 2023
0b72ae4
Fix change requests from @ anhromovyi-sysgears
DmytroLaikov Nov 1, 2023
aa58d10
Minor fixes
DmytroLaikov Nov 1, 2023
89ccbc3
Minor fixes
DmytroLaikov Nov 1, 2023
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
1 change: 1 addition & 0 deletions apps/hero/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"react-combine-providers": "^0.9.6",
"react-dom": "18.2.0",
"react-native": "0.72.5",
"react-native-country-picker-modal": "^2.0.0",
"react-native-dotenv": "^3.4.9",
"react-native-gesture-handler": "~2.12.0",
"react-native-safe-area-context": "4.6.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ export const EmailSignInForm: FC = () => {
return (
<VStack style={styles.container}>
{/* TODO replace button label and placeholders with i18n call */}
<Input placeholder="Email" control={control} name="email" />
<Input placeholder="Email" control={control} name="email" title="Email" />
<Input
placeholder="Password"
type="password"
control={control}
name="password"
title="Password"
size="md"
/>
<Button variant="solid" size="md" onPress={onSubmit}>
Continue
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"lint": "eslint . --fix"
},
"dependencies": {
"@callstack/react-theme-provider": "^3.0.9",
bnwebdev marked this conversation as resolved.
Show resolved Hide resolved
"@gluestack-style/animation-resolver": "^1.0.2",
"@gluestack-style/legend-motion-animation-driver": "^1.0.2",
"@expo/html-elements": "^0.5.1",
"@gluestack-style/react": "^1.0.8",
"@gluestack-ui/button": "^0.1.33",
Expand All @@ -32,6 +35,9 @@
"react-dom": "18.2.0",
"react-hook-form": "^7.47.0",
"react-native": "^0.72.5",
"react-native-country-picker-modal": "^2.0.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-masked-text": "^1.13.0",
"react-native-safe-area-context": "4.6.3",
"react-native-svg": "^13.4.0",
"react-native-web": "~0.19.6"
Expand Down
11 changes: 1 addition & 10 deletions packages/ui/src/components/atoms/HStack/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HStack as GluestackHStack } from '@gluestack-ui/themed';
import { FC, PropsWithChildren } from 'react';
import { StyleSheet } from 'react-native';

import { LayoutStyles } from '../../../types';

Expand All @@ -11,13 +10,5 @@ interface Props extends PropsWithChildren {
export const HStack: FC<Props> = (props) => {
const { children, style } = props;

return (
<GluestackHStack style={[styles.stack, style]}>{children}</GluestackHStack>
);
return <GluestackHStack style={style}>{children}</GluestackHStack>;
};

const styles = StyleSheet.create({
stack: {
paddingHorizontal: 8,
},
});
4 changes: 0 additions & 4 deletions packages/ui/src/components/atoms/Input/constants.ts

This file was deleted.

50 changes: 0 additions & 50 deletions packages/ui/src/components/atoms/Input/index.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions packages/ui/src/components/atoms/InputField/index.tsx

This file was deleted.

17 changes: 17 additions & 0 deletions packages/ui/src/components/atoms/KeyboardAwareScrollView/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FC, PropsWithChildren } from 'react';
import { StyleSheet } from 'react-native';
import { KeyboardAwareScrollView as RnKeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

export const KeyboardAwareScrollView: FC<PropsWithChildren> = (props) => {
const { children } = props;

return (
<RnKeyboardAwareScrollView style={styles.main}>
{children}
</RnKeyboardAwareScrollView>
);
};

const styles = StyleSheet.create({
main: { flex: 1 },
});
16 changes: 10 additions & 6 deletions packages/ui/src/components/atoms/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Text as GluestackText } from '@gluestack-ui/themed';
import { FC } from 'react';

interface Props {
children: string;
}
import { TextVariant } from './types';

export const Text: FC<Props> = (props) => {
const { children } = props;
import { Color } from '$theme/constants';

return <GluestackText>{children}</GluestackText>;
export type TextProps = {
children: string;
color?: `${Color}`;
variant?: `${TextVariant}`;
};

export const Text: FC<TextProps> = ({ children, ...restProps }) => (
<GluestackText {...restProps}>{children}</GluestackText>
);
16 changes: 16 additions & 0 deletions packages/ui/src/components/atoms/Text/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export enum TextSize {
XXS = 'xxs',
XS = 'xs',
SM = 'sm',
MD = 'md',
LG = 'lg',
XL = 'xl',
XXL = 'xxl',
XXXL = 'xxxl',
}
dmytroipatov marked this conversation as resolved.
Show resolved Hide resolved

export enum TextVariant {
REGULAR = 'regular',
SMALL = 'small',
DESCRIPTOR = 'descriptor',
}
11 changes: 1 addition & 10 deletions packages/ui/src/components/atoms/VStack/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { VStack as GluestackVStack } from '@gluestack-ui/themed';
import { FC, PropsWithChildren } from 'react';
import { StyleSheet } from 'react-native';

import { LayoutStyles } from '$types';

Expand All @@ -11,13 +10,5 @@ interface Props extends PropsWithChildren {
export const VStack: FC<Props> = (props) => {
const { children, style } = props;

return (
<GluestackVStack style={[styles.stack, style]}>{children}</GluestackVStack>
);
return <GluestackVStack style={style}>{children}</GluestackVStack>;
};

const styles = StyleSheet.create({
stack: {
paddingHorizontal: 8,
},
});
3 changes: 1 addition & 2 deletions packages/ui/src/components/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export * from './Button';
export * from './HStack';
export * from './Input';
export * from './InputField';
export * from './SafeAreaView';
export * from './Text';
export * from './Toast';
Expand All @@ -12,4 +10,5 @@ export * from './Actionsheet';
export * from './Alert';
export * from './RadioButton';
export * from './RadioGroup';
export * from './KeyboardAwareScrollView';
export * from './IconButton';
1 change: 1 addition & 0 deletions packages/ui/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './atoms';
export * from './molecules';
export * from './organisms';
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { InputField as GluestackInputField } from '@gluestack-ui/themed';
import { ReactElement } from 'react';
import { ControllerRenderProps, FieldValues, Path } from 'react-hook-form';
import { KeyboardType } from 'react-native';
import { TextInputMask } from 'react-native-masked-text';

import { InputType } from '../types';

import { InputFieldProps } from './types';

type Props<Type extends FieldValues> = {
field: ControllerRenderProps<Type, Path<Type>>;
keyboardType?: KeyboardType;
mask?: string;
placeholder?: string;
type?: `${InputType}`;
};

export const InputField = <Type extends FieldValues>(
props: Props<Type>,
): ReactElement => {
const {
placeholder,
mask,
field,
type = InputType.TEXT,
keyboardType = 'default',
} = props;

const { onChange, value, ref } = field;

const isMasked = Boolean(mask);
const isPassword = type === InputType.PASSWORD;
dmytroipatov marked this conversation as resolved.
Show resolved Hide resolved

const inputProps: InputFieldProps = {
ref,
placeholder,
type,
secureTextEntry: isPassword,
keyboardType,
};

if (isMasked) {
return (
<TextInputMask
type="custom"
customTextInput={GluestackInputField}
customTextInputProps={inputProps}
options={{ mask }}
onChangeText={onChange}
value={value}
/>
);
}

return (
<GluestackInputField
value={value}
onChangeText={onChange}
{...inputProps}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FC } from 'react';
import { FieldError } from 'react-hook-form';

import { StyledInputHelper } from '$styled';

type Props = {
error?: FieldError;
};

export const InputHelper: FC<Props> = (props): JSX.Element => {
const { error } = props;

const errorText = error?.message || '';

return <StyledInputHelper>{errorText}</StyledInputHelper>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FC } from 'react';

import { InputSize } from '../types';

import { StyledInputTitle } from '$styled';

type Props = {
size?: `${InputSize}`;
value?: string;
};

export const InputTitle: FC<Props> = (props) => {
const { value, ...restProps } = props;

if (!value) {
return null;
}

return <StyledInputTitle {...restProps}>{value}</StyledInputTitle>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { InputIcon, Pressable } from '@gluestack-ui/themed';
import { EyeIcon, EyeOffIcon } from 'lucide-react-native';
import { FC } from 'react';

type Props = {
isPasswordVisible: boolean;
toggleIsPasswordVisible: () => void;
};

export const PasswordVisibleSwitcher: FC<Props> = (props) => {
const { toggleIsPasswordVisible, isPasswordVisible } = props;

return (
<Pressable onPress={toggleIsPasswordVisible}>
<InputIcon as={isPasswordVisible ? EyeIcon : EyeOffIcon} />
</Pressable>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './InputField';
export * from './InputHelper';
export * from './InputTitle';
export * from './PasswordVisibleSwitcher';
12 changes: 12 additions & 0 deletions packages/ui/src/components/molecules/Input/components/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Ref } from 'react';
import { KeyboardType, TextInputProps } from 'react-native';

import { InputType } from '../types';

export type InputFieldProps = {
keyboardType: KeyboardType;
secureTextEntry: boolean;
placeholder?: string;
ref?: Ref<TextInputProps>;
type?: `${InputType}`;
};
Loading