-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcssTemplates.js
More file actions
1730 lines (1490 loc) · 54.1 KB
/
cssTemplates.js
File metadata and controls
1730 lines (1490 loc) · 54.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* cssTemplates.js
*
* CSS Gnommé Extension Module - GNOME 46+
* CSS template generation for theme overlay
*/
import { Constants } from "./constants.js";
import { ThemeUtils } from "./themeUtils.js";
/* cssTemplates.js
*
* CSS Template Strings for CSSGnomme Theme Overlay Generation
* Separated from overlayThemeManager.js for better organization and string pooling
* OPTIMIZATION: Reusable templates reduce memory allocation during theme generation
*/
/**
* CSS Template Generator
* Provides reusable CSS template strings with parameter substitution
* All templates are cached in memory for reuse across multiple theme generations
*/
export class CSSTemplates {
/**
* Initialize CSS template cache
* Templates are compiled once and reused for performance
*/
constructor() {
// Cache compiled templates for reuse
this._templateCache = new Map();
}
// ===== GTK THEME IMPORT TEMPLATES =====
/**
* Generate GTK theme import statement
* @param {string} sourceThemePath - Path to source theme CSS
* @param {boolean} isDark - Is dark variant
* @returns {string} CSS import statement
*/
getGtkImport(sourceThemePath, isDark) {
const variant = isDark ? "dark" : "light";
return `/* Base theme import - tint removed, original styles preserved */\n@import url('${sourceThemePath}');\n\n`;
}
/**
* Generate GTK base CSS wrapper
* @param {string} version - GTK version (gtk-3.0, gtk-4.0)
* @param {string} modifiedCss - Modified CSS content
* @returns {string} Complete CSS with header
*/
getGtkBaseCssWrapper(version, modifiedCss) {
return `/* CSSGnomme Overlay - ${version} Base Theme
* Original theme CSS with Zorin tint colors removed
* Preserves all other theme styling
*/
${modifiedCss}
`;
}
// ===== PANEL & POPUP COLOR OVERRIDES =====
/**
* Generate panel color override CSS
* @param {string} panelColor - Panel color (rgba format)
* @param {number} opacity - Panel opacity (0-1)
* @param {boolean} applyRadius - Apply border radius
* @param {number} borderRadius - Border radius value
* @returns {string} Panel override CSS
*/
getPanelColorOverride(panelColor, opacity, applyRadius, borderRadius) {
// Cache key for this combination
const cacheKey = `panel_${panelColor}_${opacity}_${applyRadius}_${borderRadius}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const radiusRule = applyRadius ? `border-radius: ${borderRadius}px;` : "";
const css = `
/* Panel Background Override */
.panel {
background-color: ${panelColor} !important;
${radiusRule}
}
`;
this._templateCache.set(cacheKey, css);
return css;
}
/**
* Generate popup menu color override CSS
* @param {string} popupColor - Popup color (rgba format)
* @param {number} opacity - Popup opacity (0-1)
* @param {boolean} applyRadius - Apply border radius
* @param {number} borderRadius - Border radius value
* @returns {string} Popup override CSS
*/
getPopupColorOverride(popupColor, opacity, applyRadius, borderRadius) {
const cacheKey = `popup_${popupColor}_${opacity}_${applyRadius}_${borderRadius}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const radiusRule = applyRadius ? `border-radius: ${borderRadius}px;` : "";
const css = `
/* Popup Menu Background Override */
.popup-menu,
.popup-menu-content {
background-color: ${popupColor} !important;
${radiusRule}
}
`;
this._templateCache.set(cacheKey, css);
return css;
}
// ===== BLUR EFFECTS =====
/**
* Generate backdrop-filter CSS only (for flexible usage)
* @param {number} radius - Blur radius
* @param {number} saturate - Saturation multiplier
* @param {number} contrast - Contrast multiplier
* @param {number} brightness - Brightness multiplier
* @returns {string} Backdrop-filter CSS or empty string if disabled
*/
getBackdropFilter(radius, saturate, contrast, brightness) {
if (radius <= 0) return "";
const cacheKey = `backdrop_${radius}_${saturate}_${contrast}_${brightness}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const css = `backdrop-filter: blur(${radius}px) saturate(${saturate}) contrast(${contrast}) brightness(${brightness}) !important;`;
this._templateCache.set(cacheKey, css);
return css;
}
// ===== GNOME SHELL SPECIFIC =====
/**
* Generate Shell panel styling
* @param {string} panelColor - Panel background color
* @param {boolean} applyRadius - Apply border radius
* @param {number} borderRadius - Border radius value
* @returns {string} Shell panel CSS
*/
getShellPanelStyle(panelColor, applyRadius, borderRadius) {
const cacheKey = `shell_panel_${panelColor}_${applyRadius}_${borderRadius}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const radiusRule = applyRadius ? `border-radius: ${borderRadius}px;` : "";
const css = `
/* GNOME Shell Panel */
#panel {
background-color: ${panelColor} !important;
${radiusRule}
}
`;
this._templateCache.set(cacheKey, css);
return css;
}
/**
* Generate Shell popup menu styling
* @param {string} popupColor - Popup background color
* @param {boolean} applyRadius - Apply border radius
* @param {number} borderRadius - Border radius value
* @returns {string} Shell popup CSS
*/
getShellPopupStyle(popupColor, applyRadius, borderRadius) {
const cacheKey = `shell_popup_${popupColor}_${applyRadius}_${borderRadius}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const radiusRule = applyRadius ? `border-radius: ${borderRadius}px;` : "";
const css = `
/* GNOME Shell Popup Menus */
.popup-menu-boxpointer,
.popup-menu-content,
.modal-dialog {
background-color: ${popupColor} !important;
${radiusRule}
}
`;
this._templateCache.set(cacheKey, css);
return css;
}
// ===== ZORIN ACCENT COLOR INTEGRATION =====
/**
* Generate Zorin accent color CSS
* @param {string} accentRgb - Accent color in rgb() format
* @param {boolean} isDark - Is dark theme
* @returns {string} Accent color CSS
*/
getZorinAccentStyle(accentRgb, isDark) {
// Null guard: Skip Zorin accent CSS if no valid color detected
// This handles neutral/grey themes (e.g., ZorinGrey-Dark) gracefully
if (!accentRgb || accentRgb === null || accentRgb === "null") {
return "/* Zorin accent color not detected - using theme defaults (neutral/grey theme) */\n";
}
const cacheKey = `zorin_accent_${accentRgb}_${isDark}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
// Enhanced pastel for dark themes
const displayColor = isDark ? this._enhancePastelForDark(accentRgb) : accentRgb;
// Generate foreground color with proper contrast
const fgColor = isDark ? Constants.AUTO_TEXT_COLORS.lightHex : Constants.AUTO_TEXT_COLORS.darkHex; // Contrasting text color
const css = `
/* Zorin Theme Accent Color Variables */
@define-color accent_color ${displayColor};
@define-color accent_bg_color ${displayColor};
@define-color accent_fg_color ${fgColor};
/* ===== MINIMAL MODE - ONLY CORE WIDGETS ===== */
/* Temporarily disabled hover/selection overrides for debugging */
/* Switch widget - track (container) */
switch:checked {
background-color: ${displayColor};
background-image: image(${displayColor});
border-color: ${displayColor};
}
/* Switch slider - contrasting color for visibility */
switch:checked > slider {
background-color: ${fgColor};
}
/* Checkboxes and Radio buttons - use accent color */
check:checked,
check:indeterminate,
radio:checked,
radio:indeterminate {
background-color: ${displayColor};
background-image: image(${displayColor});
border-color: ${displayColor};
color: ${fgColor};
box-shadow: none;
}
/* Progress bars */
progressbar > trough > progress {
background-color: ${displayColor};
}
/* ===== DISABLED FOR DEBUGGING (v2.5 testing) ===== */
/* Uncomment below to re-enable hover/selection styling */
/*
/ * Selected items in lists - subtle transparency (v2.5 Full Auto Mode) * /
row.activatable:selected,
.view:selected,
.view:selected:focus,
.view text:selected,
.view text:selected:focus,
textview text:selected,
textview text:selected:focus,
iconview:selected,
iconview:selected:focus,
flowbox > flowboxchild:selected,
.content-view .tile:selected {
background-color: alpha(${displayColor}, 0.20);
color: inherit;
}
/ * Links hover state * /
link:hover {
color: ${displayColor};
}
/ * Spinbutton/Entry progress indicator * /
spinbutton > progress > trough > progress,
entry > progress > trough > progress {
background-color: ${displayColor};
}
*/
`;
this._templateCache.set(cacheKey, css);
return css;
}
// ===== GTK4 SPECIFIC OVERRIDES =====
/**
* Get GTK4-specific CSS overrides
* @param {number} borderRadius - Border radius value
* @returns {string} GTK4 override CSS
*/
getGtk4Overrides(borderRadius) {
const cacheKey = `gtk4_overrides_${borderRadius}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const css = `
/* GTK4 Specific Overrides */
.card {
background: @cssgnomme_popup_bg;
border-radius: ${borderRadius}px;
}
window {
border-radius: ${borderRadius}px;
}
window > box > box > box {
border-radius: ${borderRadius}px;
}
/* GTK4 window decorations */
windowhandle,
windowcontrols {
border-radius: ${borderRadius}px ${borderRadius}px 0 0;
}
/* Fix ComboRow dropdown popup border (Adwaita preferences) */
.menu.background {
border: none;
box-shadow: none;
background: transparent;
}
.menu > arrow {
border: none;
background: transparent;
}
`;
this._templateCache.set(cacheKey, css);
return css;
}
// ===== GTK OVERLAY CSS COMPONENTS =====
/**
* Generate GTK CSS variables section
* @param {Object} colorSettings - Color settings from _extractColorSettings
* @returns {string} CSS variables
*/
getGtkCssVariables(colorSettings) {
return `
/*** CSSGnomme CSS Variables ***/
@define-color cssgnomme_panel_bg ${colorSettings.panel.color};
@define-color cssgnomme_panel_fg ${colorSettings.panel.fgCss};
@define-color cssgnomme_panel_hover ${colorSettings.panel.hoverCss};
@define-color cssgnomme_panel_solid_bg ${colorSettings.panel.solidCss};
@define-color cssgnomme_popup_bg ${colorSettings.popup.color};
@define-color cssgnomme_popup_fg ${colorSettings.popup.fgCss};
@define-color cssgnomme_popup_hover ${colorSettings.popup.hoverCss};
`;
}
/**
* Generate HeaderBar styling
* @param {number} borderRadius - Border radius value
* @returns {string} HeaderBar CSS
*/
getGtkHeaderBarStyle(borderRadius) {
return `
/* HeaderBar Styling - only top corners rounded (window continues below) */
headerbar {
background: @cssgnomme_panel_solid_bg;
color: @cssgnomme_panel_fg;
border-radius: ${borderRadius}px ${borderRadius}px 0 0;
}
headerbar button {
border-radius: calc(${borderRadius}px * ${Constants.BORDER_RADIUS_SCALING.panelButton});
}
/* ===== DISABLED FOR DEBUGGING (v2.5 testing) ===== */
/* Temporarily removed to test theme default behavior */
/*
headerbar button:hover {
background: @cssgnomme_panel_hover;
border-radius: inherit;
}
/ * Window control buttons ONLY - remove theme shadow/outline effects * /
headerbar.titlebar button.titlebutton,
headerbar windowcontrols button,
headerbar .windowcontrols button {
box-shadow: none !important;
outline: none !important;
}
headerbar.titlebar button.titlebutton:hover,
headerbar windowcontrols button:hover,
headerbar .windowcontrols button:hover {
box-shadow: none !important;
outline: none !important;
border-radius: inherit;
}
/ * Remove pseudo-elements that might create extra visual elements * /
headerbar.titlebar button.titlebutton::before,
headerbar.titlebar button.titlebutton::after,
headerbar windowcontrols button::before,
headerbar windowcontrols button::after {
display: none !important;
content: none !important;
}
*/
`;
}
/**
* Generate Window styling (CSD decorations)
* @param {number} borderRadius - Border radius value
* @returns {string} Window CSS
*
* NOTE: Window border-radius limitations (2025-10-31)
* =====================================================
* We do NOT apply border-radius to window.background due to GTK3/GTK4 rendering
* limitations that cause content overflow ("sharp corners bleeding outside rounded borders").
*
* ATTEMPTED WORKAROUNDS (all failed):
* 1. overflow: hidden on window.background - Ignored by GTK4
* 2. clip-path: inset(0 round Xpx) - Not respected by libadwaita
* 3. Zorin pattern (.unified selectors) - No improvement
* 4. scrolledwindow bottom-only radius - Insufficient clipping
* 5. toolbarview child selectors - Only helps AdwToolbarView apps (Nautilus)
* 6. box.vertical/horizontal clipping - Ignored
*
* ROOT CAUSE:
* - GTK3: CSS border-radius works, but overflow:hidden unreliable for some widgets
* - GTK4 + libadwaita: Hardcoded rendering in C code ignores CSS overrides
* - Software Updates (gnome-software): Uses old layout without AdwToolbarView
* - Modern apps (Nautilus): Use AdwToolbarView which auto-clips (works OK)
*
* VERIFICATION:
* - Original Zorin themes: Same problem exists (not CSSGnomme bug)
* - Fluent themes: Same problem exists
* - GNOME Terminal (GTK3): Works perfectly with border-radius
*
* DECISION: Accept limitation, focus on what works:
* - HeaderBar rounded top corners (works 100%)
* - Panel, popups, Quick Settings (full control)
* - GTK3 applications (full control)
* - Modern libadwaita apps with AdwToolbarView (acceptable)
*
* See: docs/GTK4_LIBADWAITA_LIMITATIONS.md (if created)
*/
getGtkWindowStyle(borderRadius) {
return `
/* Window Styling - Client-Side Decorations */
window.csd,
window.csd decoration,
window.solid-csd decoration {
border-radius: ${borderRadius}px;
}
/* Dialogs and floating windows */
dialog.background,
.dialog-vbox {
border-radius: ${borderRadius}px;
}
`;
}
/**
* Generate Popover/Menu styling
* @param {number} borderRadius - Border radius value
* @returns {string} Popover CSS
*/
getGtkPopoverStyle(borderRadius) {
return `
/* Popover/Menu Styling - Fixed transparent backgrounds (v2.4.1) */
popover.background,
popover.menu,
.popup-menu,
.menu.background {
background-color: @cssgnomme_popup_bg;
color: @cssgnomme_popup_fg;
border-radius: ${borderRadius}px;
}
/* Note: Removed 'popover.background > contents { background: transparent; }'
* which was causing invisible menus in Nautilus, Extension Manager, etc.
* GTK4 handles content background automatically.
*/
`;
}
/**
* Generate Tooltip styling
* @param {number} borderRadius - Border radius value
* @returns {string} Tooltip CSS
*/
getGtkTooltipStyle(borderRadius) {
return `
/* Tooltip Styling */
tooltip.background {
background: @cssgnomme_popup_bg;
color: @cssgnomme_popup_fg;
border-radius: calc(${borderRadius}px * 0.5);
}
`;
}
/**
* Generate Fluent theme titlebar fix (non-Zorin themes with Zorin integration)
* @param {boolean} isZorinTheme - Is current theme a Zorin theme
* @param {boolean} enableZorinIntegration - Is Zorin integration enabled
* @returns {string} Fluent titlebar CSS or empty string
*/
getFluentTitlebarFix(isZorinTheme, enableZorinIntegration) {
if (isZorinTheme || !enableZorinIntegration) {
return "";
}
return `
/* Fluent Theme: Window titlebar styling to match Zorin behavior when integration enabled */
/* IMPORTANT: This must be at the end to override Fluent's own headerbar rules */
/* Main titlebar/headerbar selectors - cover all window types */
.titlebar:not(headerbar),
headerbar,
window.csd > .titlebar:not(headerbar),
window.csd > headerbar,
window.solid-csd > .titlebar,
.solid-csd headerbar,
.default-decoration.titlebar:not(headerbar),
headerbar.default-decoration {
background-color: @cssgnomme_panel_bg !important;
background-image: none !important;
color: @cssgnomme_panel_fg !important;
}
/* Backdrop state */
.titlebar:backdrop:not(headerbar),
headerbar:backdrop,
window.csd > .titlebar:backdrop:not(headerbar),
window.csd > headerbar:backdrop {
background-color: @cssgnomme_panel_bg !important;
background-image: none !important;
color: @cssgnomme_panel_fg !important;
opacity: 0.9;
}
/* Title and subtitle text */
.titlebar:not(headerbar) .title,
headerbar .title {
color: @cssgnomme_panel_fg;
}
.titlebar:not(headerbar) .subtitle,
headerbar .subtitle {
color: @cssgnomme_panel_fg;
opacity: 0.7;
}
`;
}
/**
* Generate complete GTK overlay CSS (imports + overrides)
* @param {string} extensionName - Extension name
* @param {string} timestamp - Generation timestamp
* @param {string} version - GTK version (gtk-3.0, gtk-4.0)
* @param {string} importSource - Import source path
* @param {boolean} baseThemeExists - Does base-theme.css exist
* @param {boolean} isDark - Is dark variant
* @param {Object} colorSettings - Color settings from _extractColorSettings
* @param {number} borderRadius - Border radius value
* @param {Array|null} accentColor - Accent color [r, g, b] or null
* @param {boolean} themeIsLight - Is theme light mode
* @param {boolean} isZorinTheme - Is Zorin theme
* @param {boolean} enableZorinIntegration - Enable Zorin integration
* @returns {string} Complete GTK CSS
*/
getGtkOverlayCss(
extensionName,
timestamp,
version,
importSource,
baseThemeExists,
isDark,
colorSettings,
borderRadius,
accentColor,
themeIsLight,
isZorinTheme,
enableZorinIntegration
) {
const importNote = baseThemeExists
? "Modified base theme (tint removed)"
: "Original theme (base-theme not found, using fallback)";
return `/*
* ${extensionName} Overlay Theme - ${isDark ? "Dark" : "Light"} Variant
* Generated: ${timestamp}
* Source: ${importNote}
* GTK Version: ${version}
*/
/* Import ${baseThemeExists ? "modified base theme (tint removed)" : "original theme (fallback)"} */
@import url("${importSource}");
${this.getGtkCssVariables(colorSettings)}
/*** ${extensionName} Overrides ***/
${this.getGtkHeaderBarStyle(borderRadius)}
${this.getGtkWindowStyle(borderRadius)}
${this.getGtkPopoverStyle(borderRadius)}
${this.getGtkTooltipStyle(borderRadius)}
${version === "gtk-4.0" ? this.getGtk4Overrides(borderRadius) : ""}
${
// Only generate Zorin accent CSS if:
// 1. Accent color exists (not null/undefined)
// 2. Array has 3 valid RGB values
// This respects neutral/grey theme choice (no forced colors)
accentColor && Array.isArray(accentColor) && accentColor.length === 3
? this.getZorinAccentStyle(`rgb(${accentColor[0]}, ${accentColor[1]}, ${accentColor[2]})`, !themeIsLight)
: "/* No valid accent color detected - using theme defaults */\n"
}
${this.getFluentTitlebarFix(isZorinTheme, enableZorinIntegration)}
/*** End ${extensionName} ***/
`;
}
// ===== SHADOW EFFECTS =====
/**
* Generate shadow effect CSS
* @param {string} shadowColor - Shadow color
* @param {number} strength - Shadow strength (0-1)
* @returns {string} Shadow CSS
*/
getShadowStyle(shadowColor, strength) {
const cacheKey = `shadow_${shadowColor}_${strength}`;
if (this._templateCache.has(cacheKey)) {
return this._templateCache.get(cacheKey);
}
const spread = Math.round(strength * Constants.SHADOW_SPREAD_MULTIPLIER);
const css = `
/* Shadow Effects */
.panel,
.popup-menu {
box-shadow: 0 2px ${spread}px ${shadowColor};
}
`;
this._templateCache.set(cacheKey, css);
return css;
}
// ===== UTILITY METHODS =====
/**
* Clear template cache (for cleanup)
*/
clearCache() {
this._templateCache.clear();
}
/**
* Get cache size for monitoring
* @returns {number} Number of cached templates
*/
getCacheSize() {
return this._templateCache.size;
}
/**
* Enhance pastel colors for dark themes
* @private
* @param {string} rgbColor - Color in rgb() format
* @returns {string} Enhanced color
*/
_enhancePastelForDark(rgbColor) {
// Parse rgb(r, g, b) format
const match = rgbColor.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
if (!match) return rgbColor;
const r = parseInt(match[1]);
const g = parseInt(match[2]);
const b = parseInt(match[3]);
// Use ThemeUtils if available, otherwise simple boost
try {
const enhanced = ThemeUtils.enhancePastelColor([r, g, b], 0.3, 0.25);
return `rgb(${enhanced[0]}, ${enhanced[1]}, ${enhanced[2]})`;
} catch (e) {
// Fallback: Simple saturation boost
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
const delta = max - min;
if (delta === 0) return rgbColor;
const boost = 1.3;
const newR = Math.min(255, Math.round(r + (r - min) * boost * 0.3));
const newG = Math.min(255, Math.round(g + (g - min) * boost * 0.3));
const newB = Math.min(255, Math.round(b + (b - min) * boost * 0.3));
return `rgb(${newR}, ${newG}, ${newB})`;
}
}
/**
* Generate complete CSS from multiple sections
* @param {Object} sections - Object with section names as keys and CSS strings as values
* @returns {string} Complete CSS document
*/
assembleCss(sections) {
const parts = [];
// Add header
parts.push(`/* CSSGnomme Dynamic Theme Overlay */\n/* Generated: ${new Date().toISOString()} */\n`);
// Add each section with separator
for (const [name, css] of Object.entries(sections)) {
if (css && css.trim()) {
parts.push(`\n/* ========== ${name.toUpperCase()} ========== */\n`);
parts.push(css);
}
}
return parts.join("\n");
}
// ===== GNOME SHELL COMPONENT CSS GENERATORS =====
/**
* Generate panel-specific CSS for GNOME Shell
* This is a large CSS template that defines panel, panel buttons, and Zorin Taskbar styling
*
* @param {Object} vars - Complete variables object from _extractShellCssVars
* @param {number} vars.borderRadius - Border radius in pixels
* @param {number} vars.borderWidth - Border width in pixels
* @param {boolean} vars.applyPanelRadius - Apply border radius to panel
* @param {boolean} vars.enableZorinIntegration - Enable Zorin-specific styling
* @param {boolean} vars.isZorinTheme - Is current theme a Zorin theme
* @param {boolean} vars.isLightTheme - Is light theme mode
* @param {string} vars.accentRgb - Accent color RGB (e.g., "59, 66, 82")
* @param {string} vars.borderColor - Border color (rgba format)
* @param {string} vars.hoverRgb - Hover state RGB
* @param {number} vars.hoverOpacity - Hover state opacity
* @param {number} vars.activeOpacity - Active state opacity
* @param {string} vars.panelBackgroundCss - Panel background CSS rule
* @param {string} vars.backdropFilter - Backdrop filter CSS rule
* @param {string} vars.shadowColor - Shadow color (rgba format)
* @param {number} vars.shadowPanelBlur - Panel shadow blur radius
* @param {number} vars.shadowButtonBlur - Button shadow blur radius
* @param {number} vars.shadowInsetBlur - Inset shadow blur radius
* @param {number} vars.blurRadius - Blur radius in pixels
* @param {number} vars.blurSaturate - Blur saturation multiplier
* @param {number} vars.blurContrast - Blur contrast multiplier
* @param {number} vars.blurBrightness - Blur brightness multiplier
* @param {string} vars.blurBackgroundOverlay - Blur background overlay color
* @returns {string} Panel CSS content
*/
getPanelCss(vars) {
const {
borderRadius,
borderWidth,
applyPanelRadius,
enableZorinIntegration,
isZorinTheme,
isLightTheme,
accentRgb,
borderColor,
hoverRgb,
hoverOpacity,
activeOpacity,
panelBackgroundCss,
backdropFilter,
shadowColor,
shadowPanelBlur,
shadowButtonBlur,
shadowInsetBlur,
blurRadius,
blurSaturate,
blurContrast,
blurBrightness,
blurBackgroundOverlay
} = vars;
return `
/* Panel - Using !important to override Zorin Taskbar inline styles */
#panel {
${panelBackgroundCss}
${
applyPanelRadius
? `border-radius: ${borderRadius}px !important;`
: "/* border-radius disabled by user preference */"
}
border: ${borderWidth}px solid ${borderColor} !important;
backdrop-filter: blur(${blurRadius}px) saturate(${blurSaturate}) contrast(${blurContrast}) brightness(${blurBrightness}) !important;
-webkit-backdrop-filter: blur(${blurRadius}px) saturate(${blurSaturate}) contrast(${blurContrast}) brightness(${blurBrightness}) !important;
box-shadow: ${
borderWidth > 0
? `0 3px ${shadowPanelBlur}px ${shadowColor}, inset 0 0 ${shadowInsetBlur}px ${blurBackgroundOverlay}`
: `0 3px ${shadowPanelBlur}px ${shadowColor}`
} !important;
}
#panel .panel-button {
border-radius: calc(${borderRadius}px * ${Constants.BORDER_RADIUS_SCALING.panelButton}) !important;
transition: all 150ms ease-in-out !important;
}
/* Panel button hover - subtle background color change */
#panel .panel-button:hover {
background-color: rgba(${hoverRgb}, ${hoverOpacity}) !important;
}
${
isZorinTheme
? `
/* Zorin Theme: Clock display fix - hide parent hover, apply to inner .clock element */
#panel .panel-button.clock-display {
border-radius: 0 !important;
}
#panel .panel-button.clock-display:hover {
background-color: transparent !important;
}
#panel .panel-button.clock-display .clock {
border-radius: calc(${borderRadius}px * ${Constants.BORDER_RADIUS_SCALING.panelButton}) !important;
transition: all 150ms ease-in-out !important;
}
#panel .panel-button.clock-display:hover .clock {
background-color: rgba(${hoverRgb}, ${hoverOpacity}) !important;
}
/* Clock active/focus/checked state - stronger highlight on inner .clock */
#panel .panel-button.clock-display:active .clock,
#panel .panel-button.clock-display:focus .clock,
#panel .panel-button.clock-display:checked .clock {
background-color: rgba(${hoverRgb}, ${activeOpacity}) !important;
}
/* Ensure parent stays transparent even when active/focus/checked */
#panel .panel-button.clock-display:active,
#panel .panel-button.clock-display:focus,
#panel .panel-button.clock-display:checked {
background-color: transparent !important;
}
`
: ""
}
/* Panel button active/checked - stronger background */
#panel .panel-button:active,
#panel .panel-button:focus,
#panel .panel-button:checked {
background-color: rgba(${hoverRgb}, ${activeOpacity}) !important;
}
${
isZorinTheme && isLightTheme
? `
/* Zorin Light Theme: Accent color for active/checked icons */
#panel .panel-button:active StIcon,
#panel .panel-button:focus StIcon,
#panel .panel-button:checked StIcon {
color: rgb(${accentRgb}) !important;
}
`
: ""
}
${
enableZorinIntegration
? `
/* Zorin Taskbar specific enhancements - only if integration enabled */
.zorintaskbarMainPanel {
${panelBackgroundCss}
${backdropFilter}
${
applyPanelRadius
? `border-radius: ${borderRadius}px !important;`
: "/* border-radius disabled by user preference */"
}
border: ${borderWidth}px solid ${borderColor} !important;
box-shadow: 0 2px ${shadowButtonBlur}px ${shadowColor} !important;
}
.zorintaskbarMainPanel .panel-button {
border-radius: calc(${borderRadius}px * ${Constants.BORDER_RADIUS_SCALING.panelButton}) !important;
transition: all 150ms ease-in-out !important;
}
/* Zorin Taskbar button hover - subtle background color change */
.zorintaskbarMainPanel .panel-button:hover {
background-color: rgba(${hoverRgb}, ${hoverOpacity}) !important;
}
${
isZorinTheme
? `
/* Zorin Theme: Clock display fix - hide parent hover, apply to inner .clock element */
.zorintaskbarMainPanel .panel-button.clock-display {
border-radius: 0 !important;
}
.zorintaskbarMainPanel .panel-button.clock-display:hover {
background-color: transparent !important;
}
.zorintaskbarMainPanel .panel-button.clock-display .clock {
border-radius: calc(${borderRadius}px * ${Constants.BORDER_RADIUS_SCALING.panelButton}) !important;
transition: all 150ms ease-in-out !important;
}
.zorintaskbarMainPanel .panel-button.clock-display:hover .clock {
background-color: rgba(${hoverRgb}, ${hoverOpacity}) !important;
}
/* Clock active/focus/checked state - stronger highlight on inner .clock */
.zorintaskbarMainPanel .panel-button.clock-display:active .clock,
.zorintaskbarMainPanel .panel-button.clock-display:focus .clock,
.zorintaskbarMainPanel .panel-button.clock-display:checked .clock {
background-color: rgba(${hoverRgb}, ${activeOpacity}) !important;
}
/* Ensure parent stays transparent even when active/focus/checked */
.zorintaskbarMainPanel .panel-button.clock-display:active,
.zorintaskbarMainPanel .panel-button.clock-display:focus,
.zorintaskbarMainPanel .panel-button.clock-display:checked {
background-color: transparent !important;
}
`
: ""
}
/* Zorin Taskbar button active/checked - stronger background */
.zorintaskbarMainPanel .panel-button:active,
.zorintaskbarMainPanel .panel-button:focus,
.zorintaskbarMainPanel .panel-button:checked {
background-color: rgba(${hoverRgb}, ${activeOpacity}) !important;
}
${
isZorinTheme && isLightTheme
? `
/* Zorin Light Theme: Accent color for active/checked icons in taskbar */
.zorintaskbarMainPanel .panel-button:active StIcon,
.zorintaskbarMainPanel .panel-button:focus StIcon,
.zorintaskbarMainPanel .panel-button:checked StIcon {
color: rgb(${accentRgb}) !important;
}
`
: ""
}
`
: ""
}`;
}
/**
* Generate popup/menu-specific CSS for GNOME Shell
* This is a large CSS template that defines popup menus, quick settings, dash, notifications, OSD, app switcher
*
* @param {Object} vars - Complete variables object from _extractShellCssVars