about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/image.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-10-13 14:42:37 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-10-28 19:24:02 +0200
commit67b4ecdd2124cb2cf05731b26a77129bb8151236 (patch)
tree92527b2a992a3f1625341deacd50f7b3de781bb5 /app/javascript/flavours/glitch/components/image.js
parent5d4d4a69f65ea8612d6e992282c061ba9a01a8be (diff)
[Glitch] Change about page to be mounted in the web UI
Port 1bd00036c284bcafb419eaf80347ba49d1b491d9 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/components/image.js')
-rw-r--r--app/javascript/flavours/glitch/components/image.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/components/image.js b/app/javascript/flavours/glitch/components/image.js
new file mode 100644
index 000000000..6e81ddf08
--- /dev/null
+++ b/app/javascript/flavours/glitch/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>
+    );
+  }
+
+}