diff --git a/angular.json b/angular.json index 81f2b73..9317374 100644 --- a/angular.json +++ b/angular.json @@ -28,7 +28,7 @@ "output": "/" } ], - "styles": ["src/styles.css"], + "styles": ["src/styles.scss"], "scripts": [] }, "configurations": { @@ -81,7 +81,7 @@ "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "scripts": [], - "styles": ["src/styles.css"], + "styles": ["src/styles.scss"], "assets": [ { "glob": "**/*", @@ -117,7 +117,7 @@ "schematics": { "@schematics/angular:component": { "prefix": "app", - "style": "css" + "style": "scss" }, "@schematics/angular:directive": { "prefix": "app" diff --git a/src/app/app.component.html b/src/app/app.component.html index 05116da..6e5c529 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,3 +1,4 @@ + {{'Angular Update Guide'|i18n}} @@ -13,6 +14,12 @@ github-circle-white-transparent + + + dark_mode + light_mode + + @@ -31,6 +38,7 @@ + @@ -143,3 +151,5 @@ {{'After you update'|i18n}} + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 39b7b51..6924103 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -20,6 +20,12 @@ interface Option { }) export class AppComponent { title = 'Angular Update Guide'; + THEME_KEY = 'UPDATE_ANGULAR_THEME'; + mode: 'dark-mode' | 'light-mode' = localStorage.getItem(this.THEME_KEY) === 'dark-mode' ? 'dark-mode' : 'light-mode'; + toggleMode() { + this.mode = this.mode === 'light-mode' ? 'dark-mode' : 'light-mode'; + localStorage.setItem(this.THEME_KEY, this.mode); + } level = 1; options: Record = { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e150124..6fdcc9b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,6 +12,8 @@ import { MatListModule } from '@angular/material/list'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatMenuModule } from '@angular/material/menu'; +import { MatIconModule } from '@angular/material/icon'; +import { MatSidenavModule } from '@angular/material/sidenav'; import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common'; import './locales'; @@ -22,6 +24,7 @@ import { I18nPipe } from './i18n.pipe'; imports: [ BrowserModule, BrowserAnimationsModule, + MatIconModule, MatToolbarModule, MatButtonModule, MatCheckboxModule, @@ -32,6 +35,7 @@ import { I18nPipe } from './i18n.pipe'; MatProgressBarModule, MatButtonToggleModule, MatMenuModule, + MatSidenavModule, ], providers: [Location, { provide: LocationStrategy, useClass: PathLocationStrategy }], bootstrap: [AppComponent], diff --git a/src/index.html b/src/index.html index efd1156..177bdc2 100644 --- a/src/index.html +++ b/src/index.html @@ -8,6 +8,7 @@ + diff --git a/src/styles.css b/src/styles.scss similarity index 68% rename from src/styles.css rename to src/styles.scss index 5333941..d8d64f3 100644 --- a/src/styles.css +++ b/src/styles.scss @@ -1,6 +1,7 @@ -@import "@angular/material/prebuilt-themes/indigo-pink.css"; +@use '@angular/material' as mat; @import url('https://fonts.googleapis.com/css?family=Roboto'); @import url('https://fonts.googleapis.com/css?family=Roboto+Mono'); +@include mat.core(); * { margin: 0; @@ -12,10 +13,6 @@ h1, h2, h3, h4 { padding: 16px 0; } -h1, h2, h3, h4, h5, h6, p, li, ul, ol, td, th, table { - color: #333333; -} - .recommendations>*>div { margin-bottom: 16px; line-height: 1.75; @@ -104,3 +101,37 @@ code:hover { cursor: pointer; position: relative; } + +.dark-mode { + $dark-theme: mat.define-dark-theme(( + color: ( + primary: mat.define-palette(mat.$indigo-palette, 500), + accent: mat.define-palette(mat.$pink-palette, 400) + ), + density: 0, + )); + + @include mat.core-theme($dark-theme); + @include mat.core-color($dark-theme); + @include mat.button-color($dark-theme); + @include mat.all-component-themes($dark-theme); + + code { + color: black; + } +} + +.light-mode { + $light-theme: mat.define-light-theme(( + color: ( + primary: mat.define-palette(mat.$indigo-palette, 500), + accent: mat.define-palette(mat.$pink-palette, 400) + ), + density: 0, + )); + + @include mat.core-theme($light-theme); + @include mat.core-color($light-theme); + @include mat.button-color($light-theme); + @include mat.all-component-themes($light-theme); +} \ No newline at end of file