p5.js-web-editor/client/modules/User/components/SocialAuthButton.jsx

53 lines
1 KiB
React
Raw Normal View History

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