-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenubar-custom.component.ts
More file actions
120 lines (116 loc) · 3.98 KB
/
menubar-custom.component.ts
File metadata and controls
120 lines (116 loc) · 3.98 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
import { Component } from '@angular/core';
import { StoryObj } from '@storybook/angular';
import { Menubar } from 'primeng/menubar';
import { Badge } from 'primeng/badge';
import { NgIf } from '@angular/common';
import { MenuItem, SharedModule } from 'primeng/api';
const template = `
<div class="min-h-[300px]">
<p-menubar [model]="items">
<ng-template pTemplate="item" let-item let-hasSubmenu="hasSubmenu" let-root="root">
<a class="p-menubar-item-link flex items-center gap-2">
<span *ngIf="item.icon" [class]="'p-menubar-item-icon ' + item.icon"></span>
<div class="menubar-item-label">
<span class="p-menubar-item-label">{{ item.label }}</span>
<small *ngIf="item['description']" class="menubar-item-caption">{{ item['description'] }}</small>
</div>
<p-badge *ngIf="item['badge']" [value]="item['badge']"></p-badge>
<span *ngIf="hasSubmenu" [class]="root ? 'p-menubar-submenu-icon ti ti-chevron-down' : 'p-menubar-submenu-icon ti ti-chevron-right'"></span>
</a>
</ng-template>
</p-menubar>
</div>
`;
const styles = '';
@Component({
selector: 'app-menubar-custom',
standalone: true,
imports: [Menubar, Badge, NgIf, SharedModule],
template,
styles,
})
export class MenubarCustomComponent {
items: MenuItem[] = [
{
label: 'Home',
icon: 'ti ti-home',
description: 'Перейти на главную',
},
{
label: 'Features',
icon: 'ti ti-star',
description: 'Explore features',
badge: 'New',
items: [
{
label: 'Core',
icon: 'ti ti-cpu',
description: 'Основные возможности',
},
{
label: 'UI Kit',
icon: 'ti ti-palette',
description: 'UI компоненты',
},
],
},
{
label: 'Settings',
icon: 'ti ti-settings',
description: 'Настройки приложения',
},
];
}
export const Custom: StoryObj = {
render: () => ({
template: `<app-menubar-custom></app-menubar-custom>`,
}),
parameters: {
docs: {
description: { story: 'Кастомный шаблон пункта меню с описанием и бейджем.' },
source: {
language: 'ts',
code: `
import { Component } from '@angular/core';
import { Menubar } from 'primeng/menubar';
import { Badge } from 'primeng/badge';
import { NgIf } from '@angular/common';
import { MenuItem, SharedModule } from 'primeng/api';
@Component({
selector: 'app-menubar-custom',
standalone: true,
imports: [Menubar, Badge, NgIf, SharedModule],
template: \`
<p-menubar [model]="items">
<ng-template pTemplate="item" let-item let-hasSubmenu="hasSubmenu" let-root="root">
<a class="p-menubar-item-link flex items-center gap-2">
<span *ngIf="item.icon" [class]="'p-menubar-item-icon ' + item.icon"></span>
<div class="menubar-item-label">
<span class="p-menubar-item-label">{{ item.label }}</span>
<small *ngIf="item['description']" class="menubar-item-caption">{{ item['description'] }}</small>
</div>
<p-badge *ngIf="item['badge']" [value]="item['badge']"></p-badge>
<span *ngIf="hasSubmenu" [class]="root ? 'p-menubar-submenu-icon ti ti-chevron-down' : 'p-menubar-submenu-icon ti ti-chevron-right'"></span>
</a>
</ng-template>
</p-menubar>
\`,
})
export class MenubarCustomComponent {
items: MenuItem[] = [
{ label: 'Home', icon: 'ti ti-home', description: 'Перейти на главную' },
{
label: 'Features', icon: 'ti ti-star', description: 'Explore features', badge: 'New',
items: [
{ label: 'Core', icon: 'ti ti-cpu', description: 'Основные возможности' },
{ label: 'UI Kit', icon: 'ti ti-palette', description: 'UI компоненты' },
],
},
{ label: 'Settings', icon: 'ti ti-settings', description: 'Настройки приложения' },
];
}
`,
},
},
},
};