Skip to content

Commit

Permalink
chore(demo): correct version list
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Sep 26, 2024
1 parent e5178bf commit e4108ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
12 changes: 2 additions & 10 deletions projects/demo/src/modules/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {distinctUntilChanged, filter, map, takeUntil} from 'rxjs/operators';

import {AbstractDemoComponent, DEMO_PAGE_LOADED_PROVIDER} from './abstract.app';
import {YaMetrikaService} from './metrika/metrika.service';
import {
TUI_SELECTED_VERSION_META,
TUI_VERSION_MANAGER_PROVIDERS,
} from './version-manager/version-manager.providers';
import {TUI_SELECTED_VERSION_META} from './version-manager/version-manager.providers';
import {TuiVersionMeta} from './version-manager/versions.constants';

@Component({
Expand All @@ -22,12 +19,7 @@ import {TuiVersionMeta} from './version-manager/versions.constants';
styleUrls: ['./app.style.less'],
encapsulation: ViewEncapsulation.None,
changeDetection,
providers: [
TuiResizeService,
TuiDestroyService,
DEMO_PAGE_LOADED_PROVIDER,
TUI_VERSION_MANAGER_PROVIDERS,
],
providers: [TuiResizeService, TuiDestroyService, DEMO_PAGE_LOADED_PROVIDER],
})
export class AppComponent extends AbstractDemoComponent implements OnInit {
readonly isLanding$ = this.router.events.pipe(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import {DOCUMENT} from '@angular/common';
import {InjectionToken, Provider} from '@angular/core';
import {TUI_BASE_HREF} from '@taiga-ui/cdk';
import {InjectionToken} from '@angular/core';

import {TUI_VERSIONS_META_MAP, TuiVersionMeta} from './versions.constants';

export const TUI_SELECTED_VERSION_META = new InjectionToken<TuiVersionMeta | null>(
'[TUI_SELECTED_VERSION_META]: Meta information about selected version of Taiga docs',
);

export const TUI_VERSION_MANAGER_PROVIDERS: Provider[] = [
{
provide: TUI_SELECTED_VERSION_META,
deps: [TUI_BASE_HREF, DOCUMENT],
useFactory: (baseHref: string, doc: Document): TuiVersionMeta | null => {
const base = baseHref.replace(doc.location.origin, '');

return (
TUI_VERSIONS_META_MAP.get(base) ?? TUI_VERSIONS_META_MAP.get('/') ?? null
);
},
factory: () => TUI_VERSIONS_META_MAP.get('/v3/') || null,
},
];
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ export interface TuiVersionMeta {
title: string;
}

export const TUI_CURRENT_MAJOR_VERSION = parseInt(TUI_VERSION, 10);

export const TUI_VERSIONS_META: readonly TuiVersionMeta[] = [
{
label: 'next',
baseHref: '/next/',
title: `v${TUI_CURRENT_MAJOR_VERSION}.next`,
label: 'v4',
baseHref: '/',
title: 'v4',
},
{
label: `latest (v${TUI_VERSION})`,
baseHref: '/',
title: `v${TUI_CURRENT_MAJOR_VERSION}`,
label: `v${TUI_VERSION} (lts)`,
baseHref: '/v3/',
title: 'v3',
},
{
label: 'v2',
Expand Down

0 comments on commit e4108ee

Please sign in to comment.