mirror of
https://github.com/hanzoai/svelte.git
synced 2026-10-01 00:41:47 +00:00
Extracted from @hanzo/ui pkg/ui/src/backends/svelte with its history. It lived inside a React component library, which meant every consumer of @hanzo/ui resolved svelte whether they rendered a single Svelte component or not, and the package declared peer svelte>=5 against a dev svelte ^4.2.20 — two answers to one question. Three runtime dependencies, all load-bearing: class-variance-authority for the variants the components already used, and clsx + tailwind-merge behind cn. The cn helper is vendored (17 lines) rather than imported back from @hanzo/ui, because depending on the package this was extracted from would undo the split. No design-system runtime, no icon pack, no CSS-in-JS. svelte-check: 50 files, 0 errors. Co-authored-by: Hanzo Dev <[email protected]>
19 lines
702 B
TypeScript
19 lines
702 B
TypeScript
/**
|
|
* `cn` — the one class-name composer.
|
|
*
|
|
* `clsx` resolves conditional/array/object class inputs; `tailwind-merge` then
|
|
* collapses conflicting Tailwind utilities so the LAST wins (a caller's
|
|
* `bg-background` overrides a component's default `bg-popover`). Every component
|
|
* here merges through this single function.
|
|
*
|
|
* Vendored rather than imported from @hanzo/ui: this package exists so a Svelte
|
|
* app does not pull in a React component library, and depending back on it for
|
|
* three lines would undo that.
|
|
*/
|
|
import { clsx, type ClassValue } from 'clsx'
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
export function cn(...inputs: ClassValue[]): string {
|
|
return twMerge(clsx(inputs))
|
|
}
|