mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 02:09:45 +00:00
35 lines
796 B
TypeScript
35 lines
796 B
TypeScript
type Mods = Record<string, boolean | string>;
|
|
|
|
export function classNames(
|
|
cls: string,
|
|
mods?: Mods,
|
|
additional?: string[] | undefined[]
|
|
): string {
|
|
if (additional && mods) {
|
|
return [
|
|
cls,
|
|
...additional.filter(Boolean),
|
|
Object.entries(mods)
|
|
.filter(([value]) => Boolean(value))
|
|
.map(([className]) => className)
|
|
.join(" "),
|
|
].join(" ");
|
|
}
|
|
if (additional && !mods) {
|
|
return [cls, ...additional.filter(Boolean)].join(" ");
|
|
}
|
|
if (!additional && mods) {
|
|
return [
|
|
cls,
|
|
Object.entries(mods)
|
|
.filter(([value]) => Boolean(value))
|
|
.map(([className]) => className),
|
|
].join(" ");
|
|
}
|
|
return [cls].join(" ");
|
|
}
|
|
|
|
classNames("remove-btn", { hovered: true, selectable: true, red: false }, [
|
|
"pdg",
|
|
]);
|