Skip to content

Commit 0f8dcf8

Browse files
authored
docs: migrate docs app to M3 (#285)
1 parent 8be9cca commit 0f8dcf8

File tree

7 files changed

+120
-32
lines changed

7 files changed

+120
-32
lines changed

package-lock.json

+65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@angular/core": "~17.2.0",
2323
"@angular/forms": "~17.2.0",
2424
"@angular/material": "~17.2.0",
25+
"@angular/material-experimental": "~17.2.0",
2526
"@angular/platform-browser": "~17.2.0",
2627
"@angular/platform-browser-dynamic": "~17.2.0",
2728
"@angular/router": "~17.2.0",

projects/angular-intl-demo/src/app/app.component.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
alt="GitHub logo"
1313
class="logo"
1414
matButtonIcon
15-
src="assets/github-mark-white.png"
15+
[ngSrc]="
16+
isDarkTheme()
17+
? 'assets/github-mark-white.png'
18+
: 'assets/github-mark.png'
19+
"
20+
height="24"
21+
width="24"
1622
/>
1723
GitHub
1824
</a>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component } from '@angular/core';
1+
import { NgOptimizedImage } from '@angular/common';
2+
import { Component, signal } from '@angular/core';
23
import { MatAnchor, MatButton } from '@angular/material/button';
34
import { MatToolbar } from '@angular/material/toolbar';
45
import { RouterLink, RouterOutlet } from '@angular/router';
@@ -8,6 +9,21 @@ import { RouterLink, RouterOutlet } from '@angular/router';
89
templateUrl: './app.component.html',
910
styleUrls: ['./app.component.scss'],
1011
standalone: true,
11-
imports: [RouterLink, RouterOutlet, MatToolbar, MatButton, MatAnchor],
12+
imports: [
13+
RouterLink,
14+
RouterOutlet,
15+
MatToolbar,
16+
MatButton,
17+
MatAnchor,
18+
NgOptimizedImage,
19+
],
1220
})
13-
export class AppComponent {}
21+
export class AppComponent {
22+
darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)');
23+
isDarkTheme = signal(this.darkModeQuery.matches);
24+
constructor() {
25+
this.darkModeQuery.addEventListener('change', (event) => {
26+
this.isDarkTheme.set(event.matches);
27+
});
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { provideHttpClient } from '@angular/common/http';
2-
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
2+
import { ApplicationConfig } from '@angular/core';
33
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
44
import { provideAnimations } from '@angular/platform-browser/animations';
5-
import { provideRouter } from '@angular/router';
6-
import { MarkdownModule } from 'ngx-markdown';
5+
import { provideRouter, withHashLocation } from '@angular/router';
6+
import { provideMarkdown } from 'ngx-markdown';
77
import { routes } from './app.routes';
88

99
export const appConfig: ApplicationConfig = {
1010
providers: [
11-
importProvidersFrom(MarkdownModule.forRoot()),
11+
provideMarkdown(),
1212
{
1313
provide: MAT_FORM_FIELD_DEFAULT_OPTIONS,
1414
useValue: {
@@ -17,6 +17,6 @@ export const appConfig: ApplicationConfig = {
1717
},
1818
provideAnimations(),
1919
provideHttpClient(),
20-
provideRouter(routes),
20+
provideRouter(routes, withHashLocation()),
2121
],
2222
};
Loading

projects/angular-intl-demo/src/styles.scss

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
@use "@angular/material" as mat;
2+
@use "@angular/material-experimental" as matx;
23

34
@include mat.core();
45

5-
$light-theme: mat.define-light-theme(
6+
$light-theme: matx.define-theme(
67
(
78
color: (
8-
primary: mat.define-palette(mat.$deep-purple-palette),
9-
accent: mat.define-palette(mat.$deep-orange-palette),
9+
primary: matx.$m3-violet-palette,
1010
),
11-
typography: mat.define-typography-config(),
12-
density: 0,
1311
)
1412
);
1513

16-
$dark-theme: mat.define-dark-theme(
14+
$dark-theme: matx.define-theme(
1715
(
1816
color: (
19-
primary: mat.define-palette(mat.$purple-palette),
20-
accent: mat.define-palette(mat.$deep-orange-palette),
17+
theme-type: dark,
18+
primary: matx.$m3-magenta-palette,
2119
),
2220
)
2321
);
2422

25-
@include mat.core-theme($light-theme);
26-
@include mat.button-theme($light-theme);
27-
@include mat.toolbar-theme($light-theme);
28-
@include mat.tabs-theme($light-theme);
29-
@include mat.select-theme($light-theme);
30-
@include mat.input-theme($light-theme);
31-
@include mat.form-field-theme($light-theme);
23+
html {
24+
@include mat.core-theme($light-theme);
25+
@include mat.button-theme($light-theme);
26+
@include mat.toolbar-theme($light-theme);
27+
@include mat.tabs-theme($light-theme);
28+
@include mat.select-theme($light-theme);
29+
@include mat.input-theme($light-theme);
30+
@include mat.form-field-theme($light-theme);
3231

33-
@media (prefers-color-scheme: dark) {
34-
@include mat.core-color($dark-theme);
35-
@include mat.button-color($dark-theme);
36-
@include mat.toolbar-color($dark-theme);
37-
@include mat.tabs-color($dark-theme);
38-
@include mat.select-color($dark-theme);
39-
@include mat.input-color($dark-theme);
40-
@include mat.form-field-color($dark-theme);
32+
@media (prefers-color-scheme: dark) {
33+
@include mat.core-color($dark-theme);
34+
@include mat.button-color($dark-theme);
35+
@include mat.toolbar-color($dark-theme);
36+
@include mat.tabs-color($dark-theme);
37+
@include mat.select-color($dark-theme);
38+
@include mat.input-color($dark-theme);
39+
@include mat.form-field-color($dark-theme);
40+
}
4141
}
4242

4343
html,

0 commit comments

Comments
 (0)