forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsonExportControls.tsx
More file actions
60 lines (54 loc) 路 1.51 KB
/
Copy pathJsonExportControls.tsx
File metadata and controls
60 lines (54 loc) 路 1.51 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
53
54
55
56
57
58
59
60
'use client';
import { useState } from 'react';
import { downloadAnalyticsJson } from '@/lib/json-export';
export default function JsonExportControls() {
const [prettyPrint, setPrettyPrint] = useState(true);
const [status, setStatus] = useState<string | null>(null);
const handleExport = () => {
downloadAnalyticsJson(prettyPrint);
setStatus(`JSON export downloaded ${prettyPrint ? 'with' : 'without'} pretty printing.`);
window.setTimeout(() => setStatus(null), 1500);
};
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 10 }}>
<label
style={{
display: 'flex',
alignItems: 'center',
gap: 8,
fontSize: 13,
color: '#475569',
}}
>
<input
type="checkbox"
checked={prettyPrint}
onChange={(event) => setPrettyPrint(event.target.checked)}
/>
Pretty print JSON
</label>
<button
type="button"
onClick={handleExport}
style={{
border: 'none',
borderRadius: 999,
background: '#0f766e',
color: '#ffffff',
padding: '12px 18px',
fontSize: 14,
fontWeight: 700,
cursor: 'pointer',
boxShadow: '0 12px 30px rgba(15,118,110,0.20)',
}}
>
Download JSON Export
</button>
{status && (
<span style={{ fontSize: 12, color: '#0f766e' }}>
{status}
</span>
)}
</div>
);
}