2021-10-24 05:48:06 +02:00
|
|
|
import { useMemo } from 'react'
|
|
|
|
import Image from 'next/image'
|
2022-08-28 18:26:56 +02:00
|
|
|
import classNames from 'clsx'
|
2021-10-24 05:48:06 +02:00
|
|
|
|
2022-04-07 16:54:05 +02:00
|
|
|
import { ProviderOAuth } from '../../../models/OAuth'
|
|
|
|
|
|
|
|
export type SocialMedia = ProviderOAuth
|
2021-10-24 05:48:06 +02:00
|
|
|
|
|
|
|
type SocialMediaColors = {
|
|
|
|
[key in SocialMedia]: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const socialMediaColors: SocialMediaColors = {
|
|
|
|
Discord: '#404EED',
|
|
|
|
GitHub: '#24292E',
|
|
|
|
Google: '#FCFCFC'
|
|
|
|
}
|
|
|
|
|
2022-01-07 21:21:38 +01:00
|
|
|
const className =
|
|
|
|
'py-2 px-6 inline-flex outline-none items-center font-paragraph rounded-lg cursor-pointer transition duration-300 ease-in-out hover:opacity-80 focus:outline-none'
|
|
|
|
|
|
|
|
interface SocialMediaChildrenProps {
|
|
|
|
socialMedia: SocialMedia
|
|
|
|
}
|
|
|
|
|
|
|
|
const SocialMediaChildren: React.FC<SocialMediaChildrenProps> = (props) => {
|
|
|
|
const { socialMedia } = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Image
|
2022-04-07 16:54:05 +02:00
|
|
|
quality={100}
|
2022-01-07 21:21:38 +01:00
|
|
|
width={20}
|
|
|
|
height={20}
|
|
|
|
src={`/images/svg/web/${socialMedia}.svg`}
|
|
|
|
alt={socialMedia}
|
|
|
|
/>
|
|
|
|
<span className='ml-2'>{socialMedia}</span>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SocialMediaButtonProps
|
|
|
|
extends React.ComponentPropsWithRef<'button'>,
|
|
|
|
SocialMediaChildrenProps {}
|
|
|
|
|
2021-10-24 05:48:06 +02:00
|
|
|
export const SocialMediaButton: React.FC<SocialMediaButtonProps> = (props) => {
|
2022-01-07 21:21:38 +01:00
|
|
|
const { socialMedia, className: givenClassName, ...rest } = props
|
2021-10-24 05:48:06 +02:00
|
|
|
|
|
|
|
const socialMediaColor = useMemo(() => {
|
|
|
|
return socialMediaColors[socialMedia]
|
|
|
|
}, [socialMedia])
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<button
|
|
|
|
{...rest}
|
2022-01-07 21:21:38 +01:00
|
|
|
className={classNames(className, 'button', givenClassName)}
|
2021-10-24 05:48:06 +02:00
|
|
|
>
|
2022-01-07 21:21:38 +01:00
|
|
|
<SocialMediaChildren socialMedia={socialMedia} />
|
2021-10-24 05:48:06 +02:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<style jsx>
|
|
|
|
{`
|
|
|
|
.button {
|
|
|
|
background: ${socialMediaColor};
|
|
|
|
color: ${socialMedia === 'Google' ? '#000' : '#fff'};
|
|
|
|
border: ${socialMedia === 'Google' ? '1px solid #000' : 'none'};
|
|
|
|
}
|
|
|
|
.button:focus {
|
|
|
|
box-shadow: 0 0 0 2px #27b05e;
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
</style>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2022-01-07 21:21:38 +01:00
|
|
|
|
|
|
|
export interface SocialMediaLinkProps
|
|
|
|
extends React.ComponentPropsWithRef<'a'>,
|
|
|
|
SocialMediaChildrenProps {}
|
|
|
|
|
|
|
|
export const SocialMediaLink: React.FC<SocialMediaLinkProps> = (props) => {
|
|
|
|
const { socialMedia, className: givenClassName, ...rest } = props
|
|
|
|
|
|
|
|
const socialMediaColor = useMemo(() => {
|
|
|
|
return socialMediaColors[socialMedia]
|
|
|
|
}, [socialMedia])
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<a {...rest} className={classNames(className, 'link', givenClassName)}>
|
|
|
|
<SocialMediaChildren socialMedia={socialMedia} />
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<style jsx>
|
|
|
|
{`
|
|
|
|
.link {
|
|
|
|
background: ${socialMediaColor};
|
|
|
|
color: ${socialMedia === 'Google' ? '#000' : '#fff'};
|
|
|
|
border: ${socialMedia === 'Google' ? '1px solid #000' : 'none'};
|
|
|
|
}
|
|
|
|
.link:focus {
|
|
|
|
box-shadow: 0 0 0 2px #27b05e;
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
</style>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|