feat: migrate Tag, TagGroup and ErrorMessage with collection and focus contracts
Port the fixed HeroUI baseline tag/tag-group/error-message components onto the existing collection selection/registry protocols instead of a second state model. - TagGroup owns selection, disabled scope, removal requests and name/description wiring; TagGroupList renders the role=grid node and Tag renders role=row. - Removal has one path: a press inside the remove subtree is a removal request, so custom remove buttons work without a second event source; focus follows the next neighbour only after the item is actually gone. - ErrorMessage keeps the baseline slot marker and reuses the field part ids without gaining validation or aria-invalid semantics. - Ship the 12 tag-group and 2 error-message previews, both doc pages, navigation, a 35-case behavioural suite and independent tarball consumption checks.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
|
||||
/* Base error message styles */
|
||||
.hv-error-message {
|
||||
@apply h-auto text-xs wrap-break-word text-danger;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
opacity 150ms var(--ease-out),
|
||||
height 350ms var(--ease-smooth);
|
||||
@apply motion-reduce:transition-none;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
|
||||
/* Base styles */
|
||||
.hv-tag-group {
|
||||
@apply relative flex flex-col gap-1;
|
||||
}
|
||||
|
||||
.hv-tag-group__list {
|
||||
@apply relative flex flex-wrap gap-1.5;
|
||||
}
|
||||
|
||||
.hv-tag-group [slot="description"],
|
||||
.hv-tag-group [data-slot="description"],
|
||||
.hv-tag-group [slot="errorMessage"],
|
||||
.hv-tag-group [data-slot="error-message"] {
|
||||
@apply p-1;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
|
||||
/* Tag component styles */
|
||||
.hv-tag {
|
||||
--optical-offset: 0.031em;
|
||||
|
||||
@apply relative inline-flex items-center gap-1 rounded-xl font-medium select-none no-highlight;
|
||||
|
||||
/* Default size - matches .hv-tag--md */
|
||||
@apply px-2 py-1 text-xs;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition:
|
||||
color 100ms var(--ease-smooth),
|
||||
scale 100ms var(--ease-smooth),
|
||||
opacity 100ms var(--ease-smooth),
|
||||
background-color 100ms var(--ease-smooth),
|
||||
box-shadow 100ms var(--ease-out);
|
||||
@apply origin-center transform-gpu motion-reduce:transition-none;
|
||||
|
||||
/* Cursor */
|
||||
cursor: var(--cursor-interactive);
|
||||
|
||||
/* SVG icon styling */
|
||||
& svg {
|
||||
@apply pointer-events-none size-3 shrink-0 self-center text-current;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
.hv-tag:is([data-disabled="true"], [aria-disabled="true"]) {
|
||||
@apply status-disabled;
|
||||
}
|
||||
|
||||
/* Focus visible state (keyboard focus only) */
|
||||
.hv-tag:is(:focus-visible, [data-focus-visible]) {
|
||||
@apply status-focused;
|
||||
}
|
||||
|
||||
/* Pressed/Active state */
|
||||
.hv-tag:is(:active, [data-pressed="true"]) {
|
||||
}
|
||||
|
||||
/* Selected state */
|
||||
.hv-tag:is([data-selected="true"], [aria-selected="true"]) {
|
||||
@apply bg-accent-soft text-accent-soft-foreground;
|
||||
|
||||
/* Selected + Hover state */
|
||||
@media (hover: hover) {
|
||||
&:is(:hover, [data-hovered="true"]) {
|
||||
@apply bg-accent-soft-hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Size */
|
||||
.hv-tag--sm {
|
||||
@apply px-2 py-0.5 text-xs;
|
||||
}
|
||||
|
||||
.hv-tag--md {
|
||||
/* No styles as this is the default size */
|
||||
}
|
||||
|
||||
.hv-tag--lg {
|
||||
@apply rounded-2xl px-2.5 py-1.5 text-sm;
|
||||
}
|
||||
|
||||
/* Variant */
|
||||
.hv-tag--default {
|
||||
@apply bg-default text-default-foreground;
|
||||
|
||||
/* Hover state (when not selected or disabled) */
|
||||
@media (hover: hover) {
|
||||
&:is(:hover, [data-hovered="true"]):not([data-selected="true"]):not(
|
||||
[data-disabled="true"]
|
||||
) {
|
||||
@apply bg-default-hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.hv-tag--surface {
|
||||
@apply bg-surface text-surface-foreground;
|
||||
|
||||
/* Hover state (when not selected or disabled) */
|
||||
@media (hover: hover) {
|
||||
&:is(:hover, [data-hovered="true"]):not([data-selected="true"]):not(
|
||||
[data-disabled="true"]
|
||||
) {
|
||||
@apply bg-surface-hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove Button */
|
||||
.hv-tag__remove-button {
|
||||
/**
|
||||
* The glyph is 12px, half the minimum target size. A finger tap that misses it lands on the
|
||||
* tag body, which consumes the press without removing anything, so removing a tag by touch
|
||||
* takes several attempts. `touch-target` widens the pressable area to 24px. On `--sm` the
|
||||
* overlay reaches ~2px past the tag box, which the 6px list gap absorbs, so it never
|
||||
* overlaps a neighbouring tag.
|
||||
*/
|
||||
@apply touch-target size-3 text-inherit;
|
||||
|
||||
/* SVG icon styling */
|
||||
& svg {
|
||||
@apply size-[inherit] shrink-0 self-center text-current;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user