feat: publish ColorField and shared color input parts
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<script setup lang="ts">
|
||||
import { shallowRef } from "vue";
|
||||
import type { Color } from "@heroui-vue/components";
|
||||
import {
|
||||
Button,
|
||||
ColorField,
|
||||
ColorFieldGroup,
|
||||
ColorFieldInput,
|
||||
ColorFieldPrefix,
|
||||
ColorSwatch,
|
||||
Description,
|
||||
Label,
|
||||
parseColor,
|
||||
} from "@heroui-vue/components";
|
||||
const value = shallowRef<Color | null>(parseColor("#0485F7"));
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<ColorField class="w-[280px]" name="color" v-model="value">
|
||||
<Label>颜色</Label>
|
||||
<ColorFieldGroup>
|
||||
<ColorFieldPrefix>
|
||||
<ColorSwatch :color="value ?? undefined" size="xs" />
|
||||
</ColorFieldPrefix>
|
||||
<ColorFieldInput />
|
||||
</ColorFieldGroup>
|
||||
<Description>
|
||||
当前值:{{ value ? value.toString("hex") : "(空)" }}
|
||||
</Description>
|
||||
</ColorField>
|
||||
<div class="flex gap-2">
|
||||
<Button variant="tertiary" @click="value = parseColor('#EF4444')">
|
||||
设为红色
|
||||
</Button>
|
||||
<Button variant="tertiary" @click="value = parseColor('#10B981')">
|
||||
设为绿色
|
||||
</Button>
|
||||
<Button variant="tertiary" @click="value = null">清空</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user