2020-07-16 04:36:29 +03:00
|
|
|
import * as React from "react";
|
2020-09-05 02:15:29 +03:00
|
|
|
import * as SVG from "~/common/svg";
|
2020-11-28 07:39:01 +03:00
|
|
|
import * as Events from "~/common/custom-events";
|
2021-05-17 06:23:46 +03:00
|
|
|
import * as Constants from "~/common/constants";
|
2021-05-27 11:20:34 +03:00
|
|
|
import * as Styles from "~/common/styles";
|
2020-07-16 04:36:29 +03:00
|
|
|
|
2020-11-30 08:24:22 +03:00
|
|
|
import { css } from "@emotion/react";
|
2021-01-21 10:02:35 +03:00
|
|
|
import { TabGroup, PrimaryTabGroup, SecondaryTabGroup } from "~/components/core/TabGroup";
|
2020-09-14 08:22:19 +03:00
|
|
|
import { ButtonSecondary } from "~/components/system/components/Buttons";
|
2020-11-11 04:44:21 +03:00
|
|
|
import { FileTypeGroup } from "~/components/core/FileTypeIcon";
|
2021-05-27 11:20:34 +03:00
|
|
|
import { Link } from "~/components/core/Link";
|
2020-07-16 04:36:29 +03:00
|
|
|
|
|
|
|
import ScenePage from "~/components/core/ScenePage";
|
2020-08-22 07:25:34 +03:00
|
|
|
import ScenePageHeader from "~/components/core/ScenePageHeader";
|
2021-05-27 11:20:34 +03:00
|
|
|
import CollectionPreviewBlock from "~/components/core/CollectionPreviewBlock";
|
2021-03-07 23:53:54 +03:00
|
|
|
import SquareButtonGray from "~/components/core/SquareButtonGray";
|
2020-09-02 03:15:56 +03:00
|
|
|
import EmptyState from "~/components/core/EmptyState";
|
2021-05-17 06:23:46 +03:00
|
|
|
import WebsitePrototypeWrapper from "~/components/core/WebsitePrototypeWrapper";
|
2020-07-16 04:36:29 +03:00
|
|
|
|
2020-07-27 06:20:34 +03:00
|
|
|
// TODO(jim): Slates design.
|
2020-07-16 04:36:29 +03:00
|
|
|
export default class SceneSlates extends React.Component {
|
2020-09-01 07:44:56 +03:00
|
|
|
_handleAdd = () => {
|
2020-09-04 01:42:08 +03:00
|
|
|
this.props.onAction({
|
2020-09-01 07:44:56 +03:00
|
|
|
name: "Create slate",
|
|
|
|
type: "SIDEBAR",
|
|
|
|
value: "SIDEBAR_CREATE_SLATE",
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-09-14 08:22:19 +03:00
|
|
|
_handleSearch = () => {
|
2020-11-28 07:39:01 +03:00
|
|
|
Events.dispatchCustomEvent({
|
2020-11-10 00:20:38 +03:00
|
|
|
name: "show-search",
|
|
|
|
detail: {},
|
2020-09-14 08:22:19 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-07-16 04:36:29 +03:00
|
|
|
render() {
|
2021-05-06 03:08:14 +03:00
|
|
|
const tab = this.props.page.params?.tab || "collections";
|
2021-03-07 23:53:54 +03:00
|
|
|
let subscriptions = this.props.viewer.subscriptions;
|
2020-09-03 02:24:10 +03:00
|
|
|
|
2020-07-27 11:33:39 +03:00
|
|
|
return (
|
2021-05-17 06:23:46 +03:00
|
|
|
<WebsitePrototypeWrapper
|
|
|
|
title={`${this.props.page.pageTitle} • Slate`}
|
|
|
|
url={`${Constants.hostname}${this.props.page.pathname}`}
|
|
|
|
>
|
|
|
|
<ScenePage>
|
2021-05-27 11:20:34 +03:00
|
|
|
<div>
|
|
|
|
<div style={{ display: "flex", alignItems: "center", marginBottom: 24 }}>
|
|
|
|
<SecondaryTabGroup
|
|
|
|
tabs={[
|
|
|
|
{ title: "My Collections", value: { tab: "collections" } },
|
|
|
|
{ title: "Subscribed", value: { tab: "subscribed" } },
|
|
|
|
]}
|
|
|
|
value={tab}
|
2021-05-17 06:23:46 +03:00
|
|
|
onAction={this.props.onAction}
|
2021-05-27 11:20:34 +03:00
|
|
|
style={{ margin: 0 }}
|
2021-05-17 06:23:46 +03:00
|
|
|
/>
|
2021-05-27 11:20:34 +03:00
|
|
|
<SquareButtonGray onClick={this._handleAdd} style={{ marginLeft: 16 }}>
|
|
|
|
<SVG.Plus height="16px" />
|
|
|
|
</SquareButtonGray>
|
|
|
|
</div>
|
|
|
|
{tab === "collections" ? (
|
|
|
|
this.props.viewer.slates?.length ? (
|
|
|
|
<div css={Styles.COLLECTIONS_PREVIEW_GRID}>
|
|
|
|
{this.props.viewer.slates.map((slate) => (
|
|
|
|
<Link
|
|
|
|
key={slate.id}
|
|
|
|
href={`/$/slate/${slate.id}`}
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
>
|
|
|
|
<CollectionPreviewBlock
|
|
|
|
key={slate.id}
|
|
|
|
collection={slate}
|
|
|
|
viewer={this.props.viewer}
|
2021-07-15 19:32:18 +03:00
|
|
|
owner={this.props.viewer}
|
|
|
|
onAction={this.props.onAction}
|
2021-05-27 11:20:34 +03:00
|
|
|
/>
|
|
|
|
</Link>
|
|
|
|
))}
|
2021-05-17 06:23:46 +03:00
|
|
|
</div>
|
2021-05-27 11:20:34 +03:00
|
|
|
) : (
|
2021-12-14 21:06:12 +03:00
|
|
|
<div css={Styles.PAGE_EMPTY_STATE_WRAPPER}>
|
|
|
|
<EmptyState>
|
|
|
|
<FileTypeGroup />
|
|
|
|
<div style={{ marginTop: 24 }}>
|
|
|
|
Use collections to create mood boards, share files, and organize research.
|
|
|
|
</div>
|
|
|
|
<ButtonSecondary onClick={this._handleAdd} style={{ marginTop: 32 }}>
|
|
|
|
Create collection
|
|
|
|
</ButtonSecondary>
|
|
|
|
</EmptyState>
|
|
|
|
</div>
|
2021-05-27 11:20:34 +03:00
|
|
|
)
|
|
|
|
) : null}
|
2020-11-08 05:32:17 +03:00
|
|
|
|
2021-05-27 11:20:34 +03:00
|
|
|
{tab === "subscribed" ? (
|
|
|
|
subscriptions && subscriptions.length ? (
|
|
|
|
<div css={Styles.COLLECTIONS_PREVIEW_GRID}>
|
|
|
|
{subscriptions.map((slate) => (
|
|
|
|
<Link
|
|
|
|
key={slate.id}
|
|
|
|
href={`/$/slate/${slate.id}`}
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
>
|
|
|
|
<CollectionPreviewBlock
|
|
|
|
key={slate.id}
|
|
|
|
collection={slate}
|
2021-07-15 19:32:18 +03:00
|
|
|
owner={slate.owner}
|
2021-05-27 11:20:34 +03:00
|
|
|
viewer={this.props.viewer}
|
2021-07-15 19:32:18 +03:00
|
|
|
onAction={this.props.onAction}
|
2021-05-27 11:20:34 +03:00
|
|
|
/>
|
|
|
|
</Link>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<EmptyState>
|
|
|
|
You can follow any public collections on the network.
|
|
|
|
<ButtonSecondary onClick={this._handleSearch} style={{ marginTop: 32 }}>
|
|
|
|
Browse collections
|
|
|
|
</ButtonSecondary>
|
|
|
|
</EmptyState>
|
|
|
|
)
|
|
|
|
) : null}
|
|
|
|
</div>
|
2021-05-17 06:23:46 +03:00
|
|
|
</ScenePage>
|
|
|
|
</WebsitePrototypeWrapper>
|
2020-07-27 11:33:39 +03:00
|
|
|
);
|
2020-07-16 04:36:29 +03:00
|
|
|
}
|
|
|
|
}
|