Skip to content

Commit a6064ba

Browse files
committed
Remove stylesheets completely in place of styled components
1 parent 6746dd0 commit a6064ba

File tree

6 files changed

+62
-53
lines changed

6 files changed

+62
-53
lines changed

.expo-shared/assets.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

babel.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
allowUndefined: true
1717
}
1818
],
19-
['@babel/plugin-proposal-class-properties']
19+
['@babel/plugin-proposal-class-properties'], // Comment out when running "yarn run <ios or android>", but needed for doing serverless web app deploy
20+
['@babel/plugin-transform-flow-strip-types'] // Needed for react navigation issue - https://github.com/react-navigation/react-navigation/issues/6058
2021
]
2122
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
"yup": "^0.32.0"
5050
},
5151
"devDependencies": {
52+
"@babel/plugin-proposal-class-properties": "^7.13.0",
53+
"@babel/plugin-transform-flow-strip-types": "^7.13.0",
5254
"@expo/next-adapter": "^2.1.41",
5355
"@testing-library/jest-native": "^4.0.0",
5456
"@testing-library/react-native": "^7.1.0",

src/interfaces/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ export interface LoadFontProps {
4040
fontsToLoad: {
4141
[fontFamily: string]: FontSource;
4242
};
43+
// eslint-disable-next-line no-unused-vars
4344
setFontLoaded: (fontLoaded: boolean) => void;
4445
}
4546

4647
export interface TextInputProps {
48+
// eslint-disable-next-line no-unused-vars
4749
onChangeText?: (text: string) => void;
50+
// eslint-disable-next-line no-unused-vars
4851
onBlur?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
4952
onSubmitEditing?: (
53+
// eslint-disable-next-line no-unused-vars
5054
e: NativeSyntheticEvent<TextInputSubmitEditingEventData>
5155
) => void;
5256
placeholder?: string;

src/pages/login.tsx

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React, { FC, FormEvent, useRef } from 'react';
1+
import React, { FC, FormEvent } from 'react';
22
import {
33
GestureResponderEvent,
44
KeyboardAvoidingView,
55
NativeSyntheticEvent,
66
Platform,
7-
StyleSheet,
87
Text,
98
TextInput,
109
TextInputSubmitEditingEventData
@@ -27,27 +26,16 @@ const loginSchema = Yup.object().shape({
2726
password: Yup.string().required('Password is required')
2827
});
2928

30-
const styles = StyleSheet.create({
31-
errorInput: {
32-
color: 'red',
33-
fontSize: 12,
34-
marginLeft: 16
35-
},
36-
fbLoginButton: {
37-
height: 45,
38-
marginTop: 10,
39-
backgroundColor: 'transparent'
40-
},
41-
loginButton: {
42-
borderRadius: 5,
29+
const FBLoginButton = styled(Button).attrs({
30+
buttonStyle: {
31+
backgroundColor: 'transparent',
4332
height: 45,
44-
marginTop: 10,
45-
backgroundColor: colors.lightBlue
33+
marginTop: 10
4634
},
47-
signUp: {
48-
textAlign: 'center'
35+
titleStyle: {
36+
color: colors.lightBlue
4937
}
50-
});
38+
})``;
5139

5240
const KeyboardAvoidingViewStyled = styled(({ ...rest }) => (
5341
<KeyboardAvoidingView {...rest} />
@@ -57,6 +45,14 @@ const KeyboardAvoidingViewStyled = styled(({ ...rest }) => (
5745
width: ${Platform.OS == 'web' ? '100%' : '75%'};
5846
`;
5947

48+
const LoginButton = styled(Button).attrs({
49+
buttonStyle: {
50+
borderRadius: 5,
51+
height: 45,
52+
marginTop: 10
53+
}
54+
})``;
55+
6056
const LoginFormView = styled.View`
6157
flex: 1;
6258
height: 2000px;
@@ -71,7 +67,11 @@ const LogoText = styled.Text`
7167
text-align: center;
7268
`;
7369

74-
const SignUpText = styled(
70+
const SignUpText = styled.Text`
71+
text-align: center;
72+
`;
73+
74+
const SignUpTextNav = styled(
7575
({ navigation, ...rest }: SignUpButtonProps): JSX.Element => {
7676
const router = useRouter();
7777
return (
@@ -93,29 +93,32 @@ const SignUpText = styled(
9393
color: ${colors.lightBlue};
9494
`;
9595

96+
const StyledErrorText = styled.Text`
97+
color: red;
98+
font-size: 12px;
99+
margin-left: 16px;
100+
`;
101+
96102
const TextLoginInputField = styled(
97103
({
98104
touched,
99105
error,
100106
...rest
101-
}: TextInputProps & TouchedProps & ErrorProps): JSX.Element => {
102-
const passwordInput = useRef<TextInput>(null);
103-
104-
return (
105-
<>
106-
<TextInput
107-
accessible
108-
accessibilityLabel="textinput"
109-
autoCapitalize="none"
110-
ref={passwordInput}
111-
{...rest}
112-
/>
113-
{touched && error ? (
114-
<Text style={styles.errorInput}>{error}</Text>
115-
) : null}
116-
</>
117-
);
118-
}
107+
}: TextInputProps & TouchedProps & ErrorProps): JSX.Element => (
108+
<>
109+
<TextInput
110+
accessible
111+
accessibilityLabel="textinput"
112+
autoCapitalize="none"
113+
{...rest}
114+
/>
115+
{touched && error ? (
116+
<>
117+
<StyledErrorText>{error}</StyledErrorText>
118+
</>
119+
) : null}
120+
</>
121+
)
119122
)`
120123
font-size: 14px;
121124
border-radius: 5px;
@@ -232,8 +235,8 @@ const Login: FC<LoginProps> = ({ navigation }): JSX.Element => (
232235
touched={touched.password}
233236
value={values.password}
234237
/>
235-
<Button
236-
buttonStyle={[styles.loginButton]}
238+
<LoginButton
239+
// buttonStyle={[styles.loginButton]}
237240
onPress={(event: GestureResponderEvent): void => {
238241
handleSubmit(
239242
(event as unknown) as FormEvent<HTMLFormElement>
@@ -244,15 +247,18 @@ const Login: FC<LoginProps> = ({ navigation }): JSX.Element => (
244247
</>
245248
)}
246249
</Formik>
247-
<Button
248-
buttonStyle={[styles.fbLoginButton]}
249-
titleStyle={{ color: colors.lightBlue }}
250+
<FBLoginButton
251+
// buttonStyle={[styles.fbLoginButton]}
252+
// titleStyle={{ color: colors.lightBlue }}
253+
onPress={(event: GestureResponderEvent): void => {
254+
console.log(event);
255+
}}
250256
title="Login with Facebook"
251257
/>
252-
<Text style={styles.signUp}>
258+
<SignUpText>
253259
Don&apos;t have an account?{' '}
254-
<SignUpText navigation={navigation}>Sign up here</SignUpText>.
255-
</Text>
260+
<SignUpTextNav navigation={navigation}>Sign up here</SignUpTextNav>.
261+
</SignUpText>
256262
</LoginFormView>
257263
</KeyboardAvoidingViewStyled>
258264
</>

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@
737737
"@babel/helper-plugin-utils" "^7.10.4"
738738
"@babel/plugin-syntax-flow" "^7.12.1"
739739

740-
"@babel/plugin-transform-flow-strip-types@^7.0.0":
740+
"@babel/plugin-transform-flow-strip-types@^7.0.0", "@babel/plugin-transform-flow-strip-types@^7.13.0":
741741
version "7.13.0"
742742
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.13.0.tgz#58177a48c209971e8234e99906cb6bd1122addd3"
743743
integrity sha512-EXAGFMJgSX8gxWD7PZtW/P6M+z74jpx3wm/+9pn+c2dOawPpBkUX7BrfyPvo6ZpXbgRIEuwgwDb/MGlKvu2pOg==

0 commit comments

Comments
 (0)