feat: initialize Vue component library and aligned documentation

This commit is contained in:
maoyingjie
2026-10-21 09:06:28 +08:00
commit 9d40dc0ecb
149 changed files with 13208 additions and 0 deletions
+161
View File
@@ -0,0 +1,161 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
/* Button component styles */
/* Base button styles */
.hv-button {
@apply relative isolate inline-flex h-10 w-fit origin-center items-center justify-center gap-2 rounded-3xl px-4 text-sm font-medium whitespace-nowrap outline-none select-none no-highlight md:h-9;
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
transform 250ms var(--ease-smooth),
background-color 100ms var(--ease-out),
box-shadow 100ms var(--ease-out);
@apply transform-gpu motion-reduce:transition-none;
/* Cursor */
cursor: var(--cursor-interactive);
/* Default tokens (fallback behavior) */
--button-bg: transparent;
--button-bg-hover: var(--button-bg);
--button-bg-pressed: var(--button-bg-hover);
--button-fg: currentColor;
background-color: var(--button-bg);
color: var(--button-fg);
/* Focus state */
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
/* Disabled state */
&:disabled,
&[aria-disabled="true"] {
@apply status-disabled;
}
/* Pending state */
&[data-pending="true"] {
@apply status-pending;
}
/* Active / pressed */
&:active,
&[data-pressed="true"] {
@apply will-change-transform;
background-color: var(--button-bg-pressed);
transform: scale(0.97);
}
/* Hover */
@media (hover: hover) {
&:hover,
&[data-hovered="true"] {
background-color: var(--button-bg-hover);
}
}
/* SVG icon styling - exclude spinner and link-icon svgs */
& svg:not([data-slot="spinner"] svg, [data-slot="link-icon"] svg) {
@apply pointer-events-none -mx-0.5 my-0.5 size-5 shrink-0 self-center sm:my-1 sm:size-4;
}
}
/* Size variants */
.hv-button--sm {
@apply h-9 px-3 md:h-8;
& svg:not([data-slot="spinner"] svg, [data-slot="link-icon"] svg) {
@apply size-4;
}
&:active,
&[data-pressed="true"] {
transform: scale(0.98);
}
}
.hv-button--md {
/* No styles as this is the default size */
}
.hv-button--lg {
@apply h-11 text-base md:h-10;
&:active,
&[data-pressed="true"] {
transform: scale(0.96);
}
}
/* Color variants - only set custom property values */
.hv-button--primary {
--button-bg: var(--accent);
--button-bg-hover: var(--accent-hover);
--button-bg-pressed: var(--accent-hover);
--button-fg: var(--accent-foreground);
}
.hv-button--secondary {
--button-bg: var(--default);
--button-bg-hover: var(--default-hover);
--button-bg-pressed: var(--default-hover);
--button-fg: var(--accent-soft-foreground);
}
.hv-button--tertiary {
--button-bg: var(--default);
--button-bg-hover: var(--default-hover);
--button-bg-pressed: var(--default-hover);
}
.hv-button--ghost,
.hv-button--outline {
--button-bg: transparent;
--button-bg-hover: var(--default);
--button-bg-pressed: var(--default);
--button-fg: var(--default-foreground);
}
.hv-button--outline {
@apply border border-border;
--button-bg-hover: color-mix(in srgb, var(--default) 60%, transparent);
}
.hv-button--danger {
--button-bg: var(--danger);
--button-bg-hover: var(--danger-hover);
--button-bg-pressed: var(--danger-hover);
--button-fg: var(--danger-foreground);
}
.hv-button--danger-soft {
--button-bg: var(--danger-soft);
--button-bg-hover: var(--danger-soft-hover);
--button-bg-pressed: var(--danger-soft-hover);
--button-fg: var(--danger-soft-foreground);
}
/* Icon-only modifier */
.hv-button--icon-only {
@apply w-10 p-0 md:w-9;
}
.hv-button--icon-only.hv-button--sm {
@apply w-9 md:w-8;
}
.hv-button--icon-only.hv-button--lg {
@apply w-11 md:w-10;
}
/* Full width modifier */
.hv-button--full-width {
@apply w-full;
}
+53
View File
@@ -0,0 +1,53 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
/* Card component styles */
/* Block */
.hv-card {
@apply relative flex flex-col gap-3 overflow-visible p-4;
@apply shadow-surface;
border-radius: min(32px, var(--radius-3xl));
}
/* Element - header */
.hv-card__header {
@apply flex flex-col;
}
/* Element - title */
.hv-card__title {
@apply text-sm leading-6 font-medium text-foreground;
}
/* Element - description */
.hv-card__description {
@apply text-sm leading-5 text-muted;
}
/* Element - content */
.hv-card__content {
@apply flex flex-1 flex-col gap-1;
}
/* Element - footer */
.hv-card__footer {
@apply flex flex-row items-center;
}
/* Modifier - variant */
.hv-card--transparent {
@apply border-none bg-transparent shadow-none;
}
.hv-card--default {
@apply bg-surface;
}
.hv-card--secondary {
@apply bg-surface-secondary;
}
.hv-card--tertiary {
@apply bg-surface-tertiary;
}
@@ -0,0 +1,67 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix. */
/* Close Button component styles */
/* Base close button styles */
.hv-close-button {
@apply relative isolate inline-flex h-6 w-6 shrink-0 origin-center items-center justify-center rounded-xl p-1 select-none no-highlight;
/* Cursor */
cursor: var(--cursor-interactive);
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
transform 250ms var(--ease-out-quart),
color 150ms var(--ease-out),
background-color 100ms var(--ease-out),
box-shadow 150ms var(--ease-out);
@apply transform-gpu motion-reduce:transition-none;
/* Focus visible state */
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
/* Disabled state */
&:disabled,
&[aria-disabled="true"] {
@apply status-disabled;
}
/* Pending state */
&[data-pending="true"] {
@apply status-pending;
}
/* SVG icon styling*/
& svg {
@apply pointer-events-none;
@apply size-4 shrink-0 self-center;
@apply -mx-0.5 my-0.5;
}
}
/* Variants */
.hv-close-button--default {
@apply bg-default text-muted;
&:active,
&[data-pressed="true"] {
}
@media (hover: hover) {
&:hover,
&[data-hovered="true"] {
@apply bg-default-hover;
}
}
&:active,
&[data-pressed="true"] {
transform: scale(0.93);
}
}
@@ -0,0 +1,6 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
/* Base description styles */
.hv-description {
@apply text-xs text-wrap wrap-break-word text-muted;
}
+88
View File
@@ -0,0 +1,88 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
.hv-input {
@apply rounded-field border bg-field px-3 py-2 text-base text-field-foreground shadow-field outline-none placeholder:text-field-placeholder sm:text-sm;
border-width: var(--border-width-field);
border-color: var(--field-border);
/**
* 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;
@media (hover: hover) {
&:hover:not(:focus):not(:focus-visible),
&[data-hovered="true"]:not([data-focused="true"]):not(
[data-focus-visible="true"]
) {
@apply bg-field-hover;
border-color: var(--field-border-hover);
}
}
/* Focus state */
&:focus,
&[data-focused="true"] {
@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);
}
/* Disabled state */
&:disabled,
&[data-disabled="true"],
&[aria-disabled="true"] {
@apply status-disabled;
}
}
/* Variant property definitions */
.hv-input--primary {
/* Default styles */
}
.hv-input--secondary {
@apply shadow-none;
background-color: var(--input-bg);
--input-bg: var(--default);
--input-bg-hover: var(--default-hover);
--input-bg-focus: var(--default);
@media (hover: hover) {
&:hover:not(:focus):not(:focus-visible),
&[data-hovered="true"]:not([data-focus-visible="true"]):not(
[data-focused="true"]
) {
background-color: var(--input-bg-hover);
}
}
&:focus,
&[data-focused="true"] {
background-color: var(--input-bg-focus);
}
/* Invalid state */
&[data-invalid="true"] {
@apply status-invalid-field;
background-color: var(--input-bg-focus);
}
}
/* Full width modifier */
.hv-input--full-width {
@apply w-full;
}
+33
View File
@@ -0,0 +1,33 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
/* Base label styles */
.hv-label {
/* Base styling */
@apply text-sm font-medium text-foreground;
}
/*
* Exclude group-level components (RadioGroup, CheckboxGroup) and radio/checkbox items
* to ensure asterisks only appear on atomic form field labels and group labels,
* not on individual options within those groups
*/
.hv-label--required,
[data-required="true"]:not([role="group"]):not([role="radiogroup"]):not(
[role="checkboxgroup"]
)
> .hv-label,
[data-required="true"]:not([data-slot="radio"]):not([data-slot="checkbox"])
> .hv-label {
@apply after:ms-0.5 after:text-danger after:content-['*'];
}
.hv-label--disabled,
[data-disabled="true"] .hv-label {
@apply status-disabled;
}
.hv-label--invalid,
[data-invalid="true"] .hv-label,
[aria-invalid="true"] .hv-label {
@apply text-danger;
}
@@ -0,0 +1,18 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc. See third-party/HEROUI-LICENSE. */
/* Switch Group styles */
.hv-switch-group {
@apply flex flex-col gap-6;
}
.hv-switch-group__items {
@apply flex gap-4;
}
/* Orientation modifiers */
.hv-switch-group--horizontal .hv-switch-group__items {
@apply flex-row;
}
.hv-switch-group--vertical .hv-switch-group__items {
@apply flex-col;
}
+249
View File
@@ -0,0 +1,249 @@
/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
* See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
/* Switch base styles */
.hv-switch {
@apply flex flex-col items-start gap-1 no-highlight;
/* Cursor */
cursor: var(--cursor-interactive);
/* Default tokens for switch control states */
--switch-control-bg: var(--default);
--switch-control-bg-hover: color-mix(
in oklab,
var(--switch-control-bg),
transparent 20%
);
--switch-control-bg-pressed: var(--switch-control-bg-hover);
--switch-control-bg-checked: var(--accent);
--switch-control-bg-checked-hover: var(--accent-hover);
/* Disabled state */
&[data-disabled="true"] {
@apply status-disabled;
[data-slot="description"],
[data-slot="field-error"] {
@apply status-disabled;
}
.hv-switch__thumb {
@apply bg-default-foreground/20;
}
}
/* Field-level help text below the control + label row */
& > [data-slot="description"] {
@apply w-full min-w-0 ps-[calc(2.5rem+0.75rem)];
}
& > [data-slot="field-error"] {
@apply w-full min-w-0 ps-[calc(2.5rem+0.75rem)] text-xs text-muted;
}
&.hv-switch--sm > [data-slot="description"] {
@apply ps-[calc(2rem+0.75rem)];
}
&.hv-switch--sm > [data-slot="field-error"] {
@apply ps-[calc(2rem+0.75rem)];
}
&.hv-switch--lg > [data-slot="description"] {
@apply ps-[calc(3rem+0.75rem)];
}
&.hv-switch--lg > [data-slot="field-error"] {
@apply ps-[calc(3rem+0.75rem)];
}
/* Disabled + Selected state */
&:disabled[aria-checked="true"],
&:disabled[data-selected="true"],
&[data-disabled="true"][aria-checked="true"],
&[data-disabled="true"][data-selected="true"],
&[aria-disabled="true"][aria-checked="true"],
&[aria-disabled="true"][data-selected="true"] {
.hv-switch__thumb {
opacity: 0.4;
}
}
}
/* Size variants - default is medium */
.hv-switch--sm {
/* Small size modifier */
}
.hv-switch--md {
/* Medium size - no styles as this is the default */
}
.hv-switch--lg {
/* Large size modifier */
}
/* Switch control (track) */
.hv-switch__control {
/* Default size (medium) */
@apply relative flex shrink-0 items-center overflow-hidden rounded-xl;
height: 1.25rem; /* 20px on desktop (14px base), 20px on mobile (16px base) - scales with font-size */
width: 2.5rem; /* 35px on desktop, 40px on mobile - scales with font-size */
background-color: var(--switch-control-bg);
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
background-color 250ms var(--ease-smooth),
box-shadow 150ms var(--ease-out);
@apply motion-reduce:transition-none;
/* Focus states */
.hv-switch:focus-visible &,
.hv-switch:has([data-slot="switch-content"][data-focus-visible="true"]) &,
.hv-switch [data-slot="switch-content"][data-focus-visible="true"] & {
@apply status-focused;
}
/* Hover states */
.hv-switch:hover &,
.hv-switch:has([data-slot="switch-content"][data-hovered="true"]) &,
.hv-switch [data-slot="switch-content"][data-hovered="true"] & {
background-color: var(--switch-control-bg-hover);
}
/* Pressed states */
.hv-switch:active &,
.hv-switch:has([data-slot="switch-content"][data-pressed="true"]) &,
.hv-switch [data-slot="switch-content"][data-pressed="true"] & {
background-color: var(--switch-control-bg-pressed);
@apply motion-reduce:transform-none;
}
/* Checked states */
.hv-switch[aria-checked="true"] &,
.hv-switch[data-selected="true"] & {
background-color: var(--switch-control-bg-checked);
}
/* Checked + Hover states */
.hv-switch[aria-checked="true"]:hover &,
.hv-switch[data-selected="true"]:hover &,
.hv-switch[aria-checked="true"][data-hovered="true"] &,
.hv-switch[data-selected="true"][data-hovered="true"] &,
.hv-switch:has(
[data-slot="switch-content"][data-hovered="true"]
)[data-selected="true"]
& {
background-color: var(--switch-control-bg-checked-hover);
}
/* Checked + Pressed states */
.hv-switch[aria-checked="true"]:active &,
.hv-switch[data-selected="true"]:active &,
.hv-switch[aria-checked="true"][data-pressed="true"] &,
.hv-switch[data-selected="true"][data-pressed="true"] &,
.hv-switch:has(
[data-slot="switch-content"][data-pressed="true"]
)[data-selected="true"]
& {
background-color: var(--switch-control-bg-checked-hover);
}
}
/* Switch content — the clickable label (control + label text) */
.hv-switch__content {
@apply relative inline-flex cursor-[inherit] items-center gap-3 text-sm font-medium text-foreground outline-none select-none no-highlight;
}
/* Size-specific control dimensions */
.hv-switch--sm .hv-switch__control {
@apply rounded-lg;
height: 1rem; /* ~14px on desktop, ~16px on mobile */
width: 2rem; /* ~32px on desktop, ~36px on mobile */
}
.hv-switch--md .hv-switch__control {
/* No styles as this is the default size */
}
.hv-switch--lg .hv-switch__control {
height: 1.5rem; /* ~21px on desktop, ~24px on mobile */
width: 3rem; /* ~48px on desktop, ~56px on mobile */
}
/* Switch thumb */
.hv-switch__thumb {
/* Default size (medium) with margin-based positioning */
@apply ms-0.5 flex origin-center rounded-lg bg-white text-black shadow-field;
height: 1rem; /* ~14px on desktop, ~16px on mobile */
width: 1.375rem; /* ~19px on desktop, ~22px on mobile */
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
margin 300ms var(--ease-out-fluid),
background-color 200ms var(--ease-out);
@apply motion-reduce:transition-none;
/* Selected/checked state - use margin instead of translate */
.hv-switch[aria-checked="true"] &,
.hv-switch[data-selected="true"] & {
@apply ms-[calc(100%-1.5rem)] bg-accent-foreground text-accent;
box-shadow:
0px 0px 5px 0px rgb(0 0 0 / 0.02),
0px 2px 10px 0px rgb(0 0 0 / 0.06),
0px 0px 1px 0px rgb(0 0 0 / 0.3);
}
.hv-switch:active &,
.hv-switch[data-pressed="true"] & {
}
}
/* Size-specific thumb dimensions */
.hv-switch--sm .hv-switch__thumb {
@apply rounded-md;
height: 0.75rem; /* ~10.5px on desktop, ~12px on mobile */
width: 1.03125rem; /* ~14.4px on desktop, ~16.5px on mobile - maintains 1.375:1 ratio */
/* Small selected state positioning */
.hv-switch[aria-checked="true"] &,
.hv-switch[data-selected="true"] & {
@apply ms-[calc(100%-1.15625rem)];
}
}
.hv-switch--lg .hv-switch__thumb {
@apply rounded-xl;
height: 1.25rem; /* ~17.5px on desktop, ~20px on mobile */
width: 1.71875rem; /* ~24px on desktop, ~27.5px on mobile - maintains 1.375:1 ratio */
/* Large selected state positioning */
.hv-switch[aria-checked="true"] &,
.hv-switch[data-selected="true"] & {
@apply ms-[calc(100%-1.84375rem)];
}
}
/* Switch thumb content container */
.hv-switch__thumb > * {
@apply flex size-full items-center justify-center;
}
.hv-switch [data-slot="label"] {
@apply select-none;
}
.hv-switch__content [data-slot="label"] {
cursor: var(--cursor-interactive);
}
.hv-switch [data-slot="description"] {
@apply cursor-default select-none;
}