-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#35 Change global interface usage to be more common
- Loading branch information
Andrii Kirmas
committed
Mar 12, 2021
1 parent
fd6a984
commit c167228
Showing
11 changed files
with
42 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ typings/ | |
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
types | ||
|
||
# Gatsby files | ||
.cache/ | ||
|
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference types="react-classnaming" /> | ||
|
||
declare namespace ReactClassNaming { | ||
interface BemOptions { | ||
elementDelimiter: "_"; | ||
modDelimiter: "-"; | ||
} | ||
} | ||
|
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,34 +1,25 @@ | ||
//-/ <reference path="node_modules/react-classnaming/dist" /> | ||
import {classBeming, ClassNamed, ClassNamesProperty, setOptions} from "react-classnaming" | ||
import type {ClassHash, ReactClassNaming} from "react-classnaming" | ||
|
||
declare module "react-classnaming" { | ||
namespace ReactClassNaming { | ||
interface BemOptions { | ||
elementDelimiter: "_"; | ||
modDelimiter: "-"; | ||
} | ||
} | ||
} | ||
import type {ClassHash} from "react-classnaming" | ||
|
||
setOptions({ | ||
elementDelimiter: "_", | ||
modDelimiter: "-", | ||
}) | ||
|
||
type CssModule = Record< | ||
|"block-m" | ||
|"block_el"|"block_el-m-X"|"block_el-m-Y", | ||
|"block1-m" | ||
|"block2_el-m-X"|"block2_el-m-Y", | ||
ClassHash | ||
> | ||
|
||
it("go", () => { | ||
const bem = classBeming<ClassNamesProperty<CssModule> & ClassNamed>() | ||
, classNamed = bem(true, { | ||
block: "m", | ||
block_el: {"m": "X"} | ||
block1: "m", | ||
block2: true, | ||
block2_el: {"m": "X"} | ||
}) | ||
expect(classNamed).toStrictEqual({ | ||
className: "block block-m block_el block_el-m-X" | ||
className: "block1 block1-m block2 block2_el block2_el-m-X" | ||
}) | ||
}) |
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,7 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": [ | ||
"jest" | ||
"jest", | ||
"react-classnaming" | ||
] | ||
}, | ||
"exclude": [ | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** namespace ReactClassNaming */ | ||
declare namespace ReactClassNaming { | ||
/** interface BemOptions */ | ||
interface BemOptions { | ||
$default: { | ||
elementDelimiter: "__", | ||
modDelimiter: "--" | ||
} | ||
} | ||
} |
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