merge: integrate reviewed M30-M32 with NumberField Slider and migration lessons
This commit is contained in:
@@ -0,0 +1,224 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- prefix; Vue state adaptation. */
|
||||
/* Number field styles */
|
||||
.hv-number-field {
|
||||
@apply flex flex-col gap-1;
|
||||
|
||||
&[data-invalid="true"],
|
||||
&[aria-invalid="true"] {
|
||||
[data-slot="description"] {
|
||||
@apply hidden;
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="label"] {
|
||||
@apply w-fit;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-number-field__group {
|
||||
@apply grid h-9 items-center overflow-hidden rounded-field border bg-field text-sm text-field-foreground shadow-field outline-none;
|
||||
border-width: var(--border-width-field);
|
||||
border-color: var(--field-border);
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
&:has([slot="decrement"]) {
|
||||
grid-template-columns: 40px 1fr;
|
||||
}
|
||||
|
||||
&:has([slot="increment"]) {
|
||||
grid-template-columns: 1fr 40px;
|
||||
}
|
||||
|
||||
&:has([slot="decrement"]):has([slot="increment"]) {
|
||||
grid-template-columns: 40px 1fr 40px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
background-color 150ms var(--ease-smooth),
|
||||
border-color 150ms var(--ease-smooth),
|
||||
box-shadow 150ms var(--ease-out);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
/* Hover state */
|
||||
@media (hover: hover) {
|
||||
&:hover:not(:focus-within),
|
||||
&[data-hovered="true"]:not([data-focus-within="true"]) {
|
||||
@apply bg-field-hover;
|
||||
border-color: var(--field-border-hover);
|
||||
}
|
||||
}
|
||||
|
||||
/* Focus within state */
|
||||
&[data-focus-within="true"],
|
||||
&:focus-within {
|
||||
@apply status-focused-field;
|
||||
border-color: var(--field-border-focus);
|
||||
background-color: var(--field-focus);
|
||||
}
|
||||
|
||||
/* Invalid state */
|
||||
&[data-invalid="true"] {
|
||||
@apply status-invalid-field;
|
||||
background-color: var(--field-focus);
|
||||
border-color: var(--color-field-border-invalid);
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&[data-disabled="true"],
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Browser autofill state.
|
||||
* The user-agent paints `:-webkit-autofill`/`:autofill` on the inner <input>
|
||||
* only. Because the input has its border-radius stripped on whichever side
|
||||
* touches the increment/decrement buttons, the autofill highlight ends up
|
||||
* as a sharp-cornered rectangle and the buttons receive no highlight.
|
||||
* Lift the highlight onto the group so the rounded shell + buttons all
|
||||
* share it. (Affects autofilled numeric fields, e.g. OTP/year inputs.)
|
||||
*/
|
||||
&:has([data-slot="number-field-input"]:-webkit-autofill),
|
||||
&:has([data-slot="number-field-input"]:autofill) {
|
||||
background-color: var(--field-focus);
|
||||
border-color: var(--field-border-focus);
|
||||
}
|
||||
}
|
||||
|
||||
.hv-number-field__input {
|
||||
@apply min-w-0 rounded-none border-0 bg-transparent px-3 py-2 text-base tabular-nums shadow-none outline-none sm:text-sm;
|
||||
|
||||
/* Remove border radius on left side when decrement button is present */
|
||||
.hv-number-field__group:has([slot="decrement"]) & {
|
||||
@apply rounded-s-none;
|
||||
}
|
||||
|
||||
/* Remove border radius on right side when increment button is present */
|
||||
.hv-number-field__group:has([slot="increment"]) & {
|
||||
@apply rounded-e-none;
|
||||
}
|
||||
|
||||
/* Focus state - handled by group */
|
||||
&:focus,
|
||||
&:focus-visible {
|
||||
@apply outline-none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Neutralize the browser's per-input autofill paint so the inner <input>
|
||||
* doesn't draw a sharp-cornered yellow rectangle. The unified highlight
|
||||
* is applied to `.hv-number-field__group` above. Preserve the autofilled
|
||||
* text and caret colors, and pin the background-color transition so the
|
||||
* inset box-shadow trick doesn't flicker on state changes.
|
||||
*/
|
||||
&:-webkit-autofill,
|
||||
&:-webkit-autofill:hover,
|
||||
&:-webkit-autofill:focus,
|
||||
&:-webkit-autofill:active,
|
||||
&:autofill {
|
||||
-webkit-box-shadow: 0 0 0 1000px transparent inset;
|
||||
box-shadow: 0 0 0 1000px transparent inset;
|
||||
-webkit-text-fill-color: var(--field-foreground);
|
||||
caret-color: var(--field-foreground);
|
||||
transition: background-color 9999s ease-in-out 0s;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-number-field__increment-button,
|
||||
.hv-number-field__decrement-button {
|
||||
@apply flex h-full w-10 items-center justify-center rounded-none bg-transparent text-field-foreground outline-none;
|
||||
border-width: var(--border-width-field);
|
||||
border-color: var(--field-border);
|
||||
border-style: solid;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
background-color 150ms var(--ease-smooth),
|
||||
border-color 150ms var(--ease-smooth);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
/* Cursor */
|
||||
cursor: var(--cursor-interactive);
|
||||
|
||||
/* Pressed state */
|
||||
&:active,
|
||||
&[data-pressed="true"] {
|
||||
@apply bg-field-foreground/10;
|
||||
transform: scale(0.97);
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&:disabled,
|
||||
&[data-disabled="true"],
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
}
|
||||
|
||||
/* Icon styling */
|
||||
[data-slot="number-field-increment-button-icon"],
|
||||
[data-slot="number-field-decrement-button-icon"] {
|
||||
@apply size-4;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-number-field__increment-button {
|
||||
@apply rounded-s-none rounded-e-field border-s border-field-placeholder/15;
|
||||
}
|
||||
|
||||
.hv-number-field__decrement-button {
|
||||
@apply rounded-s-field rounded-e-none border-e border-field-placeholder/15;
|
||||
}
|
||||
|
||||
/* Variant property definitions */
|
||||
.hv-number-field--primary {
|
||||
/* Default styles */
|
||||
}
|
||||
|
||||
.hv-number-field--secondary .hv-number-field__group {
|
||||
@apply shadow-none;
|
||||
background-color: var(--number-field-group-bg);
|
||||
|
||||
--number-field-group-bg: var(--default);
|
||||
--number-field-group-bg-hover: var(--default-hover);
|
||||
--number-field-group-bg-focus: var(--default);
|
||||
|
||||
@media (hover: hover) {
|
||||
&:hover:not(:focus-within),
|
||||
&[data-hovered="true"]:not([data-focus-within="true"]) {
|
||||
background-color: var(--number-field-group-bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
&:focus-within,
|
||||
&[data-focus-within="true"] {
|
||||
background-color: var(--number-field-group-bg-focus);
|
||||
}
|
||||
|
||||
/* Invalid state */
|
||||
&[data-invalid="true"] {
|
||||
@apply status-invalid-field;
|
||||
border-color: var(--color-field-border-invalid);
|
||||
background-color: var(--number-field-group-bg-focus);
|
||||
}
|
||||
|
||||
[data-slot="number-field-input"] {
|
||||
@apply bg-transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/* Full width modifier */
|
||||
.hv-number-field--full-width {
|
||||
@apply w-full;
|
||||
}
|
||||
|
||||
.hv-number-field__group--full-width {
|
||||
@apply w-full;
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/* Adapted from HeroUI ce90ea3 (Apache-2.0); see third-party/HEROUI-LICENSE. */
|
||||
/* Slider styles */
|
||||
|
||||
.hv-slider {
|
||||
@apply grid w-full gap-1;
|
||||
|
||||
grid-template-areas:
|
||||
"label output"
|
||||
"track track";
|
||||
grid-template-columns: 1fr auto;
|
||||
|
||||
[data-slot="label"] {
|
||||
@apply w-fit text-sm font-medium;
|
||||
|
||||
grid-area: label;
|
||||
}
|
||||
|
||||
.hv-slider__output {
|
||||
@apply text-sm font-medium tabular-nums;
|
||||
|
||||
grid-area: output;
|
||||
}
|
||||
|
||||
.hv-slider__track {
|
||||
@apply relative rounded-xl bg-default;
|
||||
|
||||
grid-area: track;
|
||||
}
|
||||
|
||||
.hv-slider__fill {
|
||||
@apply pointer-events-none absolute bg-accent;
|
||||
}
|
||||
|
||||
.hv-slider__thumb {
|
||||
/* Flex container for centering pseudo-elements */
|
||||
@apply absolute flex cursor-grab items-center justify-center rounded-xl bg-accent no-highlight;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
background-color 250ms var(--ease-smooth),
|
||||
transform 250ms var(--ease-out),
|
||||
box-shadow 150ms var(--ease-out);
|
||||
|
||||
/* after: Visible thumb element */
|
||||
&::after {
|
||||
@apply relative z-10 rounded-lg bg-accent-foreground text-black shadow-field;
|
||||
content: "";
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
*/
|
||||
@apply origin-center transition-all;
|
||||
}
|
||||
|
||||
/* Dragging state - cursor changes and thumb scales down */
|
||||
&[data-dragging="true"] {
|
||||
@apply cursor-grabbing;
|
||||
|
||||
&::after {
|
||||
@apply scale-[0.9];
|
||||
}
|
||||
}
|
||||
|
||||
/* Focus state - increase z-index */
|
||||
&[data-focus-visible="true"] {
|
||||
@apply z-10 status-focused;
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&[data-disabled="true"] {
|
||||
@apply cursor-default;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
&:disabled,
|
||||
&[data-disabled="true"],
|
||||
&[aria-disabled="true"] {
|
||||
@apply status-disabled;
|
||||
|
||||
[data-slot="label"] {
|
||||
@apply opacity-100;
|
||||
}
|
||||
}
|
||||
|
||||
/* Horizontal orientation */
|
||||
&[data-orientation="horizontal"] {
|
||||
flex-direction: column;
|
||||
|
||||
.hv-slider__track {
|
||||
@apply h-5 w-full;
|
||||
/* Add transparent borders to provide space for thumb at edges */
|
||||
/* Thumb width is 1.5rem (24px), so half is 0.75rem (12px) */
|
||||
@apply border-x-[0.75rem] border-x-transparent;
|
||||
|
||||
&[data-fill-start="true"] {
|
||||
@apply border-s-accent;
|
||||
}
|
||||
|
||||
&[data-fill-end="true"] {
|
||||
@apply border-e-accent;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-slider__fill,
|
||||
.hv-slider__thumb {
|
||||
@apply h-full;
|
||||
}
|
||||
|
||||
.hv-slider__thumb {
|
||||
@apply top-1/2;
|
||||
|
||||
/* Thumb width + border width */
|
||||
width: calc(1.5rem + 0.25rem);
|
||||
|
||||
&::after {
|
||||
width: 1.5rem;
|
||||
height: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Vertical orientation */
|
||||
&[data-orientation="vertical"] {
|
||||
@apply h-full gap-2;
|
||||
|
||||
flex-direction: row;
|
||||
grid-template-areas:
|
||||
"output"
|
||||
"track"
|
||||
"label";
|
||||
grid-template-rows: auto 1fr auto;
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
.hv-slider__output {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-slot="label"] {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hv-slider__track {
|
||||
@apply h-full w-5;
|
||||
/* Add transparent borders to provide space for thumb at edges */
|
||||
/* Thumb height is 1.5rem (24px), so half is 0.75rem (12px) */
|
||||
@apply border-y-[0.75rem] border-y-transparent;
|
||||
justify-self: center;
|
||||
|
||||
&[data-fill-start="true"] {
|
||||
@apply border-b-accent;
|
||||
}
|
||||
|
||||
&[data-fill-end="true"] {
|
||||
@apply border-t-accent;
|
||||
}
|
||||
}
|
||||
|
||||
.hv-slider__fill,
|
||||
.hv-slider__thumb {
|
||||
@apply w-full;
|
||||
}
|
||||
|
||||
.hv-slider__thumb {
|
||||
/* Cross-axis centering; React Aria applies a physical translateX(-50%), so keep left-1/2 for RTL correctness */
|
||||
@apply left-1/2;
|
||||
|
||||
/* Thumb height + border height */
|
||||
height: calc(1.5rem + 0.25rem);
|
||||
|
||||
&::after {
|
||||
width: 1rem;
|
||||
height: 1.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hv-slider__thumb:has(.hv-slider__input:focus-visible) {
|
||||
@apply z-10 status-focused;
|
||||
}
|
||||
|
||||
/* Tailwind 4 nested pseudo variants can emit invalid :not(:is()); native media preserves the baseline. */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.hv-slider__thumb,
|
||||
.hv-slider__thumb::after {
|
||||
transition: none;
|
||||
}
|
||||
.hv-slider__thumb[data-dragging="true"]::after {
|
||||
scale: 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user