2021-07-14 18:11:43 -07:00
|
|
|
import { FunctionComponent } from 'react'
|
2021-04-29 06:51:16 -07:00
|
|
|
import styled from '@emotion/styled'
|
|
|
|
import tw from 'twin.macro'
|
|
|
|
|
2021-07-14 18:11:43 -07:00
|
|
|
export const idleGradient =
|
2021-07-16 17:56:26 -07:00
|
|
|
'bg-gradient-to-r from-secondary-2-light to-primary-light'
|
2021-07-14 18:11:43 -07:00
|
|
|
export const activeGradient =
|
2021-07-14 13:10:53 -07:00
|
|
|
'bg-gradient-to-bl from-secondary-1-light via-primary-dark to-secondary-2-light'
|
|
|
|
|
2021-07-14 18:11:43 -07:00
|
|
|
const StyledButton = styled.button<ButtonProps>`
|
2021-04-29 06:51:16 -07:00
|
|
|
:before {
|
2021-07-14 18:11:43 -07:00
|
|
|
${tw`absolute left-0 top-0 opacity-0 h-full w-full block transition-opacity duration-500`}
|
|
|
|
${({ gray }) => (gray ? tw`bg-bkg-3` : tw`${activeGradient}`)}
|
2021-04-29 06:51:16 -07:00
|
|
|
border-radius: inherit;
|
|
|
|
content: '';
|
|
|
|
z-index: -10;
|
|
|
|
}
|
|
|
|
|
|
|
|
:hover {
|
2021-07-14 13:10:53 -07:00
|
|
|
:before {
|
|
|
|
${tw`opacity-100`}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 18:11:43 -07:00
|
|
|
:focus {
|
2021-07-14 13:10:53 -07:00
|
|
|
${tw`ring-2 ring-secondary-2-light ring-opacity-40 outline-none`}
|
|
|
|
}
|
|
|
|
|
|
|
|
:active {
|
|
|
|
:before {
|
|
|
|
${tw`ring-2 ring-secondary-2-light ring-opacity-40`}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
:disabled {
|
|
|
|
${tw`cursor-not-allowed opacity-60`}
|
|
|
|
:before {
|
|
|
|
${tw`hidden`}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
2021-07-14 18:11:43 -07:00
|
|
|
interface ButtonProps {
|
|
|
|
className?: string
|
|
|
|
gray?: boolean
|
|
|
|
onClick?: () => void
|
|
|
|
disabled?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
const Button: FunctionComponent<ButtonProps> = ({
|
|
|
|
children,
|
|
|
|
className,
|
|
|
|
gray,
|
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<StyledButton
|
2021-07-16 17:56:26 -07:00
|
|
|
className={`${className} relative z-10 px-8 py-2 rounded-full text-fgd-1 font-bold ${
|
2021-07-14 18:11:43 -07:00
|
|
|
gray ? 'bg-bkg-4' : idleGradient
|
|
|
|
}`}
|
|
|
|
gray={gray}
|
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</StyledButton>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-04-26 07:22:30 -07:00
|
|
|
export default Button
|