feat: migrate ColorSwatch and public color boundary

This commit is contained in:
maoyingjie
2026-10-26 13:25:21 +08:00
parent 60af6ee40b
commit 270dea5cff
29 changed files with 1427 additions and 18 deletions
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-3">
<ColorSwatch aria-label="主品牌色" color="#0485F7" colorName="海洋蓝" />
<ColorSwatch aria-label="错误状态色" color="#EF4444" colorName="珊瑚红" />
<ColorSwatch aria-label="警告色" color="#F59E0B" colorName="落日橙" />
</div>
</template>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-3">
<ColorSwatch aria-label="蓝色" color="#0485F7" />
<ColorSwatch aria-label="红色" color="#EF4444" />
<ColorSwatch aria-label="琥珀色" color="#F59E0B" />
<ColorSwatch aria-label="绿色" color="#10B981" />
<ColorSwatch aria-label="品红" color="#D946EF" />
</div>
</template>
@@ -0,0 +1,39 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
const colors = ["#0485F7", "#EF4444", "#F59E0B", "#10B981", "#D946EF"];
</script>
<template>
<div class="flex flex-col gap-8">
<div class="flex flex-col gap-2">
<span class="text-sm text-muted">发光效果</span>
<div class="flex items-center gap-4">
<ColorSwatch
v-for="color in colors"
:key="color"
:color="color"
size="xl"
:style-fn="() => ({ boxShadow: `0 0 20px 2px ${color}` })"
/>
</div>
</div>
<div class="flex flex-col gap-2">
<span class="text-sm text-muted">渐变</span>
<div class="flex items-center gap-4">
<ColorSwatch
v-for="color in colors"
:key="color"
:color="color"
size="xl"
:style-fn="
({ color: current }) => ({
background: `linear-gradient(135deg, ${current.toString('css')}, white)`,
})
"
/>
</div>
</div>
</div>
</template>
@@ -0,0 +1,25 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
const colors = [
{ color: "#0485F7", label: "蓝色", name: "blue" },
{ color: "#EF4444", label: "红色", name: "red" },
{ color: "#F59E0B", label: "琥珀色", name: "amber" },
{ color: "#10B981", label: "绿色", name: "green" },
{ color: "#D946EF", label: "品红", name: "fuchsia" },
];
</script>
<template>
<div class="flex items-center gap-3">
<ColorSwatch
v-for="item in colors"
:key="item.color"
:color="item.color"
:aria-label="item.label"
as-child
>
<div :data-custom="item.name" />
</ColorSwatch>
</div>
</template>
+10
View File
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-3">
<ColorSwatch color="#0485F7" shape="circle" />
<ColorSwatch color="#0485F7" shape="square" />
</div>
</template>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-3">
<ColorSwatch color="#0485F7" size="xs" />
<ColorSwatch color="#EF4444" size="sm" />
<ColorSwatch color="#F59E0B" size="md" />
<ColorSwatch color="#10B981" size="lg" />
<ColorSwatch color="#D946EF" size="xl" />
</div>
</template>
@@ -0,0 +1,13 @@
<script setup lang="ts">
import { ColorSwatch } from "@heroui-vue/components";
</script>
<template>
<div class="flex items-center gap-3">
<ColorSwatch aria-label="100% 不透明度" color="rgba(4, 133, 247, 1)" />
<ColorSwatch aria-label="75% 不透明度" color="rgba(4, 133, 247, 0.75)" />
<ColorSwatch aria-label="50% 不透明度" color="rgba(4, 133, 247, 0.5)" />
<ColorSwatch aria-label="25% 不透明度" color="rgba(4, 133, 247, 0.25)" />
<ColorSwatch aria-label="0% 不透明度" color="rgba(4, 133, 247, 0)" />
</div>
</template>