-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.tsx
More file actions
66 lines (57 loc) · 1.97 KB
/
Copy pathApp.tsx
File metadata and controls
66 lines (57 loc) · 1.97 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
import { useCallback } from 'react';
import './App.css';
import 'devextreme/dist/css/dx.light.css';
import Toolbar, { Item } from 'devextreme-react/toolbar';
import type { ToolbarTypes } from 'devextreme-react/toolbar';
import type { ButtonTypes } from 'devextreme-react/button';
import notify from 'devextreme/ui/notify';
// DevExtreme types for toolbar buttons
type ToolbarButtonProperties = ButtonTypes.Properties;
const buttonOptions: ToolbarButtonProperties = {
text: 'Back',
stylingMode: 'text',
type: 'back',
};
const saveButtonOptions: ToolbarButtonProperties = {
text: 'Save',
type: 'default',
};
const printButtonOptions: ToolbarButtonProperties = {
text: 'Print',
type: 'default',
};
const refreshButtonOptions: ToolbarButtonProperties = {
icon: 'refresh',
type: 'default',
};
function App(): JSX.Element {
const showMessage = useCallback((message: string) => {
notify(message, 'info', 2000);
}, []);
const handleItemClick = useCallback((e: ToolbarTypes.ItemClickEvent) => {
const itemData = e.itemData;
if (itemData?.options?.text) {
showMessage(`${itemData.options.text} clicked`);
} else if (itemData?.options?.icon) {
showMessage(`${itemData.options.icon} clicked`);
} else if (itemData?.text) {
showMessage(`${itemData.text} clicked`);
}
}, [showMessage]);
return (
<div id="container">
<Toolbar onItemClick={handleItemClick}>
<Item location="before" widget="dxButton" options={buttonOptions} />
<Item location="after" text="Products" />
<Item location="after" widget="dxButton" options={saveButtonOptions} />
<Item location="after" widget="dxButton" options={printButtonOptions} />
<Item location="after" widget="dxButton" options={refreshButtonOptions} />
</Toolbar>
<div id="greeting">
<h1>Getting Started with DevExtreme React Toolbar</h1>
<p>Click toolbar items to see notifications.</p>
</div>
</div>
);
}
export default App;