2020-08-31 21:19:46 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
2020-09-27 23:11:04 +03:00
|
|
|
import * as Strings from "~/common/strings";
|
2021-01-08 03:48:57 +03:00
|
|
|
import * as SVG from "~/common/svg";
|
2020-08-31 21:19:46 +03:00
|
|
|
|
2020-11-30 08:24:22 +03:00
|
|
|
import { css } from "@emotion/react";
|
2020-08-31 21:19:46 +03:00
|
|
|
|
2020-11-26 02:19:02 +03:00
|
|
|
import ProcessedText from "~/components/core/ProcessedText";
|
2020-10-02 02:44:22 +03:00
|
|
|
import SlatePreviewBlocks from "~/components/core/SlatePreviewBlock";
|
2020-11-13 01:27:50 +03:00
|
|
|
import CTATransition from "~/components/core/CTATransition";
|
2021-01-08 03:48:57 +03:00
|
|
|
import DataView from "~/components/core/DataView";
|
|
|
|
import EmptyState from "~/components/core/EmptyState";
|
|
|
|
|
2021-01-06 02:09:59 +03:00
|
|
|
import { SceneUtils } from "three";
|
2021-01-08 03:48:57 +03:00
|
|
|
import { TabGroup, SecondaryTabGroup } from "~/components/core/TabGroup";
|
2021-01-06 02:09:59 +03:00
|
|
|
|
|
|
|
const STYLES_PROFILE_BACKGROUND = css`
|
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
width: 100%;
|
|
|
|
padding: 104px 56px 24px 56px;
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
padding: 80px 24px 16px 24px;
|
|
|
|
}
|
|
|
|
`;
|
2020-11-01 21:40:03 +03:00
|
|
|
|
|
|
|
const STYLES_PROFILE_INTERNAL = css`
|
|
|
|
width: 100%;
|
2021-01-08 03:48:57 +03:00
|
|
|
padding: 0px 56px 0px 56px;
|
2020-11-01 21:40:03 +03:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
2021-01-06 02:09:59 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
padding: 80px 24px 16px 24px;
|
|
|
|
}
|
2020-11-01 21:40:03 +03:00
|
|
|
`;
|
2020-08-31 21:19:46 +03:00
|
|
|
|
|
|
|
const STYLES_PROFILE = css`
|
|
|
|
width: 100%;
|
2020-11-21 00:45:10 +03:00
|
|
|
padding: 32px 32px 0px 32px;
|
2020-11-01 21:40:03 +03:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
flex-shrink: 0;
|
|
|
|
display: block;
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2021-01-06 02:09:59 +03:00
|
|
|
padding: 80px 24px 16px 24px;
|
2020-11-01 21:40:03 +03:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_PROFILE_INFO = css`
|
|
|
|
line-height: 1.3;
|
2020-11-05 00:44:28 +03:00
|
|
|
width: 50%;
|
2021-01-06 02:09:59 +03:00
|
|
|
max-width: 800px;
|
2020-11-01 21:40:03 +03:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
2021-01-06 02:09:59 +03:00
|
|
|
margin: 0 auto;
|
2020-11-05 21:31:48 +03:00
|
|
|
@media (max-width: ${Constants.sizes.tablet}px) {
|
2020-11-05 00:44:28 +03:00
|
|
|
width: 100%;
|
2021-01-06 02:09:59 +03:00
|
|
|
max-width: 100%;
|
2020-11-05 00:44:28 +03:00
|
|
|
}
|
2020-11-01 21:40:03 +03:00
|
|
|
`;
|
|
|
|
|
2021-01-06 02:09:59 +03:00
|
|
|
const STYLES_INFO = css`
|
2020-11-01 21:40:03 +03:00
|
|
|
display: block;
|
2020-11-28 04:54:42 +03:00
|
|
|
width: 100%;
|
2021-01-06 02:09:59 +03:00
|
|
|
text-align: center;
|
2020-11-01 21:40:03 +03:00
|
|
|
margin-bottom: 48px;
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
`;
|
|
|
|
|
2020-08-31 21:19:46 +03:00
|
|
|
const STYLES_PROFILE_IMAGE = css`
|
2020-12-13 04:16:55 +03:00
|
|
|
background-color: ${Constants.system.white};
|
2020-08-31 21:19:46 +03:00
|
|
|
background-size: cover;
|
|
|
|
background-position: 50% 50%;
|
2021-01-06 02:09:59 +03:00
|
|
|
width: 120px;
|
|
|
|
height: 120px;
|
2020-11-01 21:40:03 +03:00
|
|
|
flex-shrink: 0;
|
2020-09-05 04:40:23 +03:00
|
|
|
border-radius: 4px;
|
2021-01-06 02:09:59 +03:00
|
|
|
margin: 0 auto;
|
2020-11-01 21:40:03 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
width: 64px;
|
|
|
|
height: 64px;
|
|
|
|
}
|
2020-08-31 21:19:46 +03:00
|
|
|
`;
|
|
|
|
|
2021-01-06 02:09:59 +03:00
|
|
|
const STYLES_NAME = css`
|
|
|
|
font-size: ${Constants.typescale.lvl4};
|
2020-11-17 10:12:35 +03:00
|
|
|
font-family: ${Constants.font.semiBold};
|
2020-11-01 21:40:03 +03:00
|
|
|
max-width: 100%;
|
2020-11-17 10:12:35 +03:00
|
|
|
font-weight: 400;
|
2021-01-06 02:09:59 +03:00
|
|
|
margin: 16px auto;
|
2020-11-01 21:40:03 +03:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
2020-11-17 10:12:35 +03:00
|
|
|
color: ${Constants.system.black};
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
2020-09-03 00:08:32 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_DESCRIPTION = css`
|
2020-11-17 10:12:35 +03:00
|
|
|
font-size: ${Constants.typescale.lvl0};
|
|
|
|
color: ${Constants.system.darkGray};
|
2021-01-06 02:09:59 +03:00
|
|
|
max-width: 100%;
|
2020-11-01 21:40:03 +03:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
white-space: pre-wrap;
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
margin-top: 24px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_STATS = css`
|
|
|
|
font-size: ${Constants.typescale.lvl0};
|
2021-01-06 02:09:59 +03:00
|
|
|
margin: 16px auto;
|
2020-11-01 21:40:03 +03:00
|
|
|
display: flex;
|
2021-01-06 02:09:59 +03:00
|
|
|
justify-content: center;
|
2020-11-17 10:12:35 +03:00
|
|
|
color: ${Constants.system.grayBlack};
|
2020-11-01 21:40:03 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_STAT = css`
|
2020-11-17 10:12:35 +03:00
|
|
|
margin-right: 8px;
|
2020-11-01 21:40:03 +03:00
|
|
|
width: 112px;
|
|
|
|
flex-shrink: 0;
|
2020-08-31 21:19:46 +03:00
|
|
|
`;
|
|
|
|
|
2020-11-17 10:12:35 +03:00
|
|
|
const STYLES_EXPLORE = css`
|
|
|
|
margin: 160px auto 64px auto;
|
|
|
|
height: 1px;
|
|
|
|
width: 80px;
|
|
|
|
background-color: ${Constants.system.gray};
|
2020-08-31 21:19:46 +03:00
|
|
|
`;
|
|
|
|
|
2021-01-06 02:09:59 +03:00
|
|
|
const STYLES_BUTTON = css`
|
|
|
|
margin-bottom: 32px;
|
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-31 21:19:46 +03:00
|
|
|
export default class Profile extends React.Component {
|
2020-11-13 01:27:50 +03:00
|
|
|
state = {
|
2020-11-17 10:12:35 +03:00
|
|
|
exploreSlates: [],
|
2021-01-08 03:48:57 +03:00
|
|
|
tab: 1,
|
|
|
|
view: 0,
|
|
|
|
slateTab: 0,
|
|
|
|
peerTab: 0,
|
2020-11-13 01:27:50 +03:00
|
|
|
};
|
|
|
|
|
2020-08-31 21:19:46 +03:00
|
|
|
render() {
|
2020-12-13 04:16:55 +03:00
|
|
|
const external = !this.props.onAction;
|
2020-08-31 21:19:46 +03:00
|
|
|
let data = this.props.creator ? this.props.creator : this.props.data;
|
2020-11-17 10:12:35 +03:00
|
|
|
let exploreSlates = this.props.exploreSlates;
|
2021-01-10 22:34:54 +03:00
|
|
|
let subscriptions = this.props.creator.subscriptions ? this.props.creator.subscriptions : null;
|
|
|
|
let followingSlates = [];
|
|
|
|
for (let subscription of subscriptions) {
|
|
|
|
if (subscription.slate != null) {
|
|
|
|
followingSlates.push(subscription.slate);
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 21:40:03 +03:00
|
|
|
|
2021-01-10 22:34:54 +03:00
|
|
|
console.log("creator.subscription", subscriptions);
|
|
|
|
console.log("following slates", followingSlates);
|
2021-01-08 03:48:57 +03:00
|
|
|
|
2020-11-01 21:40:03 +03:00
|
|
|
let total = 0;
|
|
|
|
for (let slate of data.slates) {
|
|
|
|
total += slate.data.objects.length;
|
|
|
|
}
|
2020-08-31 21:19:46 +03:00
|
|
|
return (
|
2020-11-01 21:40:03 +03:00
|
|
|
<div>
|
2021-01-06 02:09:59 +03:00
|
|
|
<div css={STYLES_PROFILE_BACKGROUND}>
|
|
|
|
<div css={STYLES_PROFILE_INFO}>
|
|
|
|
<div
|
|
|
|
css={STYLES_PROFILE_IMAGE}
|
|
|
|
style={{ backgroundImage: `url('${data.data.photo}')` }}
|
|
|
|
/>
|
|
|
|
<div css={STYLES_INFO}>
|
|
|
|
<div css={STYLES_NAME}>{Strings.getPresentationName(data)}</div>
|
|
|
|
<div css={STYLES_BUTTON}>{this.props.buttons}</div>
|
|
|
|
{data.data.body ? (
|
|
|
|
<div css={STYLES_DESCRIPTION}>
|
|
|
|
<ProcessedText text={data.data.body} />
|
2020-11-01 21:40:03 +03:00
|
|
|
</div>
|
2021-01-06 02:09:59 +03:00
|
|
|
) : null}
|
|
|
|
<div css={STYLES_STATS}>
|
|
|
|
<div css={STYLES_STAT}>
|
|
|
|
<div style={{ fontFamily: `${Constants.font.text}` }}>
|
|
|
|
{total}{" "}
|
|
|
|
<span style={{ color: `${Constants.system.darkGray}` }}>Public data</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_STAT}>
|
|
|
|
<div style={{ fontFamily: `${Constants.font.text}` }}>
|
|
|
|
{data.slates.length}{" "}
|
|
|
|
<span style={{ color: `${Constants.system.darkGray}` }}>Public slates</span>
|
|
|
|
</div>
|
2020-11-01 21:40:03 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-03 00:08:32 +03:00
|
|
|
</div>
|
2020-11-01 21:40:03 +03:00
|
|
|
</div>
|
2020-12-13 04:16:55 +03:00
|
|
|
</div>
|
2020-11-13 01:27:50 +03:00
|
|
|
{this.state.visible && (
|
|
|
|
<div>
|
2020-11-17 05:10:43 +03:00
|
|
|
<CTATransition
|
2020-11-17 06:17:56 +03:00
|
|
|
onClose={() => this.setState({ visible: false })}
|
2020-11-17 05:10:43 +03:00
|
|
|
viewer={this.props.viewer}
|
|
|
|
open={this.state.visible}
|
2020-12-19 08:25:50 +03:00
|
|
|
redirectURL={`/_?scene=NAV_PROFILE&user=${data.username}`}
|
2020-11-17 05:10:43 +03:00
|
|
|
/>
|
2020-11-13 01:27:50 +03:00
|
|
|
</div>
|
|
|
|
)}
|
2020-11-01 21:40:03 +03:00
|
|
|
{this.props.onAction ? (
|
2021-01-06 02:09:59 +03:00
|
|
|
<div css={STYLES_PROFILE_INTERNAL}>
|
2021-01-08 03:48:57 +03:00
|
|
|
<TabGroup
|
|
|
|
tabs={["Files", "Slates", "Peers"]}
|
|
|
|
value={this.state.tab}
|
|
|
|
onChange={(value) => this.setState({ tab: value })}
|
|
|
|
style={{ marginBottom: 32 }}
|
|
|
|
/>
|
|
|
|
{this.state.tab === 0 ? (
|
|
|
|
<div>
|
|
|
|
<SecondaryTabGroup
|
|
|
|
tabs={[
|
|
|
|
<SVG.GridView height="24px" style={{ display: "block" }} />,
|
|
|
|
<SVG.TableView height="24px" style={{ display: "block" }} />,
|
|
|
|
]}
|
|
|
|
value={this.state.view}
|
|
|
|
onChange={(value) => this.setState({ view: value })}
|
|
|
|
style={{ margin: "0 0 24px 0", justifyContent: "flex-end" }}
|
|
|
|
/>
|
|
|
|
{this.props.viewer.library[0].children &&
|
|
|
|
this.props.viewer.library[0].children.length ? (
|
|
|
|
<DataView
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
viewer={this.props.viewer}
|
|
|
|
items={this.props.viewer.library[0].children}
|
|
|
|
onUpdateViewer={this.props.onUpdateViewer}
|
|
|
|
view={this.state.view}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<EmptyState>
|
|
|
|
<FileTypeGroup />
|
|
|
|
<div style={{ marginTop: 24 }}>Drag and drop files into Slate to upload</div>
|
|
|
|
</EmptyState>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
{this.state.tab === 1 ? (
|
|
|
|
<div>
|
|
|
|
<SecondaryTabGroup
|
|
|
|
tabs={["Public Slates", "Following Slates"]}
|
|
|
|
value={this.state.slateTab}
|
|
|
|
onChange={(value) => this.setState({ slateTab: value })}
|
|
|
|
style={{ margin: "0 0 24px 0" }}
|
|
|
|
/>
|
|
|
|
{this.state.slateTab === 0 ? (
|
|
|
|
<div>
|
|
|
|
{data.slates && data.slates.length ? (
|
|
|
|
<SlatePreviewBlocks
|
|
|
|
isOwner={this.props.isOwner}
|
|
|
|
external={this.props.onAction ? false : true}
|
|
|
|
slates={data.slates}
|
|
|
|
username={data.username}
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : null}
|
2021-01-10 22:34:54 +03:00
|
|
|
{this.state.slateTab === 1 ? (
|
|
|
|
<div>
|
|
|
|
{followingSlates ? (
|
|
|
|
<SlatePreviewBlocks
|
|
|
|
isOwner={false}
|
|
|
|
external={this.props.onAction ? false : true}
|
|
|
|
slates={followingSlates}
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : null}
|
2021-01-08 03:48:57 +03:00
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
{this.state.tab === 2 ? (
|
|
|
|
<div>
|
|
|
|
<SecondaryTabGroup
|
2021-01-10 22:34:54 +03:00
|
|
|
tabs={["Following", "Followers"]}
|
2021-01-08 03:48:57 +03:00
|
|
|
value={this.state.peerTab}
|
|
|
|
onChange={(value) => this.setState({ peerTab: value })}
|
|
|
|
style={{ margin: "0 0 24px 0" }}
|
|
|
|
/>
|
|
|
|
{this.state.peerTab === 0 ? <div>{/*following*/}</div> : null}
|
|
|
|
{this.state.peerTab === 1 ? <div>{/*follower*/}</div> : null}
|
|
|
|
</div>
|
2020-11-01 21:40:03 +03:00
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : (
|
2021-01-06 02:09:59 +03:00
|
|
|
<div css={STYLES_PROFILE}>
|
2020-11-01 21:40:03 +03:00
|
|
|
{data.slates && data.slates.length ? (
|
2020-12-11 11:16:12 +03:00
|
|
|
<SlatePreviewBlocks
|
2020-11-01 21:40:03 +03:00
|
|
|
isOwner={this.props.isOwner}
|
2020-12-11 11:16:12 +03:00
|
|
|
external={this.props.onAction ? false : true}
|
2020-11-01 21:40:03 +03:00
|
|
|
slates={data.slates}
|
|
|
|
username={data.username}
|
|
|
|
onAction={this.props.onAction}
|
|
|
|
/>
|
2020-11-17 10:12:35 +03:00
|
|
|
) : (
|
|
|
|
<div>
|
|
|
|
{" "}
|
|
|
|
<p style={{ marginTop: 40, color: `${Constants.system.darkGray}` }}>
|
|
|
|
No publicly shared slates from @{data.username}.
|
|
|
|
</p>
|
|
|
|
<div css={STYLES_EXPLORE} />
|
2020-12-11 11:16:12 +03:00
|
|
|
<SlatePreviewBlocks
|
|
|
|
slates={exploreSlates}
|
|
|
|
external={this.props.onAction ? false : true}
|
|
|
|
/>
|
2020-11-17 10:12:35 +03:00
|
|
|
</div>
|
|
|
|
)}
|
2020-11-01 21:40:03 +03:00
|
|
|
</div>
|
|
|
|
)}
|
2020-08-31 21:19:46 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|