-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanelmenu-custom.component.ts
More file actions
134 lines (130 loc) · 5.07 KB
/
panelmenu-custom.component.ts
File metadata and controls
134 lines (130 loc) · 5.07 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
122
123
124
125
126
127
128
129
130
131
132
133
134
import { Component } from '@angular/core';
import { StoryObj } from '@storybook/angular';
import { MenuItem } from 'primeng/api';
import { PanelMenu } from 'primeng/panelmenu';
import { Badge } from 'primeng/badge';
import { NgIf, NgClass } from '@angular/common';
const template = `
<div class="bg-surface-ground" style="width: 300px">
<p-panelmenu [model]="items" [multiple]="true">
<ng-template #item let-item let-props="props" let-hasSubmenu="hasSubmenu">
<a [attr.href]="item.url" [attr.target]="item.target" v-bind="props?.action" class="p-panelmenu-item-link flex items-center gap-2 w-full">
<span *ngIf="item.icon" [class]="'p-panelmenu-item-icon ' + item.icon"></span>
<div class="panelmenu-item-label flex-1">
<span class="p-panelmenu-item-label">{{ item.label }}</span>
<small *ngIf="item['description']" class="panelmenu-item-caption">{{ item['description'] }}</small>
</div>
<p-badge *ngIf="item['badge']" [value]="item['badge']"></p-badge>
<span *ngIf="hasSubmenu" class="p-panelmenu-submenu-icon ti ti-chevron-right"></span>
</a>
</ng-template>
</p-panelmenu>
</div>
`;
const styles = '';
@Component({
selector: 'app-panelmenu-custom',
standalone: true,
imports: [PanelMenu, Badge, NgIf, NgClass],
template,
styles,
})
export class PanelMenuCustomComponent {
items: MenuItem[] = [
{
label: 'Дашборд',
icon: 'ti ti-layout-dashboard',
description: 'Главная страница',
items: [
{ label: 'Аналитика', icon: 'ti ti-chart-line', description: 'Аналитика данных' },
{ label: 'Отчёты', icon: 'ti ti-file-analytics', description: 'Сводные отчёты' },
{ label: 'Статистика', icon: 'ti ti-chart-bar', description: 'Показатели доставки' },
],
},
{
label: 'Отправления',
icon: 'ti ti-package',
description: 'Управление заказами',
badge: 'New',
},
{
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-panelmenu-custom></app-panelmenu-custom>`,
}),
parameters: {
docs: {
description: { story: 'Кастомный шаблон пункта меню с описанием и бейджем.' },
source: {
language: 'ts',
code: `
import { Component } from '@angular/core';
import { MenuItem } from 'primeng/api';
import { PanelMenu } from 'primeng/panelmenu';
import { Badge } from 'primeng/badge';
import { NgIf } from '@angular/common';
@Component({
selector: 'app-panelmenu-custom',
standalone: true,
imports: [PanelMenu, Badge, NgIf],
template: \`
<p-panelmenu [model]="items" [multiple]="true">
<ng-template #item let-item let-props="props" let-hasSubmenu="hasSubmenu">
<a class="p-panelmenu-item-link flex items-center gap-2 w-full">
<span *ngIf="item.icon" [class]="'p-panelmenu-item-icon ' + item.icon"></span>
<div class="panelmenu-item-label flex-1">
<span class="p-panelmenu-item-label">{{ item.label }}</span>
<small *ngIf="item['description']" class="panelmenu-item-caption">{{ item['description'] }}</small>
</div>
<p-badge *ngIf="item['badge']" [value]="item['badge']"></p-badge>
<span *ngIf="hasSubmenu" class="p-panelmenu-submenu-icon ti ti-chevron-right"></span>
</a>
</ng-template>
</p-panelmenu>
\`,
})
export class PanelMenuCustomComponent {
items: MenuItem[] = [
{
label: 'Дашборд',
icon: 'ti ti-layout-dashboard',
description: 'Главная страница',
items: [
{ label: 'Аналитика', icon: 'ti ti-chart-line', description: 'Аналитика данных' },
{ label: 'Отчёты', icon: 'ti ti-file-analytics', description: 'Сводные отчёты' },
],
},
{ label: 'Отправления', icon: 'ti ti-package', description: 'Управление заказами', badge: 'New' },
{
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 },
];
}
`,
},
},
},
};