parent
dd1d98f9cf
commit
94db024e4c
@ -1,59 +0,0 @@ |
||||
import React, { Fragment } from 'react'; |
||||
import ReactDOM from 'react-dom'; |
||||
import PropTypes from 'prop-types'; |
||||
import { IntlProvider, addLocaleData } from 'react-intl'; |
||||
import { getLocale } from '../locales'; |
||||
import Card from 'flavours/glitch/features/status/components/card'; |
||||
import ModalRoot from 'flavours/glitch/components/modal_root'; |
||||
import MediaModal from 'flavours/glitch/features/ui/components/media_modal'; |
||||
import { fromJS } from 'immutable'; |
||||
|
||||
const { localeData, messages } = getLocale(); |
||||
addLocaleData(localeData); |
||||
|
||||
export default class CardsContainer extends React.PureComponent { |
||||
|
||||
static propTypes = { |
||||
locale: PropTypes.string, |
||||
cards: PropTypes.object.isRequired, |
||||
}; |
||||
|
||||
state = { |
||||
media: null, |
||||
}; |
||||
|
||||
handleOpenCard = (media) => { |
||||
document.body.classList.add('card-standalone__body'); |
||||
this.setState({ media }); |
||||
} |
||||
|
||||
handleCloseCard = () => { |
||||
document.body.classList.remove('card-standalone__body'); |
||||
this.setState({ media: null }); |
||||
} |
||||
|
||||
render () { |
||||
const { locale, cards } = this.props; |
||||
|
||||
return ( |
||||
<IntlProvider locale={locale} messages={messages}> |
||||
<Fragment> |
||||
{[].map.call(cards, container => { |
||||
const { card, ...props } = JSON.parse(container.getAttribute('data-props')); |
||||
|
||||
return ReactDOM.createPortal( |
||||
<Card card={fromJS(card)} onOpenMedia={this.handleOpenCard} {...props} />, |
||||
container, |
||||
); |
||||
})} |
||||
<ModalRoot onClose={this.handleCloseCard}> |
||||
{this.state.media && ( |
||||
<MediaModal media={this.state.media} index={0} onClose={this.handleCloseCard} /> |
||||
)} |
||||
</ModalRoot> |
||||
</Fragment> |
||||
</IntlProvider> |
||||
); |
||||
} |
||||
|
||||
} |
@ -1,26 +0,0 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import { IntlProvider, addLocaleData } from 'react-intl'; |
||||
import { getLocale } from 'mastodon/locales'; |
||||
import Video from 'flavours/glitch/features/video'; |
||||
|
||||
const { localeData, messages } = getLocale(); |
||||
addLocaleData(localeData); |
||||
|
||||
export default class VideoContainer extends React.PureComponent { |
||||
|
||||
static propTypes = { |
||||
locale: PropTypes.string.isRequired, |
||||
}; |
||||
|
||||
render () { |
||||
const { locale, ...props } = this.props; |
||||
|
||||
return ( |
||||
<IntlProvider locale={locale} messages={messages}> |
||||
<Video {...props} /> |
||||
</IntlProvider> |
||||
); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue