blob: 0b6af2936b753c18bb6c73bde43a2836a1695204 (
plain) (
blame)
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 '@primer/octicons-react';
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>,
);
}
|