-
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.
Fix cssModuleToJS with kebab case classes
- Loading branch information
1 parent
b18cdd6
commit 6630a86
Showing
6 changed files
with
49 additions
and
8 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
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,16 @@ | ||
import type { cssModuleToJS as cssModuleToJSDeclaration } from "../types"; | ||
|
||
export const cssModuleToJS: typeof cssModuleToJSDeclaration = (cssModule) => { | ||
let namedExport = ""; | ||
let defaultExport = "export default {\n"; | ||
for (const key in cssModule) { | ||
if (!key.includes("-")) { | ||
namedExport += `export const ${key} = "${cssModule[key].name}";\n`; | ||
defaultExport += ` ${key},\n`; | ||
} else { | ||
defaultExport += ` "${key}": "${cssModule[key].name}",\n`; | ||
} | ||
} | ||
defaultExport += "};"; | ||
return namedExport + defaultExport; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
import * as assert from "node:assert"; | ||
import test from "node:test"; | ||
|
||
import { cssModuleToJS } from "../src/utils/cssModuleToJS"; | ||
|
||
test("convertTargets", () => { | ||
assert.equal( | ||
cssModuleToJS({ | ||
"container": { | ||
name: "_container_11zaj_1", | ||
composes: [], | ||
isReferenced: false, | ||
}, | ||
"kebab-case": { | ||
name: "_kebab-case_11zaj_6", | ||
composes: [], | ||
isReferenced: false, | ||
}, | ||
}), | ||
` | ||
export const container = "_container_11zaj_1"; | ||
export default { | ||
container, | ||
"kebab-case": "_kebab-case_11zaj_6", | ||
};`.trim(), | ||
); | ||
}); |
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