Created
August 26, 2020 10:08
-
-
Save intrnl/5880fc4f3420767d4db3e74a2cab90db to your computer and use it in GitHub Desktop.
CSS modules namespace import
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
// 249 bytes | |
var o={helloWorld:"hello-world-123",fooBar:"foo-bar-245",barBaz:"bar-baz-934"};let l=Object.assign(document.createElement("div"),{textContent:"Hello world!",className:[o.helloWorld,o.helloWorld,o.fooBar,o.barBaz].join(" ")});document.body.append(l); |
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
// 178 bytes | |
let e="hello-world-123",o=Object.assign(document.createElement("div"),{textContent:"Hello world!",className:[e,e,"foo-bar-245","bar-baz-934"].join(" ")});document.body.append(o); |
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
// style.module.css | |
export default { | |
helloWorld: 'hello-world-123', | |
fooBar: 'foo-bar-245', | |
barBaz: 'bar-baz-934', | |
}; | |
// index.js | |
import css from './style.module.css'; | |
let el = Object.assign(document.createElement('div'), { | |
textContent: 'Hello world!', | |
className: [css.helloWorld, css.helloWorld, css.fooBar, css.barBaz].join(' '), | |
}); | |
document.body.append(el); |
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
// style.module.css | |
export let helloWorld = 'hello-world-123'; | |
export let fooBar = 'foo-bar-245'; | |
export let barBaz = 'bar-baz-934'; | |
// index.js | |
import * as css from './style.module.css'; | |
let el = Object.assign(document.createElement('div'), { | |
textContent: 'Hello world!', | |
className: [css.helloWorld, css.helloWorld, css.fooBar, css.barBaz].join(' '), | |
}); | |
document.body.append(el); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment