feat: establish composed color picker protocol
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
/* Adapted from HeroUI ce90ea3, Apache-2.0; see third-party/HEROUI-LICENSE. */
|
||||
/* ==========================================================================
|
||||
ColorPicker - Color selection component with popover
|
||||
========================================================================== */
|
||||
|
||||
/* Base color-picker styles */
|
||||
.hv-color-picker {
|
||||
@apply inline-flex;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Trigger
|
||||
========================================================================== */
|
||||
|
||||
.hv-color-picker__trigger {
|
||||
@apply inline-flex items-center gap-3 rounded-sm text-sm no-highlight;
|
||||
|
||||
/* Cursor */
|
||||
cursor: var(--cursor-interactive);
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
background-color 150ms var(--ease-smooth),
|
||||
box-shadow 150ms var(--ease-out);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
[data-slot="label"] {
|
||||
cursor: var(--cursor-interactive);
|
||||
}
|
||||
|
||||
/* Focus visible state */
|
||||
&:focus-visible:not([data-focused]),
|
||||
&[data-focus-visible="true"] {
|
||||
@apply status-focused;
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&:disabled,
|
||||
&[data-disabled="true"],
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Popover
|
||||
========================================================================== */
|
||||
|
||||
.hv-color-picker__popover {
|
||||
@apply min-w-62 origin-(--reka-popper-transform-origin) scrollbar-none overflow-x-hidden overflow-y-auto overscroll-contain bg-overlay px-2 pt-2 pb-3;
|
||||
box-shadow: var(--overlay-shadow);
|
||||
border-radius: min(32px, calc(var(--radius) * 2.5));
|
||||
/* Content layout */
|
||||
@apply flex flex-col gap-3;
|
||||
|
||||
/* Focus state */
|
||||
&:focus-visible:not([data-focused]),
|
||||
&[data-focus-visible="true"] {
|
||||
@apply outline-none;
|
||||
}
|
||||
|
||||
/* Entering animations */
|
||||
&[data-entering="true"] {
|
||||
@apply animate-in duration-150 ease-smooth fade-in-0 zoom-in-95;
|
||||
|
||||
/* Placement-specific translations */
|
||||
&[data-side="top"] {
|
||||
@apply slide-in-from-bottom-1;
|
||||
}
|
||||
|
||||
&[data-side="bottom"] {
|
||||
@apply slide-in-from-top-1;
|
||||
}
|
||||
|
||||
&[data-side="left"] {
|
||||
@apply slide-in-from-right-1;
|
||||
}
|
||||
|
||||
&[data-side="right"] {
|
||||
@apply slide-in-from-left-1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Exiting animations */
|
||||
&[data-exiting="true"] {
|
||||
@apply animate-out duration-100 ease-smooth zoom-out-95 fade-out;
|
||||
/* Stays non-interactive while closing, even if the exit animation is interrupted. */
|
||||
@apply pointer-events-none;
|
||||
}
|
||||
|
||||
&[data-exiting="true"],
|
||||
&[data-entering="true"] {
|
||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||
}
|
||||
}
|
||||
|
||||
/* Reka supplies available height on the positioned surface. Picker scrolls its own content. */
|
||||
.hv-popover.hv-color-picker__popover {
|
||||
max-height: var(--reka-popover-content-available-height);
|
||||
&[data-entering="true"] {
|
||||
--tw-enter-scale: 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-popover.hv-color-picker__popover:is(
|
||||
[data-entering="true"],
|
||||
[data-exiting="true"]
|
||||
) {
|
||||
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||
}
|
||||
@@ -168,3 +168,5 @@
|
||||
|
||||
@import "./components/color-field.css" layer(components);
|
||||
@import "./components/color-input-group.css" layer(components);
|
||||
|
||||
@import "./components/color-picker.css" layer(components);
|
||||
|
||||
Reference in New Issue
Block a user