-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtieredmenu-custom.component.ts
More file actions
121 lines (117 loc) · 4.42 KB
/
tieredmenu-custom.component.ts
File metadata and controls
121 lines (117 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { Component } from '@angular/core';
import { StoryObj } from '@storybook/angular';
import { MenuItem } from 'primeng/api';
import { TieredMenu } from 'primeng/tieredmenu';
import { Badge } from 'primeng/badge';
import { NgIf } from '@angular/common';
const template = `
<div class="bg-surface-ground" style="min-height: 280px">
<p-tieredmenu [model]="items">
<ng-template #item let-item let-hasSubmenu="hasSubmenu">
<a class="p-tieredmenu-item-link flex items-center gap-2 w-full">
<span *ngIf="item.icon" [class]="'p-tieredmenu-item-icon ' + item.icon"></span>
<div class="p-tieredmenu-item-caption flex-1">
<span class="p-tieredmenu-item-label">{{ item.label }}</span>
<small *ngIf="item['description']" class="p-tieredmenu-item-caption-text">{{ item['description'] }}</small>
</div>
<p-badge *ngIf="item['badge']" [value]="item['badge']"></p-badge>
<span *ngIf="hasSubmenu" class="p-tieredmenu-submenu-icon ti ti-chevron-right"></span>
</a>
</ng-template>
</p-tieredmenu>
</div>
`;
const styles = '';
@Component({
selector: 'app-tieredmenu-custom',
standalone: true,
imports: [TieredMenu, Badge, NgIf],
template,
styles,
})
export class TieredMenuCustomComponent {
items: MenuItem[] = [
{
label: 'Дашборд',
icon: 'ti ti-home',
description: 'Перейти на главную',
},
{
label: 'Отправления',
icon: 'ti ti-package',
description: 'Управление заказами',
badge: 'New',
items: [
{ label: 'Активные', icon: 'ti ti-circle-check', description: 'Текущие заказы' },
{ label: 'Архив', icon: 'ti ti-archive', description: 'Завершённые заказы' },
],
},
{
label: 'Склады',
icon: 'ti ti-building-warehouse',
description: 'Складское хранение',
items: [
{ label: 'Документы', icon: 'ti ti-file-text', description: 'Накладные и акты' },
{ label: 'Фото', icon: 'ti ti-photo', description: 'Фотофиксация грузов' },
],
},
{
label: 'Настройки',
icon: 'ti ti-settings',
description: 'Параметры системы',
disabled: true,
},
];
}
export const Custom: StoryObj = {
render: () => ({
template: `<app-tieredmenu-custom></app-tieredmenu-custom>`,
}),
parameters: {
docs: {
description: { story: 'Кастомный шаблон пункта меню с описанием и бейджем.' },
source: {
language: 'ts',
code: `
import { Component } from '@angular/core';
import { MenuItem } from 'primeng/api';
import { TieredMenu } from 'primeng/tieredmenu';
import { Badge } from 'primeng/badge';
import { NgIf } from '@angular/common';
@Component({
selector: 'app-tieredmenu-custom',
standalone: true,
imports: [TieredMenu, Badge, NgIf],
template: \`
<p-tieredmenu [model]="items">
<ng-template #item let-item let-hasSubmenu="hasSubmenu">
<a class="p-tieredmenu-item-link flex items-center gap-2 w-full">
<span *ngIf="item.icon" [class]="'p-tieredmenu-item-icon ' + item.icon"></span>
<div class="p-tieredmenu-item-caption flex-1">
<span class="p-tieredmenu-item-label">{{ item.label }}</span>
<small *ngIf="item['description']" class="p-tieredmenu-item-caption-text">{{ item['description'] }}</small>
</div>
<p-badge *ngIf="item['badge']" [value]="item['badge']"></p-badge>
<span *ngIf="hasSubmenu" class="p-tieredmenu-submenu-icon ti ti-chevron-right"></span>
</a>
</ng-template>
</p-tieredmenu>
\`,
})
export class TieredMenuCustomComponent {
items: MenuItem[] = [
{ label: 'Дашборд', icon: 'ti ti-home', description: 'Перейти на главную' },
{ label: 'Отправления', icon: 'ti ti-package', description: 'Управление заказами', badge: 'New',
items: [
{ label: 'Активные', icon: 'ti ti-circle-check', description: 'Текущие заказы' },
{ label: 'Архив', icon: 'ti ti-archive', description: 'Завершённые заказы' },
],
},
{ label: 'Настройки', icon: 'ti ti-settings', description: 'Параметры системы', disabled: true },
];
}
`,
},
},
},
};