Skip to content

Commit 03cf376

Browse files
committed
Add CSS example
1 parent d341fbe commit 03cf376

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.custom-widget {
2+
background-color: blue;
3+
}

{{cookiecutter.github_project_name}}/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
],
1111
"files": [
1212
"lib/**/*.js",
13-
"dist/*.js"
13+
"dist/*.js",
14+
"css/*.css"
1415
],
1516
"homepage": "https://github.com/{{ cookiecutter.github_organization_name }}/{{ cookiecutter.github_project_name }}",
1617
"bugs": {
@@ -57,6 +58,7 @@
5758
"@types/mocha": "^5.2.5",
5859
"@types/node": "^10.11.6",
5960
"@types/webpack-env": "^1.13.6",
61+
"css-loader": "^3.2.0",
6062
"expect.js": "^0.3.1",
6163
"fs-extra": "^7.0.0",
6264
"karma": "^3.0.0",
@@ -71,6 +73,7 @@
7173
"npm-run-all": "^4.1.3",
7274
"rimraf": "^2.6.2",
7375
"source-map-loader": "^0.2.4",
76+
"style-loader": "^1.0.0",
7477
"ts-loader": "^5.2.1",
7578
"typescript": "~3.1.2",
7679
"webpack": "^4.20.2",

{{cookiecutter.github_project_name}}/src/widget.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
MODULE_NAME, MODULE_VERSION
1010
} from './version';
1111

12+
// Import the CSS
13+
import '../css/widget.css'
14+
1215

1316
export
1417
class ExampleModel extends DOMWidgetModel {
@@ -41,6 +44,8 @@ class ExampleModel extends DOMWidgetModel {
4144
export
4245
class ExampleView extends DOMWidgetView {
4346
render() {
47+
this.el.classList.add('custom-widget');
48+
4449
this.value_changed();
4550
this.model.on('change:value', this.value_changed, this);
4651
}

0 commit comments

Comments
 (0)