Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo): move version manager to header
Browse files Browse the repository at this point in the history
splincode committed Sep 26, 2024
1 parent 329a782 commit 016eb15
Showing 5 changed files with 24 additions and 33 deletions.
5 changes: 0 additions & 5 deletions projects/demo/src/modules/app/app.style.less
Original file line number Diff line number Diff line change
@@ -32,11 +32,6 @@ app {
}
}

.app-selects {
padding: 0.25rem 0.125rem 0.5rem 0.75rem;
box-shadow: 0 -1px var(--tui-border-normal);
}

@media @tui-mobile {
.app-link {
display: none;
10 changes: 2 additions & 8 deletions projects/demo/src/modules/app/app.template.html
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
class="app-christmas"
/>

<version-manager />

<tui-algolia-search />

<button
@@ -113,14 +115,6 @@
[href]="playground"
></a>
</div>
<div
ngProjectAs="tuiDocNavigation"
tuiTextfieldAppearance="none"
tuiTextfieldSize="m"
class="app-selects"
>
<version-manager>Version</version-manager>
</div>
<tui-sheets-host ngProjectAs="tuiOverContent" />
<custom-host ngProjectAs="tuiOverContent" />
</tui-doc-main>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {NgForOf, NgIf} from '@angular/common';
import {NgForOf} from '@angular/common';
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {Router} from '@angular/router';
import {WA_LOCATION} from '@ng-web-apis/common';
import {tuiPure} from '@taiga-ui/cdk';
import {TuiDataList} from '@taiga-ui/core';
import {TuiStringifyContentPipe, TuiStringifyPipe} from '@taiga-ui/kit';
import {TuiButton, TuiDataList} from '@taiga-ui/core';
import {TuiChevron} from '@taiga-ui/kit';
import {TuiSelectModule} from '@taiga-ui/legacy';

import {TUI_SELECTED_VERSION_META} from './version-manager.providers';
@@ -15,15 +15,7 @@ import {TUI_VERSIONS_META_OPTIONS} from './versions.constants';
@Component({
standalone: true,
selector: 'version-manager',
imports: [
FormsModule,
NgForOf,
NgIf,
TuiDataList,
TuiSelectModule,
TuiStringifyContentPipe,
TuiStringifyPipe,
],
imports: [FormsModule, NgForOf, TuiButton, TuiChevron, TuiDataList, TuiSelectModule],
templateUrl: './version-manager.template.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
@@ -32,6 +24,7 @@ export class VersionManager {
private readonly router = inject(Router);
protected readonly initialVersion = inject(TUI_SELECTED_VERSION_META);
protected readonly versions = inject(TUI_VERSIONS_META_OPTIONS);
protected open = false;

@tuiPure
protected getVersionHref(version: TuiVersionMeta): string {
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<tui-select
*ngIf="versions.length"
[ngModel]="initialVersion"
[valueContent]="'label' | tuiStringify | tuiStringifyContent"
<button
appearance="whiteblock"
size="s"
tuiButton
tuiChevron
type="button"
[tuiDropdown]="content"
[tuiDropdownLimitWidth]="'fixed'"
[tuiDropdownMaxHeight]="700"
[(tuiDropdownOpen)]="open"
>
<ng-content />
<tui-data-list *tuiDataList>
{{ initialVersion?.label }}
</button>

<ng-template #content>
<tui-data-list size="s">
<a
*ngFor="let version of versions"
tuiOption
@@ -14,4 +23,4 @@
{{ version.label }}
</a>
</tui-data-list>
</tui-select>
</ng-template>
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ export const TUI_VERSIONS_META: readonly TuiVersionMeta[] = [
title: `v${TUI_CURRENT_MAJOR_VERSION}.next`,
},
{
label: `latest (v${TUI_VERSION})`,
label: `v${TUI_VERSION}`,
baseHref: '/',
title: `v${TUI_CURRENT_MAJOR_VERSION}`,
},

0 comments on commit 016eb15

Please sign in to comment.