From 1010923215e93d6fcc966b302587321c88812683 Mon Sep 17 00:00:00 2001 From: Fahri Gedik Date: Wed, 24 Sep 2025 08:59:22 +0300 Subject: [PATCH] Refactor LogoComponent to use injectable tokens Updated LogoComponent to use LOGO_URL_TOKEN and LOGO_APP_NAME_TOKEN for logo URL and app name, falling back to environment values if tokens are not provided. This improves flexibility and allows for easier customization of the logo and app name. --- .../src/lib/components/logo/logo.component.ts | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/npm/ng-packs/packages/theme-basic/src/lib/components/logo/logo.component.ts b/npm/ng-packs/packages/theme-basic/src/lib/components/logo/logo.component.ts index 0bc2266e0c..ff526f608f 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/components/logo/logo.component.ts +++ b/npm/ng-packs/packages/theme-basic/src/lib/components/logo/logo.component.ts @@ -1,24 +1,37 @@ -import { ApplicationInfo, EnvironmentService } from '@abp/ng.core'; +import { EnvironmentService } from '@abp/ng.core'; import { RouterLink } from '@angular/router'; import { Component, inject } from '@angular/core'; +import { LOGO_APP_NAME_TOKEN, LOGO_URL_TOKEN } from '@abp/ng.theme.shared'; @Component({ selector: 'abp-logo', template: ` - @if (appInfo.logoUrl) { - + @if (logoUrl) { + } @else { - {{ appInfo.name }} + {{ appName }} } `, + standalone: true, imports: [RouterLink], }) export class LogoComponent { private environment = inject(EnvironmentService); - get appInfo(): ApplicationInfo { - return this.environment.getEnvironment().application; + private readonly providedLogoUrl = inject(LOGO_URL_TOKEN, { optional: true }); + private readonly providedAppName = inject(LOGO_APP_NAME_TOKEN, { optional: true }); + + get logoUrl(): string { + return ( + this.providedLogoUrl ?? this.environment.getEnvironment().application?.logoUrl + ); + } + + get appName(): string { + return ( + this.providedAppName ?? this.environment.getEnvironment().application?.name + ); } }