From 343a49daad0571779cbb84c6cce15a0cd1e8248a Mon Sep 17 00:00:00 2001 From: X4Lo Date: Wed, 3 Apr 2024 16:26:31 +0000 Subject: [PATCH] add: darktheme support + theme service --- angular.json | 21 +- .../components/sidebar/sidebar.component.css | 24 +- .../components/sidebar/sidebar.component.html | 323 +++++------ .../components/sidebar/sidebar.component.ts | 10 +- .../src/app/core/services/theme.service.ts | 28 + frontend/src/assets/sass/dark-theme.scss | 32 +- frontend/src/assets/sass/main.css | 2 +- frontend/src/assets/sass/main.scss | 536 +++++++++++------- frontend/src/index.html | 5 +- 9 files changed, 584 insertions(+), 397 deletions(-) create mode 100644 frontend/src/app/core/services/theme.service.ts diff --git a/angular.json b/angular.json index abe355d..b2157d2 100644 --- a/angular.json +++ b/angular.json @@ -21,26 +21,39 @@ "assets": ["frontend/src/favicon.ico", "frontend/src/assets"], "styles": [ "frontend/src/styles.css", + "frontend/src/assets/css/bootstrap.min.css", + "frontend/src/assets/css/bootstrap-extended.css", + "frontend/src/assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css", "frontend/src/assets/plugins/metismenu/metisMenu.min.css", "frontend/src/assets/plugins/metismenu/mm-vertical.css", "frontend/src/assets/plugins/simplebar/css/simplebar.css", - "frontend/src/assets/css/bootstrap.min.css", - "frontend/src/assets/css/bootstrap-extended.css", + "frontend/src/assets/sass/main.css", - "frontend/src/assets/sass/dark-theme.css", + "frontend/src/assets/sass/main.scss", "frontend/src/assets/sass/semi-dark.css", + "frontend/src/assets/sass/dark-theme.css", + + "frontend/src/assets/sass/bordered-theme.css", + + "frontend/src/assets/plugins/select2/css/select2.min.css", + "frontend/src/assets/plugins/select2/css/select2-bootstrap4.css", + "frontend/src/assets/sass/responsive.css" ], "scripts": [ "frontend/src/assets/js/jquery.min.js", "frontend/src/assets/js/bootstrap.bundle.min.js", + "frontend/src/assets/plugins/perfect-scrollbar/js/perfect-scrollbar.js", "frontend/src/assets/plugins/metismenu/metisMenu.min.js", "frontend/src/assets/plugins/apexchart/apexcharts.min.js", - "frontend/src/assets/plugins/peity/jquery.peity.min.js", "frontend/src/assets/plugins/simplebar/js/simplebar.min.js", + "frontend/src/assets/plugins/peity/jquery.peity.min.js", + "frontend/src/assets/plugins/select2/js/select2-custom.js", + "frontend/src/assets/plugins/select2/js/select2.min.js", + "frontend/src/assets/js/index.js", "frontend/src/assets/js/main.js" ] diff --git a/frontend/src/app/core/components/sidebar/sidebar.component.css b/frontend/src/app/core/components/sidebar/sidebar.component.css index 6ef56fb..871ff7f 100644 --- a/frontend/src/app/core/components/sidebar/sidebar.component.css +++ b/frontend/src/app/core/components/sidebar/sidebar.component.css @@ -1,7 +1,27 @@ -.mm-active .parent-icon, .mm-active .menu-title { +.mm-active .parent-icon, +.mm-active .menu-title { color: #008cff; } a { cursor: pointer; -} \ No newline at end of file +} + +.sidebar-wrapper .sidebar-header .logo-img { + width: 48px; +} + +.sidebar-wrapper .sidebar-header, +.sidebar-wrapper .sidebar-nav, +.sidebar-wrapper .sidebar-bottom { + background-color: var(--bs-body-bg) !important; + border-right: 1px solid var(--bs-border-color); +} + +.sidebar-wrapper .sidebar-bottom { + border-top: 1px solid var(--bs-border-color); +} + +.sidebar-wrapper .sidebar-bottom .footer-icon { + color: #dee2e6; +} diff --git a/frontend/src/app/core/components/sidebar/sidebar.component.html b/frontend/src/app/core/components/sidebar/sidebar.component.html index 0fc6677..9339ee0 100644 --- a/frontend/src/app/core/components/sidebar/sidebar.component.html +++ b/frontend/src/app/core/components/sidebar/sidebar.component.html @@ -1,168 +1,171 @@ + \ No newline at end of file diff --git a/frontend/src/app/core/components/sidebar/sidebar.component.ts b/frontend/src/app/core/components/sidebar/sidebar.component.ts index 54aa1ee..88c9174 100644 --- a/frontend/src/app/core/components/sidebar/sidebar.component.ts +++ b/frontend/src/app/core/components/sidebar/sidebar.component.ts @@ -1,5 +1,6 @@ import { AfterViewInit, Component } from '@angular/core'; import { ToggleService } from '../../services/toggle.service'; +import { ThemeService } from '../../services/theme.service'; declare var $: any; @@ -9,7 +10,10 @@ declare var $: any; styleUrls: ['./sidebar.component.css'], }) export class SidebarComponent implements AfterViewInit { - constructor(private toggleService: ToggleService) {} + constructor( + private toggleService: ToggleService, + private themeService: ThemeService + ) {} onMouseEnter() { this.toggleService.hoverSidebar(true); @@ -22,4 +26,8 @@ export class SidebarComponent implements AfterViewInit { ngAfterViewInit() { $('#sidenav').metisMenu(); } + + toggleTheme() { + this.themeService.toggleTheme(); + } } diff --git a/frontend/src/app/core/services/theme.service.ts b/frontend/src/app/core/services/theme.service.ts new file mode 100644 index 0000000..c8028e6 --- /dev/null +++ b/frontend/src/app/core/services/theme.service.ts @@ -0,0 +1,28 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root', +}) +export class ThemeService { + private theme: 'light' | 'dark' = 'light'; + + constructor() { + this.loadTheme(); // Load the theme when the service is initialized + } + + toggleTheme(): void { + this.theme = this.theme === 'light' ? 'dark' : 'light'; + this.applyTheme(); + } + + private loadTheme(): void { + // Load theme from localStorage or default to 'light' + this.theme = (localStorage.getItem('theme') as 'light' | 'dark') || 'light'; + this.applyTheme(); + } + + private applyTheme(): void { + document.documentElement.setAttribute('data-bs-theme', this.theme); + localStorage.setItem('theme', this.theme); // Save theme to localStorage + } +} diff --git a/frontend/src/assets/sass/dark-theme.scss b/frontend/src/assets/sass/dark-theme.scss index 62ea471..97dcc81 100644 --- a/frontend/src/assets/sass/dark-theme.scss +++ b/frontend/src/assets/sass/dark-theme.scss @@ -184,39 +184,47 @@ } - /*mini sidebar*/ + /* sidebar */ - .mini-sidebar { + .sidebar-wrapper { background-color: var(--bs-body-bg); border-right: 1px solid var(--bs-border-color); - .user { + .sidebar-header { background-color: var(--bs-body-bg); - - .user-icon { + border-right: 1px solid var(--bs-border-color); + .sidebar-close { @include sidelinks() - } + } } - .quick-menu { - .nav-link { - @include sidelinks() - } + .sidebar-nav { + background-color: var(--bs-body-bg); } - .mini-footer { + .sidebar-bottom { background-color: var(--bs-body-bg); + border-top: 1px solid var(--bs-border-color); + border-right: 1px solid var(--bs-border-color); .footer-icon { @include sidelinks() } + .dropdown-menu { + background-color: var(--bs-body-bg-2); + border: 1px solid var(--bs-border-color-translucent); + } + } + } + + .chip { color: var(--bs-body-color); @@ -338,7 +346,7 @@ .metismenu { background: 0 0; - + a { color: $color_1; diff --git a/frontend/src/assets/sass/main.css b/frontend/src/assets/sass/main.css index febfc68..ab9ffd0 100644 --- a/frontend/src/assets/sass/main.css +++ b/frontend/src/assets/sass/main.css @@ -22,7 +22,7 @@ Table of Index */ /* Genral*/ -/* @import url("../../../../../cdn.jsdelivr.net/npm/bootstrap-icons%401.11.1/font/bootstrap-icons.css"); */ +@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css"); body { position: relative; font-size: 14px; diff --git a/frontend/src/assets/sass/main.scss b/frontend/src/assets/sass/main.scss index 5aa46ca..441dec9 100644 --- a/frontend/src/assets/sass/main.scss +++ b/frontend/src/assets/sass/main.scss @@ -28,6 +28,7 @@ Table of Index /* Genral*/ body { + position: relative; font-size: 14px; font-family: 'Noto Sans', sans-serif; letter-spacing: 0.5px; @@ -135,13 +136,14 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd background-color: $headerbg; height: 70px; position: fixed; - // border-bottom: 1px solid #dee2e6; - left: 70px; + // border-bottom: 1px solid var(--bs-border-color); + left: 260px; right: 0; top: 0; padding: 0 1.5rem; z-index: 10; - box-shadow: 0 0.125rem 0.25rem rgb(0 0 0 / 8%); + transition: ease-out .3s; + box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.044), 0 2px 6px 0 rgba(0, 0, 0, 0.049); .search-bar { width: auto; @@ -379,6 +381,11 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd } + .dropdown-user { + width: 260px; + border-radius: 1rem; + } + .badge-notify { position: absolute; top: 2px; @@ -426,7 +433,6 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd } } - .dropdown-menu { border-radius: 1rem; border: 0; @@ -435,79 +441,326 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd } -/*mini sidebar*/ +/* sidebar wrapper */ -.mini-sidebar { +.sidebar-wrapper { position: fixed; - left: 0; top: 0; - bottom: 0; - width: 70px; + left: 0; + width: 260px; height: 100%; - background-color: rgb(255, 255, 255); - border-right: 1px solid #dee2e6; + background-color: #ffffff; + border-right: 1px solid var(--bs-border-color); z-index: 12; - transition: 0.3s all; - box-shadow: 0 0.125rem 0.25rem rgb(0 0 0 / 8%); + transition: ease-out .3s; + box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.044), 0 2px 6px 0 rgba(0, 0, 0, 0.049); - .user { - @include alignContent(); - flex-shrink: 0; - width: 70px; + .sidebar-header { + display: flex; + align-items: center; + justify-content: start; + width: 260px; height: 70px; - z-index: 2; - cursor: pointer; + padding: 0 1rem; + gap: .5rem; + // border-bottom: 1px solid var(--bs-border-color); + position: fixed; + top: 0; background-color: #fff; + transition: ease-out .3s; + border-right: 1px solid var(--bs-border-color); - .user-icon { - @include sidelinks() + .logo-img { + width: 32px; } + + .logo-name { + h5{ + font-size: 20px; + text-transform: capitalize; + font-weight: 500; + } + } + + .sidebar-close { + @include sidelinks(); + display: none; + cursor: pointer; + } + } - .quick-menu { - .nav-link { - @include sidelinks() + +/* Metis Menu */ + +$menuLink_Color: #5f5f5f; +$menuLink_Hover_Color: #008cff; +$menu_lable_color: #b0afaf; +$menu_bg_color: rgb(0 140 255 / 5%); +$border-color_1: initial; + + .sidebar-nav { + margin-top: 70px; + height: 100%; + background-color: #ffffff; + height: calc(100% - 140px); + + ul { + padding: 10px; + margin: 0; + list-style: none; + background: 0 0; } + + .metismenu { + background: 0 0; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + + li+li { + margin-top: 5px; + } + + li { + &:first-child { + margin-top: 5px; + } + + &:last-child { + margin-bottom: 5px; + } + } + + >li { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + } + + a { + position: relative; + display: flex; + align-items: center; + justify-content: left; + padding: 6px 16px; + font-size: 15px; + color: $menuLink_Color; + outline-width: 0; + text-overflow: ellipsis; + overflow: hidden; + letter-spacing: .5px; + border-radius: 0.25rem; + transition: all .3s ease-out; + + .parent-icon { + line-height: 1; + } + + .menu-title { + margin-left: 10px; + } + + &:active { + color: $menuLink_Hover_Color; + text-decoration: none; + background-color: $menu_bg_color; + } + + &:focus { + color: $menuLink_Hover_Color; + text-decoration: none; + background-color: $menu_bg_color; + } + + &:hover { + color: $menuLink_Hover_Color; + text-decoration: none; + background-color: $menu_bg_color; + } + + } + + ul { + a { + padding: 6px 15px 6px 20px; + font-size: 15px; + border: 0; + + i { + margin-right: 5px; + } + } + + background-color: #fff; + padding: 0; + + ul { + a { + padding: 8px 15px 8px 30px; + } + + ul { + a { + padding: 8px 15px 8px 45px; + } + } + } + } + + .mm-active { + >a { + color: $menuLink_Hover_Color; + text-decoration: none; + background-color: $menu_bg_color; + } + } + + + } + } - .mini-footer { - @include alignContent(); - flex-shrink: 0; - width: 70px; + .sidebar-bottom { + display: flex; + align-items: center; + justify-content: center; + width: 260px; height: 70px; - z-index: 2; + border-top: 1px solid #dee2e6; + position: fixed; + bottom: 0; + background-color: #fff;; + transition: ease-out .3s; + border-right: 1px solid #dee2e6; cursor: pointer; - background-color: #fff; - + padding: 0 1rem; + z-index: 10; + .footer-icon { @include sidelinks() } + + } - .ps__rail-x { - height: 0px; - } - .ps__rail-y { - width: 0px; - } - - .ps__rail-x.ps--clicking .ps__thumb-x, - .ps__rail-x:focus>.ps__thumb-x, - .ps__rail-x:hover>.ps__thumb-x { - height: 7px - } - - .ps__rail-y.ps--clicking .ps__thumb-y, - .ps__rail-y:focus>.ps__thumb-y, - .ps__rail-y:hover>.ps__thumb-y { - width: 7px - } +.menu-label { + padding: 10px 16px 10px 16px; + color: $menu_lable_color; + text-transform: uppercase; + font-size: 12px; + letter-spacing: .5px; +} } + + + +.toggled { + .top-header { + .navbar { + left: 70px; + } + + } + + .main-wrapper { + margin-left: 70px; + } + + .page-footer { + left: 70px; + } + +} + + + + + + + +@media screen and (min-width:1199px) { + +body.toggled { + .sidebar-wrapper { + &:hover { + box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 15%); + .sidebar-header { + .sidebar-close { + display: flex; + } + } + } + } + &:not(.sidebar-hovered) { + .sidebar-wrapper { + .sidebar-header { + .logo-name { + display: none; + } + width: 70px; + justify-content: center; + width: 70px; + .toggle-icon { + display: none; + } + } + width: 70px; + .metismenu { + a { + justify-content: center; + } + .menu-title { + display: none; + } + li { + ul { + display: none; + } + } + li.menu-label { + display: none; + } + .has-arrow { + &:after { + display: none; + } + } + } + .sidebar-bottom { + width: 70px; + } + } + .sidebar-bottom { + .dropdown-laungauge { + display: none; + } + .dropdown-help { + display: none; + } + } + } +} + + +} + + + .chip { display: inline-block; height: 32px; @@ -551,7 +804,9 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd .main-wrapper { margin-top: 70px; - margin-left: 70px; + padding-bottom: 20px; + margin-left: 260px; + transition: ease-out .3s; .main-content { padding: 1.5rem; @@ -761,12 +1016,13 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd @include alignContent(); background-color: $headerbg; border-top: 1px solid var(--bs-border-color); - height: 70px; - position: fixed; - left: 70px; + height: 40px; + position: absolute; + left: 260px; right: 0; bottom: 0; - z-index: 2; + transition: ease-out .3s; + box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.044), 0 2px 6px 0 rgba(0, 0, 0, 0.049); } @@ -786,162 +1042,6 @@ $dropdownAnimation: .6s cubic-bezier(.25, .8, .25, 1) 0s normal forwards 1 animd } -/* Metis Menu */ -$color_1: #5f5f5f; -$color_2: #008cff; -$color_3: #b0afaf; -$background-color_1: rgb(0 140 255 / 5%); -$border-color_1: initial; - -.sidebar-nav { - ul { - padding: 0; - margin: 0; - list-style: none; - background: 0 0; - } - - .metismenu { - background: 0 0; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -ms-flex-direction: column; - flex-direction: column; - - li+li { - margin-top: 5px; - } - - li { - &:first-child { - margin-top: 5px; - } - - &:last-child { - margin-bottom: 5px; - } - } - - >li { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -ms-flex-direction: column; - flex-direction: column; - position: relative; - } - - a { - position: relative; - display: flex; - align-items: center; - justify-content: left; - padding: 6px 16px; - font-size: 15px; - color: $color_1; - outline-width: 0; - text-overflow: ellipsis; - overflow: hidden; - letter-spacing: .5px; - border-radius: 0.25rem; - transition: all .3s ease-out; - - .parent-icon { - font-size: 24px; - line-height: 1; - } - - .menu-title { - margin-left: 10px; - } - - &:active { - color: $color_2; - text-decoration: none; - background-color: $background-color_1; - } - - &:focus { - color: $color_2; - text-decoration: none; - background-color: $background-color_1; - } - - &:hover { - color: $color_2; - text-decoration: none; - background-color: $background-color_1; - } - } - - ul { - a { - padding: 6px 15px 6px 20px; - font-size: 15px; - border: 0; - - i { - margin-right: 14px; - } - } - - background-color: #fff; - - ul { - a { - padding: 8px 15px 8px 30px; - } - - ul { - a { - padding: 8px 15px 8px 45px; - } - } - } - } - - .mm-active { - >a { - color: $color_2; - text-decoration: none; - background-color: $background-color_1; - } - } - } -} - -.menu-label { - padding: 20px 15px 5px 5px; - color: $color_3; - text-transform: uppercase; - font-size: 12px; - letter-spacing: .5px; -} - -.metismenu { - .has-arrow { - &:after { - position: absolute; - content: ""; - width: .5em; - height: .5em; - border-style: solid; - border-width: 1.2px 0 0 1.2px; - border-color: $border-color_1; - right: 15px; - transform: rotate(-45deg) translateY(-50%); - transform-origin: top; - top: 50%; - transition: all .3s ease-out; - } - } -} - /* order offcanvas */ @@ -960,6 +1060,10 @@ $border-color_1: initial; display: none } +.dropup .dropdown-toggle-nocaret:after { + display: none +} + .w-260 { width: 300px !important; } @@ -1078,7 +1182,7 @@ form select.error:focus { } .bg-error { - background-image: url("../assets/images/auth/error-bg.png"); + // background-image: url("../assets/images/auth/error-bg.png"); background-position: center; background-size: cover; background-attachment: fixed; @@ -1119,7 +1223,7 @@ form select.error:focus { .chart-container2 { position: relative; - height: 180px; + height: 138px; } .gmaps, @@ -1132,7 +1236,7 @@ form select.error:focus { /* authentication */ .bg-login { - background-image: url(../assets/images/auth/bg-login.png); + // background-image: url(../assets/images/auth/bg-login.png); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; @@ -1140,17 +1244,17 @@ form select.error:focus { .bg-register { @extend .bg-login; - background-image: url(../assets/images/auth/bg-register.png); + // background-image: url(../assets/images/auth/bg-register.png); } .bg-forgot-password { @extend .bg-login; - background-image: url(../assets/images/auth/bg-forgot.png); + // background-image: url(../assets/images/auth/bg-forgot.png); } .bg-reset-password { @extend .bg-login; - background-image: url(../assets/images/auth/bg-reset-password.png); + // background-image: url(../assets/images/auth/bg-reset-password.png); } diff --git a/frontend/src/index.html b/frontend/src/index.html index be998d1..1802adf 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -12,8 +12,11 @@ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" /> + + - +