forked from refined-github/refined-github
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotice-bar.tsx
More file actions
31 lines (29 loc) · 756 Bytes
/
notice-bar.tsx
File metadata and controls
31 lines (29 loc) · 756 Bytes
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
import React from 'dom-chef';
import XIcon from 'octicons-plain-react/X';
import elementReady from 'element-ready';
type Options = {
action?: Element | false;
type?: 'success' | 'notice' | 'warn' | 'error';
};
/** https://primer.style/css/components/alerts */
export default async function addNotice(
message: string | Node | Array<string | Node>,
{
type = 'notice',
action = (
<button className="flash-close js-flash-close" type="button" aria-label="Dismiss this message">
<XIcon/>
</button>
),
}: Options = {},
): Promise<void> {
const container = await elementReady('#js-flash-container');
container!.append(
<div className={`flash flash-full flash-${type} px-4`}>
{action}
<div>
{message}
</div>
</div>,
);
}