@rxap/ngx-theme 18.0.2-dev.2 → 18.0.3-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/compodoc/changelog.html +264 -0
  4. package/compodoc/dependencies.html +203 -0
  5. package/compodoc/fonts/ionicons.eot +0 -0
  6. package/compodoc/fonts/ionicons.svg +2090 -0
  7. package/compodoc/fonts/ionicons.ttf +0 -0
  8. package/compodoc/fonts/ionicons.woff +0 -0
  9. package/compodoc/fonts/ionicons.woff2 +0 -0
  10. package/compodoc/fonts/roboto-v15-latin-300.eot +0 -0
  11. package/compodoc/fonts/roboto-v15-latin-300.svg +314 -0
  12. package/compodoc/fonts/roboto-v15-latin-300.ttf +0 -0
  13. package/compodoc/fonts/roboto-v15-latin-300.woff +0 -0
  14. package/compodoc/fonts/roboto-v15-latin-300.woff2 +0 -0
  15. package/compodoc/fonts/roboto-v15-latin-700.eot +0 -0
  16. package/compodoc/fonts/roboto-v15-latin-700.svg +310 -0
  17. package/compodoc/fonts/roboto-v15-latin-700.ttf +0 -0
  18. package/compodoc/fonts/roboto-v15-latin-700.woff +0 -0
  19. package/compodoc/fonts/roboto-v15-latin-700.woff2 +0 -0
  20. package/compodoc/fonts/roboto-v15-latin-italic.eot +0 -0
  21. package/compodoc/fonts/roboto-v15-latin-italic.svg +323 -0
  22. package/compodoc/fonts/roboto-v15-latin-italic.ttf +0 -0
  23. package/compodoc/fonts/roboto-v15-latin-italic.woff +0 -0
  24. package/compodoc/fonts/roboto-v15-latin-italic.woff2 +0 -0
  25. package/compodoc/fonts/roboto-v15-latin-regular.eot +0 -0
  26. package/compodoc/fonts/roboto-v15-latin-regular.svg +308 -0
  27. package/compodoc/fonts/roboto-v15-latin-regular.ttf +0 -0
  28. package/compodoc/fonts/roboto-v15-latin-regular.woff +0 -0
  29. package/compodoc/fonts/roboto-v15-latin-regular.woff2 +0 -0
  30. package/compodoc/graph/dependencies.svg +24 -0
  31. package/compodoc/images/compodoc-vectorise-inverted.png +0 -0
  32. package/compodoc/images/compodoc-vectorise-inverted.svg +201 -0
  33. package/compodoc/images/compodoc-vectorise.png +0 -0
  34. package/compodoc/images/compodoc-vectorise.svg +201 -0
  35. package/compodoc/images/favicon.ico +0 -0
  36. package/compodoc/index.html +190 -0
  37. package/compodoc/injectables/ThemeService.html +2164 -0
  38. package/compodoc/interfaces/ColorPalette.html +891 -0
  39. package/compodoc/interfaces/ColorPaletteConfig.html +793 -0
  40. package/compodoc/interfaces/ColorPaletteConfigWithName.html +709 -0
  41. package/compodoc/interfaces/ThemeConfig.html +883 -0
  42. package/compodoc/js/compodoc.js +14 -0
  43. package/compodoc/js/lazy-load-graphs.js +44 -0
  44. package/compodoc/js/libs/EventDispatcher.js +5 -0
  45. package/compodoc/js/libs/bootstrap-native.js +2 -0
  46. package/compodoc/js/libs/clipboard.min.js +7 -0
  47. package/compodoc/js/libs/custom-elements-es5-adapter.js +15 -0
  48. package/compodoc/js/libs/custom-elements.min.js +38 -0
  49. package/compodoc/js/libs/d3.v3.min.js +2 -0
  50. package/compodoc/js/libs/deep-iterator.js +2 -0
  51. package/compodoc/js/libs/es6-shim.min.js +12 -0
  52. package/compodoc/js/libs/htmlparser.js +23 -0
  53. package/compodoc/js/libs/innersvg.js +9 -0
  54. package/compodoc/js/libs/lit-html.js +1 -0
  55. package/compodoc/js/libs/prism.js +46 -0
  56. package/compodoc/js/libs/promise.min.js +6 -0
  57. package/compodoc/js/libs/svg-pan-zoom.min.js +3 -0
  58. package/compodoc/js/libs/tablesort.min.js +6 -0
  59. package/compodoc/js/libs/tablesort.number.min.js +6 -0
  60. package/compodoc/js/libs/vis.min.js +47 -0
  61. package/compodoc/js/libs/zepto.min.js +2 -0
  62. package/compodoc/js/menu-wc.js +120 -0
  63. package/compodoc/js/menu-wc_es5.js +40 -0
  64. package/compodoc/js/menu.js +270 -0
  65. package/compodoc/js/routes.js +301 -0
  66. package/compodoc/js/search/lunr.min.js +6 -0
  67. package/compodoc/js/search/search-lunr.js +67 -0
  68. package/compodoc/js/search/search.js +283 -0
  69. package/compodoc/js/search/search_index.js +4 -0
  70. package/compodoc/js/sourceCode.js +58 -0
  71. package/compodoc/js/svg-pan-zoom.controls.js +53 -0
  72. package/compodoc/js/tabs.js +21 -0
  73. package/compodoc/js/tree.js +147 -0
  74. package/compodoc/license.html +731 -0
  75. package/compodoc/miscellaneous/enumerations.html +267 -0
  76. package/compodoc/miscellaneous/functions.html +397 -0
  77. package/compodoc/modules.html +183 -0
  78. package/compodoc/overview.html +201 -0
  79. package/compodoc/properties.html +195 -0
  80. package/compodoc/styles/bootstrap-card.css +219 -0
  81. package/compodoc/styles/bootstrap.min.css +6 -0
  82. package/compodoc/styles/compodoc.css +1124 -0
  83. package/compodoc/styles/dark.css +121 -0
  84. package/compodoc/styles/ionicons.min.css +11 -0
  85. package/compodoc/styles/laravel.css +113 -0
  86. package/compodoc/styles/material.css +131 -0
  87. package/compodoc/styles/original.css +51 -0
  88. package/compodoc/styles/postmark.css +238 -0
  89. package/compodoc/styles/prism.css +301 -0
  90. package/compodoc/styles/readthedocs.css +117 -0
  91. package/compodoc/styles/reset.css +129 -0
  92. package/compodoc/styles/stripe.css +106 -0
  93. package/compodoc/styles/style.css +7 -0
  94. package/compodoc/styles/tablesort.css +33 -0
  95. package/compodoc/styles/vagrant.css +130 -0
  96. package/docs/.nojekyll +1 -0
  97. package/docs/assets/highlight.css +43 -0
  98. package/docs/assets/icons.js +15 -0
  99. package/docs/assets/icons.svg +1 -0
  100. package/docs/assets/main.js +59 -0
  101. package/docs/assets/navigation.js +1 -0
  102. package/docs/assets/search.js +1 -0
  103. package/docs/assets/style.css +1412 -0
  104. package/docs/classes/ThemeService.html +40 -0
  105. package/docs/documentation.json +3425 -0
  106. package/docs/enums/ColorPaletteAlgorithm.html +3 -0
  107. package/docs/enums/ThemeDensity.html +5 -0
  108. package/docs/functions/ComputeColorPalette.html +1 -0
  109. package/docs/functions/ObserveCurrentThemeDensity.html +1 -0
  110. package/docs/hierarchy.html +1 -0
  111. package/docs/index.html +16 -0
  112. package/docs/interfaces/ColorPalette.html +15 -0
  113. package/docs/interfaces/ColorPaletteConfig.html +4 -0
  114. package/docs/interfaces/ColorPaletteConfigWithName.html +5 -0
  115. package/docs/interfaces/ThemeConfig.html +6 -0
  116. package/docs/modules.html +10 -0
  117. package/package.json +8 -8
@@ -0,0 +1,709 @@
1
+ <!doctype html>
2
+ <html class="no-js" lang="">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
6
+ <title>angular-theme</title>
7
+ <meta name="description" content="">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+
10
+ <link rel="icon" type="image/x-icon" href="../images/favicon.ico">
11
+ <link rel="stylesheet" href="../styles/style.css">
12
+ <link rel="stylesheet" href="../styles/dark.css">
13
+ </head>
14
+ <body>
15
+ <script>
16
+ // Blocking script to avoid flickering dark mode
17
+ // Dark mode toggle button
18
+ var useDark = window.matchMedia('(prefers-color-scheme: dark)');
19
+ var darkModeState = useDark.matches;
20
+ var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
21
+ var $darkModeToggles = document.querySelectorAll('.dark-mode-switch');
22
+ var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state');
23
+
24
+ function checkToggle(check) {
25
+ for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
26
+ $darkModeToggleSwitchers[i].checked = check;
27
+ }
28
+ }
29
+
30
+ function toggleDarkMode(state) {
31
+ if (window.localStorage) {
32
+ localStorage.setItem('compodoc_darkmode-state', state);
33
+ }
34
+
35
+ checkToggle(state);
36
+
37
+ const hasClass = document.body.classList.contains('dark');
38
+
39
+ if (state) {
40
+ for (var i = 0; i < $darkModeToggles.length; i++) {
41
+ $darkModeToggles[i].classList.add('dark');
42
+ }
43
+ if (!hasClass) {
44
+ document.body.classList.add('dark');
45
+ }
46
+ } else {
47
+ for (var i = 0; i < $darkModeToggles.length; i++) {
48
+ $darkModeToggles[i].classList.remove('dark');
49
+ }
50
+ if (hasClass) {
51
+ document.body.classList.remove('dark');
52
+ }
53
+ }
54
+ }
55
+
56
+ useDark.addEventListener('change', function (evt) {
57
+ toggleDarkMode(evt.matches);
58
+ });
59
+ if (darkModeStateLocal) {
60
+ darkModeState = darkModeStateLocal === 'true';
61
+ }
62
+ toggleDarkMode(darkModeState);
63
+ </script>
64
+
65
+ <div class="navbar navbar-default navbar-fixed-top d-md-none p-0">
66
+ <div class="d-flex">
67
+ <a href="../" class="navbar-brand">angular-theme</a>
68
+ <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
69
+ </div>
70
+ </div>
71
+
72
+ <div class="xs-menu menu" id="mobile-menu">
73
+ <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
74
+ </div>
75
+
76
+ <div class="container-fluid main">
77
+ <div class="row main">
78
+ <div class="d-none d-md-block menu">
79
+ <compodoc-menu mode="normal"></compodoc-menu>
80
+ </div>
81
+ <!-- START CONTENT -->
82
+ <div class="content interface">
83
+ <div class="content-data">
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <ol class="breadcrumb">
98
+ <li class="breadcrumb-item">Interfaces</li>
99
+ <li class="breadcrumb-item"
100
+ >
101
+ ColorPaletteConfigWithName</li>
102
+ </ol>
103
+
104
+ <ul class="nav nav-tabs" role="tablist">
105
+ <li class="nav-item">
106
+ <a href="#info"
107
+ class="nav-link"
108
+ class="nav-link active"
109
+ role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a>
110
+ </li>
111
+ <li class="nav-item">
112
+ <a href="#source"
113
+ class="nav-link"
114
+
115
+ role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a>
116
+ </li>
117
+ </ul>
118
+
119
+ <div class="tab-content">
120
+ <div class="tab-pane fade active in" id="info">
121
+ <p class="comment">
122
+ <h3>File</h3>
123
+ </p>
124
+ <p class="comment">
125
+ <code>src/lib/theme.service.ts</code>
126
+ </p>
127
+
128
+
129
+
130
+ <p class="comment">
131
+ <h3>Extends</h3>
132
+ </p>
133
+ <p class="comment">
134
+ <code><a href="../interfaces/ColorPaletteConfig.html" target="_self" >ColorPaletteConfig</a></code>
135
+ </p>
136
+
137
+ <section data-compodoc="block-index">
138
+ <h3 id="index">Index</h3>
139
+ <table class="table table-sm table-bordered index-table">
140
+ <tbody>
141
+ <tr>
142
+ <td class="col-md-4">
143
+ <h6><b>Properties</b></h6>
144
+ </td>
145
+ </tr>
146
+ <tr>
147
+ <td class="col-md-4">
148
+ <ul class="index-list">
149
+ <li>
150
+ <span class="modifier">Optional</span>
151
+ <a href="#name"
152
+ >
153
+ name
154
+ </a>
155
+ </li>
156
+ </ul>
157
+ </td>
158
+ </tr>
159
+ </tbody>
160
+ </table>
161
+ </section>
162
+
163
+
164
+
165
+ <section data-compodoc="block-properties">
166
+ <h3 id="inputs">Properties</h3>
167
+ <table class="table table-sm table-bordered">
168
+ <tbody>
169
+ <tr>
170
+ <td class="col-md-4">
171
+ <a name="name"></a>
172
+ <span class="name "><b>name</b>
173
+ <a href="#name">
174
+ <span class="icon ion-ios-link"></span>
175
+ </a>
176
+ </span>
177
+ </td>
178
+ </tr>
179
+ <tr>
180
+ <td class="col-md-4">
181
+ <code>name: <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
182
+ </code>
183
+ </td>
184
+ </tr>
185
+
186
+
187
+ <tr>
188
+ <td class="col-md-4">
189
+ <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
190
+
191
+ </td>
192
+ </tr>
193
+
194
+ <tr>
195
+ <td class="col-md-4">
196
+ <i>Optional</i>
197
+ </td>
198
+ </tr>
199
+
200
+
201
+
202
+
203
+ </tbody>
204
+ </table>
205
+ </section>
206
+ </div>
207
+
208
+
209
+ <div class="tab-pane fade tab-source-code" id="source">
210
+ <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { MediaMatcher } from &#x27;@angular/cdk/layout&#x27;;
211
+ import {
212
+ inject,
213
+ Injectable,
214
+ signal,
215
+ WritableSignal,
216
+ } from &#x27;@angular/core&#x27;;
217
+ import { ConfigService } from &#x27;@rxap/config&#x27;;
218
+ import { PubSubService } from &#x27;@rxap/ngx-pub-sub&#x27;;
219
+ import {
220
+ ColorPalette,
221
+ ComputeColorPalette,
222
+ } from &#x27;./compute-color-palette&#x27;;
223
+
224
+ export enum ThemeDensity {
225
+ Normal &#x3D; 0,
226
+ Compact &#x3D; -1,
227
+ Dense &#x3D; -2,
228
+ VeryDense &#x3D; -3,
229
+ }
230
+
231
+ export interface ColorPaletteConfigWithName extends ColorPaletteConfig {
232
+ name?: string;
233
+ }
234
+
235
+ export interface ThemeConfig {
236
+ primaryColor?: ColorPaletteConfigWithName;
237
+ accentColor?: ColorPaletteConfigWithName;
238
+ warnColor?: ColorPaletteConfigWithName;
239
+ density?: ThemeDensity;
240
+ typography?: string;
241
+ }
242
+
243
+ export interface ColorPaletteConfig {
244
+ algorithm?: string;
245
+ base?: string;
246
+ color?: Partial&lt;ColorPalette&gt;;
247
+ }
248
+
249
+ @Injectable({ providedIn: &#x27;root&#x27; })
250
+ export class ThemeService {
251
+
252
+ public readonly config &#x3D; inject(ConfigService);
253
+ public readonly pubSub &#x3D; inject(PubSubService);
254
+
255
+ public readonly darkMode: WritableSignal&lt;boolean&gt;;
256
+ public readonly themeName: WritableSignal&lt;string&gt;;
257
+ public readonly density: WritableSignal&lt;ThemeDensity&gt;;
258
+ public readonly typography: WritableSignal&lt;string&gt;;
259
+
260
+ private readonly darkModeMediaQuery: MediaQueryList;
261
+
262
+ constructor(private readonly mediaMatcher: MediaMatcher) {
263
+ this.darkModeMediaQuery &#x3D; this.mediaMatcher.matchMedia(&#x27;(prefers-color-scheme: dark)&#x27;);
264
+ this.darkMode &#x3D; signal(this.darkModeMediaQuery.matches);
265
+ this.themeName &#x3D; signal(this.getTheme());
266
+ this.density &#x3D; signal(this.getDensity());
267
+ this.typography &#x3D; signal(this.getTypography());
268
+ this.darkModeMediaQuery.addEventListener(&#x27;change&#x27;, (event) &#x3D;&gt; {
269
+ this.setDarkTheme(event.matches, true);
270
+ });
271
+ this.restore();
272
+ }
273
+
274
+ public restore() {
275
+ // region restore dark mode
276
+ let darkMode &#x3D; this.restoreDarkMode();
277
+ // if the dark/light mode is not restored from the local storage
278
+ if (darkMode &#x3D;&#x3D;&#x3D; null) {
279
+ // set the dark mode based on the media query
280
+ darkMode &#x3D; this.darkModeMediaQuery.matches;
281
+ this.setDarkTheme(darkMode, true);
282
+ }
283
+ // endregion
284
+
285
+ this.restoreThemeName();
286
+ this.restoreDensity();
287
+ this.restoreTypography();
288
+ }
289
+
290
+ private get darkModeLocalStorageKey() {
291
+ return (
292
+ window as any
293
+ )?.[&#x27;__rxap__&#x27;]?.[&#x27;ngx&#x27;]?.[&#x27;theme&#x27;]?.[&#x27;darkMode&#x27;]?.[&#x27;key&#x27;] ?? &#x60;rxap-dark-mode&#x60;;
294
+ }
295
+
296
+ private get themeNameLocalStorageKey() {
297
+ return (
298
+ window as any
299
+ )?.[&#x27;__rxap__&#x27;]?.[&#x27;ngx&#x27;]?.[&#x27;theme&#x27;]?.[&#x27;name&#x27;]?.[&#x27;key&#x27;] ?? &#x60;rxap-theme-name&#x60;;
300
+ }
301
+
302
+ private get densityLocalStorageKey() {
303
+ return (
304
+ window as any
305
+ )?.[&#x27;__rxap__&#x27;]?.[&#x27;ngx&#x27;]?.[&#x27;theme&#x27;]?.[&#x27;density&#x27;]?.[&#x27;key&#x27;] ?? &#x60;rxap-theme-density&#x60;;
306
+ }
307
+
308
+ private get typographyLocalStorageKey() {
309
+ return (
310
+ window as any
311
+ )?.[&#x27;__rxap__&#x27;]?.[&#x27;ngx&#x27;]?.[&#x27;theme&#x27;]?.[&#x27;typography&#x27;]?.[&#x27;key&#x27;] ?? &#x60;rxap-theme-typography&#x60;;
312
+ }
313
+
314
+ // region restore
315
+
316
+ public restoreDarkMode() {
317
+ let darkMode: boolean | null &#x3D; null;
318
+ const darkModeCached &#x3D; localStorage.getItem(this.darkModeLocalStorageKey);
319
+ if (darkModeCached &#x3D;&#x3D;&#x3D; &#x27;true&#x27;) {
320
+ darkMode &#x3D; true;
321
+ }
322
+ if (darkModeCached &#x3D;&#x3D;&#x3D; &#x27;false&#x27;) {
323
+ darkMode &#x3D; false;
324
+ }
325
+ if (darkMode !&#x3D;&#x3D; null) {
326
+ this.setDarkTheme(darkMode, true);
327
+ }
328
+ return darkMode;
329
+ }
330
+
331
+ public restoreThemeName() {
332
+ const themeName &#x3D; localStorage.getItem(this.themeNameLocalStorageKey);
333
+ if (themeName) {
334
+ this.setTheme(themeName, true);
335
+ }
336
+ return themeName;
337
+ }
338
+
339
+ public restoreTypography() {
340
+ const typography &#x3D; localStorage.getItem(this.typographyLocalStorageKey);
341
+ if (typography) {
342
+ this.setTypography(typography, true);
343
+ }
344
+ return typography;
345
+ }
346
+
347
+ public restoreDensity() {
348
+ const density &#x3D; localStorage.getItem(&#x27;rxap-theme-density&#x27;);
349
+ if (density) {
350
+ const value &#x3D; Number(density) as ThemeDensity;
351
+ if (value &lt;&#x3D; 0 &amp;&amp; value &gt;&#x3D; -3) {
352
+ this.setDensity(Number(density) as ThemeDensity, true);
353
+ return value;
354
+ }
355
+ }
356
+ return null;
357
+ }
358
+
359
+ // endregion
360
+
361
+ public toggleDarkTheme(): void {
362
+ this.setDarkTheme(!this.darkMode());
363
+ }
364
+
365
+ // region set theme configuration state
366
+
367
+ public setDarkTheme(darkMode: boolean, silent?: boolean): void {
368
+ this.applyDarkMode(darkMode);
369
+ if (this.darkMode() !&#x3D;&#x3D; darkMode) {
370
+ this.darkMode.set(darkMode);
371
+ if (!silent) {
372
+ localStorage.setItem(this.darkModeLocalStorageKey, String(darkMode));
373
+ this.pubSub.publish(&#x27;rxap.theme.darkMode.change&#x27;, darkMode);
374
+ }
375
+ }
376
+ }
377
+
378
+ public setDensity(density: ThemeDensity, silent &#x3D; false): void {
379
+ this.applyDensity(density);
380
+ if (this.density() !&#x3D;&#x3D; density) {
381
+ this.density.set(density);
382
+ if (!silent) {
383
+ localStorage.setItem(this.densityLocalStorageKey, String(density));
384
+ this.pubSub.publish(&#x27;rxap.theme.density.change&#x27;, density);
385
+ }
386
+ }
387
+ }
388
+
389
+ public setTypography(typography: string, silent &#x3D; false): void {
390
+ this.applyTypography(typography);
391
+ if (this.typography() !&#x3D;&#x3D; typography) {
392
+ this.typography.set(typography);
393
+ if (!silent) {
394
+ localStorage.setItem(this.typographyLocalStorageKey, typography);
395
+ this.pubSub.publish(&#x27;rxap.theme.typography.change&#x27;, typography);
396
+ }
397
+ }
398
+ }
399
+
400
+ public setTheme(themeName: string, silent &#x3D; false) {
401
+ this.applyTheme(themeName);
402
+ this.density.set(this.getDensity());
403
+ this.typography.set(this.getTypography());
404
+ if (this.themeName() !&#x3D;&#x3D; themeName) {
405
+ this.themeName.set(themeName);
406
+ if (!silent) {
407
+ localStorage.setItem(this.themeNameLocalStorageKey, themeName);
408
+ this.pubSub.publish(&#x27;rxap.theme.preset.change&#x27;, themeName);
409
+ }
410
+ }
411
+ }
412
+
413
+ // endregion
414
+
415
+ // region apply theme configuration state
416
+
417
+ public applyDarkMode(darkMode: boolean): void {
418
+ if (darkMode) {
419
+ // region deprecated
420
+ document.body.classList.add(&#x27;dark-theme&#x27;);
421
+ localStorage.removeItem(&#x27;rxap-light-theme&#x27;);
422
+ // endregion
423
+ document.body.classList.add(&#x27;dark&#x27;);
424
+ } else {
425
+ // region deprecated
426
+ document.body.classList.remove(&#x27;dark-theme&#x27;);
427
+ localStorage.setItem(&#x27;rxap-light-theme&#x27;, &#x27;true&#x27;);
428
+ // endregion
429
+ document.body.classList.remove(&#x27;dark&#x27;);
430
+ }
431
+ }
432
+
433
+ public applyDensity(density: ThemeDensity): void {
434
+ document.body.classList.remove(&#x27;density-0&#x27;, &#x27;density-1&#x27;, &#x27;density-2&#x27;, &#x27;density-3&#x27;);
435
+ if (density &lt; 0) {
436
+ document.body.classList.add(&#x60;density${ density }&#x60;);
437
+ }
438
+ }
439
+
440
+ public applyTypography(typography: string): void {
441
+ document.body.style.setProperty(&#x27;--font-family&#x27;, &#x60;var(--font-family-${ typography })&#x60;);
442
+ }
443
+
444
+ public applyTheme(themeName: string): void {
445
+ if (themeName &#x3D;&#x3D;&#x3D; &#x27;default&#x27;) {
446
+ this.resetToDefaultTheme();
447
+ return;
448
+ }
449
+
450
+ const theme &#x3D; this.getThemeConfig(themeName);
451
+
452
+ if (theme.primaryColor?.color) {
453
+ this.setCssColorVariables(&#x27;primary&#x27;, theme.primaryColor.color);
454
+ }
455
+
456
+ if (theme.accentColor?.color) {
457
+ this.setCssColorVariables(&#x27;accent&#x27;, theme.accentColor.color);
458
+ }
459
+
460
+ if (theme.warnColor?.color) {
461
+ this.setCssColorVariables(&#x27;warn&#x27;, theme.warnColor.color);
462
+ }
463
+
464
+ if (theme.density !&#x3D;&#x3D; undefined) {
465
+ this.applyDensity(theme.density);
466
+ }
467
+
468
+ if (theme.typography) {
469
+ this.applyTypography(theme.typography);
470
+ }
471
+
472
+ document.body.style.setProperty(&#x60;--theme-name&#x60;, themeName);
473
+ }
474
+
475
+ // endregion
476
+
477
+ // region get theme configuration state
478
+
479
+ public getDensity(): ThemeDensity {
480
+ let density &#x3D; 0;
481
+ document.body.classList.forEach((className) &#x3D;&gt; {
482
+ const match &#x3D; className.match(/density-([123])/);
483
+ if (match) {
484
+ density &#x3D; Number(match[1]) * -1;
485
+ }
486
+ });
487
+ return density as ThemeDensity;
488
+ }
489
+
490
+ public getTypography(): string {
491
+ const variable &#x3D; document.body.style.getPropertyValue(&#x27;--font-family&#x27;);
492
+ const match &#x3D; variable.match(/var\(--font-family-(.*)\)/);
493
+ if (match) {
494
+ return match[1];
495
+ }
496
+ return &#x27;default&#x27;;
497
+ }
498
+
499
+ public getTheme() {
500
+ return document.body.style.getPropertyValue(&#x27;--theme-name&#x27;) || &#x27;default&#x27;;
501
+ }
502
+
503
+ // endregion
504
+
505
+ // region get available
506
+
507
+ public getAvailableColorPalettes(): string[] | null {
508
+ const colorPalettesConfigs: Record&lt;string, unknown&gt; | boolean &#x3D; this.config.get(&#x27;colorPalettes&#x27;, false);
509
+ if (!colorPalettesConfigs) {
510
+ return null;
511
+ }
512
+ const availableColorPalettes: string[] &#x3D; Object.keys(colorPalettesConfigs);
513
+ availableColorPalettes.unshift(&#x27;default&#x27;);
514
+ return availableColorPalettes;
515
+ }
516
+
517
+ public getAvailableThemes(): string[] | null {
518
+ const themeConfigs: Record&lt;string, unknown&gt; | boolean &#x3D; this.config.get(&#x27;themes&#x27;, false);
519
+ if (!themeConfigs) {
520
+ return null;
521
+ }
522
+ const availableThemes: string[] &#x3D; Object.keys(themeConfigs);
523
+ availableThemes.unshift(&#x27;default&#x27;);
524
+ return availableThemes;
525
+ }
526
+
527
+ public getAvailableTypographies(): string[] | null {
528
+ const availableTypographies &#x3D; this.config.get(&#x27;typographies&#x27;, false);
529
+ if (!availableTypographies) {
530
+ return null;
531
+ }
532
+ return Array
533
+ .from(document.styleSheets)
534
+ .filter(sheet &#x3D;&gt; sheet.href &#x3D;&#x3D;&#x3D; null || sheet.href.startsWith(window.location.origin))
535
+ .flatMap(sheet &#x3D;&gt; Array.from(sheet.cssRules || []))
536
+ .filter((rule: any) &#x3D;&gt; rule.selectorText &#x3D;&#x3D;&#x3D; &#x27;:root&#x27;)
537
+ .flatMap((rule: any) &#x3D;&gt; Array.from(rule.style))
538
+ .filter((prop: any) &#x3D;&gt; prop.startsWith(&#x27;--&#x27;))
539
+ .filter((prop: any) &#x3D;&gt; prop.startsWith(&#x27;--font-family-&#x27;))
540
+ .map((prop: any) &#x3D;&gt; prop.replace(&#x27;--font-family-&#x27;, &#x27;&#x27;))
541
+ .sort();
542
+ }
543
+
544
+ // endregion
545
+
546
+ public getColorPalette(colorPaletteName: string): Partial&lt;ColorPalette&gt; {
547
+ const colorPaletteConfig &#x3D; this.config.getOrThrow&lt;ColorPaletteConfig&gt;(&#x60;colorPalettes.${ colorPaletteName }&#x60;);
548
+ return this.coerceColorPalette(colorPaletteConfig);
549
+ }
550
+
551
+ // region utility
552
+
553
+ private coerceColorPalette(colorPaletteConfig: ColorPaletteConfig): Partial&lt;ColorPalette&gt; {
554
+ let colorPalette: Partial&lt;ColorPalette&gt; &#x3D; {};
555
+
556
+ if (colorPaletteConfig.color) {
557
+ if (Object.keys(colorPaletteConfig.color).length !&#x3D;&#x3D; 14) {
558
+ // the color palette is not complete
559
+ if (colorPaletteConfig.base) {
560
+ colorPalette &#x3D;
561
+ ComputeColorPalette(colorPaletteConfig.base, colorPaletteConfig.color, colorPaletteConfig.algorithm);
562
+ }
563
+ }
564
+ colorPalette &#x3D; colorPaletteConfig.color;
565
+ } else if (colorPaletteConfig.base) {
566
+ colorPalette &#x3D; ComputeColorPalette(colorPaletteConfig.base, {}, colorPaletteConfig.algorithm);
567
+ }
568
+
569
+ if (Object.keys(colorPalette).length &#x3D;&#x3D;&#x3D; 0) {
570
+ throw new Error(&#x27;FATAL: The color palette has neither a base nor a color property&#x27;);
571
+ }
572
+
573
+ return colorPalette;
574
+ }
575
+
576
+ private getThemeConfig(themeName: string): ThemeConfig {
577
+ const themeConfig &#x3D; this.config.getOrThrow&lt;ThemeConfig&gt;(&#x60;themes.${ themeName }&#x60;);
578
+
579
+ if (themeConfig.accentColor) {
580
+ themeConfig.accentColor.color &#x3D; this.coerceColorPalette(themeConfig.accentColor);
581
+ }
582
+
583
+ if (themeConfig.primaryColor) {
584
+ themeConfig.primaryColor.color &#x3D; this.coerceColorPalette(themeConfig.primaryColor);
585
+ }
586
+
587
+ if (themeConfig.warnColor) {
588
+ themeConfig.warnColor.color &#x3D; this.coerceColorPalette(themeConfig.warnColor);
589
+ }
590
+
591
+ return themeConfig;
592
+ }
593
+
594
+ private setCssColorVariables(name: string, colorPalette: Partial&lt;ColorPalette&gt;): void {
595
+ this.clearCssColorVariables(name);
596
+ for (const [ index, color ] of Object.entries(colorPalette)) {
597
+ document.body.style.setProperty(&#x60;--${ name }-${ index }&#x60;, color);
598
+ }
599
+ }
600
+
601
+ private clearCssColorVariables(name: string): void {
602
+ document.body.style.removeProperty(&#x60;--${ name }-50&#x60;);
603
+ for (let index &#x3D; 100; index &lt;&#x3D; 900; index +&#x3D; 100) {
604
+ document.body.style.removeProperty(&#x60;--${ name }-${ index }&#x60;);
605
+ }
606
+ document.body.style.removeProperty(&#x60;--${ name }-a100&#x60;);
607
+ document.body.style.removeProperty(&#x60;--${ name }-a200&#x60;);
608
+ document.body.style.removeProperty(&#x60;--${ name }-a400&#x60;);
609
+ document.body.style.removeProperty(&#x60;--${ name }-a700&#x60;);
610
+ }
611
+
612
+ private resetToDefaultTheme() {
613
+ this.clearCssColorVariables(&#x27;primary&#x27;);
614
+ this.clearCssColorVariables(&#x27;accent&#x27;);
615
+ this.clearCssColorVariables(&#x27;warn&#x27;);
616
+ this.setDensity(0);
617
+ this.setTypography(&#x27;default&#x27;);
618
+ document.body.style.removeProperty(&#x60;--theme-name&#x60;);
619
+ localStorage.removeItem(this.themeNameLocalStorageKey);
620
+ localStorage.removeItem(this.densityLocalStorageKey);
621
+ localStorage.removeItem(this.typographyLocalStorageKey);
622
+ }
623
+
624
+ // endregion
625
+
626
+ }
627
+ </code></pre>
628
+ </div>
629
+ </div>
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+ </div><div class="search-results">
639
+ <div class="has-results">
640
+ <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
641
+ <ul class="search-results-list"></ul>
642
+ </div>
643
+ <div class="no-results">
644
+ <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
645
+ </div>
646
+ </div>
647
+ </div>
648
+ <!-- END CONTENT -->
649
+ </div>
650
+ </div>
651
+
652
+ <label class="dark-mode-switch">
653
+ <input type="checkbox">
654
+ <span class="slider">
655
+ <svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
656
+ <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
657
+ </svg>
658
+ </span>
659
+ </label>
660
+
661
+ <script>
662
+ var COMPODOC_CURRENT_PAGE_DEPTH = 1;
663
+ var COMPODOC_CURRENT_PAGE_CONTEXT = 'interface';
664
+ var COMPODOC_CURRENT_PAGE_URL = 'ColorPaletteConfigWithName.html';
665
+ var MAX_SEARCH_RESULTS = 15;
666
+ </script>
667
+
668
+ <script>
669
+ $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
670
+ checkToggle(darkModeState);
671
+ if ($darkModeToggleSwitchers.length > 0) {
672
+ for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
673
+ $darkModeToggleSwitchers[i].addEventListener('change', function (event) {
674
+ darkModeState = !darkModeState;
675
+ toggleDarkMode(darkModeState);
676
+ });
677
+ }
678
+ }
679
+ </script>
680
+
681
+ <script src="../js/libs/custom-elements.min.js"></script>
682
+ <script src="../js/libs/lit-html.js"></script>
683
+
684
+ <script src="../js/menu-wc.js" defer></script>
685
+ <script nomodule src="../js/menu-wc_es5.js" defer></script>
686
+
687
+ <script src="../js/libs/bootstrap-native.js"></script>
688
+
689
+ <script src="../js/libs/es6-shim.min.js"></script>
690
+ <script src="../js/libs/EventDispatcher.js"></script>
691
+ <script src="../js/libs/promise.min.js"></script>
692
+ <script src="../js/libs/zepto.min.js"></script>
693
+
694
+ <script src="../js/compodoc.js"></script>
695
+
696
+ <script src="../js/tabs.js"></script>
697
+ <script src="../js/menu.js"></script>
698
+ <script src="../js/libs/clipboard.min.js"></script>
699
+ <script src="../js/libs/prism.js"></script>
700
+ <script src="../js/sourceCode.js"></script>
701
+ <script src="../js/search/search.js"></script>
702
+ <script src="../js/search/lunr.min.js"></script>
703
+ <script src="../js/search/search-lunr.js"></script>
704
+ <script src="../js/search/search_index.js"></script>
705
+ <script src="../js/lazy-load-graphs.js"></script>
706
+
707
+
708
+ </body>
709
+ </html>