-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.html
More file actions
177 lines (171 loc) · 7.14 KB
/
index.html
File metadata and controls
177 lines (171 loc) · 7.14 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form Renderer with React</title>
<style>
textarea {
width: 100%;
height: 100px;
}
</style>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://form-builder.aidbox.app/static/aidbox-forms-renderer-webcomponent.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@babel/standalone@7.25.7/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel" data-presets="env,react">
function App() {
const questionnaires = [
{
"title": "Harris Hip Score panel",
"id": "100283-1"
},
{
"title": "Meat allergen panel",
"id": "100751-7"
},
{
"title": "Schmid fall risk",
"id": "101549-4"
},
];
const [id, setId] = React.useState(questionnaires[0].id);
const [sidebarOpen, setSidebarOpen] = React.useState(false);
const [config, setConfig] = React.useState({
theme: {
button: {
"accent-color": "#e34001", // General accent color for buttons
},
}
});
return (
<div className="flex flex-col h-screen w-full">
<header
className="sticky top-0 z-20 flex flex-shrink-0 h-16 w-full items-center justify-between bg-white px-4 shadow-sm md:px-6">
<nav className="flex items-center gap-6">
<button
className={`md:hidden text-2xl h-8 w-8 grid place-items-center leading-none rounded-full ${sidebarOpen ? 'bg-gray-200' : ''}`}
onClick={() => setSidebarOpen(!sidebarOpen)}>
<div className="-mt-1.5">
☰
</div>
</button>
<a href="#" className="flex items-center gap-2 text-lg font-semibold md:text-base">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="h-6 w-6"
>
<path d="M12 6v4"></path>
<path d="M14 14h-4"></path>
<path d="M14 18h-4"></path>
<path d="M14 8h-4"></path>
<path d="M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2"></path>
<path d="M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18"></path>
</svg>
<span className="sr-only">Medical Care System</span>
</a>
<div className="hidden gap-6 text-sm font-medium md:flex">
<a className="font-bold" href="#">
Questionnaires
</a>
<a className="text-gray-500" href="#">
Clients
</a>
<a className="text-gray-500" href="#">
Questionnaire Responses
</a>
</div>
</nav>
<div className="flex items-center gap-2">
<button
className="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 rounded-full">
<img
src="https://generated.vusercontent.net/placeholder.svg"
width="32"
height="32"
className="rounded-full"
alt="Avatar"
style={{aspectRatio: '32 / 32', objectFit: 'cover'}}
/>
<span className="sr-only">Toggle user menu</span>
</button>
</div>
</header>
<div className="flex flex-1 relative">
<div
className={`flex flex-col bg-gray-100 p-4 w-[260px] z-10 max-w-full transition-all duration-100 top-0 bottom-0 absolute md:relative -left-full md:left-0 ${sidebarOpen ? 'left-0 shadow-lg' : ''}`}>
<div className="mb-4 flex items-center justify-between">
<h3 className="text-lg font-semibold">Questionnaires</h3>
</div>
<div className="overflow-auto mb-4">
<nav className="grid gap-2">
{questionnaires.map((q, index) => (
<button
key={index}
className="rounded-md bg-white p-2 text-sm font-medium transition-colors hover:bg-gray-200 text-left pr-4 relative"
onClick={() => {
setId(q.id);
setSidebarOpen(false);
}}
>
{q.title}
{q.id === id && (
<span
className="bg-red-500 outline outline-2 outline-red-200 w-2 h-2 rounded-full absolute right-3 top-1/2 -translate-y-1/2"
>
<span className="sr-only">Currently viewing</span>
</span>
)}
</button>
))}
</nav>
</div>
<button
className="mt-auto border rounded text-sm text-orange-600 hover:text-orange-500 hover:border-orange-500 active:bg-orange-600 active:text-white border-orange-600 p-2 pr-4"
onClick={() => setConfig({
theme: {
"base-font-size": "12px", // Base font size for the theme
background: {
"toolbar-color": "#2c3e50", // Background color of the toolbar
},
button: {
"accent-color": "#27ae60", // General accent color for buttons
},
}
})}
>
Apply custom theme
</button>
</div>
<main className={`flex-1 flex ${sidebarOpen ? 'brightness-50' : ''}`}>
<aidbox-form-renderer
base-url="https://form-builder.aidbox.app"
style={{width: '100%', border: 'none', alignSelf: 'stretch', display: 'flex'}}
questionnaire-id={id}
key={JSON.stringify(config)}
config={JSON.stringify(config)}
disable-load-sdc-config={true}
>
</aidbox-form-renderer>
</main>
</div>
</div>
);
}
ReactDOM.render(<App/>, document.getElementById('root'));
</script>
</body>
</html>