Skip to content

Commit 320bd26

Browse files
Add stories for the ng-wireframe components
1 parent bc07e5a commit 320bd26

31 files changed

Lines changed: 1113 additions & 0 deletions
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { componentWrapperDecorator, Meta, moduleMetadata, StoryObj } from '@storybook/angular'
2+
import { CommonModule } from '@angular/common'
3+
import { LeftSidenavComponent } from './left-sidenav.component'
4+
import { NavigationItem } from '../navigation-item/navigation-item.model'
5+
import { TranslateModule } from '@ngx-translate/core'
6+
7+
const meta: Meta<LeftSidenavComponent> = {
8+
title: 'Components/LeftSidenav',
9+
component: LeftSidenavComponent,
10+
tags: ['autodocs'],
11+
decorators: [
12+
moduleMetadata({
13+
imports: [CommonModule, TranslateModule.forRoot()]
14+
}),
15+
componentWrapperDecorator(
16+
(story) => `<div style="background-color: #18428c; height: 100vh; width: 250px;">${story}</div>`
17+
)
18+
]
19+
}
20+
21+
export default meta
22+
type Story = StoryObj<LeftSidenavComponent>
23+
24+
const navigationItems: Array<NavigationItem> = [
25+
{
26+
label: 'Dashboard',
27+
icon: 'fa-solid fa-house',
28+
fullRouterPath: '/dashboard'
29+
},
30+
{
31+
label: 'Settings',
32+
icon: 'fa-solid fa-gear',
33+
children: [
34+
{
35+
label: 'Profile',
36+
icon: 'fa-solid fa-user',
37+
fullRouterPath: '/settings/profile'
38+
},
39+
{
40+
label: 'Security',
41+
icon: 'fa-solid fa-lock',
42+
fullRouterPath: '/settings/security'
43+
}
44+
]
45+
},
46+
{
47+
label: 'External Link',
48+
icon: 'fa-solid fa-globe',
49+
fullRouterPath: 'https://storybook.js.org',
50+
isExternalLink: true
51+
}
52+
]
53+
54+
export const Default: Story = {
55+
args: {
56+
navigationItems,
57+
showMenuCloseButton: true,
58+
logoUrl: '/assets/ppwcode_logo.png',
59+
logoHeight: 60,
60+
logoWidth: 60,
61+
centerLogo: true
62+
}
63+
}
64+
65+
export const NoLogo: Story = {
66+
args: {
67+
navigationItems,
68+
showMenuCloseButton: true
69+
}
70+
}
71+
72+
export const ManyItems: Story = {
73+
args: {
74+
navigationItems: [...navigationItems, ...navigationItems, ...navigationItems],
75+
showMenuCloseButton: true
76+
}
77+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Meta, StoryObj } from '@storybook/angular'
2+
import { createPagedEntitiesMock } from '@ppwcode/ng-async'
3+
import { PaginationBarComponent } from './pagination-bar.component'
4+
5+
const meta: Meta<PaginationBarComponent> = {
6+
title: 'Components/PaginationBar',
7+
component: PaginationBarComponent,
8+
tags: ['autodocs'],
9+
render: (args) => ({
10+
props: args
11+
})
12+
}
13+
14+
export default meta
15+
type Story = StoryObj<PaginationBarComponent>
16+
17+
const mockEntities = createPagedEntitiesMock(new Array(100).fill({}))
18+
mockEntities.pageSize = 10
19+
mockEntities.pageIndex = 1
20+
mockEntities.page = 1
21+
mockEntities.totalCount = 100
22+
23+
export const Default: Story = {
24+
args: {
25+
pagedAsyncResult: mockEntities,
26+
hidePageSize: false,
27+
showFirstLastButtons: true,
28+
pageSizeOptions: [5, 10, 25, 50]
29+
}
30+
}
31+
32+
export const HidePageSize: Story = {
33+
args: {
34+
pagedAsyncResult: mockEntities,
35+
hidePageSize: true
36+
}
37+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular'
2+
import { ToolbarComponent } from './toolbar.component'
3+
import { Router } from '@angular/router'
4+
import { of } from 'rxjs'
5+
6+
const meta: Meta<ToolbarComponent> = {
7+
title: 'Components/Toolbar',
8+
component: ToolbarComponent,
9+
tags: ['autodocs'],
10+
decorators: [
11+
moduleMetadata({
12+
providers: [
13+
{
14+
provide: Router,
15+
useValue: {
16+
events: of(),
17+
routerState: {
18+
snapshot: {
19+
root: {
20+
firstChild: null,
21+
title: 'Page Title'
22+
}
23+
}
24+
}
25+
}
26+
}
27+
]
28+
})
29+
]
30+
}
31+
32+
export default meta
33+
type Story = StoryObj<ToolbarComponent>
34+
35+
export const Default: Story = {
36+
args: {
37+
showMenuToggle: true,
38+
isSidenavOpen: true,
39+
showPageTitle: true,
40+
toolbarHeightPx: 64
41+
}
42+
}
43+
44+
export const SidenavClosed: Story = {
45+
args: {
46+
showMenuToggle: true,
47+
isSidenavOpen: false,
48+
showPageTitle: true
49+
}
50+
}
51+
52+
export const NoTitle: Story = {
53+
args: {
54+
showMenuToggle: true,
55+
isSidenavOpen: true,
56+
showPageTitle: false
57+
}
58+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import { componentWrapperDecorator, Meta, moduleMetadata, StoryObj } from '@storybook/angular'
2+
import { WireframeComponent } from './wireframe.component'
3+
import { ActivatedRoute, Router, RouterLink, RouterOutlet } from '@angular/router'
4+
import { of } from 'rxjs'
5+
import { BREADCRUMB_PROVIDER_OPTIONS, BreadcrumbService } from '@ppwcode/ng-router'
6+
import { CommonModule } from '@angular/common'
7+
import { MatSidenavModule } from '@angular/material/sidenav'
8+
import { MatIconModule } from '@angular/material/icon'
9+
import { LeftSidenavComponent } from '../left-sidenav/left-sidenav.component'
10+
import { ToolbarComponent } from '../toolbar/toolbar.component'
11+
import { signal } from '@angular/core'
12+
import { TranslateModule } from '@ngx-translate/core'
13+
14+
const meta: Meta<WireframeComponent> = {
15+
title: 'Components/Wireframe',
16+
component: WireframeComponent,
17+
tags: ['autodocs'],
18+
parameters: {
19+
layout: 'fullscreen',
20+
docs: {
21+
story: {
22+
iframeHeight: 600
23+
}
24+
}
25+
},
26+
decorators: [
27+
moduleMetadata({
28+
imports: [
29+
CommonModule,
30+
MatSidenavModule,
31+
MatIconModule,
32+
RouterLink,
33+
RouterOutlet,
34+
LeftSidenavComponent,
35+
ToolbarComponent,
36+
TranslateModule.forRoot()
37+
],
38+
providers: [
39+
{
40+
provide: Router,
41+
useValue: {
42+
events: of(),
43+
routerState: {
44+
snapshot: {
45+
root: {
46+
firstChild: null,
47+
data: { showWireframe: true },
48+
url: [],
49+
pathFromRoot: []
50+
}
51+
}
52+
}
53+
}
54+
},
55+
{
56+
provide: ActivatedRoute,
57+
useValue: {
58+
snapshot: {
59+
data: { showWireframe: true }
60+
}
61+
}
62+
},
63+
{
64+
provide: BreadcrumbService,
65+
useValue: {
66+
breadcrumbs: signal([])
67+
}
68+
},
69+
{
70+
provide: BREADCRUMB_PROVIDER_OPTIONS,
71+
useValue: { preferLabelFromRouteData: false, enableAnimations: true }
72+
}
73+
]
74+
}),
75+
componentWrapperDecorator((story) => `<div style="height: 600px">${story}</div>`)
76+
]
77+
}
78+
79+
export default meta
80+
type Story = StoryObj<WireframeComponent>
81+
82+
const navigationItems = [
83+
{
84+
label: 'Dashboard',
85+
icon: 'fa-solid fa-house',
86+
fullRouterPath: '/dashboard'
87+
},
88+
{
89+
label: 'Users',
90+
icon: 'fa-solid fa-users',
91+
fullRouterPath: '/users'
92+
}
93+
]
94+
95+
export const Default: Story = {
96+
args: {
97+
navigationItems,
98+
sidebarOptions: {
99+
logoUrl: '/assets/ppwcode_logo.png',
100+
logoHeight: 60,
101+
logoWidth: 60,
102+
showPageTitle: true
103+
},
104+
toolbarHeightPx: 64,
105+
showBreadcrumb: true
106+
}
107+
}
108+
109+
export const NoNavigation: Story = {
110+
args: {
111+
navigationItems: [],
112+
hideSidenavWhenNoNavigationItems: true,
113+
sidebarOptions: {
114+
showPageTitle: true
115+
},
116+
showBreadcrumb: true
117+
}
118+
}

0 commit comments

Comments
 (0)