feat(brand): update app to use the Grimmory brand identity (#550)
This commit is contained in:
@@ -2,15 +2,21 @@
|
||||
<div class="layout-topbar">
|
||||
|
||||
<a class="layout-topbar-logo topbar-logo" routerLink="">
|
||||
<!--
|
||||
<svg class="logo-icon half-title" viewBox="0 0 126 126" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M59 4.79297C71.5051 11.5557 80 24.7854 80 40C80 40.5959 79.987 41.1888 79.9609 41.7783C79.8609 44.0406 81.7355 46 84 46C106.091 46 124 63.9086 124 86C124 108.091 106.091 126 84 126H10C4.47715 126 0 121.523 0 116V39.0068L0.0126953 38.9941C0.357624 25.0252 7.86506 12.8347 19 5.95215V63.832C19 64.8345 20.0676 65.4391 20.9121 64.9902L21.0771 64.8867L38.2227 52.3428C38.6819 52.0068 39.3064 52.0068 39.7656 52.3428L56.9229 64.8945L57.0879 64.998C57.9324 65.447 59 64.8423 59 63.8398V4.79297Z"/>
|
||||
<path
|
||||
d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z"
|
||||
fill="white"/>
|
||||
<svg class="logo-icon half-title" viewBox="0 0 100 126" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M25.8062 106.614V113.077V119.537V126L32.2559 119.537L38.7093 126V119.537V113.077V106.614H25.8062Z" fill="white"/>
|
||||
<path d="M38.7093 29.0758H96.7715C98.5535 29.0758 99.9964 27.6307 99.9964 25.846V3.22984C99.9964 1.44512 98.5535 0 96.7715 0H12.9031C10.5512 0 8.35077 0.63224 6.44975 1.73414C4.49102 2.86856 2.86054 4.50155 1.72787 6.4633C0.631268 8.36363 0 10.5674 0 12.923V106.614C0 113.753 5.7752 119.537 12.9031 119.537H21.1529V113.077H12.9031C9.33915 113.077 6.44975 110.183 6.44975 106.614C6.44975 103.044 9.33915 100.15 12.9031 100.15H93.5466C97.1106 100.15 100 97.2566 100 93.6871V41.9988C100 38.4293 97.1106 35.5355 93.5466 35.5355H38.7093C36.9273 35.5355 35.4845 36.9806 35.4845 38.7653V61.3815C35.4845 63.1662 36.9273 64.6113 38.7093 64.6113H67.7404C69.5224 64.6113 70.9653 66.0564 70.9653 67.8412C70.9653 69.6259 69.5224 71.071 67.7404 71.071H38.7093C33.3634 71.071 29.0311 66.732 29.0311 61.3779V38.7617C29.0311 33.4076 33.3634 29.0686 38.7093 29.0686V29.0758Z" fill="url(#grimmory-logo-topbar-primary-gradient)"/>
|
||||
<path d="M96.7715 113.077H43.5539V119.537H96.7715C98.5535 119.537 99.9964 118.092 99.9964 116.307C99.9964 114.522 98.5535 113.077 96.7715 113.077Z" fill="url(#grimmory-logo-topbar-primary-gradient-secondary)"/>
|
||||
<defs>
|
||||
<linearGradient id="grimmory-logo-topbar-primary-gradient" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--p-primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--p-primary-500)"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="grimmory-logo-topbar-primary-gradient-secondary" x1="50" y1="0" x2="50" y2="119.537" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" style="stop-color: var(--p-primary-300)"/>
|
||||
<stop offset="1" style="stop-color: var(--p-primary-500)"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
-->
|
||||
<span class="logo-text">Grimmory</span>
|
||||
</a>
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
.topbar-logo {
|
||||
padding-left: 1.25rem;
|
||||
padding-right: 6rem;
|
||||
gap: 0.5rem;
|
||||
.layout-topbar-logo.topbar-logo {
|
||||
width: var(--sidebar-width, 225px);
|
||||
min-width: var(--sidebar-width, 225px);
|
||||
justify-content: flex-start;
|
||||
padding-left: 2.05rem;
|
||||
padding-right: 0;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
@@ -10,6 +13,13 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
width: auto;
|
||||
height: 2rem;
|
||||
flex-shrink: 0;
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.topbar-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('FaviconService', () => {
|
||||
const createObjectUrlSpy = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:favicon');
|
||||
|
||||
const service = new FaviconService();
|
||||
service.updateFavicon('#123456');
|
||||
service.updateFavicon('#abcdef', '#123456');
|
||||
|
||||
expect(querySelectorSpy).toHaveBeenCalledWith("link[rel*='icon']");
|
||||
expect(createObjectUrlSpy).toHaveBeenCalledOnce();
|
||||
@@ -30,11 +30,28 @@ describe('FaviconService', () => {
|
||||
vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:new-favicon');
|
||||
|
||||
const service = new FaviconService();
|
||||
service.updateFavicon('#abcdef');
|
||||
service.updateFavicon('#fedcba', '#abcdef');
|
||||
|
||||
expect(appended).toEqual([favicon]);
|
||||
expect(favicon.rel).toBe('icon');
|
||||
expect(favicon.type).toBe('image/svg+xml');
|
||||
expect(favicon.href).toBe('blob:new-favicon');
|
||||
});
|
||||
|
||||
it('revokes the previous favicon object URL before replacing it', () => {
|
||||
const favicon = {type: '', href: ''} as HTMLLinkElement;
|
||||
|
||||
vi.spyOn(document, 'querySelector').mockReturnValue(favicon);
|
||||
vi.spyOn(URL, 'createObjectURL')
|
||||
.mockReturnValueOnce('blob:first-favicon')
|
||||
.mockReturnValueOnce('blob:second-favicon');
|
||||
const revokeObjectUrlSpy = vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => undefined);
|
||||
|
||||
const service = new FaviconService();
|
||||
service.updateFavicon('#fedcba', '#abcdef');
|
||||
service.updateFavicon('#89abcd', '#123456');
|
||||
|
||||
expect(revokeObjectUrlSpy).toHaveBeenCalledWith('blob:first-favicon');
|
||||
expect(favicon.href).toBe('blob:second-favicon');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,18 +2,31 @@ import {Injectable} from '@angular/core';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class FaviconService {
|
||||
private svgTemplate = (color: string) => `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 126 126" fill="currentColor">
|
||||
<path d="M59 4.79297C71.5051 11.5557 80 24.7854 80 40C80 40.5959 79.987 41.1888 79.9609 41.7783C79.8609 44.0406 81.7355 46 84 46C106.091 46 124 63.9086 124 86C124 108.091 106.091 126 84 126H10C4.47715 126 0 121.523 0 116V39.0068L0.0126953 38.9941C0.357624 25.0252 7.86506 12.8347 19 5.95215V63.832C19 64.8345 20.0676 65.4391 20.9121 64.9902L21.0771 64.8867L38.2227 52.3428C38.6819 52.0068 39.3064 52.0068 39.7656 52.3428L56.9229 64.8945L57.0879 64.998C57.9324 65.447 59 64.8423 59 63.8398V4.79297Z" fill="${color}"/>
|
||||
<path d="M40 0C43.8745 0 47.6199 0.552381 51.1631 1.58008V50.9697L44.3926 46.0176L44.0879 45.8037C40.9061 43.6679 36.7098 43.7393 33.5957 46.0176L26.8369 50.9619V2.21875C30.9593 0.782634 35.3881 0 40 0Z" fill="white"/>
|
||||
private currentUrl?: string;
|
||||
|
||||
private svgTemplate = (startColor: string, endColor: string) => `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 119 150" fill="none">
|
||||
<path d="M30.7094 126.921V134.616V142.306V150L38.3846 142.306L46.064 150V142.306V134.616V126.921H30.7094Z" fill="white"/>
|
||||
<path d="M46.0641 34.6141H115.158C117.279 34.6141 118.996 32.8937 118.996 30.769V3.84505C118.996 1.72038 117.279 0 115.158 0H15.3547C12.5559 0 9.93741 0.752667 7.6752 2.06446C5.34431 3.41496 3.40405 5.35899 2.05616 7.6944C0.751208 9.9567 0 12.5803 0 15.3845V126.921C0 135.42 6.87248 142.306 15.3547 142.306H25.1719V134.615H15.3547C11.1136 134.615 7.6752 131.17 7.6752 126.921C7.6752 122.672 11.1136 119.227 15.3547 119.227H111.32C115.562 119.227 119 115.782 119 111.532V49.9986C119 45.7492 115.562 42.3042 111.32 42.3042H46.0641C43.9435 42.3042 42.2265 44.0245 42.2265 46.1492V73.0732C42.2265 75.1978 43.9435 76.9182 46.0641 76.9182H80.6111C82.7317 76.9182 84.4487 78.6386 84.4487 80.7633C84.4487 82.8879 82.7317 84.6083 80.6111 84.6083H46.0641C39.7024 84.6083 34.547 79.4429 34.547 73.0689V46.1449C34.547 39.7709 39.7024 34.6055 46.0641 34.6055V34.6141Z" fill="url(#favicon-gradient)"/>
|
||||
<path d="M115.158 134.615H51.8291V142.306H115.158C117.279 142.306 118.996 140.585 118.996 138.461C118.996 136.336 117.279 134.615 115.158 134.615Z" fill="url(#favicon-gradient)"/>
|
||||
<defs>
|
||||
<linearGradient id="favicon-gradient" x1="59.5" y1="0" x2="59.5" y2="142.306" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0%" stop-color="${startColor}"/>
|
||||
<stop offset="100%" stop-color="${endColor}"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
updateFavicon(color: string) {
|
||||
const svg = this.svgTemplate(color);
|
||||
updateFavicon(startColor: string, endColor: string) {
|
||||
const svg = this.svgTemplate(startColor, endColor);
|
||||
const blob = new Blob([svg], {type: 'image/svg+xml'});
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
if (this.currentUrl) {
|
||||
URL.revokeObjectURL(this.currentUrl);
|
||||
}
|
||||
|
||||
let favicon = document.querySelector("link[rel*='icon']") as HTMLLinkElement;
|
||||
if (!favicon) {
|
||||
favicon = document.createElement('link');
|
||||
@@ -23,5 +36,6 @@ export class FaviconService {
|
||||
|
||||
favicon.type = 'image/svg+xml';
|
||||
favicon.href = url;
|
||||
this.currentUrl = url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import {ChangeDetectionStrategy, Component, computed, effect, inject} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, Component, computed, inject} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
|
||||
|
||||
import Aura from '../theme-palette-extend';
|
||||
|
||||
import {AppConfigService} from '../../service/app-config.service';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {FaviconService} from './favicon-service';
|
||||
import {NgClass} from '@angular/common';
|
||||
import Aura from '../theme-palette-extend';
|
||||
|
||||
type ColorPalette = Record<string, string>;
|
||||
|
||||
@@ -32,28 +28,16 @@ interface Palette {
|
||||
})
|
||||
export class ThemeConfiguratorComponent {
|
||||
readonly configService = inject(AppConfigService);
|
||||
readonly faviconService = inject(FaviconService);
|
||||
|
||||
readonly surfaces = this.configService.surfaces;
|
||||
|
||||
readonly selectedPrimaryColor = computed(() => this.configService.appState().primary);
|
||||
readonly selectedSurfaceColor = computed(() => this.configService.appState().surface);
|
||||
|
||||
readonly faviconColor = computed(() => {
|
||||
const name = this.selectedPrimaryColor() ?? 'green';
|
||||
const presetPalette = (Aura.primitive ?? {}) as Record<string, ColorPalette>;
|
||||
const colorPalette = presetPalette[name];
|
||||
return colorPalette?.[500] ?? name;
|
||||
});
|
||||
|
||||
private readonly _faviconSyncEffect = effect(() => {
|
||||
this.faviconService.updateFavicon(this.faviconColor());
|
||||
});
|
||||
|
||||
readonly primaryColors = computed<Palette[]>(() => {
|
||||
const presetPalette = (Aura.primitive ?? {}) as Record<string, ColorPalette>;
|
||||
const colors = [
|
||||
'emerald', 'green', 'lime', 'orange', 'amber', 'yellow',
|
||||
'orange', 'amber', 'yellow', 'lime', 'green', 'emerald',
|
||||
'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet',
|
||||
'purple', 'fuchsia', 'pink', 'rose', 'red',
|
||||
'coralSunset', 'roseBlush', 'melonBlush', 'cottonCandy',
|
||||
|
||||
Reference in New Issue
Block a user