Skip to content

Commit 953ffae

Browse files
author
Andrii Kirmas
committed
Clean-up TS-Doc a bit
1 parent 71f7731 commit 953ffae

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

src/defs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
Component
55
} from "react"
66

7-
/** Multipurpose generic
7+
/** Collect required `classnames` from used sub-Components
88
* @example
99
* ClassNames<true> // {className: string}
1010
* ClassNames<Props1> // {classnames: Props1["classnames"] & Props2["classnames"]}
@@ -39,7 +39,7 @@ export type ClassNames<
3939
& Ever<C10, ClassNamesFrom<C10>>
4040
>
4141

42-
/** Declaration of self Component's classNames
42+
/** Declaration of self Component's `classnames`
4343
* @example
4444
* ClassNames<{class1: ClassHash, class2: ClassHash}>
4545
* ClassNames<typeof some_module_css, {class1: ClassHash, class2: ClassHash}>

src/index.ts

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,30 @@ export type { ClassNames, ClassHash, ClassNamesProperty, ClassNamed } from "./de
1010
export default classNaming
1111
export {classNamesCheck} from "./check"
1212

13-
/**
14-
* Makes `className` string from imported CSS
15-
* @example
16-
* <div className={`${classNamingBasic({ClassName})}`} />
17-
* <div {...classNamingBasic({ClassName})} />
18-
* const cn = classNamingBasic({C1})({C2}); <div {...cn({C3})({C4})} />
19-
*/
2013
interface ClassNamingCall<
2114
//TODO #8 `extends ReactRelated`
2215
Source extends CssModule
2316
> {
2417
/**
25-
* @example
26-
* classes(true) === props.className
27-
* classes({class1: true, class2: false}) === "class1"
28-
* classes(true, {class1: true, class2: false})
29-
*/
18+
* Makes `className` string
19+
* @example
20+
* // Using in Components
21+
* <div {...classNaming(...)} data-block={`${classNaming(...)}`} />
22+
* <Component {...{
23+
* ...classNaming(...)},
24+
* ...classnames
25+
* }/>
26+
*
27+
* // With destructed `classnames`
28+
* classNaming(className?, {App__Container, App__Item})} />
29+
*
30+
* // Toggler
31+
* classNaming(true?, {Btn_Float: true, Btn___disabled: false})
32+
33+
* // Pipe-able
34+
* const Cell = classNaming(className), Col1 = Cell({Column_1})
35+
* <div {...Col1({Row_1})} />
36+
*/
3037
(
3138
arg0?: ClassNamingContext<Source> | true | string | ActionsMap<Source>,
3239
arg1?: [Extract<typeof arg0, true|string>] extends [never]
@@ -51,13 +58,28 @@ type ActionsMap<K extends CssModule> = {[k in keyof K]?: ClassHash|boolean}
5158
// type ToggleMap<K extends ClassNamesMap> = {[k in keyof K]?: boolean}
5259

5360
/**
54-
*
61+
* Makes `className` string or settle context
5562
* @example
56-
* const classes = classNaming(this.props)
57-
* const classes = classNaming({classnames, className})
58-
* const classes = classNaming({classnames})
59-
*/
63+
* // To set context
64+
* const classes = classNaming({classnames, className})
65+
*
66+
* // Using in Components
67+
* <div {...classNaming(...)} data-block={`${classNaming(...)}`} />
68+
* <Component {...{
69+
* ...classNaming(...)},
70+
* ...classnames
71+
* }/>
72+
*
73+
* // With destructed `classnames`
74+
* classNaming(className?, {App__Container, App__Item})} />
75+
*
76+
* // Toggler
77+
* classNaming(true?, {Btn_Float: true, Btn___disabled: false})
6078
79+
* // Pipe-able
80+
* const Cell = classNaming(className), Col1 = Cell({Column_1})
81+
* <div {...Col1({Row_1})} />
82+
*/
6183
function classNaming<
6284
//TODO #8 `extends ReactRelated`
6385
Source extends CssModule

0 commit comments

Comments
 (0)