slate/components/core/Profile.js

113 lines
3.0 KiB
JavaScript
Raw Normal View History

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";
import SlatePreviewBlock from "~/components/core/SlatePreviewBlock";
2020-09-06 02:41:12 +03:00
import SceneContent from "~/components/core/SceneContent";
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;
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;
`;
const STYLES_DESCRIPTION = css`
font-size: ${Constants.typescale.lvl1};
width: 100%;
max-width: 420px;
margin: 0 auto;
padding: 0 24px 0 24px;
`;
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 />
{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>
);
}
return (
2020-09-06 02:41:12 +03:00
<a
key={slate.id}
2020-09-06 02:41:12 +03:00
href={`/${data.username}/${slate.slatename}`}
css={STYLES_LINK}
>
2020-09-06 02:41:12 +03:00
<SlatePreviewBlock external slate={slate} />
</a>
);
2020-09-06 02:41:12 +03:00
})}
</div>
) : null}
</SceneContent>
</div>
);
}
}