2020-09-04 07:32:51 +03:00
|
|
|
import * as React from "react";
|
2020-08-31 21:19:46 +03:00
|
|
|
import * as Constants from "~/common/constants";
|
2020-09-01 07:44:56 +03:00
|
|
|
import * as SVG from "~/common/svg";
|
2020-11-17 06:17:56 +03:00
|
|
|
import * as Strings from "~/common/strings";
|
2020-11-28 02:02:16 +03:00
|
|
|
import * as Window from "~/common/window";
|
2020-08-31 21:19:46 +03:00
|
|
|
|
2020-11-30 08:24:22 +03:00
|
|
|
import { css } from "@emotion/react";
|
2020-09-05 00:37:50 +03:00
|
|
|
import { Boundary } from "~/components/system/components/fragments/Boundary";
|
|
|
|
import { PopoverNavigation } from "~/components/system/components/PopoverNavigation";
|
2020-09-04 07:32:51 +03:00
|
|
|
|
2020-11-26 02:19:02 +03:00
|
|
|
import ProcessedText from "~/components/core/ProcessedText";
|
2020-08-31 21:19:46 +03:00
|
|
|
import SlateMediaObjectPreview from "~/components/core/SlateMediaObjectPreview";
|
|
|
|
|
2020-11-23 02:46:49 +03:00
|
|
|
const placeholder =
|
|
|
|
"https://slate.textile.io/ipfs/bafkreidq27ycqubd4pxbo76n3rv5eefgxl3a2lh3wfvdgtil4u47so3nqe";
|
2020-10-02 02:44:22 +03:00
|
|
|
|
2020-12-11 11:16:12 +03:00
|
|
|
const STYLES_IMAGE_ROW = css`
|
|
|
|
overflow: hidden;
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
justify-content: center;
|
|
|
|
margin: 0 -8px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ITEM_BOX = css`
|
|
|
|
height: calc(33.33% - 4px);
|
|
|
|
overflow: hidden;
|
|
|
|
margin: 0px 0px 4px 4px;
|
|
|
|
box-shadow: 0px 0px 0px 1px ${Constants.system.lightBorder} inset;
|
|
|
|
cursor: pointer;
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
margin: 0 8px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_PLACEHOLDER = css`
|
|
|
|
width: 100%;
|
|
|
|
height: 320px;
|
|
|
|
background-size: cover;
|
|
|
|
background-position: 50% 50%;
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export class SlatePreviewRow extends React.Component {
|
|
|
|
render() {
|
|
|
|
let numItems = this.props.numItems || 4;
|
|
|
|
let objects;
|
|
|
|
if (this.props.slate.data.objects.length === 0) {
|
|
|
|
objects = [
|
|
|
|
<div
|
|
|
|
css={STYLES_PLACEHOLDER}
|
|
|
|
style={{
|
|
|
|
backgroundImage: `url(${placeholder})`,
|
|
|
|
...this.props.imageStyle,
|
|
|
|
}}
|
|
|
|
/>,
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
let trimmed =
|
|
|
|
this.props.slate.data.objects.length > numItems
|
|
|
|
? this.props.slate.data.objects.slice(1, numItems)
|
|
|
|
: this.props.slate.data.objects.slice(1, this.props.slate.data.objects.length);
|
|
|
|
objects = trimmed.map((each) => (
|
|
|
|
<div key={each.id} css={STYLES_ITEM_BOX}>
|
|
|
|
<SlateMediaObjectPreview
|
|
|
|
blurhash={each.blurhash}
|
|
|
|
charCap={30}
|
|
|
|
centeredImage
|
|
|
|
type={each.type}
|
|
|
|
url={each.url}
|
|
|
|
style={this.props.previewStyle}
|
2021-04-08 22:00:09 +03:00
|
|
|
cid={each.cid}
|
2020-12-11 11:16:12 +03:00
|
|
|
title={each.title || each.name}
|
|
|
|
iconOnly={this.props.small}
|
|
|
|
coverImage={each.coverImage}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
));
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div css={STYLES_IMAGE_ROW} style={{ height: `100%`, ...this.props.containerStyle }}>
|
|
|
|
{objects}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 03:41:53 +03:00
|
|
|
const STYLES_MOBILE_HIDDEN = css`
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_MOBILE_ONLY = css`
|
|
|
|
@media (min-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-09-23 23:52:00 +03:00
|
|
|
const STYLES_CREATE_NEW = css`
|
|
|
|
color: ${Constants.system.darkGray};
|
|
|
|
box-shadow: 0px 0px 0px 1px rgba(229, 229, 229, 0.5) inset;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-11-20 04:50:24 +03:00
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2020-09-23 23:52:00 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2020-10-01 03:41:53 +03:00
|
|
|
margin: 0;
|
|
|
|
border-radius: 8;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2020-09-23 23:52:00 +03:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-31 21:19:46 +03:00
|
|
|
const STYLES_BLOCK = css`
|
2020-12-11 05:59:17 +03:00
|
|
|
border-radius: 4px;
|
|
|
|
box-shadow: 0 0 40px 0 ${Constants.system.shadow};
|
2020-11-20 04:50:24 +03:00
|
|
|
padding: 24px;
|
2020-08-31 21:19:46 +03:00
|
|
|
font-size: 12px;
|
|
|
|
text-align: left;
|
|
|
|
cursor: pointer;
|
2020-11-20 04:50:24 +03:00
|
|
|
height: 440px;
|
|
|
|
width: 100%;
|
2020-12-11 05:59:17 +03:00
|
|
|
background-color: ${Constants.system.white};
|
2020-10-01 03:41:53 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
margin: 24px auto;
|
2020-11-20 04:50:24 +03:00
|
|
|
height: auto;
|
2020-10-01 03:41:53 +03:00
|
|
|
}
|
2020-08-31 21:19:46 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-01 07:44:56 +03:00
|
|
|
const STYLES_TITLE_LINE = css`
|
2020-09-06 06:07:16 +03:00
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
2020-09-01 07:44:56 +03:00
|
|
|
align-items: center;
|
2020-08-31 21:19:46 +03:00
|
|
|
font-size: ${Constants.typescale.lvl1};
|
2020-11-20 04:50:24 +03:00
|
|
|
margin-bottom: 8px;
|
2020-09-06 05:45:27 +03:00
|
|
|
overflow-wrap: break-word;
|
2020-12-11 11:16:12 +03:00
|
|
|
justify-content: space-between;
|
2020-08-31 21:19:46 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-01 07:44:56 +03:00
|
|
|
const STYLES_COPY_INPUT = css`
|
|
|
|
pointer-events: none;
|
|
|
|
position: absolute;
|
|
|
|
opacity: 0;
|
|
|
|
`;
|
|
|
|
|
2020-09-03 02:17:31 +03:00
|
|
|
const STYLES_TAG = css`
|
2020-09-06 06:07:16 +03:00
|
|
|
margin-right: 16px;
|
2020-09-03 02:17:31 +03:00
|
|
|
padding: 4px 8px;
|
2020-09-04 01:42:08 +03:00
|
|
|
border-radius: 2px;
|
2020-09-04 07:16:19 +03:00
|
|
|
border: 1px solid ${Constants.system.black};
|
|
|
|
color: ${Constants.system.black};
|
|
|
|
font-family: ${Constants.font.semiBold};
|
|
|
|
font-size: 0.9rem;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_BODY = css`
|
|
|
|
font-family: ${Constants.font.text};
|
2020-11-20 04:50:24 +03:00
|
|
|
font-size: ${Constants.typescale.lvl0};
|
|
|
|
color: ${Constants.system.darkGray};
|
2021-02-04 03:18:43 +03:00
|
|
|
margin-bottom: 16px;
|
2020-11-20 04:50:24 +03:00
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
2020-12-11 11:16:12 +03:00
|
|
|
height: 20px;
|
2021-02-04 03:18:43 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
2020-09-04 07:16:19 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-05 00:37:50 +03:00
|
|
|
const STYLES_ICON_BOX = css`
|
2021-01-06 04:21:46 +03:00
|
|
|
height: 24px;
|
|
|
|
width: 24px;
|
2020-09-05 04:40:23 +03:00
|
|
|
display: flex;
|
2020-09-05 00:37:50 +03:00
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-09-05 04:40:23 +03:00
|
|
|
position: relative;
|
|
|
|
color: ${Constants.system.darkGray};
|
2020-11-13 01:36:20 +03:00
|
|
|
|
|
|
|
:hover {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
2020-09-05 04:40:23 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_CONTEXT_MENU = css`
|
|
|
|
position: absolute;
|
2020-09-05 00:37:50 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-06 06:07:16 +03:00
|
|
|
const STYLES_TITLE = css`
|
|
|
|
font-size: ${Constants.typescale.lvl2};
|
|
|
|
font-family: ${Constants.font.semiBold};
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
margin-right: 16px;
|
|
|
|
`;
|
|
|
|
|
2020-12-11 11:16:12 +03:00
|
|
|
const STYLES_PREVIEW = css`
|
|
|
|
display: flex;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_OBJECT_COUNT = css`
|
|
|
|
width: auto;
|
|
|
|
font-size: ${Constants.typescale.lvlN1};
|
|
|
|
color: ${Constants.system.darkGray};
|
2020-12-11 05:59:17 +03:00
|
|
|
|
2020-11-23 02:46:49 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2020-12-11 11:16:12 +03:00
|
|
|
margin: 8px 0 16px 0;
|
2020-11-23 02:46:49 +03:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-10-02 02:44:22 +03:00
|
|
|
export class SlatePreviewBlock extends React.Component {
|
2020-09-01 07:44:56 +03:00
|
|
|
_ref;
|
2020-09-05 00:37:50 +03:00
|
|
|
_test;
|
2020-09-01 07:44:56 +03:00
|
|
|
|
|
|
|
state = {
|
2020-09-05 04:40:23 +03:00
|
|
|
showMenu: false,
|
2020-09-05 00:37:50 +03:00
|
|
|
copyValue: "",
|
|
|
|
};
|
|
|
|
|
2020-09-01 07:44:56 +03:00
|
|
|
_handleCopy = (e, value) => {
|
2020-09-04 07:16:19 +03:00
|
|
|
e.stopPropagation();
|
2020-09-05 00:37:50 +03:00
|
|
|
this.setState({ copyValue: value }, () => {
|
2020-09-01 07:44:56 +03:00
|
|
|
this._ref.select();
|
|
|
|
document.execCommand("copy");
|
2020-09-05 04:40:23 +03:00
|
|
|
this._handleHide();
|
2020-09-01 07:44:56 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-09-05 00:37:50 +03:00
|
|
|
_handleClick = (e) => {
|
|
|
|
e.stopPropagation();
|
2020-09-05 04:40:23 +03:00
|
|
|
if (this.state.showMenu) {
|
|
|
|
this._handleHide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.setState({ showMenu: true });
|
2020-09-05 00:37:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleHide = (e) => {
|
2020-09-05 04:40:23 +03:00
|
|
|
this.setState({ showMenu: false });
|
2020-09-05 00:37:50 +03:00
|
|
|
};
|
|
|
|
|
2020-09-01 07:44:56 +03:00
|
|
|
render() {
|
2020-12-11 11:16:12 +03:00
|
|
|
let count = 0;
|
2020-12-11 22:01:46 +03:00
|
|
|
const { objects } = this.props.slate.data;
|
2021-01-24 06:18:49 +03:00
|
|
|
if (objects.length >= 4) {
|
2020-12-11 22:01:46 +03:00
|
|
|
const set = this.props.slate.data.objects.slice(0, 4);
|
|
|
|
for (let object of set) {
|
2020-12-11 11:16:12 +03:00
|
|
|
if (object.type.startsWith("image/") && !object.type.startsWith("image/svg")) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-11 22:01:46 +03:00
|
|
|
let first = objects ? objects[0] : null;
|
2020-09-05 00:37:50 +03:00
|
|
|
let contextMenu = (
|
|
|
|
<React.Fragment>
|
|
|
|
<Boundary
|
|
|
|
captureResize={true}
|
|
|
|
captureScroll={false}
|
|
|
|
enabled
|
2020-09-06 06:07:16 +03:00
|
|
|
onOutsideRectEvent={this._handleHide}
|
|
|
|
>
|
2020-09-05 00:37:50 +03:00
|
|
|
<PopoverNavigation
|
|
|
|
style={{
|
|
|
|
top: "16px",
|
2020-09-05 04:40:23 +03:00
|
|
|
right: "-12px",
|
2020-09-05 00:37:50 +03:00
|
|
|
}}
|
2021-01-18 20:24:19 +03:00
|
|
|
navigation={[
|
|
|
|
{
|
|
|
|
text: "Copy slate ID",
|
|
|
|
onClick: (e) => this._handleCopy(e, this.props.slate.id),
|
|
|
|
},
|
|
|
|
]}
|
2020-09-05 00:37:50 +03:00
|
|
|
/>
|
|
|
|
</Boundary>
|
|
|
|
<input
|
|
|
|
readOnly
|
|
|
|
ref={(c) => {
|
|
|
|
this._ref = c;
|
|
|
|
}}
|
|
|
|
value={this.state.copyValue}
|
|
|
|
css={STYLES_COPY_INPUT}
|
|
|
|
/>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
|
2020-09-01 07:44:56 +03:00
|
|
|
return (
|
2020-11-01 21:40:03 +03:00
|
|
|
<div css={STYLES_BLOCK}>
|
2021-01-06 04:21:46 +03:00
|
|
|
<span css={STYLES_MOBILE_HIDDEN}>
|
|
|
|
<div css={STYLES_TITLE_LINE}>
|
2021-03-03 01:12:47 +03:00
|
|
|
<div css={STYLES_TITLE} style={{ width: "85%" }}>
|
2021-01-06 04:21:46 +03:00
|
|
|
{this.props.slate.data.name}
|
2021-03-03 01:12:47 +03:00
|
|
|
{this.props.isOwner && !this.props.isPublic && (
|
2021-03-12 02:33:44 +03:00
|
|
|
<span style={{ marginLeft: 12, position: "relative", top: 2 }}>
|
|
|
|
<SVG.SecurityLock height="20px" style={{ color: Constants.system.darkGray }} />
|
2021-03-03 01:12:47 +03:00
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</div>
|
2021-02-04 20:26:59 +03:00
|
|
|
|
2021-01-18 20:24:19 +03:00
|
|
|
{this.props.isOwner ? (
|
2021-01-06 04:21:46 +03:00
|
|
|
<div
|
|
|
|
style={{ marginLeft: "auto" }}
|
|
|
|
ref={(c) => {
|
|
|
|
this._test = c;
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div css={STYLES_ICON_BOX} onClick={this._handleClick}>
|
|
|
|
<SVG.MoreHorizontal height="24px" />
|
|
|
|
{this.state.showMenu ? <div css={STYLES_CONTEXT_MENU}>{contextMenu}</div> : null}
|
2020-12-11 11:16:12 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-06 04:21:46 +03:00
|
|
|
) : (
|
2020-12-11 11:16:12 +03:00
|
|
|
<div css={STYLES_OBJECT_COUNT}>
|
2020-12-11 22:01:46 +03:00
|
|
|
{objects.length} file
|
|
|
|
{objects.length > 1 ? "s" : ""}
|
2020-12-11 11:16:12 +03:00
|
|
|
</div>
|
2021-01-06 04:21:46 +03:00
|
|
|
)}
|
|
|
|
</div>
|
2021-02-04 20:26:59 +03:00
|
|
|
<div css={STYLES_BODY}>
|
|
|
|
{this.props.slate.data.body ? this.props.slate.data.body : null}
|
2021-02-04 03:18:43 +03:00
|
|
|
</div>
|
2021-01-06 04:21:46 +03:00
|
|
|
{objects.length === 1 || (objects.length != 0 && count <= 3) ? (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
width: "100%",
|
|
|
|
height: 320,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<SlateMediaObjectPreview
|
|
|
|
blurhash={first.blurhash}
|
|
|
|
centeredImage
|
|
|
|
charCap={30}
|
|
|
|
type={first.type}
|
|
|
|
url={first.url}
|
|
|
|
title={first.title || first.name}
|
|
|
|
coverImage={first.coverImage}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
) : first ? (
|
|
|
|
<div css={STYLES_PREVIEW}>
|
2020-09-04 01:42:08 +03:00
|
|
|
<div
|
2020-09-04 07:16:19 +03:00
|
|
|
style={{
|
2021-01-06 04:21:46 +03:00
|
|
|
width: "75%",
|
|
|
|
height: 320,
|
2020-09-06 06:07:16 +03:00
|
|
|
}}
|
|
|
|
>
|
2021-01-06 04:21:46 +03:00
|
|
|
<SlateMediaObjectPreview
|
|
|
|
blurhash={first.blurhash}
|
|
|
|
centeredImage
|
|
|
|
charCap={30}
|
|
|
|
type={first.type}
|
|
|
|
url={first.url}
|
2021-04-08 22:00:09 +03:00
|
|
|
cid={first.cid}
|
2021-01-06 04:21:46 +03:00
|
|
|
title={first.title || first.name}
|
|
|
|
coverImage={first.coverImage}
|
|
|
|
/>
|
2020-12-18 05:59:41 +03:00
|
|
|
</div>
|
2020-09-04 07:42:50 +03:00
|
|
|
<div
|
|
|
|
style={{
|
2021-01-06 04:21:46 +03:00
|
|
|
width: `25%`,
|
|
|
|
height: 324,
|
2020-09-06 06:07:16 +03:00
|
|
|
}}
|
|
|
|
>
|
2021-01-06 04:21:46 +03:00
|
|
|
<SlatePreviewRow {...this.props} previewStyle={this.props.previewStyle} />
|
2020-10-01 03:41:53 +03:00
|
|
|
</div>
|
2021-01-06 04:21:46 +03:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div
|
|
|
|
css={STYLES_PLACEHOLDER}
|
|
|
|
style={{
|
|
|
|
backgroundImage: `url(${placeholder})`,
|
|
|
|
...this.props.imageStyle,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
<span css={STYLES_MOBILE_ONLY}>
|
2021-02-04 20:26:59 +03:00
|
|
|
<div css={STYLES_TITLE_LINE}>
|
|
|
|
<div css={STYLES_TITLE}>{this.props.slate.data.name}</div>
|
2021-02-04 03:18:43 +03:00
|
|
|
{this.props.isOwner && (
|
2021-02-04 20:26:59 +03:00
|
|
|
<div style={{ color: Constants.system.darkGray, margin: `2px 0 0 0` }}>
|
2021-03-12 02:33:44 +03:00
|
|
|
{this.props.isPublic ? null : (
|
|
|
|
<SVG.SecurityLock height="20px" style={{ color: Constants.system.darkGray }} />
|
2021-02-04 03:18:43 +03:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
2021-02-04 20:26:59 +03:00
|
|
|
</div>
|
2021-03-12 02:33:44 +03:00
|
|
|
{this.props.slate.data.body ? (
|
|
|
|
<div css={STYLES_BODY} style={{ marginBottom: 16 }}>
|
|
|
|
{this.props.slate.data.body}
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div style={{ height: 8 }} />
|
|
|
|
)}
|
2021-01-06 04:21:46 +03:00
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
width: "100%",
|
|
|
|
height: `320px`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{first ? (
|
|
|
|
<SlateMediaObjectPreview
|
|
|
|
blurhash={first.blurhash}
|
|
|
|
centeredImage
|
|
|
|
charCap={30}
|
|
|
|
type={first.type}
|
|
|
|
url={first.url}
|
|
|
|
title={first.title || first.name}
|
|
|
|
coverImage={first.coverImage}
|
|
|
|
/>
|
|
|
|
) : (
|
2020-11-23 02:46:49 +03:00
|
|
|
<div
|
2021-01-06 04:21:46 +03:00
|
|
|
css={STYLES_PLACEHOLDER}
|
2020-11-23 02:46:49 +03:00
|
|
|
style={{
|
2021-01-06 04:21:46 +03:00
|
|
|
backgroundImage: `url(${placeholder})`,
|
|
|
|
...this.props.imageStyle,
|
2020-11-23 02:46:49 +03:00
|
|
|
}}
|
2021-01-06 04:21:46 +03:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</span>
|
2020-09-01 07:44:56 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-08-31 21:19:46 +03:00
|
|
|
}
|
2020-10-02 02:44:22 +03:00
|
|
|
|
2020-11-20 04:50:24 +03:00
|
|
|
const STYLES_SLATES = css`
|
2020-12-11 05:59:17 +03:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
|
|
|
|
grid-column-gap: 16px;
|
|
|
|
grid-row-gap: 16px;
|
2020-11-20 04:50:24 +03:00
|
|
|
padding-bottom: 48px;
|
2020-12-11 11:16:12 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.tablet}px) {
|
|
|
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
|
|
}
|
|
|
|
|
2020-11-20 04:50:24 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: block;
|
|
|
|
}
|
2020-10-02 02:44:22 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
export default class SlatePreviewBlocks extends React.Component {
|
|
|
|
render() {
|
2020-11-20 04:50:24 +03:00
|
|
|
return (
|
|
|
|
<div css={STYLES_SLATES}>
|
2020-12-11 11:16:12 +03:00
|
|
|
{this.props.external
|
2021-01-18 20:24:19 +03:00
|
|
|
? this.props.slates?.map((slate) => (
|
2020-12-13 04:16:55 +03:00
|
|
|
<a
|
2020-12-11 11:16:12 +03:00
|
|
|
key={slate.id}
|
2020-12-13 04:16:55 +03:00
|
|
|
style={{ textDecoration: "none", color: Constants.system.black }}
|
2020-12-11 11:16:12 +03:00
|
|
|
href={
|
2021-01-18 20:24:19 +03:00
|
|
|
!!this.props.username
|
2020-12-11 11:16:12 +03:00
|
|
|
? `/${this.props.username}/${slate.slatename}`
|
2021-01-18 20:24:19 +03:00
|
|
|
: `/$/slate/${slate.id}`
|
2020-12-11 11:16:12 +03:00
|
|
|
}
|
|
|
|
>
|
|
|
|
<SlatePreviewBlock
|
|
|
|
isOwner={this.props.isOwner}
|
|
|
|
username={this.props.username}
|
|
|
|
slate={slate}
|
|
|
|
external={this.props.external}
|
2021-02-04 03:18:43 +03:00
|
|
|
isPublic={slate.data.public}
|
2020-12-11 11:16:12 +03:00
|
|
|
/>
|
2020-12-13 04:16:55 +03:00
|
|
|
</a>
|
2020-12-11 11:16:12 +03:00
|
|
|
))
|
2021-01-18 20:24:19 +03:00
|
|
|
: this.props.slates?.map((slate) => (
|
2020-12-11 11:16:12 +03:00
|
|
|
<div
|
|
|
|
key={slate.id}
|
|
|
|
onClick={() =>
|
|
|
|
this.props.onAction({
|
|
|
|
type: "NAVIGATE",
|
2020-12-19 08:25:50 +03:00
|
|
|
value: "NAV_SLATE",
|
2020-12-11 11:16:12 +03:00
|
|
|
data: { decorator: "SLATE", ...slate },
|
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<SlatePreviewBlock
|
|
|
|
isOwner={this.props.isOwner}
|
|
|
|
username={this.props.username}
|
|
|
|
slate={slate}
|
|
|
|
external={this.props.external}
|
2021-02-04 03:18:43 +03:00
|
|
|
isPublic={slate.data.public}
|
2020-12-11 11:16:12 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
))}
|
2020-10-02 02:44:22 +03:00
|
|
|
</div>
|
2020-11-20 04:50:24 +03:00
|
|
|
);
|
2020-10-02 02:44:22 +03:00
|
|
|
}
|
|
|
|
}
|