Skip to content

Commit

Permalink
feat(addon-doc): support external link in navigation (#7030)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Mar 19, 2024
1 parent 657c6e3 commit 4dbe8ac
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 54 deletions.
162 changes: 109 additions & 53 deletions projects/addon-doc/components/navigation/navigation.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,40 @@
*ngFor="let group of filtered$ | async; let index = index"
[label]="labels[index] || ''"
>
<a
*ngFor="let item of group"
tuiOption
[attr.rel]="item.rel"
[fragment]="item.fragment"
[routerLink]="item.route"
[target]="item.target || '_self'"
(click)="onClick(input)"
>
{{ item.title }}
<tui-svg
*polymorpheusOutlet="item.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>
<ng-container *ngFor="let item of group">
<a
*ngIf="item.route.includes('://'); else internal"
tuiOption
[attr.rel]="item.rel"
[href]="item.route"
[target]="item.target || '_self'"
>
{{ item.title }}
<tui-svg
*polymorpheusOutlet="item.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>

<ng-template #internal>
<a
tuiOption
[attr.rel]="item.rel"
[fragment]="item.fragment"
[routerLink]="item.route"
[target]="item.target || '_self'"
(click)="onClick(input)"
>
{{ item.title }}
<tui-svg
*polymorpheusOutlet="item.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>
</ng-template>
</ng-container>
</tui-opt-group>
</tui-data-list>
</ng-container>
Expand Down Expand Up @@ -78,24 +96,43 @@
let-index="index"
let-item="item"
>
<a
*ngIf="!item.subPages; else subPagesTemplate"
routerLinkActive="t-sublink_active"
tuiLink
class="t-sublink"
[attr.rel]="item.rel"
[routerLink]="item.route"
[target]="item.target || '_self'"
[tuiScrollIntoViewLink]="isActive(item.route)"
(click)="closeMenu()"
>
{{ item.title }}
<tui-svg
*polymorpheusOutlet="item.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>
<ng-container *ngIf="!item.subPages; else subPagesTemplate">
<a
*ngIf="item.route.includes('://'); else internal"
tuiLink
class="t-sublink"
[attr.rel]="item.rel"
[href]="item.route"
[target]="item.target || '_self'"
>
{{ item.title }}
<tui-svg
*polymorpheusOutlet="item.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>

<ng-template #internal>
<a
routerLinkActive="t-sublink_active"
tuiLink
class="t-sublink"
[attr.rel]="item.rel"
[routerLink]="item.route"
[target]="item.target || '_self'"
[tuiScrollIntoViewLink]="isActive(item.route)"
(click)="closeMenu()"
>
{{ item.title }}
<tui-svg
*polymorpheusOutlet="item.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>
</ng-template>
</ng-container>

<ng-template #subPagesTemplate>
<div
Expand Down Expand Up @@ -127,25 +164,44 @@
[expanded]="!!openPagesGroupsArr[index]"
>
<div class="t-section t-section_bordered">
<a
*ngFor="let subPage of $pages(item.subPages)"
routerLinkActive="t-sublink_active"
tuiLink
class="t-sublink t-sublink_small"
[attr.rel]="subPage.rel"
[fragment]="subPage.fragment"
[routerLink]="subPage.route"
[target]="subPage.target || '_self'"
[tuiScrollIntoViewLink]="isActive(subPage.route)"
(click)="closeMenu()"
>
{{ subPage.title }}
<tui-svg
*polymorpheusOutlet="subPage.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>
<ng-container *ngFor="let subPage of $pages(item.subPages)">
<a
*ngIf="subPage.route.includes('://'); else internal"
tuiLink
class="t-sublink t-sublink_small"
[attr.rel]="subPage.rel"
[href]="subPage.route"
[target]="subPage.target || '_self'"
>
{{ subPage.title }}
<tui-svg
*polymorpheusOutlet="subPage.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>

<ng-template #internal>
<a
routerLinkActive="t-sublink_active"
tuiLink
class="t-sublink t-sublink_small"
[attr.rel]="subPage.rel"
[fragment]="subPage.fragment"
[routerLink]="subPage.route"
[target]="subPage.target || '_self'"
[tuiScrollIntoViewLink]="isActive(subPage.route)"
(click)="closeMenu()"
>
{{ subPage.title }}
<tui-svg
*polymorpheusOutlet="subPage.icon as icon"
class="t-icon"
[src]="icon"
></tui-svg>
</a>
</ng-template>
</ng-container>
</div>
</tui-expand>
</div>
Expand Down
3 changes: 2 additions & 1 deletion projects/demo-playwright/tests/demo/get-demo-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function tuiGetDemoPathsForE2E(
.filter(
page =>
!exclusionSection.includes(page.section!) &&
!exclusionRoutes.includes(page.route),
!exclusionRoutes.includes(page.route) &&
!page.route.includes('://'),
)
.map(({route}) => route),
),
Expand Down
7 changes: 7 additions & 0 deletions projects/demo/src/modules/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,13 @@ export const pages: TuiDocPages = [
},
],
},
{
section: 'Components',
title: 'ColorPicker',
keywords: 'color, picker, input, color',
route: 'https://taiga-family.github.io/tui-editor/color-picker',
target: '_blank',
},
{
section: 'Components',
title: 'Island',
Expand Down

0 comments on commit 4dbe8ac

Please sign in to comment.