Skip to content

Commit 9a421f3

Browse files
author
m2rt
committed
fix(breadcrumbs): migrated from ngFor to new @for loop with proper item tracking #305
also renamed breadcrumbs class and fixed dropdown story typo
1 parent 6ef28bf commit 9a421f3

4 files changed

Lines changed: 39 additions & 50 deletions

File tree

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,38 @@
1-
<nav
2-
*ngIf="this.breakpointInputs().crumbs.length > 0"
3-
aria-label="Breadcrumb"
4-
class="tedi__breadcrumbs"
5-
>
6-
<ol class="tedi__breadcrumbs__list">
7-
<ng-container *ngIf="!this.breakpointInputs().shortCrumbs">
8-
<ng-container
9-
*ngFor="let crumb of this.breakpointInputs().crumbs; let last = last"
10-
>
11-
@if (!last) {
12-
<li class="tedi__breadcrumbs__item">
13-
<a tedi-link [routerLink]="crumb.href" [underline]="false">{{
14-
crumb.label
15-
}}</a>
16-
<tedi-icon color="brand" name="chevron_right" />
17-
</li>
18-
} @else {
19-
<li
20-
aria-current="page"
21-
tedi-text
22-
modifiers="inline-block"
23-
color="secondary"
24-
>
25-
{{ crumb.label }}
26-
</li>
1+
@if (breakpointInputs().crumbs.length > 0) {
2+
<nav aria-label="Breadcrumb" class="tedi-breadcrumbs">
3+
<ol class="tedi-breadcrumbs__list">
4+
@if (!breakpointInputs().shortCrumbs) {
5+
@for (crumb of breakpointInputs().crumbs; track crumb.href; let last = $last) {
6+
@if (!last) {
7+
<li class="tedi-breadcrumbs__item">
8+
<a tedi-link [routerLink]="crumb.href" [underline]="false">{{
9+
crumb.label
10+
}}</a>
11+
<tedi-icon color="brand" name="chevron_right" />
12+
</li>
13+
} @else {
14+
<li
15+
aria-current="page"
16+
tedi-text
17+
modifiers="inline-block"
18+
color="secondary"
19+
>
20+
{{ crumb.label }}
21+
</li>
22+
}
2723
}
28-
</ng-container>
29-
</ng-container>
30-
</ol>
31-
<ng-container
32-
*ngIf="
33-
this.breakpointInputs().crumbs.length > 1 &&
34-
this.breakpointInputs().shortCrumbs
35-
"
36-
>
37-
<div class="tedi__breadcrumbs__item">
38-
<tedi-icon color="brand" name="arrow_back" />
39-
<a
40-
tedi-link
41-
[routerLink]="getSecondLastCrumb()?.href"
42-
[underline]="false"
43-
>{{ getSecondLastCrumb()?.label }}</a
44-
>
45-
</div>
46-
</ng-container>
47-
</nav>
24+
}
25+
</ol>
26+
@if (breakpointInputs().crumbs.length > 1 && breakpointInputs().shortCrumbs) {
27+
<div class="tedi-breadcrumbs__item">
28+
<tedi-icon color="brand" name="arrow_back" />
29+
<a
30+
tedi-link
31+
[routerLink]="getSecondLastCrumb()?.href"
32+
[underline]="false"
33+
>{{ getSecondLastCrumb()?.label }}</a
34+
>
35+
</div>
36+
}
37+
</nav>
38+
}

community/components/navigation/breadcrumbs/breadcrumbs.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
display: block;
33
}
44

5-
.tedi__breadcrumbs {
5+
.tedi-breadcrumbs {
66
&__list {
77
display: flex;
88
flex-wrap: wrap;

community/components/navigation/breadcrumbs/breadcrumbs.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component, computed, inject, input } from "@angular/core";
2-
import { CommonModule } from "@angular/common";
32
import { RouterLink } from "@angular/router";
43
import {
54
IconComponent,
@@ -45,7 +44,6 @@ export type Breadcrumbs = {
4544
selector: "tedi-breadcrumbs",
4645
standalone: true,
4746
imports: [
48-
CommonModule,
4947
RouterLink,
5048
LinkComponent,
5149
IconComponent,

tedi/components/overlay/dropdown/dropdown.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const Default: Story = {
150150
props: args,
151151
template: `
152152
<tedi-dropdown [position]="position" [preventOverflow]="preventOverflow" [appendTo]="appendTo">
153-
<button tedi-button tedi-dropdown-trigger [ariaHasPopuo]="ariaHasPopup">
153+
<button tedi-button tedi-dropdown-trigger [ariaHasPopup]="ariaHasPopup">
154154
Trigger
155155
</button>
156156
<tedi-dropdown-content [dropdownRole]="dropdownRole">

0 commit comments

Comments
 (0)