Files
link-free/src/components/Button/styles.ts

232 lines
5.5 KiB
TypeScript
Raw Normal View History

2021-12-11 13:42:11 -03:00
import { ColorsType, styled, theme, VariantProps } from '../../styles/stitches.config'
2021-12-11 01:48:15 -03:00
const colorVariantFn = (
2021-12-11 13:42:11 -03:00
lightColor: ColorsType,
regularColor: ColorsType,
darkColor: ColorsType,
darkerColor: ColorsType
2021-12-11 01:48:15 -03:00
) => ({
background: theme.colors[regularColor],
borderColor: theme.colors[regularColor],
color: theme.colors[lightColor],
'&:hover': {
background: theme.colors[darkColor],
borderColor: theme.colors[darkColor]
},
'&:active': {
background: theme.colors[darkerColor],
borderColor: theme.colors[darkerColor]
}
})
2021-12-12 23:45:41 -03:00
const outlineVariantFn = (color: ColorsType) => ({
color: theme.colors[color],
2021-12-11 01:48:15 -03:00
'&:hover': {
2021-12-12 23:45:41 -03:00
background: 'rgba(0, 0, 0, 0.05)'
2021-12-11 01:48:15 -03:00
},
'&:active': {
2021-12-12 23:45:41 -03:00
background: 'rgba(0, 0, 0, 0.1)'
2021-12-11 01:48:15 -03:00
}
})
export const Wrapper = styled('button', {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
height: '3rem',
borderWidth: '2.5px',
borderStyle: 'solid',
fontSize: '1rem',
2021-12-12 23:45:41 -03:00
fontWeight: 500,
2021-12-11 01:48:15 -03:00
cursor: 'pointer',
transition: 'all 0.25s ease-in-out',
'&:hover': {
transform: 'translateY(-0.15rem)'
},
variants: {
color: {
slate: colorVariantFn('slate50', 'slate600', 'slate700', 'slate800'),
gray: colorVariantFn('gray50', 'gray600', 'gray700', 'gray800'),
zinc: colorVariantFn('zinc50', 'zinc600', 'zinc700', 'zinc800'),
neutral: colorVariantFn('neutral50', 'neutral600', 'neutral700', 'neutral800'),
stone: colorVariantFn('stone50', 'stone600', 'stone700', 'stone800'),
red: colorVariantFn('red50', 'red600', 'red700', 'red800'),
orange: colorVariantFn('orange50', 'orange600', 'orange700', 'orange800'),
amber: colorVariantFn('amber50', 'amber600', 'amber700', 'amber800'),
yellow: colorVariantFn('yellow50', 'yellow600', 'yellow700', 'yellow800'),
lime: colorVariantFn('lime50', 'lime600', 'lime700', 'lime800'),
green: colorVariantFn('green50', 'green600', 'green700', 'green800'),
emerald: colorVariantFn('emerald50', 'emerald600', 'emerald700', 'emerald800'),
teal: colorVariantFn('teal50', 'teal600', 'teal700', 'teal800'),
cyan: colorVariantFn('cyan50', 'cyan600', 'cyan700', 'cyan800'),
sky: colorVariantFn('sky50', 'sky600', 'sky700', 'sky800'),
blue: colorVariantFn('blue50', 'blue600', 'blue700', 'blue800'),
indigo: colorVariantFn('indigo50', 'indigo600', 'indigo700', 'indigo800'),
violet: colorVariantFn('violet50', 'violet600', 'violet700', 'violet800'),
purple: colorVariantFn('purple50', 'purple600', 'purple700', 'purple800'),
fuchsia: colorVariantFn('fuchsia50', 'fuchsia600', 'fuchsia700', 'fuchsia800'),
pink: colorVariantFn('pink50', 'pink600', 'pink700', 'pink800'),
rose: colorVariantFn('rose50', 'rose600', 'rose700', 'rose800')
},
schema: {
square: {
borderRadius: '0'
},
rounded: {
borderRadius: '0.5rem'
},
pill: {
borderRadius: '9999px'
2021-12-11 12:37:12 -03:00
}
},
2021-12-12 23:45:41 -03:00
font: {
baloo: {
fontFamily: theme.fonts.baloo
},
montserrat: {
fontFamily: theme.fonts.montserrat
},
roboto: {
fontFamily: theme.fonts.roboto
}
},
2021-12-11 12:37:12 -03:00
outline: {
true: {
2021-12-11 01:48:15 -03:00
background: 'transparent'
}
}
},
compoundVariants: [
{
color: 'slate',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('slate600')
2021-12-11 01:48:15 -03:00
},
{
color: 'gray',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('gray600')
2021-12-11 01:48:15 -03:00
},
{
color: 'zinc',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('zinc600')
2021-12-11 01:48:15 -03:00
},
{
color: 'neutral',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('neutral600')
2021-12-11 01:48:15 -03:00
},
{
color: 'stone',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('stone600')
2021-12-11 01:48:15 -03:00
},
{
color: 'red',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('red600')
2021-12-11 01:48:15 -03:00
},
{
color: 'orange',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('orange600')
2021-12-11 01:48:15 -03:00
},
{
color: 'amber',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('amber600')
2021-12-11 01:48:15 -03:00
},
{
color: 'yellow',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('yellow600')
2021-12-11 01:48:15 -03:00
},
{
color: 'lime',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('lime600')
2021-12-11 01:48:15 -03:00
},
{
color: 'green',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('green600')
2021-12-11 01:48:15 -03:00
},
{
color: 'emerald',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('emerald600')
2021-12-11 01:48:15 -03:00
},
{
color: 'teal',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('teal600')
2021-12-11 01:48:15 -03:00
},
{
color: 'cyan',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('cyan600')
2021-12-11 01:48:15 -03:00
},
{
color: 'sky',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('sky600')
2021-12-11 01:48:15 -03:00
},
{
color: 'blue',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('blue600')
2021-12-11 01:48:15 -03:00
},
{
color: 'indigo',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('indigo600')
2021-12-11 01:48:15 -03:00
},
{
color: 'violet',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('violet600')
2021-12-11 01:48:15 -03:00
},
{
color: 'purple',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('purple600')
2021-12-11 01:48:15 -03:00
},
{
color: 'fuchsia',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('fuchsia600')
2021-12-11 01:48:15 -03:00
},
{
color: 'pink',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('pink600')
2021-12-11 01:48:15 -03:00
},
{
color: 'rose',
2021-12-11 12:37:12 -03:00
outline: true,
2021-12-12 23:45:41 -03:00
css: outlineVariantFn('rose600')
2021-12-11 01:48:15 -03:00
}
],
defaultVariants: {
color: 'teal',
2021-12-11 12:37:12 -03:00
schema: 'pill',
2021-12-12 23:45:41 -03:00
font: 'roboto',
2021-12-11 12:37:12 -03:00
outline: false
2021-12-11 01:48:15 -03:00
}
})
2021-12-11 13:42:11 -03:00
export type ButtonVariantProps = VariantProps<typeof Wrapper>