From 29a4c0ca694451a98dc0d88c78bf0aa5fb9d8652 Mon Sep 17 00:00:00 2001 From: counterweight Date: Fri, 14 Mar 2025 16:57:55 +0100 Subject: [PATCH] popup component --- src/front/components/PopupNotification.js | 25 +++++++++++++ src/front/components/WarningDiv.js | 25 +++++++++++++ src/front/pages/invite.js | 45 +++++++---------------- src/views/invite.ejs | 8 +--- 4 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 src/front/components/PopupNotification.js create mode 100644 src/front/components/WarningDiv.js diff --git a/src/front/components/PopupNotification.js b/src/front/components/PopupNotification.js new file mode 100644 index 0000000..e2a0588 --- /dev/null +++ b/src/front/components/PopupNotification.js @@ -0,0 +1,25 @@ +class PopupNotification { + constructor({ parentElement, id, text }) { + this.element = null; + this.parentElement = parentElement; + this.id = id; + this.text = text; + } + + render() { + const div = document.createElement('div'); + div.id = this.id; + div.className = 'top-notification-good'; + + div.innerHTML = ` +

${this.text}

`; + + this.element = div; + this.parentElement.appendChild(div); + } + + display() { + this.element.classList.add('revealed'); + } +} +module.exports = PopupNotification; diff --git a/src/front/components/WarningDiv.js b/src/front/components/WarningDiv.js new file mode 100644 index 0000000..ab4fa93 --- /dev/null +++ b/src/front/components/WarningDiv.js @@ -0,0 +1,25 @@ +class WarningDiv { + constructor({ parentElement, id, innerHTML }) { + this.element = null; + this.parentElement = parentElement; + this.id = id; + this.innerHTML = innerHTML; + } + + render() { + const div = document.createElement('div'); + div.id = this.id; + div.className = 'card-secondary'; + div.style.display = 'none'; + + div.innerHTML = this.innerHTML; + + this.element = div; + this.parentElement.appendChild(div); + } + + display() { + this.element.style.display = 'block'; + } +} +module.exports = WarningDiv; diff --git a/src/front/pages/invite.js b/src/front/pages/invite.js index 5a7678c..e67ca9c 100644 --- a/src/front/pages/invite.js +++ b/src/front/pages/invite.js @@ -2,37 +2,14 @@ const checkNostrExtension = require('../utils/checkNostrExtension'); const signupService = require('../services/signupService'); const constants = require('../../constants'); const NostrSignupButton = require('../components/NostrSignupButton'); - -const warningsContainer = document.getElementById('warnings-container'); -const nostrSignupArea = document.getElementById('nostr-signup-area'); -const signUpSuccessNotification = document.getElementById('sign-up-success'); - -class WarningDiv { - constructor({ parentElement, id, innerHTML }) { - this.element = null; - this.parentElement = parentElement; - this.id = id; - this.innerHTML = innerHTML; - } - - render() { - const div = document.createElement('div'); - div.id = this.id; - div.className = 'card-secondary'; - div.style.display = 'none'; - - div.innerHTML = this.innerHTML; - - this.element = div; - this.parentElement.appendChild(div); - } - - display() { - this.element.style.display = 'block'; - } -} +const WarningDiv = require('../components/WarningDiv'); +const PopupNotification = require('../components/PopupNotification'); const invitesFunction = () => { + const body = document.querySelector('body'); + const warningsContainer = document.getElementById('warnings-container'); + const nostrSignupArea = document.getElementById('nostr-signup-area'); + const signupButton = new NostrSignupButton({ parentElement: nostrSignupArea, id: 'nostr-signup-button', @@ -94,9 +71,15 @@ const invitesFunction = () => { equivocado, puedes intentarlo de nuevo.

`, }); - rejectedNostrWarning.render(); + const signUpSuccessPopup = new PopupNotification({ + parentElement: body, + id: 'sign-up-success', + text: '¡Bien! Hemos dado de alta tu clave de Nostr. Te vamos a redirigir a la seca, espera un momento.', + }); + signUpSuccessPopup.render(); + window.onload = () => { checkNostrExtension( window, @@ -112,7 +95,7 @@ const invitesFunction = () => { }; function showConfirmationAndRedirect() { - signUpSuccessNotification.classList.add('revealed'); + signUpSuccessPopup.display(); setTimeout(() => { window.location.href = constants.API_PATHS.createProfile; }, constants.DEFAULT_REDIRECT_DELAY); diff --git a/src/views/invite.ejs b/src/views/invite.ejs index ad4a406..d6ddaea 100644 --- a/src/views/invite.ejs +++ b/src/views/invite.ejs @@ -23,13 +23,7 @@

Usa tu extensión de Nostr para darte de alta:

-
- -

- ¡Bien! Hemos dado de alta tu clave de Nostr. Te vamos a redirigir - a la seca, espera un momento. -

-
+

¿No tienes cuenta de Nostr?