Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
export type ClassName = string | false | void | null | 0; | ||
import { LinariaClassName } from './css'; | ||
|
||
type CX = (...classNames: ClassName[]) => string; | ||
export type ClassName<T = string> = T | false | void | null | 0 | ''; | ||
|
||
const cx: CX = function cx() { | ||
return Array.prototype.slice.call(arguments).filter(Boolean).join(' '); | ||
interface ICX { | ||
(...classNames: ClassName<LinariaClassName>[]): LinariaClassName; | ||
(...classNames: ClassName[]): string; | ||
} | ||
|
||
const cx: ICX = function cx() { | ||
const result = Array.prototype.slice | ||
.call(arguments) | ||
.filter(Boolean) | ||
.join(' '); | ||
return result as LinariaClassName; | ||
}; | ||
|
||
export default cx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters