cond0r 30174c597c
Updated Shopify Provider Structure (#340)
* Add codegen, update fragments & schemas

* Update checkout-create.ts

* Update checkout-create.ts

* Update README.md

* Update product mutations & queries

* Uptate customer fetch types

* Update schemas

* Start updates

* Moved Page, AllPages & Site Info

* Moved product, all products (paths)

* Add translations, update operations & fixes

* Update api endpoints, types & fixes

* Add api checkout endpoint

* Updates

* Fixes

* Update commerce.config.json

Co-authored-by: B <curciobelen@gmail.com>
2021-05-31 12:39:13 -05:00

55 lines
1.1 KiB
TypeScript

import cn from 'classnames'
import { FC } from 'react'
import s from './Swatch.module.css'
import { Check } from '@components/icons'
import Button, { ButtonProps } from '@components/ui/Button'
import { isDark } from '@lib/colors'
interface Props {
active?: boolean
children?: any
className?: string
label?: string
variant?: 'size' | 'color' | string
color?: string
}
const Swatch: FC<Omit<ButtonProps, 'variant'> & Props> = ({
className,
color = '',
label,
variant = 'size',
active,
...props
}) => {
variant = variant?.toLowerCase()
label = label?.toLowerCase()
const rootClassName = cn(
s.root,
{
[s.active]: active,
[s.size]: variant === 'size',
[s.color]: color,
[s.dark]: color ? isDark(color) : false,
},
className
)
return (
<Button
className={rootClassName}
style={color ? { backgroundColor: color } : {}}
aria-label="Variant Swatch"
{...props}
>
{variant === 'color' && active && (
<span>
<Check />
</span>
)}
{variant === 'size' ? label : null}
</Button>
)
}
export default Swatch