diff --git a/src/app/core/shell/toolbar/toolbar.component.html b/src/app/core/shell/toolbar/toolbar.component.html index 4d03bbdd5..3c10b8f7d 100644 --- a/src/app/core/shell/toolbar/toolbar.component.html +++ b/src/app/core/shell/toolbar/toolbar.component.html @@ -58,6 +58,10 @@ +
+ +
+
diff --git a/src/app/theme-toggle/theme-toggle.component.scss b/src/app/theme-toggle/theme-toggle.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/theme-toggle/theme-toggle.component.spec.ts b/src/app/theme-toggle/theme-toggle.component.spec.ts new file mode 100644 index 000000000..2da9bb2f1 --- /dev/null +++ b/src/app/theme-toggle/theme-toggle.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ThemeToggleComponent } from './theme-toggle.component'; + +describe('ThemeToggleComponent', () => { + let component: ThemeToggleComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ThemeToggleComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ThemeToggleComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/theme-toggle/theme-toggle.component.ts b/src/app/theme-toggle/theme-toggle.component.ts new file mode 100644 index 000000000..13b0a5002 --- /dev/null +++ b/src/app/theme-toggle/theme-toggle.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { ThemeService } from '../theme.service'; + +@Component({ + selector: 'theme-toggle-component', + templateUrl: './theme-toggle.component.html', + styleUrls: ['./theme-toggle.component.scss'], +}) +export class ThemeToggleComponent { + isDarkMode: boolean; + + constructor(private themeService: ThemeService) { + this.isDarkMode = this.themeService.isDarkMode(); + } + + toggleTheme() { + this.isDarkMode = !this.isDarkMode; + this.themeService.setDarkMode(this.isDarkMode); + } +} diff --git a/src/app/theme.service.spec.ts b/src/app/theme.service.spec.ts new file mode 100644 index 000000000..1c2957ba8 --- /dev/null +++ b/src/app/theme.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ThemeService } from './theme.service'; + +describe('ThemeService', () => { + let service: ThemeService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ThemeService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/theme.service.ts b/src/app/theme.service.ts new file mode 100644 index 000000000..1189e722c --- /dev/null +++ b/src/app/theme.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root', +}) +export class ThemeService { + private darkMode = false; + + isDarkMode() { + return this.darkMode; + } + + setDarkMode(isDarkMode: boolean) { + this.darkMode = isDarkMode; + if (isDarkMode) { + document.body.classList.add('dark-theme'); + } else { + document.body.classList.remove('dark-theme'); + } + } +} diff --git a/src/assets/images/mifos_lg-logo.png b/src/assets/images/mifos_lg-logo.png new file mode 100644 index 000000000..64ca09243 Binary files /dev/null and b/src/assets/images/mifos_lg-logo.png differ diff --git a/src/theme/_material-palette.scss b/src/theme/_material-palette.scss index 61e9accf0..6fd22058e 100644 --- a/src/theme/_material-palette.scss +++ b/src/theme/_material-palette.scss @@ -1,3 +1,6 @@ + +/* ############ Light mode palettes ################*/ + $primary-palette: ( 100: #5ba2ec, 500: #1074b9, @@ -19,3 +22,27 @@ $accent-palette: ( 700: rgba(black, 0.87) ) ); + +/* ############ Dark mode palettes ################*/ + +$dark-primary-palette: ( + 100: #273350, + 500: #313f6b, + 700: #39415c, + contrast: ( + 100: white, + 500: rgba(white, 0.87), + 700: rgba(white, 0.87) + ) +); + +$dark-accent-palette: ( + 100: #364461, + 500: #3e5372, + 700: #476385, + contrast: ( + 100: white, + 500: white, + 700: white + ) +); diff --git a/src/theme/mifosx-theme.scss b/src/theme/mifosx-theme.scss index 82f447422..563d79f3e 100644 --- a/src/theme/mifosx-theme.scss +++ b/src/theme/mifosx-theme.scss @@ -15,6 +15,10 @@ // Be sure that you only ever include this mixin once! @include mat.core(); + +/* ################################## Light theme ################################### */ + + // Define the palettes for your theme using the Material Design palettes available in palette.scss // (imported above). For each palette, you can optionally specify a default, lighter, and darker // hue. Available color palettes: https://material.io/design/color/ @@ -36,3 +40,51 @@ $mifosx-app-theme: mat.define-light-theme($mifosx-app-primary, $mifosx-app-accen @include dashboard-component-theme($mifosx-app-theme); @include shares-account-view-component-theme($mifosx-app-theme); @include account-view-component-theme($mifosx-app-theme); + + +/* ################################## Dark theme ################################### */ + + +// Define the palettes for your theme using the Material Design palettes available in palette.scss +$mifosx-app-dark-primary: mat.define-palette($dark-primary-palette); +$mifosx-app-dark-accent: mat.define-palette($dark-accent-palette); +$mifosx-app-dark-warn: mat.define-palette(mat.$red-palette); + +// Create the theme object (a Sass map containing all of the palettes). +$mifosx-app-dark-theme: mat.define-dark-theme($mifosx-app-dark-primary, $mifosx-app-dark-accent, $mifosx-app-dark-warn); + +// Include theme styles for core and each component used in your app. +.dark-theme { + + // Override the background color of the label text for dark theme + .mat-option-text,.mat-input-element,.mat-form-field-label{ + color: white !important; + } + mifosx-popover,.mat-menu-content{ + background-color: #303135; + color : white; + } + + // Override the background color of the calendar for dark theme + .mat-calendar, + .mat-calendar-body-cell, + .mat-calendar-body-label, + .mat-calendar-table{ + background-color: #303135; + border: none; + } + + // Changing the logo color for dark mode + .img-button, + .app-user-photo, + .profile-image{ + filter: invert(100%); + } + + @include mat.all-component-themes($mifosx-app-dark-theme); + @include groups-view-component-theme($mifosx-app-dark-theme); + @include centers-view-component-theme($mifosx-app-dark-theme); + @include dashboard-component-theme($mifosx-app-dark-theme); + @include shares-account-view-component-theme($mifosx-app-dark-theme); + @include account-view-component-theme($mifosx-app-dark-theme); +} \ No newline at end of file