{
e.stopPropagation();
this.setState({
- menu:
- this.state.menu === each.id
- ? null
- : each.id,
+ menu: this.state.menu === each.id ? null : each.id,
});
}
}
>
{this.state.loading[cid] ? (
-
+
) : (
)}
@@ -807,10 +753,7 @@ export default class DataView extends React.Component {
{
text: "Copy link",
onClick: (e) =>
- this._handleCopy(
- e,
- `${Constants.gateways.ipfs}/${cid}`
- ),
+ this._handleCopy(e, `${Constants.gateways.ipfs}/${cid}`),
},
{
text: "Delete",
@@ -841,16 +784,12 @@ export default class DataView extends React.Component {
>
this.setState({ checked: {} })}
- >
-
+ this.setState({ checked: {} })}>
+
) : (
@@ -933,24 +866,22 @@ export default class DataView extends React.Component {
position: "relative",
right: 3,
margin: "12px 0",
- opacity:
- numChecked > 0 || this.state.hover === index ? "100%" : "0%",
+ opacity: numChecked > 0 || this.state.hover === index ? "100%" : "0%",
}}
/>
),
name: (
- this._handleSelect(this.state.startIndex + index)}
- >
+
this._handleSelect(this.state.startIndex + index)}
>
-
+
+
+
+
{each.file || each.name}
- {each.file || each.name}
-
+
),
size: {Strings.bytesToSize(each.size)}
,
more: (
@@ -990,19 +921,13 @@ export default class DataView extends React.Component {
},
{
text: "Copy link",
- onClick: (e) =>
- this._handleCopy(
- e,
- `${Constants.gateways.ipfs}/${cid}`
- ),
+ onClick: (e) => this._handleCopy(e, `${Constants.gateways.ipfs}/${cid}`),
},
{
text: "Delete",
onClick: (e) => {
e.stopPropagation();
- this.setState({ menu: null }, () =>
- this._handleDelete(cid)
- );
+ this.setState({ menu: null }, () => this._handleDelete(cid));
},
},
]}
diff --git a/components/core/FilePreviewBubble.js b/components/core/FilePreviewBubble.js
new file mode 100644
index 00000000..67f1bab7
--- /dev/null
+++ b/components/core/FilePreviewBubble.js
@@ -0,0 +1,64 @@
+import * as React from "react";
+import * as Constants from "~/common/constants";
+
+import { css, keyframes } from "@emotion/react";
+import { useState } from "react";
+import SlateMediaObjectPreview from "~/components/core/SlateMediaObjectPreview";
+import SlateMediaObject from "~/components/core/SlateMediaObject";
+
+const fadein = keyframes`
+ 0%{
+ opacity: 0;
+ }
+ 100%{
+ opacity: 1;
+ }
+`;
+
+const STYLES_FILE_PREVIEW_BUBBLE = css`
+ z-index: ${Constants.zindex.tooltip};
+ padding: 8px;
+ border-radius: 4px;
+ background-color: ${Constants.system.black};
+ animation: ${fadein} 200ms ease-out 1;
+ width: 200px;
+ position: absolute;
+`;
+
+const STYLES_FILE_PREVIEW = css`
+ width: 100%;
+ height: 100%;
+`;
+
+const STYLES_BUBBLE_ANCHOR = css`
+ box-sizing: border-box;
+ display: inline-flex;
+ align-item: center;
+ justify-content: center;
+ cursor: pointer;
+`;
+
+export const FilePreviewBubble = (props) => {
+ const [onHover, setHover] = useState(false);
+ const type = props.type && props.type.startsWith("image/") && onHover;
+ console.log(type);
+
+ return (
+
+ setHover(true)}
+ onMouseLeave={() => setHover(false)}
+ >
+ {props.children}
+
+ {type && (
+
+
+
+ )}
+
+ );
+};
+
+export default FilePreviewBubble;