forked from patternfly/widgetized-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithoutDrawerExample.tsx
More file actions
142 lines (133 loc) · 4.14 KB
/
WithoutDrawerExample.tsx
File metadata and controls
142 lines (133 loc) · 4.14 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
135
136
137
138
139
140
141
import React from 'react';
import WidgetLayout from '../../../src/WidgetLayout/WidgetLayout';
import { WidgetMapping, ExtendedTemplateConfig } from '../../../src/WidgetLayout/types';
import { CubeIcon, ChartLineIcon, BellIcon, ExternalLinkAltIcon, ArrowRightIcon } from '@patternfly/react-icons';
import { Card, CardBody, CardFooter, Content, Icon } from '@patternfly/react-core';
interface SimpleWidgetProps {
id: number;
body: string;
linkTitle: string;
url: string;
isExternal?: boolean;
}
const CardExample: React.FunctionComponent<SimpleWidgetProps> = (props) => (
<Card isPlain>
<CardBody className="pf-v6-u-p-md pf-v6-u-pb-0">
<Content
key={props.id}
className="pf-v6-u-display-flex pf-v6-u-flex-direction-column"
>
<Content component="p" className="pf-v6-u-flex-grow-1">
{props.body}
</Content>
</Content>
</CardBody>
<CardFooter className="pf-v6-u-p-md">
{props.isExternal ? (
<a href={props.url}>
{props.linkTitle}
<Icon className="pf-v6-u-ml-sm" isInline>
<ExternalLinkAltIcon />
</Icon>
</a>
) : (
<a href={props.url}>
{props.linkTitle}
<Icon className="pf-v6-u-ml-sm" isInline>
<ArrowRightIcon />
</Icon>
</a>
)}
</CardFooter>
</Card>
);
// Example widget content components
const ExampleWidget1 = () => (
<CardExample
id={1}
body="This is the content of the first example widget. You can put any React content here!"
linkTitle="View details"
url="https://www.patternfly.org"
isExternal={true}
/>
);
const ExampleWidget2 = () => (
<CardExample
id={2}
body="Chart and visualization content would be displayed here."
linkTitle="View full report"
url="#"
isExternal={false}
/>
);
const ExampleWidget3 = () => (
<CardExample
id={3}
body="Recent notifications and updates will appear in this widget."
linkTitle="View all notifications"
url="#"
isExternal={false}
/>
);
// Define widget mapping
const widgetMapping: WidgetMapping = {
'example-widget-1': {
defaults: { w: 2, h: 3, maxH: 6, minH: 2 },
config: {
title: 'Example Widget',
icon: <CubeIcon />,
headerLink: {
title: 'View details',
href: '#'
}
},
renderWidget: () => <ExampleWidget1 />
},
'chart-widget': {
defaults: { w: 2, h: 4, maxH: 8, minH: 3 },
config: {
title: 'Chart Widget',
icon: <ChartLineIcon />
},
renderWidget: () => <ExampleWidget2 />
},
'notifications-widget': {
defaults: { w: 1, h: 3, maxH: 6, minH: 2 },
config: {
title: 'Notification Widget',
icon: <BellIcon />
},
renderWidget: () => <ExampleWidget3 />
}
};
// Define initial template
const initialTemplate: ExtendedTemplateConfig = {
xl: [
{ i: 'example-widget-1#1', x: 0, y: 0, w: 2, h: 3, widgetType: 'example-widget-1', title: 'Example Widget' },
{ i: 'chart-widget#1', x: 2, y: 0, w: 2, h: 4, widgetType: 'chart-widget', title: 'Chart Widget' }
],
lg: [
{ i: 'example-widget-1#1', x: 0, y: 0, w: 2, h: 3, widgetType: 'example-widget-1', title: 'Example Widget' },
{ i: 'chart-widget#1', x: 0, y: 3, w: 2, h: 4, widgetType: 'chart-widget', title: 'Chart Widget' }
],
md: [
{ i: 'example-widget-1#1', x: 0, y: 0, w: 2, h: 3, widgetType: 'example-widget-1', title: 'Example Widget' },
{ i: 'chart-widget#1', x: 0, y: 3, w: 2, h: 4, widgetType: 'chart-widget', title: 'Chart Widget' }
],
sm: [
{ i: 'example-widget-1#1', x: 0, y: 0, w: 1, h: 3, widgetType: 'example-widget-1', title: 'Example Widget' },
{ i: 'chart-widget#1', x: 0, y: 3, w: 1, h: 4, widgetType: 'chart-widget', title: 'Chart Widget' }
]
};
export const WithoutDrawerExample: React.FunctionComponent = () => (
<div style={{ height: '600px', width: '100%', overflow: 'auto', position: 'relative', isolation: 'isolate' }}>
<WidgetLayout
widgetMapping={widgetMapping}
initialTemplate={initialTemplate}
showDrawer={false}
onTemplateChange={(_newTemplate) => {
// Template changes can be saved here
}}
/>
</div>
);