Files
heroui-vue/apps/docs/demos/color-field-channel-editing.vue
T

70 lines
1.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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>