diff options
author | Spencer Alves <impiaaa@gmail.com> | 2018-05-31 21:33:16 -0700 |
---|---|---|
committer | Spencer Alves <impiaaa@gmail.com> | 2018-05-31 21:33:16 -0700 |
commit | 7d2e6429c27c5ddc8ef3d2366c44329092e07f77 (patch) | |
tree | 7cfd2035f69616a369b2f3762ce9cefe61c2bd22 /app/javascript/flavours/glitch/packs | |
parent | f2ff167c1a8df9b2521d33fcca15b8d5c67c50b1 (diff) | |
parent | e396fbfe3bf4d2a404e78e73cff1a609dd0a9bfb (diff) |
Merge branch 'glitch' into thread-icon
Diffstat (limited to 'app/javascript/flavours/glitch/packs')
-rw-r--r-- | app/javascript/flavours/glitch/packs/public.js | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/app/javascript/flavours/glitch/packs/public.js b/app/javascript/flavours/glitch/packs/public.js index ed685b6b7..78e8f1053 100644 --- a/app/javascript/flavours/glitch/packs/public.js +++ b/app/javascript/flavours/glitch/packs/public.js @@ -6,8 +6,6 @@ function main() { const emojify = require('flavours/glitch/util/emoji').default; 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'); @@ -52,24 +50,15 @@ function main() { }); }); - [].forEach.call(document.querySelectorAll('[data-component="Video"]'), (content) => { - const props = JSON.parse(content.getAttribute('data-props')); - 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 mediaGalleries = document.querySelectorAll('[data-component="MediaGallery"]'); - - if (mediaGalleries.length > 0) { - const MediaGalleriesContainer = require('flavours/glitch/containers/media_galleries_container').default; - const content = document.createElement('div'); - - ReactDOM.render(<MediaGalleriesContainer locale={locale} galleries={mediaGalleries} />, content); - document.body.appendChild(content); + const reactComponents = document.querySelectorAll('[data-component]'); + if (reactComponents.length > 0) { + import(/* webpackChunkName: "containers/media_container" */ 'flavours/glitch/containers/media_container') + .then(({ default: MediaContainer }) => { + const content = document.createElement('div'); + ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content); + document.body.appendChild(content); + }) + .catch(error => console.error(error)); } }); } |