ColorPickerRoot
ColorPickerRoot compone un disparador con muestra de color y una superficie de popover, y deja la interfaz del editor a sus ranuras. La ranura del disparador recibe el estilo actual de la muestra; la ranura predeterminada recibe el color actual del grafo de escena.
openChange informa del límite completo de la interacción con el selector. cancel se emite antes de un cierre con Escape, lo que permite a los consumidores de BindableValue revertir juntas la desvinculación de una variable y la actualización de la pintura. Abrir el selector o darle el foco no emite ninguna actualización de color.
vue
<script setup lang="ts">
import { ref } from 'vue'
import type { Color } from '@pairdraw/scene-graph/primitives'
import { ColorPickerRoot } from '@pairdraw/vue/primitives/ColorPicker'
const color = ref<Color>({ r: 0.2, g: 0.5, b: 0.9, a: 1 })
</script>
<template>
<ColorPickerRoot
:color="color"
@update="color = $event"
@open-change="open => console.log(open)"
@cancel="console.log('cancel')"
>
<template #trigger="{ style }">
<button :style="style" aria-label="Edit color" />
</template>
<template #default="{ color: currentColor }">
<output>{{ currentColor.r }}, {{ currentColor.g }}, {{ currentColor.b }}</output>
</template>
</ColorPickerRoot>
</template>Referencia de API generada
ColorPickerRoot
Generated from packages/vue/src/primitives/ColorPicker/ColorPickerRoot.vue
Props
| Prop | Default | Type |
|---|---|---|
color* | — | Color |
label | "Edit color" | string | undefined |
ui | — | ColorPickerUI | undefined |
colorProfileThe profile the color is stored in; the trigger's swatch then draws the color the canvas draws.
Defaults to sRGB. | "srgb" | ColorProfile | undefined |
escapeRevertsFor a colour with no undo history, such as a preference: Escape closing the picker puts back
the colour it opened with. Otherwise Escape keeps the edit, as Figma's picker does. | false | boolean | undefined |
keepOpenWhether a press outside the picker should leave it open, such as one that samples the canvas. | — | PickerKeepOpen | undefined |
Events
| Event | Payload | Description |
|---|---|---|
cancel | [cause: PickerCancelCause] | |
commit | [] | |
update | [color: Color] | |
openChange | [open: boolean] |
Slots
| Slot | Props | Description |
|---|---|---|
trigger | { style: { background: string; }; } | |
default | { color: Color; update: (next: Color) => void; } |