feat: move sidebar width from global setting to localStorage with view preferences UI (#2749)
This commit is contained in:
+2
-2
@@ -447,7 +447,7 @@
|
||||
z-index: 50;
|
||||
|
||||
@media (max-width: 991px) {
|
||||
width: 225px;
|
||||
width: var(--sidebar-width, 225px);
|
||||
position: fixed;
|
||||
top: 3.85rem;
|
||||
right: 0;
|
||||
@@ -478,7 +478,7 @@
|
||||
}
|
||||
|
||||
&.active {
|
||||
width: 225px;
|
||||
width: var(--sidebar-width, 225px);
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
margin-left: 1rem;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
:host ::ng-deep .cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper {
|
||||
width: 190px !important;
|
||||
width: calc(var(--sidebar-width, 225px) - 35px) !important;
|
||||
min-width: unset;
|
||||
}
|
||||
|
||||
|
||||
+34
@@ -17,5 +17,39 @@
|
||||
<app-sidebar-sorting-preferences></app-sidebar-sorting-preferences>
|
||||
<div class="section-divider"><hr></div>
|
||||
<app-meta-center-view-mode-component></app-meta-center-view-mode-component>
|
||||
<div class="section-divider"><hr></div>
|
||||
|
||||
<div class="preferences-section">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-objects-column"></i>
|
||||
{{ t('layout.sectionTitle') }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('layout.sidebarWidth', {value: sidebarWidth}) }}</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
[(ngModel)]="sidebarWidth"
|
||||
[min]="175"
|
||||
[max]="400"
|
||||
[step]="1"
|
||||
(onChange)="onSidebarWidthChange()"
|
||||
(onSlideEnd)="saveSidebarWidth()">
|
||||
</p-slider>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
{{ t('layout.sidebarWidthDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
+90
@@ -16,3 +16,93 @@
|
||||
}
|
||||
|
||||
@include settings.settings-section-divider;
|
||||
|
||||
.preferences-section {
|
||||
@media (min-width: 768px) {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 2rem;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.setting-label {
|
||||
display: block;
|
||||
font-weight: settings.$settings-section-title-weight;
|
||||
color: var(--p-text-color);
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.setting-label-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.setting-label {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
min-width: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
|
||||
.pi {
|
||||
color: var(--p-primary-color);
|
||||
margin-top: 0.125rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
max-width: 300px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
min-width: 180px;
|
||||
max-width: 250px;
|
||||
}
|
||||
}
|
||||
|
||||
+29
-3
@@ -1,4 +1,4 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {ToastModule} from 'primeng/toast';
|
||||
@@ -6,7 +6,10 @@ import {ViewPreferencesComponent} from './view-preferences/view-preferences.comp
|
||||
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
|
||||
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
|
||||
import {FilterPreferencesComponent} from './filter-preferences/filter-preferences.component';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {LocalStorageService} from '../../../shared/service/local-storage.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-preferences-parent',
|
||||
@@ -20,10 +23,33 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
MetaCenterViewModeComponent,
|
||||
FilterPreferencesComponent,
|
||||
TranslocoDirective,
|
||||
Slider,
|
||||
],
|
||||
templateUrl: './view-preferences-parent.component.html',
|
||||
styleUrl: './view-preferences-parent.component.scss'
|
||||
})
|
||||
export class ViewPreferencesParentComponent {
|
||||
export class ViewPreferencesParentComponent implements OnInit {
|
||||
|
||||
sidebarWidth = 225;
|
||||
|
||||
private localStorageService = inject(LocalStorageService);
|
||||
private messageService = inject(MessageService);
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.sidebarWidth = this.localStorageService.get<number>('sidebarWidth') ?? 225;
|
||||
}
|
||||
|
||||
onSidebarWidthChange(): void {
|
||||
document.documentElement.style.setProperty('--sidebar-width', this.sidebarWidth + 'px');
|
||||
}
|
||||
|
||||
saveSidebarWidth(): void {
|
||||
this.localStorageService.set('sidebarWidth', this.sidebarWidth);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('settingsView.layout.saved'),
|
||||
detail: this.t.translate('settingsView.layout.savedDetail')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user