You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,54 @@ By using `:host` we are able to provide styles for the parent element:
99
99
</style>
100
100
```
101
101
102
+
## Dynamic vs static
103
+
Sheetify is very good for namespacing static css assets in your javaScript code. Currently there is no support for dynamic variables within sheetify, however you could achieve this by setting the inline style property of an element.
Should you want to, you could even set dynamic variables in an object and do a rather complicated JSON.stringify with a replace on that object to turn it into a style for an element.
130
+
131
+
```js
132
+
133
+
constdynamicStyles= {
134
+
width:global.window.innerWidth,
135
+
height:global.window.innerHeight,
136
+
}
137
+
138
+
let dynamicStyleString =JSON.stringify(dynamicStyles)
139
+
.replace(/\,/g,';')
140
+
.replace(/\"/g,'')
141
+
.replace(/\{|\}/g,'')
142
+
143
+
consttree=html`
144
+
<divstyle="${dynamicStyleString}">
145
+
<h1>My beautiful, window width</h1>
146
+
</div>
147
+
`
148
+
```
149
+
102
150
103
151
## External files
104
152
To include an external CSS file you can pass a path to sheetify as
0 commit comments