Fix timeline (#3262)
This commit is contained in:
parent
f5c4a5ad49
commit
82caef0689
2 changed files with 27 additions and 62 deletions
|
@ -1,20 +1,18 @@
|
||||||
|
import { useUser } from "@dashboard/auth";
|
||||||
import { Button } from "@dashboard/components/Button";
|
import { Button } from "@dashboard/components/Button";
|
||||||
import { Avatar, CardContent, TextField } from "@material-ui/core";
|
import { getUserInitials } from "@dashboard/misc";
|
||||||
import deepPurple from "@material-ui/core/colors/deepPurple";
|
import { CardContent, TextField } from "@material-ui/core";
|
||||||
import PersonIcon from "@material-ui/icons/Person";
|
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
import { Avatar, vars } from "@saleor/macaw-ui/next";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
avatar: {
|
avatar: {
|
||||||
"& span": {
|
left: -19,
|
||||||
height: "100%",
|
position: "absolute",
|
||||||
width: "100%",
|
top: 20,
|
||||||
},
|
|
||||||
alignSelf: "flex-start",
|
|
||||||
marginRight: theme.spacing(3.5),
|
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
padding: `7px`,
|
padding: `7px`,
|
||||||
|
@ -33,11 +31,11 @@ const useStyles = makeStyles(
|
||||||
opacity: [[1], "!important"] as any,
|
opacity: [[1], "!important"] as any,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
background: theme.palette.background.paper,
|
background: vars.colors.background.surfaceNeutralPlain,
|
||||||
},
|
},
|
||||||
noteRoot: {
|
noteRoot: {
|
||||||
marginBottom: theme.spacing(3),
|
marginBottom: theme.spacing(3),
|
||||||
position: "absolute",
|
// position: "absolute",
|
||||||
top: 0,
|
top: 0,
|
||||||
left: -19,
|
left: -19,
|
||||||
right: 0,
|
right: 0,
|
||||||
|
@ -47,14 +45,11 @@ const useStyles = makeStyles(
|
||||||
paddingBottom: 0,
|
paddingBottom: 0,
|
||||||
paddingRight: 0,
|
paddingRight: 0,
|
||||||
},
|
},
|
||||||
alignItems: "center",
|
|
||||||
display: "flex",
|
|
||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
},
|
},
|
||||||
root: {
|
root: {
|
||||||
marginLeft: 20,
|
marginLeft: 20,
|
||||||
paddingTop: theme.spacing(12),
|
paddingLeft: 21,
|
||||||
paddingLeft: theme.spacing(3.27),
|
|
||||||
position: "relative",
|
position: "relative",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@ -84,6 +79,7 @@ export const Timeline: React.FC<TimelineProps> = props => {
|
||||||
export const TimelineAddNote: React.FC<TimelineAddNoteProps> = props => {
|
export const TimelineAddNote: React.FC<TimelineAddNoteProps> = props => {
|
||||||
const { message, onChange, onSubmit, reset, disabled } = props;
|
const { message, onChange, onSubmit, reset, disabled } = props;
|
||||||
const classes = useStyles(props);
|
const classes = useStyles(props);
|
||||||
|
const { user } = useUser();
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
|
@ -95,12 +91,12 @@ export const TimelineAddNote: React.FC<TimelineAddNoteProps> = props => {
|
||||||
return (
|
return (
|
||||||
<div className={classes.noteRoot}>
|
<div className={classes.noteRoot}>
|
||||||
<CardContent className={classes.noteTitle}>
|
<CardContent className={classes.noteTitle}>
|
||||||
<Avatar
|
<Avatar.User
|
||||||
style={{ background: deepPurple[500] }}
|
initials={getUserInitials(user)}
|
||||||
|
scheme="decorative2"
|
||||||
|
src={user?.avatar?.url}
|
||||||
className={classes.avatar}
|
className={classes.avatar}
|
||||||
>
|
/>
|
||||||
<PersonIcon />
|
|
||||||
</Avatar>
|
|
||||||
<TextField
|
<TextField
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
|
|
@ -1,33 +1,12 @@
|
||||||
import { useUser } from "@dashboard/auth";
|
import { useUser } from "@dashboard/auth";
|
||||||
import { UserFragment } from "@dashboard/graphql";
|
import { getUserInitials } from "@dashboard/misc";
|
||||||
import { Avatar, Card, CardContent, Typography } from "@material-ui/core";
|
import { Card, CardContent, Typography } from "@material-ui/core";
|
||||||
import * as colors from "@material-ui/core/colors";
|
|
||||||
import PersonIcon from "@material-ui/icons/Person";
|
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
import CRC from "crc-32";
|
import { Avatar, vars } from "@saleor/macaw-ui/next";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { DateTime } from "../Date";
|
import { DateTime } from "../Date";
|
||||||
|
|
||||||
const palette = [
|
|
||||||
colors.amber,
|
|
||||||
colors.blue,
|
|
||||||
colors.cyan,
|
|
||||||
colors.deepOrange,
|
|
||||||
colors.deepPurple,
|
|
||||||
colors.green,
|
|
||||||
colors.indigo,
|
|
||||||
colors.lightBlue,
|
|
||||||
colors.lightGreen,
|
|
||||||
colors.lime,
|
|
||||||
colors.orange,
|
|
||||||
colors.pink,
|
|
||||||
colors.purple,
|
|
||||||
colors.red,
|
|
||||||
colors.teal,
|
|
||||||
colors.yellow,
|
|
||||||
].map(color => color[500]);
|
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
avatar: {
|
avatar: {
|
||||||
|
@ -37,11 +16,13 @@ const useStyles = makeStyles(
|
||||||
},
|
},
|
||||||
card: {
|
card: {
|
||||||
marginBottom: theme.spacing(3),
|
marginBottom: theme.spacing(3),
|
||||||
marginLeft: theme.spacing(3),
|
|
||||||
position: "relative",
|
position: "relative",
|
||||||
boxShadow: "none",
|
boxShadow: "none",
|
||||||
|
background: vars.colors.background.surfaceNeutralPlain,
|
||||||
},
|
},
|
||||||
cardContent: {
|
cardContent: {
|
||||||
|
borderRadius: "4px",
|
||||||
|
border: `1px solid ${vars.colors.border.neutralDefault}`,
|
||||||
"&:last-child": {
|
"&:last-child": {
|
||||||
padding: 16,
|
padding: 16,
|
||||||
},
|
},
|
||||||
|
@ -57,7 +38,6 @@ const useStyles = makeStyles(
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
marginBottom: theme.spacing(),
|
marginBottom: theme.spacing(),
|
||||||
paddingLeft: theme.spacing(3),
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{ name: "TimelineNote" },
|
{ name: "TimelineNote" },
|
||||||
|
@ -104,26 +84,15 @@ export const TimelineNote: React.FC<TimelineNoteProps> = props => {
|
||||||
return user?.email;
|
return user?.email;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBackgroundColor = (
|
|
||||||
user: TimelineNoteProps["user"],
|
|
||||||
currentUser: UserFragment,
|
|
||||||
) => {
|
|
||||||
if (user.email === currentUser.email) {
|
|
||||||
return colors.deepPurple[500];
|
|
||||||
}
|
|
||||||
|
|
||||||
return palette[CRC.str(user.email) % palette.length];
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
{user && (
|
{user && (
|
||||||
<Avatar
|
<Avatar.User
|
||||||
|
initials={getUserInitials(currentUser)}
|
||||||
|
scheme="decorative2"
|
||||||
|
src={currentUser?.avatar?.url}
|
||||||
className={classes.avatar}
|
className={classes.avatar}
|
||||||
style={{ background: getBackgroundColor(user, currentUser) }}
|
/>
|
||||||
>
|
|
||||||
<PersonIcon />
|
|
||||||
</Avatar>
|
|
||||||
)}
|
)}
|
||||||
<div className={classes.title}>
|
<div className={classes.title}>
|
||||||
<Typography>{getUserTitleOrEmail()}</Typography>
|
<Typography>{getUserTitleOrEmail()}</Typography>
|
||||||
|
|
Loading…
Reference in a new issue