-
Notifications
You must be signed in to change notification settings - Fork 604
Expand file tree
/
Copy pathprerender.jsx
More file actions
52 lines (46 loc) · 1.23 KB
/
prerender.jsx
File metadata and controls
52 lines (46 loc) · 1.23 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
/* @flow */
/** @jsx node */
import { type RenderOptionsType } from "@krakenjs/zoid/src";
import { node, dom } from "@krakenjs/jsx-pragmatic/src";
import { SpinnerPage } from "@paypal/common-components/src";
import { getCSPNonce } from "@paypal/sdk-client/src";
import { type QRCodeProps } from "./types";
export function prerenderTemplate({
doc,
close,
}: RenderOptionsType<QRCodeProps>): ?HTMLElement {
const cspNonce = __WEB__ ? getCSPNonce() : undefined;
const style = `
#close {
position: absolute;
right: 16px;
top: 16px;
width: 16px;
height: 16px;
opacity: 0.6;
z-index: 100;
}
#close:hover {
opacity: 1;
}
#close:before, #close:after {
position: absolute;
left: 8px;
content: ' ';
height: 20px;
width: 2px;
background-color: #FFF;
}
#close:before {
transform: rotate(45deg);
}
#close:after {
transform: rotate(-45deg);
}
`;
const children = [
<style nonce={cspNonce} innerHTML={style} />,
<a href="#" id="close" aria-label="close" role="button" onClick={close} />,
];
return new SpinnerPage({ nonce: cspNonce }, children).render(dom({ doc }));
}