Fix staff avatars (#3314)

This commit is contained in:
Krzysztof Żuraw 2023-03-13 15:20:58 +01:00 committed by GitHub
parent d33db9f2f5
commit 48fb75423a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 67 deletions

View file

@ -21,11 +21,11 @@ export const UserInfo = () => {
justifyContent="space-between" justifyContent="space-between"
> >
<Box display="flex" gap={6} alignItems="center"> <Box display="flex" gap={6} alignItems="center">
<Avatar.User {user?.avatar?.url ? (
initials={getUserInitials(user)} <Avatar.User scheme="decorative3" src={user.avatar.url} />
scheme="decorative2" ) : (
src={user?.avatar?.url} <Avatar.User initials={getUserInitials(user)} scheme="decorative3" />
/> )}
<Box __width={128} className="ellipsis"> <Box __width={128} className="ellipsis">
<Text variant="bodyStrong" size="small"> <Text variant="bodyStrong" size="small">
{getUserName(user, true)} {getUserName(user, true)}

View file

@ -11,6 +11,7 @@ html {
body { body {
color: var(--mu-colors-foreground-text-neutral-plain) !important; color: var(--mu-colors-foreground-text-neutral-plain) !important;
overscroll-behavior-y: none; overscroll-behavior-y: none;
-webkit-font-smoothing: subpixel-antialiased;
} }
.hide-scrollbar::-webkit-scrollbar { .hide-scrollbar::-webkit-scrollbar {

View file

@ -7,7 +7,6 @@ import { StaffListQuery } from "@dashboard/graphql";
import { import {
getUserInitials, getUserInitials,
getUserName, getUserName,
maybe,
renderCollection, renderCollection,
} from "@dashboard/misc"; } from "@dashboard/misc";
import { import {
@ -21,53 +20,26 @@ import {
TableCell, TableCell,
TableFooter, TableFooter,
TableHead, TableHead,
Typography,
} from "@material-ui/core"; } from "@material-ui/core";
import { makeStyles } from "@saleor/macaw-ui"; import { makeStyles } from "@saleor/macaw-ui";
import { Avatar, Box, Text } from "@saleor/macaw-ui/next";
import clsx from "clsx"; import clsx from "clsx";
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 => ({ {
avatar: {
alignItems: "center",
borderRadius: "100%",
display: "grid",
float: "left",
height: 47,
justifyContent: "center",
marginRight: theme.spacing(1),
overflow: "hidden",
width: 47,
},
avatarDefault: {
"& div": {
color: theme.palette.primary.contrastText,
lineHeight: "47px",
},
background: theme.palette.primary.main,
height: 47,
textAlign: "center",
width: 47,
},
avatarImage: {
pointerEvents: "none",
width: "100%",
},
colEmail: { colEmail: {
width: 400, width: 400,
}, },
statusText: {
color: "#9E9D9D",
},
tableRow: { tableRow: {
cursor: "pointer", cursor: "pointer",
}, },
wideColumn: { wideColumn: {
width: "80%", width: "80%",
}, },
}), },
{ name: "StaffList" }, { name: "StaffList" },
); );
@ -149,29 +121,28 @@ const StaffList: React.FC<StaffListProps> = props => {
key={staffMember ? staffMember.id : "skeleton"} key={staffMember ? staffMember.id : "skeleton"}
> >
<TableCell> <TableCell>
<div className={classes.avatar} data-test-id="staffAvatar"> <Box display="flex" alignItems="center" gap={5}>
{maybe(() => staffMember.avatar.url) ? ( {staffMember?.avatar?.url ? (
<img <Avatar.User
className={classes.avatarImage} scheme="decorative3"
src={maybe(() => staffMember.avatar.url)} src={staffMember.avatar.url}
size="large"
/> />
) : ( ) : (
<div className={classes.avatarDefault}> <Avatar.User
<Typography>{getUserInitials(staffMember)}</Typography> initials={getUserInitials(staffMember)}
</div> scheme="decorative3"
size="large"
/>
)} )}
</div> <Box display="flex" flexDirection="column">
<Typography> <Text>{getUserName(staffMember) || <Skeleton />}</Text>
{getUserName(staffMember) || <Skeleton />} <Text
</Typography> variant="caption"
<Typography data-test-id="staffStatusText"
variant={"caption"} color="textNeutralSubdued"
className={classes.statusText} >
data-test-id="staffStatusText" {staffMember?.isActive
>
{maybe<React.ReactNode>(
() =>
staffMember.isActive
? intl.formatMessage({ ? intl.formatMessage({
id: "9Zlogd", id: "9Zlogd",
defaultMessage: "Active", defaultMessage: "Active",
@ -181,13 +152,13 @@ const StaffList: React.FC<StaffListProps> = props => {
id: "7WzUxn", id: "7WzUxn",
defaultMessage: "Inactive", defaultMessage: "Inactive",
description: "staff member status", description: "staff member status",
}), })}
<Skeleton />, </Text>
)} </Box>
</Typography> </Box>
</TableCell> </TableCell>
<TableCell> <TableCell>
{maybe<React.ReactNode>(() => staffMember.email, <Skeleton />)} <Text size="small">{staffMember?.email}</Text>
</TableCell> </TableCell>
</TableRowLink> </TableRowLink>
), ),

View file

@ -6,16 +6,16 @@ import {
UserFragment, UserFragment,
} from "@dashboard/graphql"; } from "@dashboard/graphql";
import { commonMessages } from "@dashboard/intl"; import { commonMessages } from "@dashboard/intl";
import { getUserInitials } from "@dashboard/misc";
import { getFormErrors } from "@dashboard/utils/errors"; import { getFormErrors } from "@dashboard/utils/errors";
import getStaffErrorMessage from "@dashboard/utils/errors/staff"; import getStaffErrorMessage from "@dashboard/utils/errors/staff";
import { Card, CardContent, TextField, Typography } from "@material-ui/core"; import { Card, CardContent, TextField, Typography } from "@material-ui/core";
import { makeStyles } from "@saleor/macaw-ui"; import { makeStyles } from "@saleor/macaw-ui";
import { vars } from "@saleor/macaw-ui/next";
import React from "react"; import React from "react";
import SVG from "react-inlinesvg"; import SVG from "react-inlinesvg";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import { getUserInitials } from "../../../misc";
const useStyles = makeStyles( const useStyles = makeStyles(
theme => ({ theme => ({
avatar: { avatar: {
@ -44,12 +44,12 @@ const useStyles = makeStyles(
}, },
avatarDefault: { avatarDefault: {
"& div": { "& div": {
color: theme.palette.primary.contrastText, color: vars.colors.foreground.textNeutralContrasted,
fontSize: 35, fontSize: 35,
fontWeight: "bold", fontWeight: 580,
lineHeight: "120px", lineHeight: "120px",
}, },
background: theme.palette.primary.main, background: vars.colors.background.decorativeSurfacePlain3,
height: 120, height: 120,
textAlign: "center", textAlign: "center",
width: 120, width: 120,