-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: implement breadcrumbs (#2552)
- Loading branch information
Showing
26 changed files
with
467 additions
and
406 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
web/projects/ui/src/app/apps/portal/components/header/breadcrumb.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
HostBinding, | ||
inject, | ||
Input, | ||
} from '@angular/core' | ||
import { Breadcrumb } from '../../services/breadcrumbs.service' | ||
import { TuiIconModule, TuiTitleModule } from '@taiga-ui/experimental' | ||
import { | ||
TUI_ANIMATION_OPTIONS, | ||
tuiFadeIn, | ||
tuiWidthCollapse, | ||
} from '@taiga-ui/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'a[headerBreadcrumb]', | ||
template: ` | ||
@if (item.icon?.startsWith('tuiIcon')) { | ||
<tui-icon [icon]="item.icon || ''" /> | ||
} @else if (item.icon) { | ||
<img [style.width.rem]="2" [src]="item.icon" [alt]="item.title" /> | ||
} | ||
<span tuiTitle> | ||
{{ item.title }} | ||
@if (item.subtitle) { | ||
<span tuiSubtitle="">{{ item.subtitle }}</span> | ||
} | ||
</span> | ||
<ng-content /> | ||
`, | ||
styles: [ | ||
` | ||
:host { | ||
display: flex; | ||
align-items: center; | ||
gap: 1rem; | ||
min-width: 1.25rem; | ||
white-space: nowrap; | ||
text-transform: capitalize; | ||
--clip-path: polygon( | ||
calc(100% - 1.75rem) 0%, | ||
calc(100% - 0.875rem) 50%, | ||
100% 100%, | ||
0% 100%, | ||
0.875rem 50%, | ||
0% 0% | ||
); | ||
&:not(.active) { | ||
--clip-path: polygon( | ||
calc(100% - 1.75rem) 0%, | ||
calc(100% - 0.875rem) 50%, | ||
calc(100% - 1.75rem) 100%, | ||
0% 100%, | ||
0.875rem 50%, | ||
0% 0% | ||
); | ||
} | ||
& > * { | ||
font-weight: bold; | ||
gap: 0; | ||
border-radius: 100%; | ||
} | ||
&::before, | ||
&::after { | ||
content: ''; | ||
margin: 0.5rem; | ||
} | ||
&::before { | ||
margin: 0.25rem; | ||
} | ||
} | ||
`, | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [TuiIconModule, TuiTitleModule], | ||
animations: [tuiWidthCollapse, tuiFadeIn], | ||
}) | ||
export class HeaderBreadcrumbComponent { | ||
@Input({ required: true, alias: 'headerBreadcrumb' }) | ||
item!: Breadcrumb | ||
|
||
@HostBinding('@tuiFadeIn') | ||
@HostBinding('@tuiWidthCollapse') | ||
readonly animation = inject(TUI_ANIMATION_OPTIONS) | ||
} |
16 changes: 13 additions & 3 deletions
16
...nts/header/header-connection.component.ts → ...components/header/connection.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
web/projects/ui/src/app/apps/portal/components/header/corner.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { CommonModule } from '@angular/common' | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
HostListener, | ||
inject, | ||
ViewChild, | ||
} from '@angular/core' | ||
import { Router } from '@angular/router' | ||
import { TuiSidebarModule } from '@taiga-ui/addon-mobile' | ||
import { tuiContainsOrAfter, tuiIsElement, TuiLetModule } from '@taiga-ui/cdk' | ||
import { | ||
TuiBadgedContentModule, | ||
TuiBadgeNotificationModule, | ||
TuiButtonModule, | ||
} from '@taiga-ui/experimental' | ||
import { Subject } from 'rxjs' | ||
import { HeaderMenuComponent } from './menu.component' | ||
import { HeaderNotificationsComponent } from './notifications.component' | ||
import { SidebarDirective } from '../../../../app/sidebar-host.component' | ||
import { NotificationService } from '../../services/notification.service' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'header-corner', | ||
template: ` | ||
<ng-content /> | ||
<tui-badged-content | ||
*tuiLet="notificationService.unreadCount$ | async as unread" | ||
[style.--tui-radius.%]="50" | ||
> | ||
<tui-badge-notification *ngIf="unread" tuiSlot="top" size="s"> | ||
{{ unread }} | ||
</tui-badge-notification> | ||
<button | ||
tuiIconButton | ||
iconLeft="tuiIconBellLarge" | ||
appearance="icon" | ||
size="s" | ||
[style.color]="'var(--tui-text-01)'" | ||
(click)="handleNotificationsClick(unread || 0)" | ||
> | ||
Notifications | ||
</button> | ||
</tui-badged-content> | ||
<header-menu></header-menu> | ||
<header-notifications | ||
(onEmpty)="this.open$.next(false)" | ||
*tuiSidebar="!!(open$ | async); direction: 'right'; autoWidth: true" | ||
/> | ||
`, | ||
styles: [ | ||
` | ||
:host { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.25rem; | ||
padding: 0 0.5rem 0 1.75rem; | ||
--clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 1.75rem 100%); | ||
} | ||
`, | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [ | ||
CommonModule, | ||
HeaderMenuComponent, | ||
HeaderNotificationsComponent, | ||
SidebarDirective, | ||
TuiBadgeNotificationModule, | ||
TuiBadgedContentModule, | ||
TuiButtonModule, | ||
TuiLetModule, | ||
TuiSidebarModule, | ||
], | ||
}) | ||
export class HeaderCornerComponent { | ||
private readonly router = inject(Router) | ||
readonly notificationService = inject(NotificationService) | ||
|
||
@ViewChild(HeaderNotificationsComponent, { read: ElementRef }) | ||
private readonly panel?: ElementRef<HTMLElement> | ||
|
||
private readonly _ = this.router.events.subscribe(() => { | ||
this.open$.next(false) | ||
}) | ||
|
||
readonly open$ = new Subject<boolean>() | ||
|
||
@HostListener('document:click.capture', ['$event.target']) | ||
onClick(target: EventTarget | null) { | ||
if ( | ||
tuiIsElement(target) && | ||
this.panel?.nativeElement && | ||
!tuiContainsOrAfter(this.panel.nativeElement, target) | ||
) { | ||
this.open$.next(false) | ||
} | ||
} | ||
|
||
handleNotificationsClick(unread: number) { | ||
if (unread) { | ||
this.open$.next(true) | ||
} else { | ||
this.router.navigateByUrl('/portal/system/notifications') | ||
} | ||
} | ||
} |
Oops, something went wrong.