refactor(Button): use VariantProps for Button Props instead of NonNullable
This commit is contained in:
parent
ff2727500c
commit
2643f562cc
|
|
@ -1,15 +1,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { VariantProps } from 'class-variance-authority'
|
||||||
import { Primitive, type PrimitiveProps } from 'radix-vue'
|
import { Primitive, type PrimitiveProps } from 'radix-vue'
|
||||||
import { buttonVariants } from '.'
|
import { buttonVariants } from '.'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
|
interface ButtonVariantProps extends VariantProps<typeof buttonVariants> {}
|
||||||
|
|
||||||
interface Props extends PrimitiveProps {
|
interface Props extends PrimitiveProps {
|
||||||
variant?: NonNullable<Parameters<typeof buttonVariants>[0]>['variant']
|
variant?: ButtonVariantProps['variant']
|
||||||
size?: NonNullable<Parameters<typeof buttonVariants>[0]>['size']
|
size?: ButtonVariantProps['size']
|
||||||
as?: string
|
as?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
withDefaults(defineProps<Props>(), {
|
withDefaults(defineProps<Props>(), {
|
||||||
|
variant: 'default',
|
||||||
|
size: 'default',
|
||||||
as: 'button',
|
as: 'button',
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { VariantProps } from 'class-variance-authority'
|
||||||
import { Primitive, type PrimitiveProps } from 'radix-vue'
|
import { Primitive, type PrimitiveProps } from 'radix-vue'
|
||||||
import { buttonVariants } from '.'
|
import { buttonVariants } from '.'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
|
interface ButtonVariantProps extends VariantProps<typeof buttonVariants> {}
|
||||||
|
|
||||||
interface Props extends PrimitiveProps {
|
interface Props extends PrimitiveProps {
|
||||||
variant?: NonNullable<Parameters<typeof buttonVariants>[0]>['variant']
|
variant?: ButtonVariantProps['variant']
|
||||||
size?: NonNullable<Parameters<typeof buttonVariants>[0]>['size']
|
size?: ButtonVariantProps['size']
|
||||||
as?: string
|
as?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
withDefaults(defineProps<Props>(), {
|
withDefaults(defineProps<Props>(), {
|
||||||
|
variant: 'default',
|
||||||
|
size: 'default',
|
||||||
as: 'button',
|
as: 'button',
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user