Files
Daniel VigaruandJoseph Chambers 5c147350ea fix(mobile): margin for "Lists" tab content (#927)
* fix: left margin for list items

* refactor: move type into func definition

* fix: missing return type

Co-authored-by: Joseph Chambers <5374985+imcodingideas@users.noreply.github.com>

* style: remove trailing space

---------

Co-authored-by: Joseph Chambers <5374985+imcodingideas@users.noreply.github.com>
2025-02-01 23:20:21 +00:00

45 lines
995 B
TypeScript

import type { ClassValue } from "clsx";
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
/**
* Merge props conditionally.
*
* @example
* ```
* <View {...condProps(
* { condition: true, props: { className: "foo" } },
* { condition: true, props: { style: { margin: "10px" } } },
* )} />
* ```
* results in:
* ```
* <View className="foo" style={ margin: "10px" } />
* ```
* @example
* ```
* <View style={condProps(
* { condition: true, color: "red" },
* { condition: true, fontWeight: "bold" }
* )} />
* ```
* results in:
* ```
* <View style={ color: "red", fontWeight: "bold" } />
* ```
*/
export function condProps(
...condProps: {
condition: boolean;
props: Record<string, unknown>;
}[]
): Record<string, unknown> {
return condProps.reduce((acc, { condition, props }) => {
return condition ? { ...acc, ...props } : acc;
}, {});
}