2020-04-19 20:45:09 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
2020-04-26 13:32:50 +00:00
|
|
|
import { remSize } from '../../../theme';
|
2020-04-19 20:45:09 +00:00
|
|
|
|
2020-05-26 20:17:24 +00:00
|
|
|
import { GithubIcon, GoogleIcon } from '../../../common/icons';
|
2020-04-19 20:45:09 +00:00
|
|
|
import Button from '../../../common/Button';
|
|
|
|
|
|
|
|
const authUrls = {
|
2020-05-11 20:28:18 +00:00
|
|
|
github: '/auth/github',
|
|
|
|
google: '/auth/google'
|
2020-04-19 20:45:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const labels = {
|
2020-05-11 20:28:18 +00:00
|
|
|
github: 'Login with GitHub',
|
|
|
|
google: 'Login with Google'
|
|
|
|
};
|
|
|
|
|
|
|
|
const icons = {
|
2020-05-19 16:31:36 +00:00
|
|
|
github: GithubIcon,
|
|
|
|
google: GoogleIcon
|
2020-04-19 20:45:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const services = {
|
2020-05-11 20:28:18 +00:00
|
|
|
github: 'github',
|
|
|
|
google: 'google'
|
2020-04-19 20:45:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const StyledButton = styled(Button)`
|
|
|
|
width: ${remSize(300)};
|
|
|
|
`;
|
|
|
|
|
|
|
|
function SocialAuthButton({ service }) {
|
2020-05-11 20:28:18 +00:00
|
|
|
const ServiceIcon = icons[service];
|
2020-04-19 20:45:09 +00:00
|
|
|
return (
|
|
|
|
<StyledButton
|
2020-05-19 16:31:36 +00:00
|
|
|
iconBefore={<ServiceIcon aria-label={`${service} logo`} />}
|
2020-04-19 20:45:09 +00:00
|
|
|
href={authUrls[service]}
|
|
|
|
>
|
2020-05-19 16:31:36 +00:00
|
|
|
{labels[service]}
|
2020-04-19 20:45:09 +00:00
|
|
|
</StyledButton>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
SocialAuthButton.services = services;
|
|
|
|
|
|
|
|
SocialAuthButton.propTypes = {
|
2020-05-11 20:28:18 +00:00
|
|
|
service: PropTypes.oneOf(['github', 'google']).isRequired
|
2020-04-19 20:45:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default SocialAuthButton;
|