signal-desktop/ts/util/getClassNamesFor.ts

23 lines
521 B
TypeScript
Raw Normal View History

2021-05-10 20:50:43 -04: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 14:55:44 -04:00
if (modifier === undefined) {
return '';
}
const cx = modules
.flatMap(m => (m ? m.split(' ') : undefined))
.map(parentModule =>
parentModule ? `${parentModule}${modifier}` : undefined
);
2021-05-10 20:50:43 -04:00
return classNames(cx);
};
}