diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-10-13 14:42:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 14:42:37 +0200 |
commit | 1bd00036c284bcafb419eaf80347ba49d1b491d9 (patch) | |
tree | 4feb5850a11db2b60a56deb21101251a83247db7 /app/javascript/mastodon/components/image.js | |
parent | b04633a9614609f18b39ba0f0015df301a04ab64 (diff) |
Change about page to be mounted in the web UI (#19345)
Diffstat (limited to 'app/javascript/mastodon/components/image.js')
-rw-r--r-- | app/javascript/mastodon/components/image.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/javascript/mastodon/components/image.js b/app/javascript/mastodon/components/image.js new file mode 100644 index 000000000..6e81ddf08 --- /dev/null +++ b/app/javascript/mastodon/components/image.js @@ -0,0 +1,33 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import Blurhash from './blurhash'; +import classNames from 'classnames'; + +export default class Image extends React.PureComponent { + + static propTypes = { + src: PropTypes.string, + srcSet: PropTypes.string, + blurhash: PropTypes.string, + className: PropTypes.string, + }; + + state = { + loaded: false, + }; + + handleLoad = () => this.setState({ loaded: true }); + + render () { + const { src, srcSet, blurhash, className } = this.props; + const { loaded } = this.state; + + return ( + <div className={classNames('image', { loaded }, className)} role='presentation'> + {blurhash && <Blurhash hash={blurhash} className='image__preview' />} + <img src={src} srcSet={srcSet} alt='' onLoad={this.handleLoad} /> + </div> + ); + } + +} |