-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/improvement/2121-update-the-bran…
…d-to-adapt-new-design' into w/2.5/improvement/2121-update-the-brand-to-adapt-new-design
- Loading branch information
Showing
11 changed files
with
278 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
{ | ||
"brand": { | ||
"base": "#19161D", | ||
"baseContrast1": "#26232A", | ||
"primary": "#e99121", | ||
"secondary": "#2979ff", | ||
"success": "#006F62", | ||
"info": "#00B2A9", | ||
"warning": "#F1B434", | ||
"danger": "#EF3340", | ||
"background": "#26232A", | ||
"backgroundContrast1": "#2E2B32", | ||
"backgroundContrast2": "#353239", | ||
"text": "#ffffff", | ||
"border": "#ffffff" | ||
} | ||
"theme":{ | ||
"light":{ | ||
"brand":{ | ||
"base": "#F7F6F9", | ||
"baseContrast1": "#ECF4FF", | ||
"primary": "#313B44", | ||
"secondary": "#e99121", | ||
"success": "#23AD56", | ||
"info": "#00B2A9", | ||
"warning": "#F1B434", | ||
"danger": "#EF3340", | ||
"background": "#ffffff", | ||
"backgroundContrast1": "#F7F6F9", | ||
"backgroundContrast2": "#FAF9FB", | ||
"text":"#000000", | ||
"border":"#000000" | ||
}, | ||
"logo_path":"/brand/assets/branding-light.svg" | ||
}, | ||
"dark":{ | ||
"brand":{ | ||
"base": "#121214", | ||
"baseContrast1": "#192A41", | ||
"primary": "#A7B6C3", | ||
"secondary": "#2979ff", | ||
"success": "#23AD56", | ||
"info": "#00B2A9", | ||
"warning": "#F1B434", | ||
"danger": "#EF3340", | ||
"background": "#0D0D0D", | ||
"backgroundContrast1": "#1D1D21", | ||
"backgroundContrast2": "#171717", | ||
"text": "#ffffff", | ||
"border": "#ffffff" | ||
}, | ||
"logo_path":"/brand/assets/branding-dark.svg" | ||
}, | ||
"custom":{} | ||
}, | ||
"default": "light" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import React from 'react'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { Formik, Form } from 'formik'; | ||
import * as yup from 'yup'; | ||
import { Button, Input } from '@scality/core-ui'; | ||
import { brand, padding } from '@scality/core-ui/dist/style/theme'; | ||
import styled from 'styled-components'; | ||
import { authenticateAction } from '../ducks/login'; | ||
import { injectIntl } from 'react-intl'; | ||
import isEmpty from 'lodash.isempty'; | ||
|
||
const LoginFormContainer = styled.div` | ||
height: 100vh; | ||
background: url(${process.env.PUBLIC_URL + '/brand/assets/login.jpg'}); | ||
background-size: cover; | ||
position: relative; | ||
form { | ||
padding: 200px 50px; | ||
position: absolute; | ||
background-color: rgba(70, 103, 127, 0.8); | ||
top: 0; | ||
bottom: 0; | ||
.sc-input { | ||
display: block; | ||
margin: 30px 0; | ||
.sc-input-label { | ||
padding: 0; | ||
font-weight: bold; | ||
display: block; | ||
margin-bottom: ${padding.smaller}; | ||
margin-top: ${padding.larger}; | ||
color: white; | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const Error = styled.span` | ||
display: block; | ||
color: ${brand.danger}; | ||
`; | ||
|
||
const LogoContainer = styled.div` | ||
position: absolute; | ||
top: 45px; | ||
`; | ||
|
||
const LoginForm = props => { | ||
const { | ||
values, | ||
touched, | ||
errors, | ||
dirty, | ||
intl, | ||
setFieldValue, | ||
setFieldTouched, | ||
asyncErrors, | ||
} = props; | ||
//handleChange of the Formik props does not update 'values' when field value is empty | ||
const handleChange = field => e => { | ||
const { value, checked, type } = e.target; | ||
setFieldValue(field, type === 'checkbox' ? checked : value, true); | ||
}; | ||
//touched is not "always" correctly set | ||
const handleOnBlur = e => setFieldTouched(e.target.name, true); | ||
|
||
return ( | ||
<Form autoComplete="off"> | ||
<LogoContainer> | ||
<img | ||
alt="logo" | ||
src={process.env.PUBLIC_URL + '/brand/assets/branding-dark.svg'} | ||
/> | ||
</LogoContainer> | ||
<Input | ||
name="username" | ||
type="text" | ||
label={intl.messages.username} | ||
error={touched.username && errors.username} | ||
value={values.username} | ||
onChange={handleChange('username')} | ||
onBlur={handleOnBlur} | ||
/> | ||
<Input | ||
name="password" | ||
type="password" | ||
label={intl.messages.password} | ||
error={touched.password && errors.password} | ||
value={values.password} | ||
onChange={handleChange('password')} | ||
onBlur={handleOnBlur} | ||
/> | ||
<Button | ||
type="submit" | ||
text={intl.messages.submit} | ||
disabled={!dirty || !isEmpty(errors)} | ||
/> | ||
{asyncErrors && asyncErrors.authentication && ( | ||
<Error>{asyncErrors.authentication}</Error> | ||
)} | ||
</Form> | ||
); | ||
}; | ||
|
||
const initialValues = { | ||
username: '', | ||
password: '', | ||
}; | ||
|
||
const validationSchema = yup.object().shape({ | ||
username: yup.string().required(), | ||
password: yup.string().required(), | ||
}); | ||
|
||
const Login = props => { | ||
const asyncErrors = useSelector(state => state.login.errors); | ||
const dispatch = useDispatch(); | ||
const authenticate = values => dispatch(authenticateAction(values)); | ||
|
||
return ( | ||
<LoginFormContainer> | ||
<Formik | ||
initialValues={initialValues} | ||
validationSchema={validationSchema} | ||
onSubmit={authenticate} | ||
render={renderProps => { | ||
const formikProps = { | ||
...renderProps, | ||
...props, | ||
asyncErrors: asyncErrors, | ||
}; | ||
return <LoginForm {...formikProps} />; | ||
}} | ||
/> | ||
</LoginFormContainer> | ||
); | ||
}; | ||
|
||
export default injectIntl(Login); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.