feat: publish ColorField and shared color input parts

This commit is contained in:
maoyingjie
2026-10-27 11:53:02 +08:00
parent 108a120c81
commit 6a7a89be6b
34 changed files with 1511 additions and 39 deletions
@@ -0,0 +1,69 @@
<script setup lang="ts">
import { shallowRef } from "vue";
import type { Color } from "@heroui-vue/components";
import {
ColorField,
ColorFieldGroup,
ColorFieldInput,
ColorFieldSuffix,
ColorSwatch,
Label,
parseColor,
} from "@heroui-vue/components";
const color = shallowRef<Color | null>(parseColor("#7F007F"));
</script>
<template>
<div class="flex flex-col gap-4">
<p class="text-sm text-muted">分别编辑 HSL 通道:</p>
<div class="flex gap-4">
<ColorField
channel="hue"
class="w-[100px]"
color-space="hsl"
name="hue"
v-model="color"
>
<Label>色相</Label>
<ColorFieldGroup>
<ColorFieldInput />
</ColorFieldGroup>
</ColorField>
<ColorField
channel="saturation"
class="w-[100px]"
color-space="hsl"
name="saturation"
v-model="color"
>
<Label>饱和度</Label>
<ColorFieldGroup>
<ColorFieldInput />
<ColorFieldSuffix>
<span class="text-sm text-muted">%</span>
</ColorFieldSuffix>
</ColorFieldGroup>
</ColorField>
<ColorField
channel="lightness"
class="w-[100px]"
color-space="hsl"
name="lightness"
v-model="color"
>
<Label>明度</Label>
<ColorFieldGroup>
<ColorFieldInput />
<ColorFieldSuffix>
<span class="text-sm text-muted">%</span>
</ColorFieldSuffix>
</ColorFieldGroup>
</ColorField>
</div>
<div class="flex items-center gap-2">
<ColorSwatch :color="color ?? undefined" size="md" />
<span class="text-sm">
当前:{{ color ? color.toString("hex") : "(空)" }}
</span>
</div>
</div>
</template>