feat: initialize Vue component library and aligned documentation
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import { defineComponent, h, type PropType } from "vue";
|
||||
import { Button, buttonVariants, tv } from "@heroui-vue/components";
|
||||
const myButtonVariants = tv({
|
||||
extend: buttonVariants,
|
||||
base: "text-base font-semibold shadow-md text-shadow-lg data-[pending=true]:opacity-40",
|
||||
variants: {
|
||||
variant: {
|
||||
primary:
|
||||
"text-white dark:bg-white/10 dark:text-white dark:hover:bg-white/15",
|
||||
},
|
||||
radius: {
|
||||
full: "rounded-full",
|
||||
lg: "rounded-lg",
|
||||
md: "rounded-md",
|
||||
sm: "rounded-sm",
|
||||
},
|
||||
size: {
|
||||
sm: "h-10 px-4",
|
||||
md: "h-11 px-6",
|
||||
lg: "h-12 px-8",
|
||||
xl: "h-13 px-10",
|
||||
},
|
||||
},
|
||||
defaultVariants: { radius: "full", size: "md", variant: "primary" },
|
||||
});
|
||||
const CustomButton = defineComponent({
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
radius: {
|
||||
type: String as PropType<"full" | "lg" | "md" | "sm">,
|
||||
default: "full",
|
||||
},
|
||||
size: {
|
||||
type: String as PropType<"sm" | "md" | "lg" | "xl">,
|
||||
default: "md",
|
||||
},
|
||||
},
|
||||
setup(props, { attrs, slots }) {
|
||||
return () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
...attrs,
|
||||
class: myButtonVariants({
|
||||
radius: props.radius,
|
||||
size: props.size,
|
||||
class: attrs.class as string,
|
||||
}),
|
||||
},
|
||||
slots,
|
||||
);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<CustomButton>自定义按钮</CustomButton>
|
||||
</template>
|
||||
Reference in New Issue
Block a user