Skip to content

Commit

Permalink
Chore(demo): Hide elements in Supernova component preview
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed Nov 27, 2024
1 parent 0b690ae commit eababba
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/demo/partials/layout/base.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
});
targetElement.classList.add(`theme-${theme}`);
};
// Hide elements with hide-from-visual-tests class in Supernova component preview via postMessage
// see https://app.supernova.io/8830-alma-spirit/10180-spirit/10368-shared-draft/9731-default/documentation/settings/customization/footer for iframe event listener script
window.addEventListener('message', (event) => {
// Check if the postMessage is from the Supernova.io domain
if (event.origin === 'https://app.supernova.io' && event.data.action === 'hide-from-visual-tests') {
const elements = document.querySelectorAll('.hide-from-visual-tests');
elements.forEach(element => {
element.style.cssText = event.data.style;
});
}
});
</script>

{{#> scripts}}
Expand Down

0 comments on commit eababba

Please sign in to comment.