Added ability to show / hide signup form in a post (#16792)

closes https://github.com/TryGhost/Team/issues/3200
https://ghost.slack.com/archives/C02G9E68C/p1684150226572149

- a little prototype to see if we can hide the new WIP signup form in a
post, if a user is already logged in and portal is loaded.
- the idea is that the signup card will be hidden by default in a post/page and only initiated by Portal if the defined conditions are met.
This commit is contained in:
Ronald Langeveld 2023-05-16 13:11:40 +02:00 committed by GitHub
parent ef0b863c2b
commit 6289d756ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,6 +183,18 @@ export default class App extends React.Component {
this.updateStateForPreviewLinks();
};
window.addEventListener('hashchange', this.hashHandler, false);
// spike ship - to test if we can show / hide signup forms inside post / page
if (!member) {
// the signup card will ship hidden by default, so we need to show it if the user is not logged in
// not sure why a user would have more than one form on a post, but just in case we'll find them all
const formElements = document.querySelectorAll('[data-lexical-signup-form]');
if (formElements.length > 0){
formElements.forEach((element) => {
element.style.display = '';
});
}
}
} catch (e) {
/* eslint-disable no-console */
console.error(`[Portal] Failed to initialize:`, e);