Skip to content

Commit 6dc5c97

Browse files
committed
fix up some ui components. refactor . build out more of onboard
1 parent 9db941b commit 6dc5c97

File tree

14 files changed

+436
-290
lines changed

14 files changed

+436
-290
lines changed

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"react-router-dom": "^5.0.0",
3737
"react-router-native": "^5.0.0",
3838
"react-scripts": "3.0.0",
39+
"react-spring": "^8.0.21",
3940
"styled-components": "^4.2.1"
4041
},
4142
"devDependencies": {

client/src/components/Button/Button.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { Text, TouchableOpacity } from 'react-native'
2+
import { Text, TouchableOpacity, TouchableOpacityProps } from 'react-native'
33
import styled from 'styled-components'
44

55
export enum Variants {
@@ -19,7 +19,7 @@ const Wrapper = styled(TouchableOpacity)<{ variant?: Variants; disabled?: boolea
1919
text-align: center;
2020
box-shadow: 0 20px 30px 0 rgba(87, 91, 126, 0.3);
2121
padding: 17px 45px;
22-
${props => (props.disabled ? 'opacity: 0.6;' : '')}
22+
opacity: ${props => (props.disabled ? '0.6' : '1')};
2323
`
2424

2525
const Label = styled(Text)`
@@ -30,22 +30,14 @@ const Label = styled(Text)`
3030
letter-spacing: -0.5px;
3131
`
3232

33-
interface ButtonProps {
33+
interface ButtonProps extends TouchableOpacityProps {
3434
children: string
35-
onPress: () => void
36-
disabled?: boolean
3735
variant?: Variants
3836
style?: any
3937
}
4038

41-
const Button = ({ children, onPress, disabled, variant, style }: ButtonProps) => (
42-
<Wrapper
43-
variant={variant}
44-
onPress={onPress}
45-
activeOpacity={0.6}
46-
disabled={disabled}
47-
style={style}
48-
>
39+
const Button = ({ children, variant, style, ...props }: ButtonProps) => (
40+
<Wrapper {...props} variant={variant} activeOpacity={0.6} style={style}>
4941
<Label>{children}</Label>
5042
</Wrapper>
5143
)

client/src/components/Input/Input.tsx

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import * as React from 'react'
2-
import {
3-
View,
4-
Text,
5-
TextInput,
6-
TextInputIOSProps,
7-
NativeSyntheticEvent,
8-
TextInputKeyPressEventData,
9-
} from 'react-native'
2+
import { View, Text, TextInput, TextInputProps } from 'react-native'
103
import styled, { css } from 'styled-components'
114

125
const Base = styled(TextInput)<{
@@ -25,6 +18,7 @@ const Base = styled(TextInput)<{
2518
font-weight: 900;
2619
color: var(--dark-blue);
2720
letter-spacing: -0.91px;
21+
outline: none;
2822
transition: box-shadow 0.3s ease;
2923
3024
${props =>
@@ -45,63 +39,46 @@ const Label = styled(Text)`
4539
letter-spacing: -0.61px;
4640
`
4741

48-
interface InputProps {
42+
interface InputProps extends TextInputProps {
4943
style?: any
5044
inputStyle?: any
5145
name?: string
5246
label?: string
53-
placeholder?: string
54-
value?: string
55-
onChangeText: (text: string) => void
56-
onBlur?: (e: any) => void
57-
onFocus?: (e: any) => void
58-
onKeyPress?: (e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void
5947
secure?: boolean
60-
focused?: boolean
6148
focusable?: boolean
62-
textContentType?: TextInputIOSProps['textContentType']
6349
}
6450

6551
const Input = React.forwardRef(
66-
(
67-
{
68-
style,
69-
inputStyle,
70-
name,
71-
label,
72-
placeholder,
73-
value,
74-
onChangeText,
75-
onBlur,
76-
onFocus,
77-
onKeyPress,
78-
secure,
79-
focused,
80-
focusable,
81-
textContentType,
82-
}: InputProps,
83-
ref
84-
) => (
85-
<View style={style}>
86-
{label && <Label>{label}</Label>}
87-
<Base
88-
innerRef={ref}
89-
style={inputStyle}
90-
name={name}
91-
value={value}
92-
onChangeText={onChangeText}
93-
onBlur={onBlur}
94-
onFocus={onFocus}
95-
onKeyPress={onKeyPress}
96-
placeholder={placeholder}
97-
placeholderTextColor="var(--dark-moderate-blue-30)"
98-
textContentType={textContentType}
99-
secureTextEntry={secure}
100-
focused={focused}
101-
focusable={focusable}
102-
/>
103-
</View>
104-
)
52+
({ style, inputStyle, name, label, secure, focusable, ...props }: InputProps, ref) => {
53+
const [focused, setFocused] = React.useState(false)
54+
return (
55+
<View style={style}>
56+
{label && <Label>{label}</Label>}
57+
<Base
58+
{...props}
59+
innerRef={ref}
60+
style={inputStyle}
61+
name={name}
62+
placeholderTextColor="var(--dark-moderate-blue-30)"
63+
secureTextEntry={secure}
64+
focused={focused}
65+
focusable={focusable}
66+
onFocus={e => {
67+
setFocused(true)
68+
if (props.onFocus) {
69+
props.onFocus(e)
70+
}
71+
}}
72+
onBlur={e => {
73+
setFocused(false)
74+
if (props.onBlur) {
75+
props.onBlur(e)
76+
}
77+
}}
78+
/>
79+
</View>
80+
)
81+
}
10582
)
10683

10784
export default Input

client/src/components/Router/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export default () => {
1313
return () => {}
1414
}, [userState.user && userState.user.id])
1515

16-
console.log('userState', userState)
16+
if (!userState.user && userState.loggingIn) {
17+
return null
18+
}
1719

1820
return (
1921
<Router>

client/src/generated/graphql.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export type UserInput = {
187187
export type MeQueryVariables = {}
188188

189189
export type MeQuery = { __typename?: 'Query' } & {
190-
me: { __typename?: 'User' } & Pick<User, '_id'> & {
190+
me: { __typename?: 'User' } & Pick<User, '_id' | 'isOnboarded'> & {
191191
profile: { __typename?: 'Profile' } & Pick<Profile, 'firstName' | 'lastName'>
192192
emails: Maybe<Array<{ __typename?: 'EmailRecord' } & Pick<EmailRecord, 'address'>>>
193193
}
@@ -204,6 +204,7 @@ export const MeDocument = gql`
204204
emails {
205205
address
206206
}
207+
isOnboarded
207208
}
208209
}
209210
`

client/src/screens/Home/Home.tsx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import * as React from 'react'
22
import { View, Text } from 'react-native'
3+
import gql from 'graphql-tag'
34
import styled from 'styled-components'
5+
import { useMeQuery } from '../../generated/graphql'
46
import { SidebarContext } from '../../components/MainLayout'
57
import Dashboard from './components/Dashboard'
6-
import OnboardBox from './components/OnboardBox'
8+
import Onboard from './components/Onboard'
9+
10+
export const GET_USER = gql`
11+
query Me {
12+
me {
13+
_id
14+
profile {
15+
firstName
16+
lastName
17+
}
18+
emails {
19+
address
20+
}
21+
isOnboarded
22+
}
23+
}
24+
`
725

826
const Wrapper = styled(View)<{ sidebarOpen: boolean }>`
927
flex: 1;
@@ -24,15 +42,18 @@ const Title = styled(Text)`
2442
`
2543

2644
const Home = () => {
45+
const { data, loading } = useMeQuery()
2746
const { sidebarOpen } = React.useContext(SidebarContext)
28-
const firstName = 'Jason'
29-
const isOnboarded = false
47+
const firstName = data && data.me && data.me.profile.firstName
48+
const isOnboarded = data && data.me && data.me.isOnboarded
3049
return (
3150
<Wrapper sidebarOpen={sidebarOpen}>
32-
<View style={{ width: '75%' }}>
33-
<Title>{`Hello, ${firstName}!`}</Title>
34-
{isOnboarded ? <Dashboard /> : <OnboardBox />}
35-
</View>
51+
{loading ? null : (
52+
<View style={{ width: '75%', height: '75%', overflow: 'hidden' }}>
53+
<Title>{`Hello, ${firstName}!`}</Title>
54+
{isOnboarded ? <Dashboard /> : <Onboard />}
55+
</View>
56+
)}
3657
</Wrapper>
3758
)
3859
}

0 commit comments

Comments
 (0)