const metadata = {
title: "Custom Button",
description: "A customizable button component with multiple styles",
category: "Controls"
}
const properties = {
title: {
type: "string",
title: "Button Title"
},
color: {
type: "enum",
options: ["blue", "green", "red", "gray"],
title: "Color"
},
size: {
type: "enum",
options: ["small", "medium", "large"],
title: "Size"
}
} satisfies ComponentProperties;
const body = (props, children) => {
const height = props.size === "small" ? 36
: props.size === "large" ? 56
: 44;
const horizontalPadding = props.size === "small" ? 16
: props.size === "large" ? 32
: 23;
return Text(props.title || "Button")
.fontWeight("semibold")
.foregroundStyle(Color("white"))
.padding('horizontal', horizontalPadding)
.padding('vertical', 8)
.frame({ height })
.background(
Capsule()
.fill(Color(props.color || "blue"))
)
.shadow({ radius: 4, y: 2, color: Color('black').opacity(0.1) })
};
const previews = [
Self({ title: "Click Me", color: "blue", size: "medium" })
.previewName("Default"),
Self({ title: "Submit", color: "green", size: "medium" })
.previewName("Success"),
Self({ title: "Delete", color: "red", size: "medium" })
.previewName("Danger"),
Self({ title: "Small", color: "blue", size: "small" })
.previewName("Small Size"),
Self({ title: "Large Button", color: "blue", size: "large" })
.previewName("Large Size")
];
export default defineComponent({ metadata, properties, body, previews });