Skip to content

Commit 063a650

Browse files
author
Andrii Kirmas
committed
#35 Update readme
1 parent 25e729c commit 063a650

File tree

7 files changed

+46
-8
lines changed

7 files changed

+46
-8
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,40 @@ Default options BEM naming:
241241
- Modifier's and value's separator is a double hyphen `"--"`
242242
- Element's separator is a double underscore `"__"`
243243
244-
It is required to change this options twice, both on JS (`setOpts(...)`) and TS `namespace ReactClassNaming { interface BemOptions {...} }`) levels. See [./\__recipes__/](https://github.com/askirmas/react-classnaming/tree/main/__recipes__/)
244+
It is required to change this options twice, both on JS and TS levels.
245+
246+
- TS: in declaration file like [\./\__recipes\__/global.d.ts](https://github.com/askirmas/react-classnaming/blob/main/__recipes__/global.d.ts) you to add those lines:
247+
248+
```typescript
249+
/// <reference types="react-classnaming" />
250+
declare namespace ReactClassNaming {
251+
interface BemOptions {
252+
elementDelimiter: "_";
253+
modDelimiter: "-";
254+
}
255+
}
256+
```
257+
258+
And optionally in add to *tsconfig.json*:
259+
260+
```diff
261+
"compilerOptions": {
262+
"types": [
263+
+ "react-classnaming"
264+
]
265+
}
266+
```
267+
268+
269+
270+
- JS: [./\__recipes\__/index.test.ts#L2-L7](https://github.com/askirmas/react-classnaming/blob/main/__recipes__/index.test.ts#L2-L7)
271+
272+
```typescript
273+
import setOptions from "react-classnaming"
274+
setOptions({...})
275+
```
276+
277+
245278

246279
### function [`classNamesMap`](https://github.com/askirmas/react-classnaming/projects/5)
247280

__recipes__/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference types="react-classnaming" />
2-
32
declare namespace ReactClassNaming {
43
interface BemOptions {
54
elementDelimiter: "_";

__recipes__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {classBeming, ClassNamed, ClassNamesProperty, setOptions} from "react-classnaming"
2-
import type {ClassHash} from "react-classnaming"
1+
import type {ClassHash, ClassNamed, ClassNamesProperty} from "react-classnaming"
2+
import {classBeming, setOptions} from "react-classnaming"
33

44
setOptions({
55
elementDelimiter: "_",

__recipes__/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"compilerOptions": {
33
"types": [
4-
"jest",
5-
"react-classnaming"
4+
"jest"
65
]
76
},
87
"exclude": [

src/bem.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { classBeming } from "./bem";
1+
import { classBeming, setOptions } from "./bem";
22
import { ClassHash } from "./definitions.types";
33
import { ClassNamed, ClassNamesProperty } from "./main.types";
44

@@ -53,3 +53,5 @@ it("TS UX", () => {
5353

5454
expect(check).toBeInstanceOf(Object)
5555
})
56+
57+
it("cover reexported", () => expect(setOptions).toThrow())

src/bem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { bem2arr } from "./bem.core";
44
import { joinWithLead, picker, wrapper } from "./core"
55
import { EMPTY_OBJECT } from "./consts.json"
66

7+
export {setOptions} from "./bem.core"
78
export {
89
classBeming
910
}

src/global.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/**
22
* Tools to establish CSS classes as an explicit abstraction layer and to handle it as an interface between React and CSSStyleDeclaration
33
* GitHub: https://github.com/askirmas/react-classnaming
4+
*
5+
* Contains:
6+
* ```typescript
7+
* interface BemOptions {}
8+
* ```
49
*/
510
declare namespace ReactClassNaming {
611
/**
@@ -14,7 +19,6 @@ declare namespace ReactClassNaming {
1419
* ```
1520
*/
1621
interface BemOptions {
17-
1822
$default: {
1923
elementDelimiter: "__",
2024
modDelimiter: "--"

0 commit comments

Comments
 (0)