Homepage alignments (#3421)
* Home alignments * Set paddings * Messages * Center cheviron * Center cheviron
This commit is contained in:
parent
8ef76a7518
commit
41ad0f6fd8
6 changed files with 68 additions and 123 deletions
|
@ -4847,6 +4847,9 @@
|
||||||
"context": "title",
|
"context": "title",
|
||||||
"string": "Reserved stock"
|
"string": "Reserved stock"
|
||||||
},
|
},
|
||||||
|
"X7jl6w": {
|
||||||
|
"string": "Orders"
|
||||||
|
},
|
||||||
"X8qjg3": {
|
"X8qjg3": {
|
||||||
"context": "inactive",
|
"context": "inactive",
|
||||||
"string": "Inactive"
|
"string": "Inactive"
|
||||||
|
|
|
@ -1,92 +1,39 @@
|
||||||
import { Card, CardContent, Typography } from "@material-ui/core";
|
import { Box, Text } from "@saleor/macaw-ui/next";
|
||||||
import { IconProps } from "@material-ui/core/Icon";
|
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
|
||||||
import { vars } from "@saleor/macaw-ui/next";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
|
||||||
theme => ({
|
|
||||||
cardContent: {
|
|
||||||
display: "grid",
|
|
||||||
gridColumnGap: theme.spacing(3),
|
|
||||||
gridTemplateColumns: "1fr 64px",
|
|
||||||
border: `1px solid ${vars.colors.border.neutralPlain}`,
|
|
||||||
borderRadius: vars.borderRadius[3],
|
|
||||||
},
|
|
||||||
cardSpacing: {
|
|
||||||
[theme.breakpoints.down("sm")]: {
|
|
||||||
marginBottom: theme.spacing(1),
|
|
||||||
},
|
|
||||||
marginBottom: theme.spacing(3),
|
|
||||||
},
|
|
||||||
cardSubtitle: {
|
|
||||||
fontSize: 12,
|
|
||||||
height: "20px",
|
|
||||||
lineHeight: 0.9,
|
|
||||||
},
|
|
||||||
cardTitle: {
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: 500 as 500,
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
color: theme.palette.primary.contrastText,
|
|
||||||
fontSize: 54,
|
|
||||||
margin: ".5rem .3rem",
|
|
||||||
},
|
|
||||||
iconBackground: {
|
|
||||||
backgroundColor: theme.palette.background.default,
|
|
||||||
borderRadius: "8px",
|
|
||||||
color: "white",
|
|
||||||
fontSize: "54px",
|
|
||||||
height: "100%",
|
|
||||||
padding: "10px 5px 0px 5px",
|
|
||||||
width: "100%",
|
|
||||||
},
|
|
||||||
value: {
|
|
||||||
textAlign: "right",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
{ name: "HomeAnalyticsCard" },
|
|
||||||
);
|
|
||||||
|
|
||||||
interface HomeAnalyticsCardProps {
|
interface HomeAnalyticsCardProps {
|
||||||
testId?: string;
|
testId?: string;
|
||||||
icon: React.ReactElement<IconProps>;
|
|
||||||
title: string;
|
title: string;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HomeAnalyticsCard: React.FC<HomeAnalyticsCardProps> = props => {
|
const HomeAnalyticsCard: React.FC<HomeAnalyticsCardProps> = props => {
|
||||||
const { children, title, icon, testId } = props;
|
const { children, title, testId } = props;
|
||||||
|
|
||||||
const classes = useStyles(props);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={classes.cardSpacing}>
|
<Box
|
||||||
<CardContent className={classes.cardContent} data-test-id={testId}>
|
borderWidth={1}
|
||||||
<div>
|
borderStyle="solid"
|
||||||
<Typography className={classes.cardTitle} variant="subtitle1">
|
borderColor="neutralPlain"
|
||||||
|
borderRadius={3}
|
||||||
|
padding={8}
|
||||||
|
display="flex"
|
||||||
|
justifyContent="space-between"
|
||||||
|
data-test-id={testId}
|
||||||
|
>
|
||||||
|
<Box display="flex" flexDirection="column" gap={2}>
|
||||||
|
<Text size="large" variant="body">
|
||||||
{title}
|
{title}
|
||||||
</Typography>
|
</Text>
|
||||||
<Typography
|
<Text size="medium" variant="caption" color="iconNeutralPlain">
|
||||||
className={classes.cardSubtitle}
|
|
||||||
variant="caption"
|
|
||||||
color="textSecondary"
|
|
||||||
>
|
|
||||||
<FormattedMessage id="zWgbGg" defaultMessage="Today" />
|
<FormattedMessage id="zWgbGg" defaultMessage="Today" />
|
||||||
</Typography>
|
</Text>
|
||||||
<Typography
|
</Box>
|
||||||
className={classes.value}
|
<Text as="h4" variant="heading">
|
||||||
color="textPrimary"
|
|
||||||
variant="h4"
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</Typography>
|
</Text>
|
||||||
</div>
|
</Box>
|
||||||
<div className={classes.iconBackground}>{icon}</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
HomeAnalyticsCard.displayName = "HomeAnalyticsCard";
|
HomeAnalyticsCard.displayName = "HomeAnalyticsCard";
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight";
|
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight";
|
||||||
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 { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
@ -21,13 +22,22 @@ const useStyles = makeStyles(
|
||||||
() => ({
|
() => ({
|
||||||
arrowIcon: {
|
arrowIcon: {
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
width: 100,
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-end",
|
||||||
},
|
},
|
||||||
tableCard: {
|
tableCard: {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
|
borderRadius: 0,
|
||||||
},
|
},
|
||||||
tableRow: {
|
tableRow: {
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
|
/* Table to be replaced with Box */
|
||||||
|
"& .MuiTableCell-root": {
|
||||||
|
paddingLeft: `${vars.space[8]} !important`,
|
||||||
|
paddingRight: `${vars.space[8]} !important`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
cardContent: {
|
cardContent: {
|
||||||
padding: 0,
|
padding: 0,
|
||||||
|
|
|
@ -6,39 +6,16 @@ import RequirePermissions from "@dashboard/components/RequirePermissions";
|
||||||
import Skeleton from "@dashboard/components/Skeleton";
|
import Skeleton from "@dashboard/components/Skeleton";
|
||||||
import { HomeQuery, PermissionEnum } from "@dashboard/graphql";
|
import { HomeQuery, PermissionEnum } from "@dashboard/graphql";
|
||||||
import { RelayToFlat } from "@dashboard/types";
|
import { RelayToFlat } from "@dashboard/types";
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
|
||||||
import { Box } from "@saleor/macaw-ui/next";
|
import { Box } from "@saleor/macaw-ui/next";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import Orders from "../../../icons/Orders";
|
|
||||||
import Sales from "../../../icons/Sales";
|
|
||||||
import HomeActivityCard from "../HomeActivityCard";
|
import HomeActivityCard from "../HomeActivityCard";
|
||||||
import HomeAnalyticsCard from "../HomeAnalyticsCard";
|
import HomeAnalyticsCard from "../HomeAnalyticsCard";
|
||||||
import HomeHeader from "../HomeHeader";
|
import HomeHeader from "../HomeHeader";
|
||||||
import HomeNotificationTable from "../HomeNotificationTable/HomeNotificationTable";
|
import HomeNotificationTable from "../HomeNotificationTable/HomeNotificationTable";
|
||||||
import HomeProductListCard from "../HomeProductListCard";
|
import HomeProductListCard from "../HomeProductListCard";
|
||||||
|
import { homePageMessages } from "./messages";
|
||||||
const useStyles = makeStyles(
|
|
||||||
theme => ({
|
|
||||||
cardContainer: {
|
|
||||||
display: "grid",
|
|
||||||
gridColumnGap: theme.spacing(3),
|
|
||||||
gridTemplateColumns: "1fr 1fr",
|
|
||||||
[theme.breakpoints.down("sm")]: {
|
|
||||||
gridColumnGap: theme.spacing(1),
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down("xs")]: {
|
|
||||||
gridTemplateColumns: "1fr",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
"& path": {
|
|
||||||
fill: theme.palette.primary.main,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
{ name: "HomePage" },
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface HomePageProps {
|
export interface HomePageProps {
|
||||||
activities: RelayToFlat<HomeQuery["activities"]>;
|
activities: RelayToFlat<HomeQuery["activities"]>;
|
||||||
|
@ -72,8 +49,7 @@ const HomePage: React.FC<HomePageProps> = props => {
|
||||||
productsOutOfStock = 0,
|
productsOutOfStock = 0,
|
||||||
noChannel,
|
noChannel,
|
||||||
} = props;
|
} = props;
|
||||||
|
const intl = useIntl();
|
||||||
const classes = useStyles(props);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DetailPageLayout withSavebar={false}>
|
<DetailPageLayout withSavebar={false}>
|
||||||
|
@ -84,17 +60,15 @@ const HomePage: React.FC<HomePageProps> = props => {
|
||||||
<RequirePermissions
|
<RequirePermissions
|
||||||
requiredPermissions={[PermissionEnum.MANAGE_ORDERS]}
|
requiredPermissions={[PermissionEnum.MANAGE_ORDERS]}
|
||||||
>
|
>
|
||||||
<div className={classes.cardContainer}>
|
<Box
|
||||||
|
display="grid"
|
||||||
|
__gridTemplateColumns="repeat(2, 1fr)"
|
||||||
|
gap={8}
|
||||||
|
marginBottom={8}
|
||||||
|
>
|
||||||
<HomeAnalyticsCard
|
<HomeAnalyticsCard
|
||||||
title={"Sales"}
|
title={intl.formatMessage(homePageMessages.salesCardTitle)}
|
||||||
testId="sales-analytics"
|
testId="sales-analytics"
|
||||||
icon={
|
|
||||||
<Sales
|
|
||||||
className={classes.icon}
|
|
||||||
fontSize={"inherit"}
|
|
||||||
viewBox="0 0 64 64"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{noChannel ? (
|
{noChannel ? (
|
||||||
0
|
0
|
||||||
|
@ -105,15 +79,8 @@ const HomePage: React.FC<HomePageProps> = props => {
|
||||||
)}
|
)}
|
||||||
</HomeAnalyticsCard>
|
</HomeAnalyticsCard>
|
||||||
<HomeAnalyticsCard
|
<HomeAnalyticsCard
|
||||||
title={"Orders"}
|
title={intl.formatMessage(homePageMessages.ordersCardTitle)}
|
||||||
testId="orders-analytics"
|
testId="orders-analytics"
|
||||||
icon={
|
|
||||||
<Orders
|
|
||||||
className={classes.icon}
|
|
||||||
fontSize={"inherit"}
|
|
||||||
viewBox="0 0 64 64"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{noChannel ? (
|
{noChannel ? (
|
||||||
0
|
0
|
||||||
|
@ -123,7 +90,7 @@ const HomePage: React.FC<HomePageProps> = props => {
|
||||||
<Skeleton style={{ width: "5em" }} />
|
<Skeleton style={{ width: "5em" }} />
|
||||||
)}
|
)}
|
||||||
</HomeAnalyticsCard>
|
</HomeAnalyticsCard>
|
||||||
</div>
|
</Box>
|
||||||
</RequirePermissions>
|
</RequirePermissions>
|
||||||
<HomeNotificationTable
|
<HomeNotificationTable
|
||||||
createNewChannelHref={createNewChannelHref}
|
createNewChannelHref={createNewChannelHref}
|
||||||
|
|
12
src/home/components/HomePage/messages.ts
Normal file
12
src/home/components/HomePage/messages.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { defineMessages } from "react-intl";
|
||||||
|
|
||||||
|
export const homePageMessages = defineMessages({
|
||||||
|
salesCardTitle: {
|
||||||
|
defaultMessage: "Sales",
|
||||||
|
id: "c8nvms",
|
||||||
|
},
|
||||||
|
ordersCardTitle: {
|
||||||
|
defaultMessage: "Orders",
|
||||||
|
id: "X7jl6w",
|
||||||
|
},
|
||||||
|
});
|
|
@ -15,6 +15,7 @@ import {
|
||||||
Typography,
|
Typography,
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
import { vars } 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";
|
||||||
|
@ -46,6 +47,11 @@ const useStyles = makeStyles(
|
||||||
},
|
},
|
||||||
tableRow: {
|
tableRow: {
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
|
/* Table to be replaced with Box */
|
||||||
|
"& .MuiTableCell-root": {
|
||||||
|
paddingLeft: `${vars.space[8]} !important`,
|
||||||
|
paddingRight: `${vars.space[8]} !important`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
cardContent: {
|
cardContent: {
|
||||||
padding: 0,
|
padding: 0,
|
||||||
|
|
Loading…
Reference in a new issue