Combine similar components into one on public UI (#7458)
This commit is contained in:
parent
4d706f9976
commit
f9afd06221
5 changed files with 33 additions and 127 deletions
|
@ -24,7 +24,6 @@ function main() {
|
|||
const emojify = require('../mastodon/features/emoji/emoji').default;
|
||||
const { getLocale } = require('../mastodon/locales');
|
||||
const { localeData } = getLocale();
|
||||
const VideoContainer = require('../mastodon/containers/video_container').default;
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
|
||||
|
@ -69,30 +68,16 @@ 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);
|
||||
});
|
||||
const reactComponents = document.querySelectorAll('[data-component]');
|
||||
if (reactComponents.length > 0) {
|
||||
import(/* webpackChunkName: "containers/media_container" */ '../mastodon/containers/media_container')
|
||||
.then(({ default: MediaContainer }) => {
|
||||
const content = document.createElement('div');
|
||||
|
||||
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"]');
|
||||
|
||||
if (mediaGalleries.length > 0) {
|
||||
const MediaGalleriesContainer = require('../mastodon/containers/media_galleries_container').default;
|
||||
const content = document.createElement('div');
|
||||
|
||||
ReactDOM.render(<MediaGalleriesContainer locale={locale} galleries={mediaGalleries} />, content);
|
||||
document.body.appendChild(content);
|
||||
ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
|
||||
document.body.appendChild(content);
|
||||
})
|
||||
.catch(error => console.error(error));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue