2020-08-31 21:19:46 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
2020-09-03 00:08:32 +03:00
|
|
|
import { ProcessedText } from "~/components/system/components/Typography";
|
2020-08-31 21:19:46 +03:00
|
|
|
|
|
|
|
import SlatePreviewBlock from "~/components/core/SlatePreviewBlock";
|
2020-09-06 02:41:12 +03:00
|
|
|
import SceneContent from "~/components/core/SceneContent";
|
2020-08-31 21:19:46 +03:00
|
|
|
|
|
|
|
const STYLES_PROFILE = css`
|
|
|
|
text-align: center;
|
|
|
|
width: 100%;
|
|
|
|
margin-top: 16px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_PROFILE_IMAGE = css`
|
|
|
|
background-size: cover;
|
|
|
|
background-position: 50% 50%;
|
2020-09-05 04:40:23 +03:00
|
|
|
width: 152px;
|
|
|
|
height: 152px;
|
|
|
|
border-radius: 4px;
|
2020-08-31 21:19:46 +03:00
|
|
|
margin: 0 auto;
|
|
|
|
padding: 0;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_NAME = css`
|
|
|
|
font-size: ${Constants.typescale.lvl3};
|
2020-09-04 07:16:19 +03:00
|
|
|
font-family: ${Constants.font.medium};
|
2020-09-03 00:08:32 +03:00
|
|
|
width: 100%;
|
|
|
|
max-width: 420px;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding: 0 24px 0 24px;
|
2020-09-06 07:32:39 +03:00
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2020-09-03 00:08:32 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_DESCRIPTION = css`
|
|
|
|
font-size: ${Constants.typescale.lvl1};
|
|
|
|
width: 100%;
|
2020-09-06 07:32:39 +03:00
|
|
|
max-width: 800px;
|
2020-09-03 00:08:32 +03:00
|
|
|
margin: 0 auto;
|
|
|
|
padding: 0 24px 0 24px;
|
2020-09-06 07:32:39 +03:00
|
|
|
word-wrap: break-word;
|
2020-08-31 21:19:46 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_LINK = css`
|
|
|
|
color: ${Constants.system.black};
|
|
|
|
text-decoration: none;
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default class Profile extends React.Component {
|
|
|
|
render() {
|
|
|
|
let data = this.props.creator ? this.props.creator : this.props.data;
|
|
|
|
return (
|
|
|
|
<div css={STYLES_PROFILE}>
|
|
|
|
<div
|
|
|
|
css={STYLES_PROFILE_IMAGE}
|
|
|
|
style={{ backgroundImage: `url('${data.data.photo}')` }}
|
|
|
|
/>
|
2020-09-03 00:08:32 +03:00
|
|
|
<br />
|
|
|
|
<div css={STYLES_NAME}>{data.data.name || data.username}</div>
|
|
|
|
<br />
|
|
|
|
{data.data.body ? (
|
|
|
|
<React.Fragment>
|
|
|
|
<div css={STYLES_DESCRIPTION}>
|
|
|
|
<ProcessedText text={data.data.body} />
|
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
</React.Fragment>
|
|
|
|
) : null}
|
|
|
|
<br />
|
2020-08-31 21:19:46 +03:00
|
|
|
{this.props.buttons}
|
|
|
|
<br />
|
2020-09-06 02:41:12 +03:00
|
|
|
<SceneContent>
|
|
|
|
{data.slates && data.slates.length ? (
|
|
|
|
<div>
|
|
|
|
{data.slates.map((slate) => {
|
|
|
|
if (this.props.onAction) {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
key={slate.id}
|
|
|
|
onClick={() =>
|
|
|
|
this.props.onAction({
|
|
|
|
type: "NAVIGATE",
|
|
|
|
value: this.props.sceneId,
|
|
|
|
scene: "PUBLIC_SLATE",
|
|
|
|
data: slate,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<SlatePreviewBlock
|
|
|
|
slate={slate}
|
|
|
|
username={data.username}
|
|
|
|
editing={this.props.editing}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-08-31 21:19:46 +03:00
|
|
|
return (
|
2020-09-06 02:41:12 +03:00
|
|
|
<a
|
2020-09-05 07:06:36 +03:00
|
|
|
key={slate.id}
|
2020-09-06 02:41:12 +03:00
|
|
|
href={`/${data.username}/${slate.slatename}`}
|
|
|
|
css={STYLES_LINK}
|
2020-08-31 21:19:46 +03:00
|
|
|
>
|
2020-09-06 02:41:12 +03:00
|
|
|
<SlatePreviewBlock external slate={slate} />
|
|
|
|
</a>
|
2020-08-31 21:19:46 +03:00
|
|
|
);
|
2020-09-06 02:41:12 +03:00
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</SceneContent>
|
2020-08-31 21:19:46 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|