2018-07-23 12:14:53 -04:00
|
|
|
import React from 'react';
|
2018-08-27 10:23:21 -06:00
|
|
|
import PropTypes from 'prop-types';
|
2019-03-15 10:19:57 -04:00
|
|
|
import styled from '@emotion/styled';
|
2018-07-23 12:14:53 -04:00
|
|
|
import Icon from './Icon';
|
|
|
|
import { buttons, shadows } from './styles';
|
2019-11-03 09:23:11 +01:00
|
|
|
import GoBackButton from './GoBackButton';
|
2018-07-23 12:14:53 -04:00
|
|
|
|
|
|
|
const StyledAuthenticationPage = styled.section`
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column nowrap;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
height: 100vh;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-23 12:14:53 -04:00
|
|
|
|
2018-11-02 18:25:36 +01:00
|
|
|
const CustomIconWrapper = styled.span`
|
|
|
|
width: 300px;
|
|
|
|
height: 200px;
|
|
|
|
margin-top: -150px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const NetlifyLogoIcon = styled(Icon)`
|
2018-07-23 12:14:53 -04:00
|
|
|
color: #c4c6d2;
|
|
|
|
margin-top: -300px;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-23 12:14:53 -04:00
|
|
|
|
2018-11-02 18:25:36 +01:00
|
|
|
const NetlifyCreditIcon = styled(Icon)`
|
|
|
|
color: #c4c6d2;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 10px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const CustomLogoIcon = ({ url }) => {
|
|
|
|
return (
|
|
|
|
<CustomIconWrapper>
|
|
|
|
<img src={url} alt="Logo" />
|
|
|
|
</CustomIconWrapper>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderPageLogo = logoUrl => {
|
|
|
|
if (logoUrl) {
|
|
|
|
return <CustomLogoIcon url={logoUrl} />;
|
|
|
|
}
|
|
|
|
return <NetlifyLogoIcon size="300px" type="netlify-cms" />;
|
|
|
|
};
|
|
|
|
|
2018-07-23 12:14:53 -04:00
|
|
|
const LoginButton = styled.button`
|
|
|
|
${buttons.button};
|
|
|
|
${shadows.dropDeep};
|
|
|
|
${buttons.default};
|
|
|
|
${buttons.gray};
|
2018-08-27 10:25:32 -06:00
|
|
|
&[disabled] {
|
|
|
|
${buttons.disabled};
|
|
|
|
}
|
2018-07-23 12:14:53 -04:00
|
|
|
|
|
|
|
padding: 0 12px;
|
|
|
|
margin-top: -40px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
position: relative;
|
2018-08-07 14:46:54 -06:00
|
|
|
`;
|
2018-07-23 12:14:53 -04:00
|
|
|
|
2018-07-23 17:13:34 -04:00
|
|
|
const AuthenticationPage = ({
|
|
|
|
onLogin,
|
|
|
|
loginDisabled,
|
|
|
|
loginErrorMessage,
|
|
|
|
renderButtonContent,
|
|
|
|
renderPageContent,
|
2018-11-02 18:25:36 +01:00
|
|
|
logoUrl,
|
2019-10-28 20:20:41 +01:00
|
|
|
siteUrl,
|
2020-02-28 18:12:10 +08:00
|
|
|
t,
|
2018-07-23 17:13:34 -04:00
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<StyledAuthenticationPage>
|
2018-11-02 18:25:36 +01:00
|
|
|
{renderPageLogo(logoUrl)}
|
2018-07-23 17:13:34 -04:00
|
|
|
{loginErrorMessage ? <p>{loginErrorMessage}</p> : null}
|
2019-07-24 15:20:41 -07:00
|
|
|
{!renderPageContent ? null : renderPageContent({ LoginButton })}
|
2018-08-07 14:46:54 -06:00
|
|
|
{!renderButtonContent ? null : (
|
2018-07-23 17:13:34 -04:00
|
|
|
<LoginButton disabled={loginDisabled} onClick={onLogin}>
|
|
|
|
{renderButtonContent()}
|
|
|
|
</LoginButton>
|
2018-08-07 14:46:54 -06:00
|
|
|
)}
|
2020-02-28 18:12:10 +08:00
|
|
|
{siteUrl && <GoBackButton href={siteUrl} t={t} />}
|
2018-11-02 18:25:36 +01:00
|
|
|
{logoUrl ? <NetlifyCreditIcon size="100px" type="netlify-cms" /> : null}
|
2018-07-23 17:13:34 -04:00
|
|
|
</StyledAuthenticationPage>
|
|
|
|
);
|
|
|
|
};
|
2018-07-23 12:14:53 -04:00
|
|
|
|
2018-08-27 10:23:21 -06:00
|
|
|
AuthenticationPage.propTypes = {
|
|
|
|
onLogin: PropTypes.func,
|
2018-11-02 18:25:36 +01:00
|
|
|
logoUrl: PropTypes.string,
|
2019-10-28 20:20:41 +01:00
|
|
|
siteUrl: PropTypes.string,
|
2018-08-27 10:23:21 -06:00
|
|
|
loginDisabled: PropTypes.bool,
|
|
|
|
loginErrorMessage: PropTypes.node,
|
|
|
|
renderButtonContent: PropTypes.func,
|
|
|
|
renderPageContent: PropTypes.func,
|
2020-02-28 18:12:10 +08:00
|
|
|
t: PropTypes.func.isRequired,
|
2018-08-27 10:23:21 -06:00
|
|
|
};
|
|
|
|
|
2018-07-23 12:14:53 -04:00
|
|
|
export default AuthenticationPage;
|