mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 10:05:02 +03:00
feat(ApplicationUserControls): update to new styles
This commit is contained in:
parent
a45a843282
commit
c38f84733d
@ -2,18 +2,18 @@ import * as React from "react";
|
|||||||
import * as Constants from "~/common/constants";
|
import * as Constants from "~/common/constants";
|
||||||
import * as Styles from "~/common/styles";
|
import * as Styles from "~/common/styles";
|
||||||
import * as UserBehaviors from "~/common/user-behaviors";
|
import * as UserBehaviors from "~/common/user-behaviors";
|
||||||
|
import * as Strings from "~/common/strings";
|
||||||
|
|
||||||
import { PopoverNavigation } from "~/components/system";
|
import { PopoverNavigation } from "~/components/system";
|
||||||
import { css } from "@emotion/react";
|
import { css } from "@emotion/react";
|
||||||
import { Link } from "~/components/core/Link";
|
import { Link } from "~/components/core/Link";
|
||||||
import ProfilePhoto from "~/components/core/ProfilePhoto";
|
|
||||||
|
|
||||||
import { Boundary } from "~/components/system/components/fragments/Boundary";
|
import { Boundary } from "~/components/system/components/fragments/Boundary";
|
||||||
import { useIntercom } from "react-use-intercom";
|
import { H4, P3 } from "~/components/system/components/Typography";
|
||||||
|
|
||||||
|
import ProfilePhoto from "~/components/core/ProfilePhoto";
|
||||||
|
|
||||||
const STYLES_HEADER = css`
|
const STYLES_HEADER = css`
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-left: 16px;
|
|
||||||
|
|
||||||
@media (max-width: ${Constants.sizes.mobile}px) {
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
@ -21,111 +21,88 @@ const STYLES_HEADER = css`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const STYLES_PROFILE = css`
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-start;
|
|
||||||
min-width: 10%;
|
|
||||||
width: 204px;
|
|
||||||
|
|
||||||
color: ${Constants.system.black};
|
|
||||||
background-color: ${Constants.system.white};
|
|
||||||
font-size: 12px;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
min-height: 48px;
|
|
||||||
cursor: pointer;
|
|
||||||
border: 1px solid rgba(229, 229, 229, 0.5);
|
|
||||||
box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.03);
|
|
||||||
|
|
||||||
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const STYLES_PROFILE_MOBILE = css`
|
const STYLES_PROFILE_MOBILE = css`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const STYLES_PROFILE_IMAGE = css`
|
const STYLES_POPOVER_CONTANIER = (theme) => css`
|
||||||
background-color: ${Constants.semantic.bgLight};
|
padding: 16px 20px;
|
||||||
background-size: cover;
|
border-radius: 16px;
|
||||||
background-position: 50% 50%;
|
border: 1px solid ${theme.semantic.borderGrayLight4};
|
||||||
flex-shrink: 0;
|
box-shadow: ${theme.shadow.lightLarge};
|
||||||
height: 24px;
|
|
||||||
width: 24px;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
${"" /* @media (max-width: ${Constants.sizes.mobile}px) {
|
@supports ((-webkit-backdrop-filter: blur(75px)) or (backdrop-filter: blur(75px))) {
|
||||||
height: 24px;
|
background-color: ${theme.semantic.bgBlurWhite};
|
||||||
width: 24px;
|
-webkit-backdrop-filter: blur(75px);
|
||||||
} */}
|
backdrop-filter: blur(75px);
|
||||||
`;
|
|
||||||
|
|
||||||
const STYLES_PROFILE_USERNAME = css`
|
|
||||||
min-width: 10%;
|
|
||||||
width: 100%;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
padding: 12px;
|
|
||||||
user-select: none;
|
|
||||||
font-family: ${Constants.font.medium};
|
|
||||||
font-size: ${Constants.typescale.lvl1};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const STYLES_ITEM_BOX_MOBILE = css`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 4px;
|
|
||||||
background-color: ${Constants.system.white};
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 4px;
|
|
||||||
border-left: 2px solid ${Constants.semantic.bgLight};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const STYLES_ITEM_BOX = css`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
|
||||||
padding: 8px;
|
|
||||||
padding-right: 9px;
|
|
||||||
transition: 200ms ease all;
|
|
||||||
border-left: 2px solid ${Constants.semantic.bgLight};
|
|
||||||
|
|
||||||
:hover {
|
|
||||||
color: ${Constants.system.blue};
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// const OpenIntercom = ({ user, onTogglePopup }) => {
|
const STYLES_POPOVER_SECTION = (theme) => css`
|
||||||
// const { show, update } = useIntercom();
|
border-top: 1px solid ${theme.semantic.borderGrayLight4};
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
|
||||||
// return (
|
p {
|
||||||
// <span
|
display: block;
|
||||||
// style={{ cursor: "pointer", display: "block" }}
|
width: 100%;
|
||||||
// onClick={() => {
|
}
|
||||||
// onTogglePopup();
|
|
||||||
// update({
|
:last-child {
|
||||||
// name: user.data.name,
|
padding-bottom: 0px;
|
||||||
// email: user.email,
|
}
|
||||||
// customAttributes: {
|
|
||||||
// slate_userid: user.id,
|
* + * {
|
||||||
// username: user.username,
|
margin-top: 4px;
|
||||||
// },
|
}
|
||||||
// });
|
`;
|
||||||
// show();
|
|
||||||
// }}
|
const STYLES_POPOVER_SECTION_ITEM = (theme) => css`
|
||||||
// >
|
position: relative;
|
||||||
// Help
|
width: calc(100% + 16px);
|
||||||
// </span>
|
left: -8px;
|
||||||
// );
|
padding: 1px 8px 3px;
|
||||||
// };
|
border-radius: 8px;
|
||||||
|
&:hover {
|
||||||
|
background-color: ${theme.system.grayLight4};
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const STYLES_DATAMETER_WRAPPER = (theme) => css`
|
||||||
|
width: 100%;
|
||||||
|
min-width: 240px;
|
||||||
|
height: 8px;
|
||||||
|
background-color: ${theme.semantic.bgBlurWhiteTRN};
|
||||||
|
border: 1px solid ${theme.semantic.borderGrayLight4};
|
||||||
|
border-radius: 2px;
|
||||||
|
overflow: hidden;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const STYLES_DATAMETER = (theme) => css`
|
||||||
|
height: 100%;
|
||||||
|
background-color: ${theme.system.blue};
|
||||||
|
border-radius: 2px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const DataMeter = ({ bytes = 1000, maximumBytes = 4000, ...props }) => {
|
||||||
|
const percentage = bytes / maximumBytes;
|
||||||
|
return (
|
||||||
|
<div css={STYLES_DATAMETER_WRAPPER} {...props}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: `calc(${percentage} * 100%)`,
|
||||||
|
}}
|
||||||
|
css={STYLES_DATAMETER}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export class ApplicationUserControlsPopup extends React.Component {
|
export class ApplicationUserControlsPopup extends React.Component {
|
||||||
_handleAction = (props) => {
|
_handleAction = (props) => {
|
||||||
@ -141,32 +118,28 @@ export class ApplicationUserControlsPopup extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.popup === "profile") {
|
if (this.props.popup !== "profile") return null;
|
||||||
const topSection = (
|
|
||||||
<div css={Styles.HORIZONTAL_CONTAINER} style={{ marginBottom: 14 }}>
|
|
||||||
<div style={{ marginRight: "16px", cursor: "default" }}>
|
|
||||||
<ProfilePhoto user={this.props.viewer} size={46} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
const username = this.props.viewer.data.name || `@${this.props.viewer.username}`;
|
||||||
css={Styles.VERTICAL_CONTAINER}
|
const objectsLength = this.props.viewer.library.length;
|
||||||
style={{
|
const { stats } = this.props.viewer;
|
||||||
height: 46,
|
|
||||||
justifyContent: "space-between",
|
const topSection = (
|
||||||
}}
|
<div style={{ marginBottom: 16 }} css={Styles.VERTICAL_CONTAINER_CENTERED}>
|
||||||
>
|
<ProfilePhoto user={this.props.viewer} style={{ borderRadius: "12px" }} size={48} />
|
||||||
<div css={Styles.H4}>
|
<H4 color="textBlack" style={{ marginTop: 10 }}>
|
||||||
{this.props.viewer.data.name || `@${this.props.viewer.username}`}
|
{username}
|
||||||
</div>
|
</H4>
|
||||||
<div css={Styles.HORIZONTAL_CONTAINER}>
|
<div style={{ marginTop: 6 }} css={Styles.HORIZONTAL_CONTAINER}>
|
||||||
<span css={Styles.P3} style={{ marginRight: 8 }}>{`${
|
<P3 color="textBlack" style={{ marginRight: 8 }}>
|
||||||
this.props.viewer.library.length
|
{objectsLength} {Strings.pluralize("Object", objectsLength)}
|
||||||
} File${this.props.viewer.library.length === 1 ? "" : "s"}`}</span>
|
</P3>
|
||||||
<span css={Styles.P3}>{`${this.props.viewer.slates.length} Collection${
|
<P3 color="textBlack" style={{ marginLeft: 8 }}>
|
||||||
this.props.viewer.slates.length === 1 ? "" : "s"
|
{Strings.bytesToSize(stats.bytes, 0)} of {Strings.bytesToSize(stats.maximumBytes, 0)}{" "}
|
||||||
}`}</span>
|
Stored
|
||||||
</div>
|
</P3>
|
||||||
</div>
|
</div>
|
||||||
|
<DataMeter bytes={stats.bytes} maximumBytes={stats.maximumBytes} style={{ marginTop: 8 }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -218,17 +191,6 @@ export class ApplicationUserControlsPopup extends React.Component {
|
|||||||
</Link>
|
</Link>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
|
||||||
[
|
|
||||||
// {
|
|
||||||
// text: (
|
|
||||||
// <OpenIntercom
|
|
||||||
// style={{ display: "block" }}
|
|
||||||
// user={this.props.viewer}
|
|
||||||
// onTogglePopup={this.props.onTogglePopup}
|
|
||||||
// />
|
|
||||||
// ),
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
text: "Sign out",
|
text: "Sign out",
|
||||||
onClick: (e) => {
|
onClick: (e) => {
|
||||||
@ -249,14 +211,15 @@ export class ApplicationUserControlsPopup extends React.Component {
|
|||||||
>
|
>
|
||||||
<PopoverNavigation
|
<PopoverNavigation
|
||||||
style={{
|
style={{
|
||||||
width: "max-content",
|
|
||||||
position: "relative",
|
position: "relative",
|
||||||
border: "none",
|
border: "none",
|
||||||
boxShadow: "none",
|
boxShadow: "none",
|
||||||
width: "100vw",
|
|
||||||
background: "none",
|
background: "none",
|
||||||
pointerEvents: "auto",
|
pointerEvents: "auto",
|
||||||
}}
|
}}
|
||||||
|
containerCss={STYLES_POPOVER_CONTANIER}
|
||||||
|
sectionCss={STYLES_POPOVER_SECTION}
|
||||||
|
sectionItemCss={STYLES_POPOVER_SECTION_ITEM}
|
||||||
css={Styles.H4}
|
css={Styles.H4}
|
||||||
itemStyle={{ fontSize: Constants.typescale.lvl0 }}
|
itemStyle={{ fontSize: Constants.typescale.lvl0 }}
|
||||||
topSection={topSection}
|
topSection={topSection}
|
||||||
@ -273,10 +236,13 @@ export class ApplicationUserControlsPopup extends React.Component {
|
|||||||
>
|
>
|
||||||
<PopoverNavigation
|
<PopoverNavigation
|
||||||
style={{
|
style={{
|
||||||
top: 36,
|
top: 34,
|
||||||
right: 0,
|
left: "-12px",
|
||||||
width: "max-content",
|
width: "max-content",
|
||||||
}}
|
}}
|
||||||
|
containerCss={STYLES_POPOVER_CONTANIER}
|
||||||
|
sectionCss={STYLES_POPOVER_SECTION}
|
||||||
|
sectionItemCss={STYLES_POPOVER_SECTION_ITEM}
|
||||||
css={Styles.H4}
|
css={Styles.H4}
|
||||||
itemStyle={{ fontSize: Constants.typescale.lvl0 }}
|
itemStyle={{ fontSize: Constants.typescale.lvl0 }}
|
||||||
topSection={topSection}
|
topSection={topSection}
|
||||||
@ -287,8 +253,6 @@ export class ApplicationUserControlsPopup extends React.Component {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ApplicationUserControls extends React.Component {
|
export class ApplicationUserControls extends React.Component {
|
||||||
@ -296,15 +260,15 @@ export class ApplicationUserControls extends React.Component {
|
|||||||
let tooltip = <ApplicationUserControlsPopup {...this.props} />;
|
let tooltip = <ApplicationUserControlsPopup {...this.props} />;
|
||||||
return (
|
return (
|
||||||
<div css={STYLES_HEADER}>
|
<div css={STYLES_HEADER}>
|
||||||
<div
|
<button
|
||||||
css={STYLES_PROFILE_MOBILE}
|
css={[Styles.BUTTON_RESET, STYLES_PROFILE_MOBILE]}
|
||||||
onClick={() => this.props.onTogglePopup("profile")}
|
onClick={() => this.props.onTogglePopup("profile")}
|
||||||
style={{ position: "relative", cursor: "pointer" }}
|
style={{ position: "relative", cursor: "pointer" }}
|
||||||
>
|
>
|
||||||
<ProfilePhoto user={this.props.viewer} size={24} />
|
<ProfilePhoto user={this.props.viewer} style={{ borderRadius: "8px" }} size={24} />
|
||||||
|
</button>
|
||||||
{this.props.popup === "profile" ? tooltip : null}
|
{this.props.popup === "profile" ? tooltip : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user