Skip to content

Commit f0684c3

Browse files
committed
dark theme color improvements; scss improvements, removed hardcoded colors. Incorporate4d lots of vbakke's requests (cleaning up code). Fixed the persistence of theme after refresh.
1 parent 94420d8 commit f0684c3

6 files changed

Lines changed: 63 additions & 64 deletions

File tree

src/app/component/circular-heatmap/circular-heatmap.component.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,7 @@ export class CircularHeatmapComponent implements OnInit {
6565
showFilters: boolean;
6666
markdown: md = md();
6767
theme: string;
68-
theme_colors: Record<string, string>;
69-
themes: Record<string, Record<string, string>> = {
70-
light: {
71-
background: '#ffffff',
72-
disabled: '#dddddd',
73-
filled: 'green',
74-
cursor: 'green',
75-
},
76-
night: {
77-
background: '#dddddd',
78-
disabled: '#888888',
79-
filled: 'green',
80-
cursor: 'green',
81-
},
82-
};
68+
theme_colors!: Record<string, string>;
8369

8470
constructor(
8571
private yaml: ymlService,
@@ -89,10 +75,7 @@ export class CircularHeatmapComponent implements OnInit {
8975
) {
9076
this.showOverlay = false;
9177
this.showFilters = true;
92-
this.theme = 'light';
9378
this.theme = this.themeService.getTheme();
94-
95-
this.theme_colors = this.themes[this.theme];
9679
}
9780

9881
ngOnInit(): void {
@@ -657,17 +640,11 @@ export class CircularHeatmapComponent implements OnInit {
657640
cursors
658641
.append('path')
659642
.attr('id', 'hover')
660-
.attr('pointer-events', 'none')
661-
.attr('stroke', _self.theme_colors['cursor'])
662-
.attr('stroke-width', '7')
663-
.attr('fill', 'transparent');
643+
.attr('pointer-events', 'none');
664644
cursors
665645
.append('path')
666646
.attr('id', 'selected')
667-
.attr('pointer-events', 'none')
668-
.attr('stroke', '#232323')
669-
.attr('stroke-width', '4')
670-
.attr('fill', 'transparent');
647+
.attr('pointer-events', 'none');
671648
});
672649
}
673650

src/app/component/sidenav-buttons/sidenav-buttons.component.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,13 @@ export class SidenavButtonsComponent implements OnInit {
4040
constructor(private themeService: ThemeService) {}
4141

4242
ngOnInit(): void {
43-
const themePref = localStorage.getItem('theme');
44-
this.isNightMode = themePref === 'dark';
45-
this.applyTheme();
43+
const currentTheme = this.themeService.getTheme();
44+
this.isNightMode = currentTheme === 'dark';
4645
}
4746

4847
toggleTheme(): void {
49-
console.log('[toggleTheme] Triggered');
50-
5148
this.isNightMode = !this.isNightMode;
5249
const newTheme = this.isNightMode ? 'dark' : 'light';
5350
this.themeService.setTheme(newTheme);
5451
}
55-
56-
private applyTheme(): void {
57-
if (this.isNightMode) {
58-
document.body.classList.add('night-mode');
59-
} else {
60-
document.body.classList.remove('night-mode');
61-
}
62-
}
63-
}
52+
}

src/app/service/theme.service.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ export class ThemeService {
66
private themeSubject = new BehaviorSubject<string>('light');
77
public readonly theme$ = this.themeSubject.asObservable();
88

9-
constructor() {
10-
const savedTheme = localStorage.getItem('theme') || 'light';
11-
this.setTheme(savedTheme);
12-
}
9+
constructor() {}
1310

1411
initTheme(): void {
1512
const saved = localStorage.getItem('theme') || 'light';
@@ -19,12 +16,8 @@ export class ThemeService {
1916
setTheme(theme: string): void {
2017
document.body.classList.remove('light-theme', 'dark-theme');
2118
document.body.classList.add(`${theme}-theme`);
22-
23-
// Force this before other reads
24-
requestAnimationFrame(() => {
25-
this.themeSubject.next(theme);
26-
localStorage.setItem('theme', theme);
27-
});
19+
localStorage.setItem('theme', theme);
20+
this.themeSubject.next(theme);
2821
}
2922

3023
getTheme(): string {

src/custom-theme.scss

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ body {
7575

7676
.light-theme {
7777
--heatmap-filled: #4caf50;
78-
--heatmap-disabled: #888888;
79-
--heatmap-cursor: #3f51b5;
78+
--heatmap-disabled: #dddddd;
79+
--heatmap-cursor: green;
8080
--heatmap-background: white;
8181
--heatmap-stroke: black;
82+
--heatmap-cursor-selected:var(--heatmap-cursor);
83+
--heatmap-cursor-hover: transparent;
84+
85+
8286

8387
@include mat.all-component-themes($DSOMM-light-theme);
8488
}
@@ -129,12 +133,6 @@ body.dark-theme {
129133
}
130134
}
131135

132-
// Matrix override
133-
.matrix-output p,
134-
.matrix-output span,
135-
.matrix-output div {
136-
color: #e0e0e0;
137-
}
138136

139137
// Circular heatmap (radar chart)
140138
.circular-heat text,
@@ -145,24 +143,61 @@ body.dark-theme {
145143

146144
.circular-heat line,
147145
.circular-heat path {
148-
stroke: #000000;
146+
stroke: var(--heatmap-stroke);
149147
}
150148
}
151149

152-
.dark-theme {
150+
body.dark-theme {
153151
--heatmap-filled: #4caf50;
154152
--heatmap-disabled: #666666;
155-
--heatmap-cursor: #80deea;
153+
--heatmap-cursor: green;
156154
--heatmap-background: #bbbbbb;
157155
--heatmap-stroke: #000000;
156+
--heatmap-cursor-selected:var(--heatmap-cursor);
157+
--heatmap-cursor-hover: transparent;
158158

159+
app-matrix a:visited {
160+
color: #d4baf4;
161+
}
159162

163+
app-matrix .tags-activity,
164+
app-matrix .tags-activity span {
165+
color: #397af4;
166+
}
160167

161-
@include mat.all-component-themes($DSOMM-dark-theme);
168+
.mat-chip.mat-standard-chip {
169+
color: #ababab;
170+
}
171+
172+
.mat-chip.mat-standard-chip.mat-chip-selected.mat-primary {
173+
background-color: #74b277;
174+
}
162175
}
163176

177+
178+
179+
180+
@include mat.all-component-themes($DSOMM-dark-theme);
181+
182+
164183
.button-container {
165184
display: flex;
166185
flex-direction: column; // Vertical alignment
167186
gap: 10px; // Space between buttons
168-
}
187+
}
188+
189+
svg .cursors path {
190+
fill: transparent;
191+
pointer-events: none;
192+
}
193+
194+
svg .cursors #hover {
195+
stroke: var(--heatmap-cursor);
196+
stroke-width: 7px;
197+
}
198+
199+
svg .cursors #selected {
200+
stroke: var(--heatmap-cursor-selected, #000000); // optional fallback
201+
stroke-width: 7px;
202+
}
203+

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
rel="stylesheet"
1818
href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" />
1919
</head>
20-
<body class="light-theme">
20+
<body>
2121
<app-root></app-root>
2222
</body>
2323
</html>

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
const savedTheme = localStorage.getItem('theme') || 'light';
2+
document.body.classList.remove('light-theme', 'dark-theme');
3+
document.body.classList.add(`${savedTheme}-theme`);
4+
console.log('[main.ts] Theme set to:', savedTheme); //
5+
16
import { enableProdMode } from '@angular/core';
27
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
38

0 commit comments

Comments
 (0)