|
3 | 3 | import darkStyle from 'data-text:./assets/dark.css'; |
4 | 4 | import lightStyle from 'data-text:./assets/light.css'; |
5 | 5 |
|
6 | | - (async function (w, storage, panels, browserAction) { |
| 6 | + (async function(w, storage, panels, browserAction) { |
7 | 7 | const SETTINGS = 'devtools-settings'; |
8 | 8 | const DEVTOOLS_THEME = 'devtools-theme'; |
9 | 9 | const DEVTOOLS_FONT = 'devtools-font'; |
|
62 | 62 | cyan, |
63 | 63 | white, |
64 | 64 | gray, |
65 | | - error, |
| 65 | + error |
66 | 66 | } = currentTheme.colors; |
67 | 67 |
|
68 | 68 | return this.styles({ |
|
106 | 106 | error, |
107 | 107 | fontFamily: currentFontFamily, |
108 | 108 | fontSize: currentFontSize, |
109 | | - accentColor: accentColor, |
| 109 | + accentColor: accentColor |
110 | 110 | }); |
111 | 111 | } |
112 | 112 | }, |
|
197 | 197 | error, |
198 | 198 | fontFamily, |
199 | 199 | fontSize, |
200 | | - accentColor, |
| 200 | + accentColor |
201 | 201 | }) { |
202 | 202 | // language=CSS |
203 | 203 | return ` |
204 | | - :root { |
205 | | - --bg: ${background}; |
206 | | - --fg: ${foreground}; |
207 | | - --text: ${primary}; |
208 | | - --selBg: ${selectBg}; |
209 | | - --selFg: ${selectFg}; |
210 | | - --selFg2: ${selectFg2}; |
211 | | - --button: ${button}; |
212 | | - --disabled: ${disabled}; |
213 | | - --contrast: ${contrast}; |
214 | | - --second: ${second}; |
215 | | - --active: ${table}; |
216 | | - --border: ${border}; |
217 | | - --hl: ${highlight}; |
218 | | - --tree: ${tree}; |
219 | | - --notif: ${notif}; |
220 | | - --accent: ${accentColor || accent}; |
221 | | - --excluded: ${excluded}; |
| 204 | + :root { |
| 205 | + --bg: ${background}; |
| 206 | + --fg: ${foreground}; |
| 207 | + --text: ${primary}; |
| 208 | + --selBg: ${selectBg}; |
| 209 | + --selFg: ${selectFg}; |
| 210 | + --selFg2: ${selectFg2}; |
| 211 | + --button: ${button}; |
| 212 | + --disabled: ${disabled}; |
| 213 | + --contrast: ${contrast}; |
| 214 | + --second: ${second}; |
| 215 | + --active: ${table}; |
| 216 | + --border: ${border}; |
| 217 | + --hl: ${highlight}; |
| 218 | + --tree: ${tree}; |
| 219 | + --notif: ${notif}; |
| 220 | + --accent: ${accentColor || accent}; |
| 221 | + --excluded: ${excluded}; |
222 | 222 |
|
223 | | - --tags: ${tags}; |
224 | | - --attributes: ${attributes}; |
225 | | - --comments: ${comments}; |
226 | | - --keywords: ${keywords}; |
227 | | - --errors: ${errors}; |
228 | | - --vars: ${vars}; |
229 | | - --operators: ${operators}; |
230 | | - --functions: ${functions}; |
231 | | - --strings: ${strings}; |
232 | | - --numbers: ${numbers}; |
233 | | - --links: ${links}; |
234 | | - --parameters: ${parameters}; |
235 | | - --green: ${green}; |
236 | | - --red: ${red}; |
237 | | - --yellow: ${yellow}; |
238 | | - --blue: ${blue}; |
239 | | - --purple: ${purple}; |
240 | | - --orange: ${orange}; |
241 | | - --cyan: ${cyan}; |
242 | | - --white: ${white}; |
243 | | - --gray: ${gray}; |
244 | | - --error: ${error}; |
| 223 | + --tags: ${tags}; |
| 224 | + --attributes: ${attributes}; |
| 225 | + --comments: ${comments}; |
| 226 | + --keywords: ${keywords}; |
| 227 | + --errors: ${errors}; |
| 228 | + --vars: ${vars}; |
| 229 | + --operators: ${operators}; |
| 230 | + --functions: ${functions}; |
| 231 | + --strings: ${strings}; |
| 232 | + --numbers: ${numbers}; |
| 233 | + --links: ${links}; |
| 234 | + --parameters: ${parameters}; |
| 235 | + --green: ${green}; |
| 236 | + --red: ${red}; |
| 237 | + --yellow: ${yellow}; |
| 238 | + --blue: ${blue}; |
| 239 | + --purple: ${purple}; |
| 240 | + --orange: ${orange}; |
| 241 | + --cyan: ${cyan}; |
| 242 | + --white: ${white}; |
| 243 | + --gray: ${gray}; |
| 244 | + --error: ${error}; |
245 | 245 |
|
246 | 246 |
|
247 | | - --ui-font-family: Roboto, Helvetica Neue, Arial, sans-serif; |
248 | | - --font-family: ${fontFamily}, Menlo, Consolas, "Fira Code", monospace; |
249 | | - --font-size: ${fontSize || 10}px; |
250 | | - } |
251 | | - `; |
252 | | - }, |
| 247 | + --ui-font-family: Roboto, Helvetica Neue, Arial, sans-serif; |
| 248 | + --font-family: ${fontFamily}, Menlo, Consolas, "Fira Code", monospace; |
| 249 | + --font-size: ${fontSize || 10}px; |
| 250 | + } |
| 251 | + `; |
| 252 | + } |
253 | 253 | }; |
254 | 254 |
|
255 | 255 | function generateScrollbarsStyle(scrollbars = true) { |
|
258 | 258 | } |
259 | 259 | // language=CSS |
260 | 260 | return ` |
261 | | - :host ::-webkit-scrollbar, |
262 | | - html ::-webkit-scrollbar, |
263 | | - .-theme-with-dark-background ::-webkit-scrollbar, |
264 | | - :host-context(.-theme-with-dark-background) ::-webkit-scrollbar { |
265 | | - width: 10px !important; |
266 | | - height: 10px !important; |
267 | | - opacity: 0 !important; |
268 | | - transition: opacity 0.4s ease; |
269 | | - } |
270 | | - `; |
| 261 | + :host ::-webkit-scrollbar, |
| 262 | + html ::-webkit-scrollbar, |
| 263 | + .-theme-with-dark-background ::-webkit-scrollbar, |
| 264 | + :host-context(.-theme-with-dark-background) ::-webkit-scrollbar { |
| 265 | + width: 10px !important; |
| 266 | + height: 10px !important; |
| 267 | + opacity: 0 !important; |
| 268 | + transition: opacity 0.4s ease; |
| 269 | + } |
| 270 | + `; |
271 | 271 | } |
272 | 272 |
|
273 | 273 | async function themeSetup() { |
274 | 274 | storage.get(SETTINGS, async (object) => { |
275 | 275 | const settings = object[SETTINGS]; |
276 | 276 | if (settings && settings.startsWith('{')) { |
277 | 277 | const json = JSON.parse(settings); |
278 | | - const size = json[DEVTOOLS_SIZE], |
279 | | - theme = json[DEVTOOLS_THEME] || 'Oceanic', |
280 | | - current = json[DEVTOOLS_CURRENT], |
281 | | - family = json[DEVTOOLS_FONT], |
| 278 | + const size = json[DEVTOOLS_SIZE], |
| 279 | + theme = json[DEVTOOLS_THEME] || 'Oceanic', |
| 280 | + current = json[DEVTOOLS_CURRENT], |
| 281 | + family = json[DEVTOOLS_FONT], |
282 | 282 | scrollbars = json[DEVTOOLS_SCROLLBARS] ?? true, |
283 | | - accent = json[DEVTOOLS_ACCENT_COLOR]; |
| 283 | + accent = json[DEVTOOLS_ACCENT_COLOR]; |
284 | 284 |
|
285 | 285 | // Variables |
286 | 286 | let style = styleBuilder.generateThemeVars(current, family, size, accent); |
|
293 | 293 | // Apply theme |
294 | 294 | if (current.dark) { |
295 | 295 | panels.applyStyleSheet(lightStyle); |
296 | | - } else { |
| 296 | + } |
| 297 | + else { |
297 | 298 | panels.applyStyleSheet(darkStyle); |
298 | 299 | } |
299 | 300 | // Apply def style |
300 | 301 | panels.applyStyleSheet(scroll); |
301 | | - } else { |
| 302 | + } |
| 303 | + else { |
302 | 304 | // Append scroll manually |
303 | 305 | const scroll = generateScrollbarsStyle(true); |
304 | | -
|
305 | | - // css = await fetch('~/assets/default.css').then((res) => res.text()); |
306 | | -
|
307 | | - console.log('applying default theme'); |
308 | 306 | panels.applyStyleSheet(defaultStyle); |
309 | 307 | panels.applyStyleSheet(scroll); |
310 | 308 | } |
|
0 commit comments