diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-05-17 16:45:19 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-05-17 18:37:00 +0200 |
commit | dd1d98f9cf405104ef106ee5f376bd09815dac42 (patch) | |
tree | 6d8a797aad14e7640ca2ffaa6395aa8f322895e8 /app/javascript/flavours/glitch/packs | |
parent | 4bf43e6f3e93643d989a2872763b41505fab2206 (diff) |
[Glitch] Show card modal on public pages
Port 16fee0335f2b10b0ce54f71965d2f2acc0e24942 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/packs')
-rw-r--r-- | app/javascript/flavours/glitch/packs/public.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/javascript/flavours/glitch/packs/public.js b/app/javascript/flavours/glitch/packs/public.js index ed685b6b7..4e621c67f 100644 --- a/app/javascript/flavours/glitch/packs/public.js +++ b/app/javascript/flavours/glitch/packs/public.js @@ -7,7 +7,6 @@ function main() { const { getLocale } = require('locales'); const { localeData } = getLocale(); const VideoContainer = require('flavours/glitch/containers/video_container').default; - const CardContainer = require('flavours/glitch/containers/card_container').default; const React = require('react'); const ReactDOM = require('react-dom'); @@ -57,10 +56,16 @@ function main() { ReactDOM.render(<VideoContainer locale={locale} {...props} />, content); }); - [].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => { - const props = JSON.parse(content.getAttribute('data-props')); - ReactDOM.render(<CardContainer locale={locale} {...props} />, content); - }); + const cards = document.querySelectorAll('[data-component="Card"]'); + + if (cards.length > 0) { + import(/* webpackChunkName: "containers/cards_container" */ '../mastodon/containers/cards_container').then(({ default: CardsContainer }) => { + const content = document.createElement('div'); + + ReactDOM.render(<CardsContainer locale={locale} cards={cards} />, content); + document.body.appendChild(content); + }).catch(error => console.error(error)); + } const mediaGalleries = document.querySelectorAll('[data-component="MediaGallery"]'); |