Skip to content

Commit eb119db

Browse files
authored
feat: 💄 Add dark mode toggle (#36)
* feat: 💄 Add darkr mode toggle * font replace
1 parent 0bff1f8 commit eb119db

File tree

13 files changed

+181
-3800
lines changed

13 files changed

+181
-3800
lines changed

apps/spotify/src/app/app.component.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Component, HostBinding, OnDestroy, OnInit } from '@angular/core';
1+
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
22

3+
import { DOCUMENT } from '@angular/common';
34
import { Subscription } from 'rxjs';
45
import { tap } from 'rxjs/operators';
56

@@ -15,22 +16,21 @@ import { environment } from '../environments/environment';
1516
styleUrls: ['./app.component.scss'],
1617
})
1718
export class AppComponent implements OnInit, OnDestroy {
18-
@HostBinding('class') className = '';
19-
2019
protected readonly subscriptions: Subscription[] = [];
2120
protected readonly darkClassName = 'darkMode';
2221

2322
cookiesAccepted = true;
2423

2524
constructor(
2625
protected userSettings: UserSettingsService,
27-
protected env: EnvSettingsService
26+
protected env: EnvSettingsService,
27+
@Inject(DOCUMENT) private document: Document
2828
) {}
2929

3030
ngOnInit(): void {
3131
this.env.init(environment);
3232
const darkModeSub = this.userSettings.darkModeOn$.subscribe((darkMode) => {
33-
this.className = darkMode ? this.darkClassName : '';
33+
this.handleDarkModeChange(darkMode);
3434
});
3535
this.subscriptions.push(darkModeSub);
3636
this.userSettings.cookiesAccepted$
@@ -52,4 +52,12 @@ export class AppComponent implements OnInit, OnDestroy {
5252
this.cookiesAccepted = true;
5353
this.userSettings.allowCookies();
5454
}
55+
56+
protected handleDarkModeChange(newMode: boolean) {
57+
if (newMode) {
58+
this.document.body.classList.add(this.darkClassName);
59+
} else {
60+
this.document.body.classList.remove(this.darkClassName);
61+
}
62+
}
5563
}

apps/spotify/src/assets/logo_1x2.png

7.21 KB
Loading
28.3 KB
Loading
7.71 KB
Loading

apps/spotify/src/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<meta name="description" content="Spotify Karaoke: Sing along with us!" />
1010
<link rel="preconnect" href="https://fonts.gstatic.com" />
1111
<link
12-
href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap"
12+
href="https://fonts.googleapis.com/css?family=Lato:400,700&display=swap"
1313
rel="stylesheet"
14+
type="text/css"
1415
/>
1516

1617
<!-- Open Graph / Facebook -->

apps/spotify/src/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ body {
1818
body {
1919
margin: 0;
2020
text-overflow: ellipsis;
21-
font-family: Roboto, 'Helvetica Neue', sans-serif;
21+
font-family: Lato, 'Helvetica Neue', sans-serif;
2222
overflow: overlay;
2323
}
2424

apps/spotify/src/styles/theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
.material-icons {
2828
font-size: 24px;
29-
font-family: 'Material Icons', 'Material Icons';
29+
font-family: 'Material Icons';
3030
.mat-badge-content {
31-
font-family: 'Roboto';
31+
font-family: 'Lato';
3232
}
3333
}

apps/spotify/src/styles/theme_variables.scss

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99

1010
// Fonts
1111
@import 'https://fonts.googleapis.com/css?family=Material+Icons';
12-
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500');
12+
@import url('https://fonts.googleapis.com/css?family=Lato:300,400,500');
1313

1414
$fontConfig: (
15-
display-4: mat-typography-level(112px, 112px, 300, 'Roboto', -0.0134em),
16-
display-3: mat-typography-level(56px, 56px, 400, 'Roboto', -0.0089em),
17-
display-2: mat-typography-level(45px, 48px, 400, 'Roboto', 0em),
18-
display-1: mat-typography-level(34px, 40px, 400, 'Roboto', 0.0074em),
19-
headline: mat-typography-level(24px, 32px, 400, 'Roboto', 0em),
20-
title: mat-typography-level(20px, 32px, 500, 'Roboto', 0.0075em),
21-
subheading-2: mat-typography-level(16px, 28px, 400, 'Roboto', 0.0094em),
22-
subheading-1: mat-typography-level(15px, 24px, 500, 'Roboto', 0.0067em),
23-
body-2: mat-typography-level(14px, 24px, 500, 'Roboto', 0.0179em),
24-
body-1: mat-typography-level(14px, 20px, 400, 'Roboto', 0.0179em),
25-
button: mat-typography-level(14px, 14px, 500, 'Roboto', 0.0893em),
26-
caption: mat-typography-level(12px, 20px, 400, 'Roboto', 0.0333em),
27-
input: mat-typography-level(inherit, 1.125, 400, 'Roboto', 1.5px),
15+
display-4: mat-typography-level(112px, 112px, 300, 'Lato', -0.0134em),
16+
display-3: mat-typography-level(56px, 56px, 400, 'Lato', -0.0089em),
17+
display-2: mat-typography-level(45px, 48px, 400, 'Lato', 0em),
18+
display-1: mat-typography-level(34px, 40px, 400, 'Lato', 0.0074em),
19+
headline: mat-typography-level(24px, 32px, 400, 'Lato', 0em),
20+
title: mat-typography-level(20px, 32px, 500, 'Lato', 0.0075em),
21+
subheading-2: mat-typography-level(16px, 28px, 400, 'Lato', 0.0094em),
22+
subheading-1: mat-typography-level(15px, 24px, 500, 'Lato', 0.0067em),
23+
body-2: mat-typography-level(14px, 24px, 500, 'Lato', 0.0179em),
24+
body-1: mat-typography-level(14px, 20px, 400, 'Lato', 0.0179em),
25+
button: mat-typography-level(14px, 14px, 500, 'Lato', 0.0893em),
26+
caption: mat-typography-level(12px, 20px, 400, 'Lato', 0.0333em),
27+
input: mat-typography-level(inherit, 1.125, 400, 'Lato', 1.5px),
2828
);
2929

3030
// Foreground Elements

0 commit comments

Comments
 (0)