feat: migrate button groups and toggle buttons with focus regressions
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
|
||||
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
|
||||
/* ==========================================================================
|
||||
ButtonGroup - Groups related buttons together
|
||||
========================================================================== */
|
||||
|
||||
/* Base button group styles */
|
||||
.hv-button-group {
|
||||
@apply inline-flex h-auto items-center justify-center gap-0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Orientation variants
|
||||
========================================================================== */
|
||||
|
||||
.hv-button-group--horizontal {
|
||||
@apply flex-row;
|
||||
}
|
||||
|
||||
.hv-button-group--vertical {
|
||||
@apply flex-col;
|
||||
}
|
||||
|
||||
/* Remove border radius from all buttons in group */
|
||||
.hv-button-group .hv-button {
|
||||
@apply rounded-none;
|
||||
}
|
||||
|
||||
/* Apply border radius to first button (start edge) */
|
||||
.hv-button-group--horizontal .hv-button:first-child {
|
||||
@apply rounded-s-3xl;
|
||||
}
|
||||
|
||||
/* Apply border radius to last button (end edge) */
|
||||
.hv-button-group--horizontal .hv-button:last-child {
|
||||
@apply rounded-e-3xl;
|
||||
}
|
||||
|
||||
/* If only one button, apply both rounded edges */
|
||||
.hv-button-group--horizontal .hv-button:first-child:last-child {
|
||||
@apply rounded-3xl;
|
||||
}
|
||||
|
||||
/* Apply border radius to first button (top edge) in vertical */
|
||||
.hv-button-group--vertical .hv-button:first-child {
|
||||
@apply rounded-t-3xl;
|
||||
}
|
||||
|
||||
/* Apply border radius to last button (bottom edge) in vertical */
|
||||
.hv-button-group--vertical .hv-button:last-child {
|
||||
@apply rounded-b-3xl;
|
||||
}
|
||||
|
||||
/* If only one button in vertical, apply all rounded edges */
|
||||
.hv-button-group--vertical .hv-button:first-child:last-child {
|
||||
@apply rounded-3xl;
|
||||
}
|
||||
|
||||
/* Remove scale transform on active/pressed state for buttons in group */
|
||||
.hv-button-group .hv-button:active,
|
||||
.hv-button-group .hv-button[data-pressed="true"] {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Raise focused button so its outward focus ring + gap shows above adjacent buttons */
|
||||
.hv-button-group .hv-button:focus-visible:not([data-focused]),
|
||||
.hv-button-group .hv-button[data-focus-visible="true"] {
|
||||
@apply z-10;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Separator (compound component)
|
||||
========================================================================== */
|
||||
|
||||
.hv-button-group__separator {
|
||||
@apply rounded-sm bg-current opacity-15;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
|
||||
/**
|
||||
* Transitions
|
||||
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
|
||||
*/
|
||||
transition: opacity 150ms var(--ease-smooth);
|
||||
@apply motion-reduce:transition-none;
|
||||
|
||||
/* Horizontal orientation - vertical divider */
|
||||
.hv-button-group--horizontal & {
|
||||
inset-inline-start: -1px;
|
||||
top: 25%;
|
||||
width: 1px;
|
||||
height: 50%;
|
||||
}
|
||||
|
||||
/* Vertical orientation - horizontal divider */
|
||||
.hv-button-group--vertical & {
|
||||
inset-inline-start: 25%;
|
||||
top: -1px;
|
||||
width: 50%;
|
||||
height: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Outline button border handling
|
||||
========================================================================== */
|
||||
|
||||
/* Remove adjacent borders from outline buttons in horizontal group */
|
||||
/* First button: remove end border (right in LTR, left in RTL) */
|
||||
.hv-button-group--horizontal .hv-button--outline:first-child {
|
||||
@apply border-e-0;
|
||||
}
|
||||
|
||||
/* Last button: remove start border (left in LTR, right in RTL) */
|
||||
.hv-button-group--horizontal .hv-button--outline:last-child {
|
||||
@apply border-s-0;
|
||||
}
|
||||
|
||||
/* Middle buttons: remove both inline borders */
|
||||
.hv-button-group--horizontal
|
||||
.hv-button--outline:not(:first-child):not(:last-child) {
|
||||
@apply border-x-0;
|
||||
}
|
||||
|
||||
/* Remove adjacent borders from outline buttons in vertical group */
|
||||
/* First button: remove bottom border */
|
||||
.hv-button-group--vertical .hv-button--outline:first-child {
|
||||
@apply border-b-0;
|
||||
}
|
||||
|
||||
/* Last button: remove top border */
|
||||
.hv-button-group--vertical .hv-button--outline:last-child {
|
||||
@apply border-t-0;
|
||||
}
|
||||
|
||||
/* Middle buttons: remove both block borders */
|
||||
.hv-button-group--vertical
|
||||
.hv-button--outline:not(:first-child):not(:last-child) {
|
||||
@apply border-y-0;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Full width modifier
|
||||
========================================================================== */
|
||||
|
||||
.hv-button-group--full-width {
|
||||
@apply w-full;
|
||||
}
|
||||
Reference in New Issue
Block a user