feat: establish shared color state and area interaction foundation

This commit is contained in:
maoyingjie
2026-10-25 11:10:47 +08:00
parent 58ca16e774
commit 57d7cbb2d6
26 changed files with 2429 additions and 88 deletions
+147
View File
@@ -0,0 +1,147 @@
<script setup lang="ts">
import { shallowRef } from "vue";
import Area from "../../../packages/vue/tests/fixtures/ColorAreaFoundation.vue";
import Picker from "../../../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
import { parseColor } from "../../../packages/vue/src/components/color/value";
import {
Button,
Popover,
PopoverContent,
PopoverDialog,
} from "@heroui-vue/components";
const count = shallowRef(0),
end = shallowRef(0),
rejected = shallowRef(0),
rejectEnd = shallowRef(0);
const rejectedValue = parseColor("hsb(240,50%,50%)");
</script>
<template>
<main class="color-foundation-lab">
<h1>颜色共享状态 · 私有基建验收</h1>
<p>颜色、通道与透明度共用一个接受值;公开组件和正式文档尚未迁移。</p>
<div class="color-foundation-grid">
<section id="color-shared">
<h2>Area / Hue / 文本 / Swatch 同步</h2>
<form>
<Picker
name="color"
default-value="hsb(240,50%,50%)"
@change="count++"
@change-end="end++"
/>
<output>change {{ count }} / changeEnd {{ end }}</output>
<Button type="reset" variant="secondary" size="sm">原生重置</Button>
</form>
</section>
<section id="color-rejected">
<h2>受控拒绝:指针和提交保持父值</h2>
<Picker
:model-value="rejectedValue"
@change="rejected++"
@change-end="rejectEnd++"
/>
<output>拒绝 {{ rejected }} / 完成 {{ rejectEnd }}</output>
</section>
<section id="color-gray">
<h2>灰色保留色相和 alpha</h2>
<Picker default-value="hsb(270,0%,50%,.5)" />
</section>
<section id="color-rgb">
<h2>RGB 交换轴 / RTL</h2>
<Area
default-value="rgb(80,120,160)"
color-space="rgb"
x-channel="blue"
y-channel="red"
dir="rtl"
aria-label="RGB blue/red"
/>
</section>
<section id="color-hue-y">
<h2>Hue 在 Y 轴</h2>
<Area
default-value="hsb(240,70%,70%)"
color-space="hsb"
x-channel="brightness"
y-channel="hue"
aria-label="Brightness/hue"
/>
</section>
<section id="color-popover">
<h2>跨 Popover 保持共享 owner</h2>
<Picker default-value="hsb(120,50%,70%)" v-slot="{ value }">
<Popover>
<Button variant="secondary">打开颜色区域</Button>
<PopoverContent class="w-64">
<PopoverDialog>
<Area
color-space="hsb"
x-channel="saturation"
y-channel="brightness"
aria-label="Popover color area"
/>
</PopoverDialog>
</PopoverContent>
</Popover>
<output>{{ value?.toString("hsb") }}</output>
</Picker>
</section>
</div>
</main>
</template>
<style>
.color-foundation-lab {
padding: 32px;
min-height: 100vh;
background: var(--background);
color: var(--foreground);
font-family: Inter, sans-serif;
}
.color-foundation-lab h1 {
font-size: 24px;
margin-bottom: 8px;
}
.color-foundation-lab p {
color: var(--muted);
margin-bottom: 24px;
}
.color-foundation-grid {
display: flex;
flex-wrap: wrap;
gap: 24px;
align-items: flex-start;
}
.color-foundation-grid section {
padding: 20px;
border: 1px solid var(--border);
border-radius: 16px;
min-width: 300px;
}
.color-foundation-grid h2 {
font-size: 14px;
margin-bottom: 20px;
}
.color-foundation-grid output {
display: block;
font-size: 12px;
margin: 12px 0;
}
.color-foundation-grid
[data-color-picker-foundation]
> input:not([type="hidden"]) {
display: block;
margin-top: 16px;
max-width: 224px;
}
.color-foundation-grid [data-color-text] {
border: 1px solid var(--border);
border-radius: 8px;
padding: 6px;
font-size: 13px;
}
.color-foundation-grid [data-color-swatch] {
margin-top: 8px;
border: 1px solid var(--border);
border-radius: 8px;
}
</style>