From fb62e003bb45348e9ebba754bb81cf71a6046f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Curda?= Date: Tue, 26 Nov 2024 13:31:24 +0100 Subject: [PATCH] Chore: Handling CORS on Netlify --- apps/demo/partials/layout/base.hbs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/demo/partials/layout/base.hbs b/apps/demo/partials/layout/base.hbs index 885dcc3455..c1e4560b51 100644 --- a/apps/demo/partials/layout/base.hbs +++ b/apps/demo/partials/layout/base.hbs @@ -46,6 +46,19 @@ }); targetElement.classList.add(`theme-${theme}`); }; + + // Hide elements with hide-from-visual-tests class in Supernova component preview via postMessage + window.addEventListener('message', (event) => { + // Check if the postMessage is from the Supernova.io domain + if (event.origin === 'https://app.supernova.io') { + if (event.data.action === 'hide-from-visual-tests') { + const elements = document.querySelectorAll('.hide-from-visual-tests'); + elements.forEach(el => { + el.style.cssText = event.data.style; + }); + } + } + }); {{#> scripts}}