-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprint_note.tsx
42 lines (38 loc) · 1.22 KB
/
print_note.tsx
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
import { Component, Suspense, createResource } from "solid-js"
import BaseModal from "./base"
import render from "../../core/renderer"
import { LoadingRing } from "../loading"
import Icon from "../icon"
type PrintNoteModalProps = {
onClose: () => any
content: string
}
const PrintNoteModal: Component<PrintNoteModalProps> = (props) => {
let iframeElement: HTMLIFrameElement
const [contentRendered] = createResource(props.content, render)
return (
<BaseModal title="Print Note">
<div class="flex flex-col gap-2">
<Suspense fallback={<LoadingRing />}>
<div class="overflow-y-auto max-h-32 rounded border">
<iframe
class="w-full h-screen"
ref={(el) => iframeElement = el}
srcdoc={contentRendered()}>
</iframe>
</div>
<button
class="btn btn-outline"
onClick={() => iframeElement.contentWindow?.print()}
>
<Icon name="printer" />
Print</button>
</Suspense>
<div class="modal-action">
<button onclick={() => props.onClose()} class="btn" type="button">Close</button>
</div>
</div>
</BaseModal>
)
}
export default PrintNoteModal