-
Notifications
You must be signed in to change notification settings - Fork 2
Divyanshu | Design Improvements #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
e4651e2
refactor: improve search component styling and add client name tooltip
dvCodeWorld a4a8825
refactor: extract UI settings and side nav state into services, impro…
dvCodeWorld 3b3f25f
refactor: improve create-feature component styling and template consi…
dvCodeWorld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ import { MatToolbarModule } from '@angular/material/toolbar'; | |
| import { MatExpansionModule } from '@angular/material/expansion'; | ||
| import { MatTooltipModule } from '@angular/material/tooltip'; | ||
| import { MatSlideToggleModule } from '@angular/material/slide-toggle'; | ||
| import { CDKScrollComponent } from '@proxy/ui/virtual-scroll'; | ||
| import { ScrollingModule } from '@angular/cdk/scrolling'; | ||
| import { MainLeftSideNavComponent } from './main-left-side-nav/main-left-side-nav.component'; | ||
| import { IClient, IClientSettings, IFirebaseUserModel, IPaginatedResponse } from '@proxy/models/root-models'; | ||
|
|
@@ -36,6 +35,8 @@ import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; | |
| import { RootService } from '@proxy/services/proxy/root'; | ||
| import { environment } from '../../environments/environment'; | ||
| import { AuthService } from '@proxy/services/proxy/auth'; | ||
| import { SideNavService } from './side-nav.service'; | ||
| import { UiSettingsService } from './ui-settings.service'; | ||
| @Component({ | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| selector: 'proxy-layout', | ||
|
|
@@ -65,7 +66,6 @@ export class LayoutComponent extends BaseComponent implements OnInit, OnDestroy | |
| public clients$: Observable<IPaginatedResponse<IClient[]>>; | ||
| public swtichClientSuccess$: Observable<boolean>; | ||
|
|
||
| public isSideNavOpen = signal<boolean>(true); | ||
| public isDarkMode = signal<boolean>(false); | ||
|
|
||
| public toggleMenuSideBar: boolean; | ||
|
|
@@ -81,6 +81,8 @@ export class LayoutComponent extends BaseComponent implements OnInit, OnDestroy | |
| private rootService = inject(RootService); | ||
| private authService = inject(AuthService); | ||
| private cdr = inject(ChangeDetectorRef); | ||
| public sideNavService = inject(SideNavService); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sideNavService is injected as public but should be private since it's only used internally in component methods. This helps encapsulate implementation details. |
||
| private uiSettings = inject(UiSettingsService); | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
@@ -122,7 +124,7 @@ export class LayoutComponent extends BaseComponent implements OnInit, OnDestroy | |
| this.getCurrentTheme(); | ||
|
|
||
| if (this.isMobileDevice()) { | ||
| this.toggleSideBarEvent(); | ||
| this.sideNavService.close(); | ||
| } | ||
| this.swtichClientSuccess$.pipe(takeUntil(this.destroy$)).subscribe((res) => { | ||
| if (res) { | ||
|
|
@@ -189,19 +191,12 @@ export class LayoutComponent extends BaseComponent implements OnInit, OnDestroy | |
| } | ||
|
|
||
| public getCurrentTheme() { | ||
| if ( | ||
| localStorage.getItem('selected-theme') === null || | ||
| localStorage.getItem('selected-theme') === 'light-theme' | ||
| ) { | ||
| this.switchedDarkMode(false); | ||
| } else { | ||
| this.switchedDarkMode(true); | ||
| } | ||
| this.switchedDarkMode(this.uiSettings.theme === 'dark-theme'); | ||
| } | ||
|
|
||
| switchedDarkMode(isDarkMode: boolean) { | ||
| const hostClass = isDarkMode ? 'dark-theme' : 'light-theme'; | ||
| localStorage.setItem('selected-theme', hostClass); | ||
| this.uiSettings.setTheme(hostClass); | ||
| document.body.classList.remove('dark-theme', 'light-theme'); | ||
| document.body.classList.add(hostClass); | ||
| this.isDarkMode.set(isDarkMode); | ||
|
|
@@ -218,6 +213,6 @@ export class LayoutComponent extends BaseComponent implements OnInit, OnDestroy | |
| } | ||
|
|
||
| public toggleSideBarEvent(): void { | ||
| this.isSideNavOpen.set(!this.isSideNavOpen()); | ||
| this.sideNavService.toggle(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +0,0 @@ | ||
| .service-list { | ||
| .mat-mdc-list-item { | ||
| border-radius: 8px !important; | ||
| height: 42px !important; | ||
| margin-bottom: 2px; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { Injectable, inject, signal } from '@angular/core'; | ||
| import { UiSettingsService } from './ui-settings.service'; | ||
|
|
||
| @Injectable({ providedIn: 'root' }) | ||
| export class SideNavService { | ||
| private uiSettings = inject(UiSettingsService); | ||
|
|
||
| public isSideNavOpen = signal<boolean>(this.uiSettings.sideNavOpen); | ||
|
|
||
| public toggle(): void { | ||
| const next = !this.isSideNavOpen(); | ||
| this.isSideNavOpen.set(next); | ||
| this.uiSettings.setSideNavOpen(next); | ||
| } | ||
|
|
||
| public open(): void { | ||
| this.isSideNavOpen.set(true); | ||
| this.uiSettings.setSideNavOpen(true); | ||
| } | ||
|
|
||
| public close(): void { | ||
| this.isSideNavOpen.set(false); | ||
| this.uiSettings.setSideNavOpen(false); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { Injectable } from '@angular/core'; | ||
|
|
||
| export type AppTheme = 'light-theme' | 'dark-theme'; | ||
|
|
||
| interface UiSettings { | ||
| theme: AppTheme; | ||
| sideNavOpen: boolean; | ||
| _savedAt: number; | ||
| } | ||
|
|
||
| const STORAGE_KEY = 'ui-settings'; | ||
| const TTL_MS = 30 * 24 * 60 * 60 * 1000; // 30 days | ||
|
|
||
| const DEFAULTS: Omit<UiSettings, '_savedAt'> = { | ||
| theme: 'light-theme', | ||
| sideNavOpen: true, | ||
| }; | ||
|
|
||
| @Injectable({ providedIn: 'root' }) | ||
| export class UiSettingsService { | ||
| private _settings: UiSettings; | ||
|
|
||
| constructor() { | ||
| this._settings = this._load(); | ||
| } | ||
|
|
||
| get theme(): AppTheme { | ||
| return this._settings.theme; | ||
| } | ||
|
|
||
| get sideNavOpen(): boolean { | ||
| return this._settings.sideNavOpen; | ||
| } | ||
|
|
||
| setTheme(value: AppTheme): void { | ||
| this._settings.theme = value; | ||
| this._save(); | ||
| } | ||
|
|
||
| setSideNavOpen(value: boolean): void { | ||
| this._settings.sideNavOpen = value; | ||
| this._save(); | ||
| } | ||
|
|
||
| private _load(): UiSettings { | ||
| try { | ||
| const raw = localStorage.getItem(STORAGE_KEY); | ||
| if (raw) { | ||
| const parsed: UiSettings = JSON.parse(raw); | ||
| if (parsed._savedAt && Date.now() - parsed._savedAt < TTL_MS) { | ||
| return { ...DEFAULTS, ...parsed }; | ||
| } | ||
| } | ||
| } catch { | ||
| // corrupted storage — fall through to defaults | ||
| } | ||
| return { ...DEFAULTS, _savedAt: Date.now() }; | ||
| } | ||
|
|
||
| private _save(): void { | ||
| this._settings._savedAt = Date.now(); | ||
| localStorage.setItem(STORAGE_KEY, JSON.stringify(this._settings)); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SideNavService and UiSettingsService are imported but not included in the component's imports array. Make sure to add them to ensure proper dependency declaration.