-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathWithPopper.tsx
More file actions
35 lines (30 loc) · 1.13 KB
/
Copy pathWithPopper.tsx
File metadata and controls
35 lines (30 loc) · 1.13 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
import React from 'react';
import {SecondaryButton} from '@workday/canvas-kit-react/button';
import {Popper} from '@workday/canvas-kit-react/popup';
import {Toast} from '@workday/canvas-kit-react/toast';
import {checkIcon} from '@workday/canvas-system-icons-web';
import {system} from '@workday/canvas-tokens-web';
export const WithPopper = () => {
const [open, setOpen] = React.useState(false);
const containerRef = React.useRef(null);
const handleClose = () => {
setOpen(false);
};
const handleOpen = () => {
setOpen(true);
};
return (
<div ref={containerRef}>
<SecondaryButton onClick={handleOpen}>Show Toast</SecondaryButton>
<Popper placement="bottom-end" open={open} anchorElement={containerRef}>
<Toast mode="dialog" aria-label="notification">
<Toast.Icon icon={checkIcon} color={system.color.brand.fg.positive.default} />
<Toast.Body>
<Toast.Message>Your workbook was successfully processed.</Toast.Message>
</Toast.Body>
<Toast.CloseIcon aria-label="Close notification" onClick={handleClose} />
</Toast>
</Popper>
</div>
);
};