From dd843f687bc90c39a36497c5c28c3f9e38562b8b Mon Sep 17 00:00:00 2001 From: LarsVomMars Date: Sat, 10 Oct 2020 12:05:53 +0200 Subject: Dynamic question loading --- profile/public/index.html | 6 ++---- profile/public/script.js | 14 ++++++++++++++ profile/public/style.css | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) (limited to 'profile/public') diff --git a/profile/public/index.html b/profile/public/index.html index 30f9de8..5fcee74 100644 --- a/profile/public/index.html +++ b/profile/public/index.html @@ -21,14 +21,12 @@
Steckbrief - -
- + - \ No newline at end of file + diff --git a/profile/public/script.js b/profile/public/script.js index e69de29..7c72b69 100644 --- a/profile/public/script.js +++ b/profile/public/script.js @@ -0,0 +1,14 @@ +const fs = document.querySelector("fieldset"); + +function appendQuestions(question) { + const field = document.createElement("input"); + field.name = question.id; + field.value = question.answer ?? ""; + field.placeholder = question.question; + fs.insertBefore(field, fs.querySelector("button")); +} + +fetch("api/questions") + .then((response) => response.json()) + .then((response) => response.forEach(appendQuestions)) + .catch(console.error); diff --git a/profile/public/style.css b/profile/public/style.css index e69de29..2e7b945 100644 --- a/profile/public/style.css +++ b/profile/public/style.css @@ -0,0 +1,39 @@ +html, +body { + padding: 0; + margin: 0; + height: 100%; + width: 100%; + background-color: #eec0c6; + background-image: linear-gradient(315deg, #eec0c6 0%, #7ee8fa 74%); +} + +div { + background: white; +} + +main { + position: absolute; + max-height: 80%; + overflow-y: auto; + width: 30%; + left: 50%; + top: 50%; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + padding: 20px; + border-radius: 10px; + background: white; +} + +input, +button, +select { + width: 100%; +} + +@media only screen and (max-width: 600px) { + main { + width: calc(100% - 50px); + } +} -- cgit v1.2.3