Browse Source

Add logo provider and tokens to theme-shared package

pull/23750/head
Fahri Gedik 1 year ago
parent
commit
dab7280dd2
  1. 1
      npm/ng-packs/packages/theme-shared/src/lib/providers/index.ts
  2. 51
      npm/ng-packs/packages/theme-shared/src/lib/providers/logo.provider.ts
  3. 1
      npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts
  4. 6
      npm/ng-packs/packages/theme-shared/src/lib/tokens/logo.token.ts
  5. 3
      templates/app-nolayers/angular/src/app/app.config.ts
  6. 3
      templates/app/angular/src/app/app.config.ts

1
npm/ng-packs/packages/theme-shared/src/lib/providers/index.ts

@ -3,3 +3,4 @@ export * from './route.provider';
export * from './tenant-not-found.provider';
export * from './error-handlers.provider';
export * from './theme-shared-config.provider';
export * from './logo.provider';

51
npm/ng-packs/packages/theme-shared/src/lib/providers/logo.provider.ts

@ -0,0 +1,51 @@
import { Environment } from '@abp/ng.core';
import {
EnvironmentProviders,
makeEnvironmentProviders,
Provider,
} from '@angular/core';
import { LOGO_APP_NAME_TOKEN, LOGO_URL_TOKEN } from '../tokens/logo.token';
export enum LpxLogoFeatureKind {
Options,
}
export interface LpxLogoFeature<KindT extends LpxLogoFeatureKind> {
ɵkind: KindT;
ɵproviders: (Provider | EnvironmentProviders)[];
}
function makeLpxLogoFeature<KindT extends LpxLogoFeatureKind>(
kind: KindT,
providers: (Provider | EnvironmentProviders)[],
): LpxLogoFeature<KindT> {
return {
ɵkind: kind,
ɵproviders: providers,
};
}
export function withEnvironmentOptions(
options = {} as Environment,
): LpxLogoFeature<LpxLogoFeatureKind.Options> {
const { name, logoUrl } = options.application || {};
return makeLpxLogoFeature(LpxLogoFeatureKind.Options, [
{
provide: LOGO_URL_TOKEN,
useValue: logoUrl || '',
},
{
provide: LOGO_APP_NAME_TOKEN,
useValue: name || 'ProjectName',
},
]);
}
export function provideLogo(
...features: LpxLogoFeature<LpxLogoFeatureKind>[]
): EnvironmentProviders {
const providers: (Provider | EnvironmentProviders)[] = [];
features.forEach(({ ɵproviders }) => providers.push(...ɵproviders));
return makeEnvironmentProviders(providers);
}

1
npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts

@ -3,3 +3,4 @@ export * from './http-error.token';
export * from './ngx-datatable-messages.token';
export * from './suppress-unsaved-changes-warning.token';
export * from './confirmation-icons.token';
export * from './logo.token';

6
npm/ng-packs/packages/theme-shared/src/lib/tokens/logo.token.ts

@ -0,0 +1,6 @@
import { InjectionToken } from '@angular/core';
export const LOGO_URL_TOKEN = new InjectionToken<string>('LOGO_URL_TOKEN');
export const LOGO_APP_NAME_TOKEN = new InjectionToken<string>(
'LOGO_APP_NAME_TOKEN',
);

3
templates/app-nolayers/angular/src/app/app.config.ts

@ -7,7 +7,7 @@ import { provideAbpCore, withOptions } from '@abp/ng.core';
import { environment } from '../environments/environment';
import { registerLocale } from '@abp/ng.core/locale';
import { provideAbpOAuth } from '@abp/ng.oauth';
import { provideAbpThemeShared } from '@abp/ng.theme.shared';
import { provideAbpThemeShared, provideLogo, withEnvironmentOptions} from '@abp/ng.theme.shared';
import { provideSettingManagementConfig } from '@abp/ng.setting-management/config';
import { provideAccountConfig } from '@abp/ng.account/config';
import { provideIdentityConfig } from '@abp/ng.identity/config';
@ -15,7 +15,6 @@ import { provideTenantManagementConfig } from '@abp/ng.tenant-management/config'
import { provideFeatureManagementConfig } from '@abp/ng.feature-management';
import { provideThemeLeptonX } from '@abp/ng.theme.lepton-x';
import { provideSideMenuLayout } from '@abp/ng.theme.lepton-x/layouts';
import { provideLogo, withEnvironmentOptions } from '@volo/ngx-lepton-x.core';
export const appConfig: ApplicationConfig = {
providers: [

3
templates/app/angular/src/app/app.config.ts

@ -8,7 +8,7 @@ import { provideAbpCore, withOptions } from '@abp/ng.core';
import { environment } from '../environments/environment';
import { registerLocale } from '@abp/ng.core/locale';
import { provideAbpOAuth } from '@abp/ng.oauth';
import { provideAbpThemeShared } from '@abp/ng.theme.shared';
import { provideAbpThemeShared, provideLogo, withEnvironmentOptions} from '@abp/ng.theme.shared';
import { provideSettingManagementConfig } from '@abp/ng.setting-management/config';
import { provideAccountConfig } from '@abp/ng.account/config';
import { provideIdentityConfig } from '@abp/ng.identity/config';
@ -16,7 +16,6 @@ import { provideTenantManagementConfig } from '@abp/ng.tenant-management/config'
import { provideFeatureManagementConfig } from '@abp/ng.feature-management';
import { provideThemeLeptonX } from '@abp/ng.theme.lepton-x';
import { provideSideMenuLayout } from '@abp/ng.theme.lepton-x/layouts';
import { provideLogo, withEnvironmentOptions } from '@volo/ngx-lepton-x.core';
export const appConfig: ApplicationConfig = {
providers: [

Loading…
Cancel
Save