Signal-Desktop/ts/util/getClassNamesFor.ts

23 lines
521 B
TypeScript
Raw Normal View History

2021-05-11 00:50:43 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import classNames from 'classnames';
export function getClassNamesFor(
...modules: Array<string | undefined>
): (modifier?: string) => string {
return modifier => {
2022-07-25 18:55:44 +00:00
if (modifier === undefined) {
return '';
}
const cx = modules
.flatMap(m => (m ? m.split(' ') : undefined))
.map(parentModule =>
parentModule ? `${parentModule}${modifier}` : undefined
);
2021-05-11 00:50:43 +00:00
return classNames(cx);
};
}