diff options
author | David Yip <yipdw@member.fsf.org> | 2018-05-18 07:53:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-18 07:53:53 -0500 |
commit | 5d823ee00a5c4e06aec457783499ce0f82558bed (patch) | |
tree | bb0bbc474132e71b9f7fb0ccaaac46132dbaa806 /app/javascript/flavours/glitch/packs/public.js | |
parent | 2636a23092306bdb07250add02d2851476d58bc2 (diff) | |
parent | 07baa1ddb59356bf42fff8e61fe104cf0af79bad (diff) |
Merge pull request #489 from ThibG/glitch-soc/features/port-public-ui-changes
Port public UI changes from upstream
Diffstat (limited to 'app/javascript/flavours/glitch/packs/public.js')
-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)); } }); } |