diff --git a/index.html b/index.html index 007c953..302c8aa 100644 --- a/index.html +++ b/index.html @@ -48,6 +48,7 @@

đź’ˇ StarterPacks?!

StarterPacks bieten thematisch kuratierte Listen von Fediverse-Accounts, um dir den Einstieg in verschiedene Bereiche und Communities – rund um den Hashtag #Fedikirche – zu erleichtern.

+

Möchtest du dein eigenes StarterKit erstellen?

diff --git a/src/main.js b/src/main.js index 41428cb..934d55f 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,7 @@ import { createStarterKitElement, enhanceStarterKits } from './utils/starterkit-utils.js'; import { seededShuffleChildren } from './utils/shuffle-utils.js'; +import { initializeCreateStarterKitPopup } from './utils/create-starterkit.js'; + let userConsent = null; export { userConsent }; @@ -17,6 +19,8 @@ async function loadTemplates() { document.addEventListener('DOMContentLoaded', async function () { await loadTemplates(); // Templates laden + initializeCreateStarterKitPopup(); + const container = document.getElementById('starterkit-container'); const shuffleContainers = document.querySelectorAll('.shuffle-container'); const seed = Date.now(); diff --git a/src/template/template.html b/src/template/template.html index 2993cef..915a051 100644 --- a/src/template/template.html +++ b/src/template/template.html @@ -28,3 +28,38 @@
+ + + + diff --git a/src/utils/create-starterkit.js b/src/utils/create-starterkit.js new file mode 100644 index 0000000..0d1f0d1 --- /dev/null +++ b/src/utils/create-starterkit.js @@ -0,0 +1,83 @@ +export function initializeCreateStarterKitPopup() { + const createButton = document.getElementById('create-starterkit-btn'); + const popupTemplate = document.getElementById('create-starterkit-popup-template'); + + if (!popupTemplate) { + console.error('Template für StarterKit-Popup nicht gefunden!'); + return; + } + + createButton.addEventListener('click', () => { + const popupClone = popupTemplate.content.cloneNode(true); + const popupElement = popupClone.querySelector('#create-starterkit-popup'); + + // Events für Popup schließen + const closePopupButton = popupClone.querySelector('.close-popup'); + closePopupButton.addEventListener('click', () => popupElement.remove()); + + popupElement.addEventListener('click', (event) => { + if (event.target === popupElement) { + popupElement.remove(); + } + }); + + // Verarbeite das Formular und richte Logik ein + setupFormEvents(popupClone); + + document.body.appendChild(popupClone); + popupElement.classList.add('show'); + }); +} + +function setupFormEvents(popupClone) { + const form = popupClone.querySelector('#starterkit-form'); + const downloadButton = popupClone.querySelector('#download-starterkit-btn'); + + form.addEventListener('submit', (event) => { + event.preventDefault(); + const formData = new FormData(form); + + const kitName = formData.get('kitName'); + const kitDescription = formData.get('kitDescription'); + let kitAuthor = formData.get('kitAuthor'); + const kitAccounts = formData + .get('kitAccounts') + .split('\n') + .map((url) => url.trim()) + .filter((url) => url); + + if (kitAuthor && kitAuthor.startsWith('@')) { + const [username, domain] = kitAuthor.slice(1).split('@'); + if (username && domain) { + kitAuthor = `https://${domain}/@${username}`; + } else { + alert('Ungültiger Mastodon-Handle. Bitte im Format @benutzername@domain eingeben.'); + return; + } + } + + if (!kitName || !kitDescription || !kitAuthor || kitAccounts.length === 0) { + alert('Bitte alle Felder ausfüllen.'); + return; + } + + const starterKit = { + name: kitName, + description: kitDescription, + author: kitAuthor, + accounts: kitAccounts, + }; + + const jsonString = JSON.stringify(starterKit, null, 2); + const blob = new Blob([jsonString], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + + const tempLink = document.createElement('a'); + tempLink.href = url; + tempLink.download = `${kitName.toLowerCase().replace(/\s+/g, '_')}.json`; + document.body.appendChild(tempLink); + tempLink.click(); + document.body.removeChild(tempLink); + URL.revokeObjectURL(url); + }); +} diff --git a/style/site.css b/style/site.css index ab0642a..6e2c9b7 100644 --- a/style/site.css +++ b/style/site.css @@ -17,6 +17,7 @@ a { text-decoration: none; } .container { + position:relative; width: 100%; max-width: 1200px; margin: 0 auto; @@ -219,7 +220,23 @@ section { gap: 5px; } +.hint-button { + background-color: var(--primary-color); + color: white; + border: none; + padding: 0.5rem 1rem; + font-size: 1rem; + cursor: pointer; + border-radius: 4px; + margin-left: 0.5rem; + transition: background-color 0.3s ease, transform 0.2s ease; +} +.hint-button:hover { + background-color: var(--primary-color-hover); + transform: translateY(-2px); + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); +} footer { text-align: center; @@ -255,4 +272,134 @@ footer p { .footer-credits a:hover { color: #fff; text-decoration: underline; +} + + +/* ------------------------------------------------------*/ + /* Popup-Styles */ + .popup { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(53, 53, 53, 0.8); + display: flex; + justify-content: center; + align-items: center; + z-index: 9999; + } + + .popup.hidden { + display: none; +} + +.popup-content { + position: relative; + background-color: var(--background-color); + padding: 20px; + border-radius: 15px; + width: 90vh; + max-width: 800px; + max-height: 90vh; + overflow-y: scroll; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.popup-content h3 { + margin-top: 0; + font-size: 1.5rem; + color: var(--primary-color, #333); +} + +.popup-content p { + font-size: 1rem; + margin: 10px 0; + color: #555; +} + +/* Buttons */ +button { + display: inline-block; + background-color: var(--primary-color, #6364FF); + color: white; + padding: 10px 15px; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 1rem; + margin-top: 10px; + transition: background-color 0.3s ease, transform 0.2s ease; +} + +button:hover { + background-color: var(--primary-color-hover, #4444CC); + transform: translateY(-2px); +} + +button:active { + background-color: var(--primary-color-hover, #4444CC); + transform: translateY(0); +} + +/* Formularstile */ +form { + margin: 20px 0; +} + +form label { + display: block; + font-size: 0.9rem; + font-weight: bold; + margin-bottom: 5px; + color: #444; +} + +form input[type="text"], +form textarea { + width: 100%; + padding: 10px; + margin-bottom: 15px; + border: 1px solid #ccc; + border-radius: 5px; + font-size: 1rem; + color: #333; + box-sizing: border-box; +} + +form textarea { + height: 80px; + resize: vertical; +} + +/* Erklärung unter dem Formular */ +.popup-content h5 { + margin: 20px 0 10px; + font-size: 1.2rem; + color: var(--primary-color, #333); +} + +.popup-content a { + color: var(--primary-color, #6364FF); + text-decoration: none; +} + +.popup-content a:hover { + text-decoration: underline; +} + +/* Hintergrund für das Popup */ +.popup-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.6); + z-index: 999; + display: none; +} + +.popup-overlay.active { + display: block; } \ No newline at end of file