forked from cerc-io/snowballtools-base
merge
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { clsx } from 'clsx';
|
||||
import type { ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
/**
|
||||
* Returns a merged class name string by merging and processing multiple class names and Tailwind CSS styles.
|
||||
*
|
||||
* @param {...string[]} args - One or more class names and/or Tailwind CSS styles to be merged.
|
||||
* @returns {string} - The merged class name string.
|
||||
*/
|
||||
export function cn(...args: ClassValue[]): string {
|
||||
return twMerge(clsx(args));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Children, cloneElement, isValidElement } from 'react';
|
||||
import type { Attributes, ReactElement, ReactNode } from 'react';
|
||||
|
||||
/**
|
||||
* Clones an icon element with optional additional props.
|
||||
* @param {ReactNode} icon - The icon element to clone.
|
||||
* @param {Attributes & P} [props] - Additional props to apply to the cloned icon.
|
||||
* @returns {ReactNode} - The cloned icon element with the applied props.
|
||||
*/
|
||||
export function cloneIcon<P extends object>(
|
||||
icon: ReactNode,
|
||||
props?: Attributes & P,
|
||||
): ReactNode {
|
||||
return Children.map(icon, (child) =>
|
||||
isValidElement(child) ? cloneElement(child as ReactElement, props) : child,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user