Add theme selector
This commit is contained in:
@@ -76,7 +76,7 @@ export class BookMetadataComponent implements OnInit, OnDestroy {
|
|||||||
openEditDialog(bookId: number | undefined, libraryId: number | undefined) {
|
openEditDialog(bookId: number | undefined, libraryId: number | undefined) {
|
||||||
this.dialogRef = this.dialogService.open(BooksMetadataDialogComponent, {
|
this.dialogRef = this.dialogService.open(BooksMetadataDialogComponent, {
|
||||||
header: 'Metadata: Google Books',
|
header: 'Metadata: Google Books',
|
||||||
modal: false,
|
modal: true,
|
||||||
width: '65%',
|
width: '65%',
|
||||||
height: '85%',
|
height: '85%',
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
<div *ngIf="isLibrariesEmpty; else dashboardScroller">
|
|
||||||
|
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty; else dashboardScroller">
|
||||||
<h1 class="no-library-header">
|
<h1 class="no-library-header">
|
||||||
Looks like you haven't added a library yet. Let's add one!
|
Looks like you haven't added a library yet. Let's add one!
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard-no-library {
|
||||||
|
margin-top: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
.dashboard .p-dialog {
|
.dashboard .p-dialog {
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroll
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home-page',
|
selector: 'app-home-page',
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
|
styleUrls: ['./dashboard.component.scss'],
|
||||||
imports: [
|
imports: [
|
||||||
Button,
|
Button,
|
||||||
NgIf,
|
NgIf,
|
||||||
DashboardScrollerComponent
|
DashboardScrollerComponent
|
||||||
],
|
],
|
||||||
styleUrls: ['./dashboard.component.scss'],
|
|
||||||
providers: [DialogService],
|
providers: [DialogService],
|
||||||
})
|
})
|
||||||
export class DashboardComponent {
|
export class DashboardComponent {
|
||||||
|
|||||||
@@ -30,10 +30,9 @@
|
|||||||
<i class="pi pi-upload"></i>
|
<i class="pi pi-upload"></i>
|
||||||
<span>Profile</span>
|
<span>Profile</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="p-link layout-topbar-button" [routerLink]="'/documentation'">
|
|
||||||
<i class="pi pi-cog"></i>
|
|
||||||
<span>Settings</span>
|
|
||||||
</button>
|
|
||||||
<app-notification></app-notification>
|
<app-notification></app-notification>
|
||||||
|
<div class="top-bar-app-theme-switcher">
|
||||||
|
<app-theme-switcher></app-theme-switcher>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {LayoutService} from './service/app.layout.service';
|
|||||||
import {RouterLink} from '@angular/router';
|
import {RouterLink} from '@angular/router';
|
||||||
import {DialogService as PrimeDialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DialogService as PrimeDialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {LibraryCreatorComponent} from '../library-creator/library-creator.component';
|
import {LibraryCreatorComponent} from '../library-creator/library-creator.component';
|
||||||
|
import {ThemeSwitcherComponent} from '../../../theme-switcher/theme-switcher.component';
|
||||||
import {TooltipModule} from 'primeng/tooltip';
|
import {TooltipModule} from 'primeng/tooltip';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {InputTextModule} from 'primeng/inputtext';
|
||||||
@@ -19,7 +20,8 @@ import {FileUploadComponent} from '../file-upload/file-upload.component';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
InputTextModule,
|
InputTextModule,
|
||||||
SearchComponent,
|
SearchComponent,
|
||||||
NotificationComponent
|
NotificationComponent,
|
||||||
|
ThemeSwitcherComponent
|
||||||
],
|
],
|
||||||
templateUrl: './app.topbar.component.html',
|
templateUrl: './app.topbar.component.html',
|
||||||
})
|
})
|
||||||
@@ -37,9 +39,20 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
openLibraryCreatorDialog(): void {
|
openLibraryCreatorDialog(): void {
|
||||||
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||||
header: 'Create New Library',
|
header: 'Create New Library',
|
||||||
modal: false,
|
modal: true,
|
||||||
width: '50%',
|
width: '50%',
|
||||||
height: '50%',
|
height: '50%',
|
||||||
|
style: {bottom: '15%'}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
openFileUploadDialog() {
|
||||||
|
this.ref = this.dialogService.open(FileUploadComponent, {
|
||||||
|
header: 'Upload Book',
|
||||||
|
modal: true,
|
||||||
|
width: '45%',
|
||||||
|
height: '40%',
|
||||||
|
style: {bottom: '20%'}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,14 +61,4 @@ export class AppTopBarComponent implements OnDestroy {
|
|||||||
this.ref.close();
|
this.ref.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openFileUploadDialog() {
|
|
||||||
this.ref = this.dialogService.open(FileUploadComponent, {
|
|
||||||
header: 'Upload Book',
|
|
||||||
modal: false,
|
|
||||||
width: '45%',
|
|
||||||
height: '40%',
|
|
||||||
style: { bottom: '20%' }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class LibraryCreatorComponent {
|
|||||||
show() {
|
show() {
|
||||||
this.ref = this.dialogService.open(DirectoryPickerComponent, {
|
this.ref = this.dialogService.open(DirectoryPickerComponent, {
|
||||||
header: 'Select Media Directory',
|
header: 'Select Media Directory',
|
||||||
modal: false,
|
modal: true,
|
||||||
width: '50%',
|
width: '50%',
|
||||||
height: '75%',
|
height: '75%',
|
||||||
contentStyle: {overflow: 'auto'},
|
contentStyle: {overflow: 'auto'},
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<div>
|
||||||
|
<p-dropdown
|
||||||
|
[options]="themes"
|
||||||
|
[(ngModel)]="currentTheme"
|
||||||
|
(onChange)="changeTheme($event)"
|
||||||
|
id="theme"
|
||||||
|
optionLabel="label"
|
||||||
|
optionValue="value"
|
||||||
|
placeholder="Choose a theme">
|
||||||
|
</p-dropdown>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import {DropdownChangeEvent, DropdownModule} from 'primeng/dropdown';
|
||||||
|
import {FormsModule} from '@angular/forms';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-theme-switcher',
|
||||||
|
templateUrl: './theme-switcher.component.html',
|
||||||
|
standalone: true,
|
||||||
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
DropdownModule
|
||||||
|
],
|
||||||
|
styleUrl: './theme-switcher.component.scss'
|
||||||
|
})
|
||||||
|
export class ThemeSwitcherComponent implements OnInit {
|
||||||
|
themes: { value: string; label: string }[] = [];
|
||||||
|
currentTheme: string = '';
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.http
|
||||||
|
.get<{ value: string; label: string }[]>('assets/themes/themes.json')
|
||||||
|
.subscribe(
|
||||||
|
(data) => {
|
||||||
|
this.themes = data;
|
||||||
|
const savedTheme = localStorage.getItem('selected-theme');
|
||||||
|
if (savedTheme) {
|
||||||
|
this.currentTheme = savedTheme;
|
||||||
|
this.applyTheme(savedTheme);
|
||||||
|
} else if (this.themes.length > 0) {
|
||||||
|
this.currentTheme = this.themes[0].value;
|
||||||
|
this.applyTheme(this.currentTheme);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error('Error loading themes:', error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTheme(event: DropdownChangeEvent) {
|
||||||
|
const selectedTheme = event.value;
|
||||||
|
this.currentTheme = selectedTheme;
|
||||||
|
this.applyTheme(selectedTheme);
|
||||||
|
localStorage.setItem('selected-theme', selectedTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
private applyTheme(theme: string) {
|
||||||
|
const themeLink = document.getElementById('theme-link') as HTMLLinkElement;
|
||||||
|
if (themeLink) {
|
||||||
|
themeLink.href = `assets/layout/styles/theme/${theme}/theme.css`;
|
||||||
|
console.log(`Theme applied: ${theme}`);
|
||||||
|
} else {
|
||||||
|
console.error('Theme link element not found!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
.top-bar-app-theme-switcher {
|
||||||
|
margin-left: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
.layout-topbar {
|
.layout-topbar {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
height: 4.25rem;
|
height: 4.25rem;
|
||||||
@@ -79,6 +83,7 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
.layout-topbar-button {
|
.layout-topbar-button {
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
[
|
||||||
|
{ "value": "arya-blue", "label": "Arya Blue" },
|
||||||
|
{ "value": "arya-green", "label": "Arya Green" },
|
||||||
|
{ "value": "arya-orange", "label": "Arya Orange" },
|
||||||
|
{ "value": "arya-purple", "label": "Arya Purple" },
|
||||||
|
{ "value": "aura-dark-amber", "label": "Aura Dark Amber" },
|
||||||
|
{ "value": "aura-dark-blue", "label": "Aura Dark Blue" },
|
||||||
|
{ "value": "aura-dark-cyan", "label": "Aura Dark Cyan" },
|
||||||
|
{ "value": "aura-dark-green", "label": "Aura Dark Green" },
|
||||||
|
{ "value": "aura-dark-indigo", "label": "Aura Dark Indigo" },
|
||||||
|
{ "value": "aura-dark-lime", "label": "Aura Dark Lime" },
|
||||||
|
{ "value": "aura-dark-noir", "label": "Aura Dark Noir" },
|
||||||
|
{ "value": "aura-dark-pink", "label": "Aura Dark Pink" },
|
||||||
|
{ "value": "aura-dark-purple", "label": "Aura Dark Purple" },
|
||||||
|
{ "value": "aura-dark-teal", "label": "Aura Dark Teal" },
|
||||||
|
{ "value": "bootstrap4-dark-blue", "label": "Bootstrap4 Dark Blue" },
|
||||||
|
{ "value": "bootstrap4-dark-purple", "label": "Bootstrap4 Dark Purple" },
|
||||||
|
{ "value": "lara-dark-amber", "label": "Lara Dark Amber" },
|
||||||
|
{ "value": "lara-dark-blue", "label": "Lara Dark Blue" },
|
||||||
|
{ "value": "lara-dark-cyan", "label": "Lara Dark Cyan" },
|
||||||
|
{ "value": "lara-dark-green", "label": "Lara Dark Green" },
|
||||||
|
{ "value": "lara-dark-indigo", "label": "Lara Dark Indigo" },
|
||||||
|
{ "value": "lara-dark-pink", "label": "Lara Dark Pink" },
|
||||||
|
{ "value": "lara-dark-purple", "label": "Lara Dark Purple" },
|
||||||
|
{ "value": "lara-dark-teal", "label": "Lara Dark Teal" },
|
||||||
|
{ "value": "luna-amber", "label": "Luna Amber" },
|
||||||
|
{ "value": "luna-blue", "label": "Luna Blue" },
|
||||||
|
{ "value": "luna-green", "label": "Luna Green" },
|
||||||
|
{ "value": "luna-pink", "label": "Luna Pink" },
|
||||||
|
{ "value": "md-dark-deeppurple", "label": "MD Dark Deep Purple" },
|
||||||
|
{ "value": "md-dark-indigo", "label": "MD Dark Indigo" },
|
||||||
|
{ "value": "mdc-dark-deeppurple", "label": "MDC Dark Deep Purple" },
|
||||||
|
{ "value": "mdc-dark-indigo", "label": "MDC Dark Indigo" },
|
||||||
|
{ "value": "mira", "label": "Mira" },
|
||||||
|
{ "value": "soho-dark", "label": "Soho Dark" },
|
||||||
|
{ "value": "vela-blue", "label": "Vela Blue" },
|
||||||
|
{ "value": "vela-green", "label": "Vela Green" },
|
||||||
|
{ "value": "vela-orange", "label": "Vela Orange" },
|
||||||
|
{ "value": "vela-purple", "label": "Vela Purple" },
|
||||||
|
{ "value": "viva-dark", "label": "Viva Dark" }
|
||||||
|
]
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
<link id="theme-css" rel="stylesheet" type="text/css" href="assets/layout/styles/theme/arya-orange/theme.css">
|
<link id="theme-link" rel="stylesheet" type="text/css" href="assets/layout/styles/theme/mdc-dark-deeppurple/theme.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user