Skip to content

Commit 035bf4e

Browse files
committed
Add cssobject.js bundle file
1 parent 49aaf15 commit 035bf4e

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

cssobject.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
font-weight: 300;
2929
}
3030

31-
/* css object */
31+
/* CSS Object JSON code */
3232
.cssobject {
3333
padding: 10px 20px;
3434
}
@@ -52,6 +52,32 @@ <h1 id="title">CSSObject.js</h1>
5252
<!-- CSSObject -->
5353
</div>
5454

55-
<script src="./main.js" type="module"></script>
55+
<script src="./cssobject.js" type="text/javascript"></script>
56+
<script type="text/javascript">
57+
// to show cssobj stylesheet on page
58+
let div = document.querySelector('.cssobject')
59+
const printJSON = (style) => {
60+
// shows in console
61+
console.log(style)
62+
63+
let cssjson = JSON.stringify(style, null, ' ')
64+
let pre = document.createElement('pre'),
65+
code = document.createElement('code')
66+
code.innerText = cssjson
67+
pre.appendChild(code)
68+
div.appendChild(pre)
69+
}
70+
71+
// instance css object
72+
let cssobj = new CSSObject()
73+
74+
// set options
75+
cssobj.options({ load_min: false, ignore_files: ['demo.css'] })
76+
// get external stylesheets
77+
.external(style => printJSON(style))
78+
// get local stylesheets
79+
.local(style => printJSON(style))
80+
81+
</script>
5682
</body>
5783
</html>

0 commit comments

Comments
 (0)