mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
classnames: Support bind constructor
This commit is contained in:
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export type ClassNamesFn = (
|
||||
...args: Array<string | string[] | Record<string, boolean | undefined | null>>
|
||||
) => string;
|
||||
|
||||
export function bind(styles: Record<string, string>): ClassNamesFn;
|
||||
@@ -1,5 +1,6 @@
|
||||
import classNames = require('classnames');
|
||||
import * as classNames2 from 'classnames';
|
||||
import * as cn from 'classnames/bind';
|
||||
|
||||
classNames2('foo', 'bar'); // => 'foo bar'
|
||||
|
||||
@@ -23,3 +24,14 @@ classNames(null, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'
|
||||
|
||||
// Supporting booleans is tricky since we should only support passing in false, which is ignored
|
||||
// classNames(false, 'bar', 0, 1, { baz: null }, ''); // => 'bar 1'
|
||||
|
||||
// Support for CSS-Modules. Example from README:
|
||||
// https://github.com/JedWatson/classnames/blob/master/README.md#alternate-bind-version-for-css-modules
|
||||
const styles = {
|
||||
foo: 'abc',
|
||||
bar: 'def',
|
||||
baz: 'xyz'
|
||||
};
|
||||
|
||||
const cx = cn.bind(styles);
|
||||
const className = cx('foo', ['bar'], { baz: true }); // => "abc def xyz"
|
||||
|
||||
Vendored
+2
@@ -5,7 +5,9 @@
|
||||
// Jason Killian <https://github.com/JKillian>
|
||||
// Sean Kelley <https://github.com/seansfkelley/>
|
||||
// Michal Adamczyk <https://github.com/mradamczyk>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
type ClassValue = string | number | ClassDictionary | ClassArray | undefined | null | false;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bind.d.ts",
|
||||
"classnames-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user