Only have aura

This commit is contained in:
aditya.chandel
2025-02-13 10:03:20 -07:00
parent cd12ff3f49
commit 7378f25467
4 changed files with 68 additions and 164 deletions
@@ -14,6 +14,23 @@
position: relative; position: relative;
} }
.cover-container::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.6) 100%);
opacity: 0;
transition: opacity 0.2s ease-in-out;
pointer-events: none;
}
.cover-container:hover::after {
opacity: 1;
}
.book-title-container { .book-title-container {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -45,6 +62,7 @@
transform: translateX(-50%); transform: translateX(-50%);
display: none; display: none;
transition: opacity 0.2s ease-in-out; transition: opacity 0.2s ease-in-out;
z-index: 2;
} }
.info-btn { .info-btn {
@@ -55,10 +73,6 @@
bottom: 25%; bottom: 25%;
} }
.cover-container:hover .book-cover {
filter: blur(2px);
}
.cover-container:hover .info-btn, .cover-container:hover .info-btn,
.cover-container:hover .read-btn { .cover-container:hover .read-btn {
display: block; display: block;
@@ -69,7 +83,7 @@
top: 8px; top: 8px;
right: 8px; right: 8px;
display: none; display: none;
z-index: 1; z-index: 2;
} }
.cover-container:hover .select-checkbox { .cover-container:hover .select-checkbox {
@@ -30,17 +30,4 @@
</div> </div>
</div> </div>
<div class="config-panel-settings">
<span class="config-panel-label">Presets</span>
<p-selectbutton [options]="presets" [ngModel]="selectedPreset()" (ngModelChange)="onPresetChange($event)" [allowEmpty]="false" size="small"></p-selectbutton>
</div>
<div class="flex">
<div class="flex-1">
<div class="config-panel-settings">
<span class="config-panel-label">Ripple</span>
<p-toggleswitch [(ngModel)]="ripple"/>
</div>
</div>
</div>
</div> </div>
@@ -1,16 +1,12 @@
import {CommonModule, isPlatformBrowser} from '@angular/common'; import {CommonModule, isPlatformBrowser} from '@angular/common';
import {Component, computed, inject, PLATFORM_ID, OnInit} from '@angular/core'; import {Component, computed, inject, OnInit, PLATFORM_ID} from '@angular/core';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {$t, updatePreset, updateSurfacePalette} from '@primeng/themes'; import {$t, updatePreset, updateSurfacePalette} from '@primeng/themes';
import Aura from '@primeng/themes/aura'; import Aura from '@primeng/themes/aura';
import Lara from '@primeng/themes/lara';
import Material from '@primeng/themes/material';
import Nora from '@primeng/themes/nora';
import {ButtonModule} from 'primeng/button'; import {ButtonModule} from 'primeng/button';
import {PrimeNG} from 'primeng/config'; import {PrimeNG} from 'primeng/config';
import {InputSwitchModule} from 'primeng/inputswitch'; import {InputSwitchModule} from 'primeng/inputswitch';
import {RadioButtonModule} from 'primeng/radiobutton'; import {RadioButtonModule} from 'primeng/radiobutton';
import {SelectButton} from 'primeng/selectbutton';
import {ToggleSwitchModule} from 'primeng/toggleswitch'; import {ToggleSwitchModule} from 'primeng/toggleswitch';
import {AppConfigService} from '../../../core/service/app-config.service'; import {AppConfigService} from '../../../core/service/app-config.service';
@@ -21,13 +17,6 @@ interface Palette {
palette: ColorPalette; palette: ColorPalette;
} }
const presets = {
Aura,
Material,
Lara,
Nora
};
@Component({ @Component({
selector: 'app-theme-configurator', selector: 'app-theme-configurator',
standalone: true, standalone: true,
@@ -35,21 +24,12 @@ const presets = {
host: { host: {
class: 'config-panel hidden' class: 'config-panel hidden'
}, },
imports: [CommonModule, FormsModule, InputSwitchModule, ButtonModule, RadioButtonModule, SelectButton, ToggleSwitchModule] imports: [CommonModule, FormsModule, InputSwitchModule, ButtonModule, RadioButtonModule, ToggleSwitchModule]
}) })
export class ThemeConfiguratorComponent implements OnInit { export class ThemeConfiguratorComponent implements OnInit {
get ripple() {
return this.config.ripple();
}
set ripple(value: boolean) {
this.config.ripple.set(value);
}
config: PrimeNG = inject(PrimeNG); config: PrimeNG = inject(PrimeNG);
configService: AppConfigService = inject(AppConfigService); configService: AppConfigService = inject(AppConfigService);
presets = Object.keys(presets);
platformId = inject(PLATFORM_ID); platformId = inject(PLATFORM_ID);
surfaces = [ surfaces = [
@@ -197,51 +177,32 @@ export class ThemeConfiguratorComponent implements OnInit {
selectedSurfaceColor = computed(() => this.configService.appState().surface); selectedSurfaceColor = computed(() => this.configService.appState().surface);
selectedPreset = computed(() => this.configService.appState().preset); primaryColors = computed<Palette[]>(() => {
const presetPalette = Aura.primitive ?? {};
primaryColors = computed(() => {
// @ts-ignore
const presetPalette = presets[this.configService.appState().preset].primitive;
const colors = ['emerald', 'green', 'lime', 'orange', 'amber', 'yellow', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']; const colors = ['emerald', 'green', 'lime', 'orange', 'amber', 'yellow', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose'];
const palettes: Palette[] = [{ name: 'noir', palette: {} }]; return [{ name: 'noir', palette: {} }].concat(
colors.map((color) => ({
colors.forEach((color) => {
palettes.push({
name: color, name: color,
palette: presetPalette[color] || {}, // Fallback to an empty object palette: presetPalette[color] ?? {}
}); }))
}); );
return palettes;
}); });
ngOnInit() { ngOnInit() {
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
this.onPresetChange(this.configService.appState().preset); this.onPresetChange();
} }
} }
getPresetExt(): object {
getPresetExt() {
const color = this.primaryColors().find((c) => c.name === this.selectedPrimaryColor()); const color = this.primaryColors().find((c) => c.name === this.selectedPrimaryColor());
if (!color) return {}; // Safe fallback
if (color!.name === 'noir') { if (color.name === 'noir') {
return { return {
semantic: { semantic: {
primary: { primary: {...this.surfaces.find((s) => s.name === this.selectedSurfaceColor())?.palette},
50: '{surface.50}',
100: '{surface.100}',
200: '{surface.200}',
300: '{surface.300}',
400: '{surface.400}',
500: '{surface.500}',
600: '{surface.600}',
700: '{surface.700}',
800: '{surface.800}',
900: '{surface.900}',
950: '{surface.950}'
},
colorScheme: { colorScheme: {
dark: { dark: {
primary: { primary: {
@@ -260,85 +221,37 @@ export class ThemeConfiguratorComponent implements OnInit {
} }
} }
}; };
} else {
if (this.configService.appState().preset === 'Nora') {
return {
semantic: {
primary: color!.palette,
colorScheme: {
dark: {
primary: {
color: '{primary.500}',
contrastColor: '{surface.900}',
hoverColor: '{primary.400}',
activeColor: '{primary.300}'
},
highlight: {
background: '{primary.500}',
focusBackground: '{primary.400}',
color: '{surface.900}',
focusColor: '{surface.900}'
}
}
}
}
};
} else if (this.configService.appState().preset === 'Material') {
return {
semantic: {
primary: color!.palette,
colorScheme: {
dark: {
primary: {
color: '{primary.400}',
contrastColor: '{surface.900}',
hoverColor: '{primary.300}',
activeColor: '{primary.200}'
},
highlight: {
background: 'color-mix(in srgb, {primary.400}, transparent 84%)',
focusBackground: 'color-mix(in srgb, {primary.400}, transparent 76%)',
color: 'rgba(255,255,255,.87)',
focusColor: 'rgba(255,255,255,.87)'
}
}
}
}
};
} else {
return {
semantic: {
primary: color!.palette,
colorScheme: {
dark: {
primary: {
color: '{primary.400}',
contrastColor: '{surface.900}',
hoverColor: '{primary.300}',
activeColor: '{primary.200}'
},
highlight: {
background: 'color-mix(in srgb, {primary.400}, transparent 84%)',
focusBackground: 'color-mix(in srgb, {primary.400}, transparent 76%)',
color: 'rgba(255,255,255,.87)',
focusColor: 'rgba(255,255,255,.87)'
}
}
}
}
};
}
} }
return {
semantic: {
primary: color.palette,
colorScheme: {
dark: {
primary: {
color: '{primary.400}',
contrastColor: '{surface.900}',
hoverColor: '{primary.300}',
activeColor: '{primary.200}'
},
highlight: {
background: 'color-mix(in srgb, {primary.400}, transparent 84%)',
focusBackground: 'color-mix(in srgb, {primary.400}, transparent 76%)',
color: 'rgba(255,255,255,.87)',
focusColor: 'rgba(255,255,255,.87)'
}
}
}
}
};
} }
updateColors(event: any, type: string, color: any) { updateColors(event: Event, type: 'primary' | 'surface', color: { name: string; palette?: ColorPalette }) {
if (type === 'primary') { this.configService.appState.update((state) => ({
this.configService.appState.update((state) => ({...state, primary: color.name})); ...state,
} else if (type === 'surface') { [type]: color.name
this.configService.appState.update((state) => ({...state, surface: color.name})); }));
}
this.applyTheme(type, color); this.applyTheme(type, color);
event.stopPropagation(); event.stopPropagation();
} }
@@ -350,18 +263,8 @@ export class ThemeConfiguratorComponent implements OnInit {
} }
} }
onPresetChange(event: any) { onPresetChange() {
this.configService.appState.update((state) => ({...state, preset: event})); const surfacePalette = this.primaryColors().find(c => c.name === this.selectedSurfaceColor())?.palette;
// @ts-ignore $t().preset(Aura).preset(this.getPresetExt()).surfacePalette(surfacePalette).use({useDefaultOptions: true});
const preset = presets[event];
const surfacePalette = this.surfaces.find((s) => s.name === this.selectedSurfaceColor())?.palette;
if (this.configService.appState().preset === 'Material') {
document.body.classList.add('material');
this.config.ripple.set(true);
} else {
document.body.classList.remove('material');
this.config.ripple.set(false);
}
$t().preset(preset).preset(this.getPresetExt()).surfacePalette(surfacePalette).use({useDefaultOptions: true});
} }
} }
@@ -10,11 +10,6 @@
<p *ngIf="metadata.seriesName" class="italic">{{ metadata.seriesName }} #{{ metadata.seriesNumber }} </p> <p *ngIf="metadata.seriesName" class="italic">{{ metadata.seriesName }} #{{ metadata.seriesNumber }} </p>
<p class="text-2xl font-bold">{{ metadata.title }}</p> <p class="text-2xl font-bold">{{ metadata.title }}</p>
<p class="text-xl">{{ getAuthorNames(metadata?.authors || []) }}</p> <p class="text-xl">{{ getAuthorNames(metadata?.authors || []) }}</p>
<div class="flex items-center gap-4 pt-2 pb-4">
<p-rating [(ngModel)]="metadata.rating" readonly stars="5"></p-rating>
<p class="font-semibold">({{ metadata.reviewCount || 0 }} Reviews)</p>
</div>
</div> </div>
<div class="flex gap-4 pr-4"> <div class="flex gap-4 pr-4">
<p-button [rounded]="true" [raised]="true" severity="info" (onClick)="readBook(metadata.bookId)" icon="pi pi-eye"></p-button> <p-button [rounded]="true" [raised]="true" severity="info" (onClick)="readBook(metadata.bookId)" icon="pi pi-eye"></p-button>
@@ -22,6 +17,11 @@
</div> </div>
</div> </div>
<div class="flex items-center gap-4 pb-4">
<p-rating [(ngModel)]="metadata.rating" readonly stars="5"></p-rating>
<p class="font-semibold">({{ metadata.reviewCount || 0 }} Reviews)</p>
</div>
<div class="grid grid-cols-3 gap-2"> <div class="grid grid-cols-3 gap-2">
<p><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p> <p><span class="font-bold">Publisher:</span> {{ metadata.publisher || '-' }}</p>
<p><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p> <p><span class="font-bold">Published:</span> {{ metadata.publishedDate || '-' }}</p>