Skip to content

Commit 128683d

Browse files
authored
Merge pull request #113 from rdkelley/login-animation
Fix animation, improve spacing on login screen for mobile devices
2 parents ef46a2f + 2a0d45d commit 128683d

File tree

6 files changed

+93
-37
lines changed

6 files changed

+93
-37
lines changed

web/client/src/App.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$small: 672px;
1+
$small: 320px;
2+
$medium: 672px;
3+
$large: 1056px;
24
$events-map-mobile-threshold: 1100px;
35

46
@import '~carbon-components/scss/globals/scss/vendor/@carbon/type/scss/font-family.scss';

web/client/src/components/LoginInput/index.js

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ const LoginInput = ({
7676
handleSubmit()
7777
}}
7878
>
79-
{step === 2 && <input type="email" style={{ display: 'none' }} />}
79+
{step === 2 && (
80+
<input
81+
type="email"
82+
autoComplete="username"
83+
style={{ display: 'none' }}
84+
/>
85+
)}
8086
<TextInput
8187
id={step === 1 ? 'openeewId' : 'password'}
8288
type={step === 1 ? 'email' : 'password'}
@@ -122,34 +128,44 @@ const LoginInput = ({
122128
autoComplete={step === 1 ? 'email' : 'current-password'}
123129
/>
124130
{step === 1 && (
125-
<input type="password" style={{ display: 'none' }} />
131+
<input
132+
type="password"
133+
autoComplete="current-password"
134+
style={{ display: 'none' }}
135+
/>
126136
)}
127-
<Button
128-
renderIcon={step === 1 ? ArrowRight32 : null}
129-
className={`login__continue-button marb-1 ${
130-
isSubmitting ? 'display-none' : ''
131-
}`}
132-
type="submit"
133-
iconDescription={t('content.login.continue')}
134-
>
135-
{step === 1 ? 'Continue' : 'Log in'}
136-
</Button>
137+
138+
<div style={{ height: '55px' }}>
139+
<Button
140+
renderIcon={step === 1 ? ArrowRight32 : null}
141+
className={`login__continue-button marb-1 ${
142+
isSubmitting ? 'display-none' : ''
143+
}`}
144+
type="submit"
145+
iconDescription={t('content.login.continue')}
146+
>
147+
{step === 1 ? 'Continue' : 'Log in'}
148+
</Button>
149+
150+
{isSubmitting && step === 2 ? (
151+
<InlineLoading
152+
className="space-t-2"
153+
description={t('content.login.loggingIn')}
154+
status={'active'}
155+
aria-live={'polite'}
156+
/>
157+
) : null}
158+
</div>
159+
137160
{step === 1 ? (
138161
<Checkbox
139162
labelText={t('content.login.rememberMe')}
140-
className="login__checkbox"
163+
className={`login__checkbox marb-1 ${
164+
isSubmitting ? 'display-none' : ''
165+
}`}
141166
id="login_rememberMe"
142167
/>
143168
) : null}
144-
145-
{isSubmitting ? (
146-
<InlineLoading
147-
className="space-t-2"
148-
description={t('content.login.loggingIn')}
149-
status={'active'}
150-
aria-live={'polite'}
151-
/>
152-
) : null}
153169
</Form>
154170
)
155171
}}

web/client/src/content/Login/Login.scss

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,23 @@
8686
-webkit-text-fill-color: #f4f4f4 !important;
8787
}
8888

89-
@media only screen and (max-width: $small) {
89+
@media only screen and (min-width: $medium) and (max-width: $large) {
9090
.login__container {
91-
padding: 0 40px;
91+
padding-left: 45px;
92+
}
93+
}
94+
95+
@media only screen and (max-width: $medium) {
96+
.login__container {
97+
padding: 0 1rem;
9298
max-width: none;
9399
}
94100

95101
.login__spacer {
96-
padding-bottom: 6rem;
102+
padding-bottom: $layout-05;
103+
}
104+
105+
.login__supportingContainer {
106+
min-height: $layout-06 / 2;
97107
}
98108
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const loginAnimation = {
2+
desktop: {
3+
transition: {
4+
type: 'spring',
5+
bounce: 0.25,
6+
duration: 0.3,
7+
},
8+
initial: { x: 200, opacity: 0 },
9+
animate: { x: 0, opacity: 1 },
10+
exit: { x: -200, opacity: 0 },
11+
},
12+
mobile: {
13+
transition: {
14+
duration: 0.18,
15+
},
16+
initial: { x: 0, opacity: 0 },
17+
animate: { x: 0, opacity: 1 },
18+
exit: { x: 0, opacity: 0 },
19+
},
20+
}
21+
22+
export default loginAnimation

web/client/src/content/Login/index.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useCallback, useState } from 'react'
1+
import React, { useContext, useCallback, useState, useEffect } from 'react'
22
import { motion, AnimatePresence } from 'framer-motion'
33
import { InlineNotification } from 'carbon-components-react'
44

@@ -9,12 +9,16 @@ import Header from '../../components/Header'
99
import { ReactComponent as Logo } from '../../assets/openeew_logo.svg'
1010

1111
import AuthClient from '../../rest/auth'
12+
import animation from './animation'
1213

1314
const Login = ({ history }) => {
1415
const { t, setCurrentUser } = useContext(AppContext)
1516
const [error, setError] = useState('')
1617
const [step, setStep] = useState(1)
1718
const [loginId, setLoginId] = useState('')
19+
const [activeAnimation, setActiveAnimation] = useState(() =>
20+
window.innerWidth < 672 ? animation.mobile : animation.desktop
21+
)
1822

1923
const initLogin = useCallback(
2024
/**
@@ -39,7 +43,6 @@ const Login = ({ history }) => {
3943
lastName: user.familyName,
4044
})
4145

42-
console.log('Login successful ', user.email)
4346
return history.push('/events')
4447
} catch (e) {
4548
setSubmitting(false)
@@ -50,6 +53,16 @@ const Login = ({ history }) => {
5053
[loginId, setCurrentUser, history]
5154
)
5255

56+
useEffect(() => {
57+
window.addEventListener('resize', () =>
58+
setActiveAnimation(
59+
window.innerWidth < 672
60+
? { ...animation.mobile }
61+
: { ...animation.desktop }
62+
)
63+
)
64+
}, [])
65+
5366
return (
5467
<>
5568
<Header removeLogin />
@@ -67,14 +80,7 @@ const Login = ({ history }) => {
6780
<motion.div
6881
// By changing the key, React treats each step as a unique component
6982
key={`login-${step}`}
70-
transition={{
71-
type: 'spring',
72-
bounce: 0.4,
73-
duration: 0.35,
74-
}}
75-
initial={{ x: 200, opacity: 0 }}
76-
animate={{ x: 0, opacity: 1 }}
77-
exit={{ x: -200, opacity: 0 }}
83+
{...activeAnimation}
7884
>
7985
<div className="login__supportingContainer">
8086
{step === 2 ? (

web/client/src/content/Onboard/Onboard.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
@include carbon--type-style('productive-heading-01');
4343
}
4444

45-
@media screen and (min-width: $small) {
45+
@media screen and (min-width: $medium) {
4646
.onboard__container {
4747
max-width: 400px;
4848
margin-left: 3rem;

0 commit comments

Comments
 (0)