feat(components/ui): add reusable Button component
This commit is contained in:
22
src/components/ui/Button.astro
Normal file
22
src/components/ui/Button.astro
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
import { cx } from '@styled-system/css'
|
||||||
|
import {
|
||||||
|
type ButtonVariantProps,
|
||||||
|
button as buttonRecipe
|
||||||
|
} from '@styled-system/recipes/button'
|
||||||
|
import type { HTMLAttributes } from 'astro/types'
|
||||||
|
import type { MergeOmitting } from '@/types/utilities'
|
||||||
|
|
||||||
|
type ButtonProps = MergeOmitting<HTMLAttributes<'button'>, ButtonVariantProps>
|
||||||
|
|
||||||
|
export type Props = ButtonProps
|
||||||
|
|
||||||
|
const { class: className, type = 'button', ...props } = Astro.props
|
||||||
|
|
||||||
|
const [buttonRecipeArgs, ButtonProps] = buttonRecipe.splitVariantProps(props)
|
||||||
|
const buttonClass = buttonRecipe(buttonRecipeArgs)
|
||||||
|
---
|
||||||
|
|
||||||
|
<button {...ButtonProps} type={type} class={cx(buttonClass, className)}>
|
||||||
|
<slot />
|
||||||
|
</button>
|
||||||
Reference in New Issue
Block a user