feature: move all shadcn related code to src/shared/shadcn
This commit is contained in:
37
src/shared/shadcn/utils/shadcn-utils.ts
Normal file
37
src/shared/shadcn/utils/shadcn-utils.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { type ClassValue, clsx } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
/**
|
||||
* Utility function to merge Tailwind CSS classes
|
||||
* Combines clsx for conditional classes and tailwind-merge to handle conflicts
|
||||
*/
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Type utility to add a ref property to HTML element attributes
|
||||
* Used in shadcn-svelte components to support element references
|
||||
* @template T - The attributes type (e.g., HTMLAttributes<HTMLDivElement>)
|
||||
* @template E - The element type (e.g., HTMLDivElement)
|
||||
*/
|
||||
export type WithElementRef<T, E extends HTMLElement = HTMLElement> = T & {
|
||||
/**
|
||||
* Reference to the DOM element
|
||||
*/
|
||||
ref?: E | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Type utility to remove 'children' and 'child' properties from a type
|
||||
* Used in shadcn-svelte components that use Snippets instead of children
|
||||
* @template T - The type to remove children from
|
||||
*/
|
||||
export type WithoutChildren<T> = Omit<T, 'children'>;
|
||||
|
||||
/**
|
||||
* Type utility to remove 'children' and 'child' properties from a type
|
||||
* Used in shadcn-svelte components that use Snippets instead of children
|
||||
* @template T - The type to remove children and child from
|
||||
*/
|
||||
export type WithoutChildrenOrChild<T> = Omit<T, 'children' | 'child'>;
|
||||
Reference in New Issue
Block a user