Fix sales/voucher page styles and fix date tooltips styles (#2154)
* Fix voucher sales page style * Update date tooltips in sales and vouchers
This commit is contained in:
parent
ef3c7a203b
commit
9aab4fb3a2
6 changed files with 35 additions and 19 deletions
|
@ -5,6 +5,7 @@ import React from "react";
|
||||||
|
|
||||||
import { LocaleConsumer } from "../Locale";
|
import { LocaleConsumer } from "../Locale";
|
||||||
import { Consumer } from "./DateContext";
|
import { Consumer } from "./DateContext";
|
||||||
|
import { useStyles } from "./styles";
|
||||||
|
|
||||||
interface DateProps {
|
interface DateProps {
|
||||||
date: string;
|
date: string;
|
||||||
|
@ -12,7 +13,10 @@ interface DateProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Date: React.FC<DateProps> = ({ date, plain }) => {
|
export const Date: React.FC<DateProps> = ({ date, plain }) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
const localizeDate = useDateLocalize();
|
const localizeDate = useDateLocalize();
|
||||||
|
|
||||||
const getHumanized = (value: string, locale: string, currentDate: number) =>
|
const getHumanized = (value: string, locale: string, currentDate: number) =>
|
||||||
moment(value)
|
moment(value)
|
||||||
.locale(locale)
|
.locale(locale)
|
||||||
|
@ -26,7 +30,12 @@ export const Date: React.FC<DateProps> = ({ date, plain }) => {
|
||||||
plain ? (
|
plain ? (
|
||||||
localizeDate(date)
|
localizeDate(date)
|
||||||
) : (
|
) : (
|
||||||
<Tooltip title={localizeDate(date)}>
|
<Tooltip
|
||||||
|
title={localizeDate(date)}
|
||||||
|
PopperProps={{
|
||||||
|
className: classes.tooltip,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<time dateTime={date}>
|
<time dateTime={date}>
|
||||||
{getHumanized(date, locale, currentDate)}
|
{getHumanized(date, locale, currentDate)}
|
||||||
</time>
|
</time>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import ReactMoment from "react-moment";
|
||||||
import { LocaleConsumer } from "../Locale";
|
import { LocaleConsumer } from "../Locale";
|
||||||
import { TimezoneConsumer } from "../Timezone";
|
import { TimezoneConsumer } from "../Timezone";
|
||||||
import { Consumer } from "./DateContext";
|
import { Consumer } from "./DateContext";
|
||||||
|
import { useStyles } from "./styles";
|
||||||
|
|
||||||
interface DateTimeProps {
|
interface DateTimeProps {
|
||||||
date: string;
|
date: string;
|
||||||
|
@ -13,6 +14,8 @@ interface DateTimeProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DateTime: React.FC<DateTimeProps> = ({ date, plain }) => {
|
export const DateTime: React.FC<DateTimeProps> = ({ date, plain }) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
const getTitle = (value: string, locale?: string, tz?: string) => {
|
const getTitle = (value: string, locale?: string, tz?: string) => {
|
||||||
let date = moment(value).locale(locale);
|
let date = moment(value).locale(locale);
|
||||||
if (tz !== undefined) {
|
if (tz !== undefined) {
|
||||||
|
@ -20,6 +23,7 @@ export const DateTime: React.FC<DateTimeProps> = ({ date, plain }) => {
|
||||||
}
|
}
|
||||||
return date.format("lll");
|
return date.format("lll");
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TimezoneConsumer>
|
<TimezoneConsumer>
|
||||||
{tz => (
|
{tz => (
|
||||||
|
@ -30,7 +34,12 @@ export const DateTime: React.FC<DateTimeProps> = ({ date, plain }) => {
|
||||||
plain ? (
|
plain ? (
|
||||||
getTitle(date, locale, tz)
|
getTitle(date, locale, tz)
|
||||||
) : (
|
) : (
|
||||||
<Tooltip title={getTitle(date, locale, tz)}>
|
<Tooltip
|
||||||
|
title={getTitle(date, locale, tz)}
|
||||||
|
PopperProps={{
|
||||||
|
className: classes.tooltip,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ReactMoment from={currentDate} locale={locale} tz={tz}>
|
<ReactMoment from={currentDate} locale={locale} tz={tz}>
|
||||||
{date}
|
{date}
|
||||||
</ReactMoment>
|
</ReactMoment>
|
||||||
|
|
14
src/components/Date/styles.ts
Normal file
14
src/components/Date/styles.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
|
||||||
|
export const useStyles = makeStyles(
|
||||||
|
theme => ({
|
||||||
|
tooltip: {
|
||||||
|
"& .MuiTooltip-tooltip": {
|
||||||
|
color: theme.palette.getContrastText(theme.palette.text.primary),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
name: "DateTime",
|
||||||
|
},
|
||||||
|
);
|
|
@ -9,7 +9,6 @@ import {
|
||||||
import CardTitle from "@saleor/components/CardTitle";
|
import CardTitle from "@saleor/components/CardTitle";
|
||||||
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
||||||
import { FormSpacer } from "@saleor/components/FormSpacer";
|
import { FormSpacer } from "@saleor/components/FormSpacer";
|
||||||
import Hr from "@saleor/components/Hr";
|
|
||||||
import RadioGroupField from "@saleor/components/RadioGroupField";
|
import RadioGroupField from "@saleor/components/RadioGroupField";
|
||||||
import ResponsiveTable from "@saleor/components/ResponsiveTable";
|
import ResponsiveTable from "@saleor/components/ResponsiveTable";
|
||||||
import Skeleton from "@saleor/components/Skeleton";
|
import Skeleton from "@saleor/components/Skeleton";
|
||||||
|
@ -172,7 +171,6 @@ const VoucherValue: React.FC<VoucherValueProps> = props => {
|
||||||
<FormSpacer />
|
<FormSpacer />
|
||||||
{variant === "update" && (
|
{variant === "update" && (
|
||||||
<>
|
<>
|
||||||
<Hr className={classes.hr} />
|
|
||||||
<RadioGroupField
|
<RadioGroupField
|
||||||
choices={voucherTypeChoices}
|
choices={voucherTypeChoices}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
|
|
@ -15,16 +15,11 @@ export const useStyles = makeStyles(
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
width: 300,
|
width: 300,
|
||||||
},
|
},
|
||||||
hr: {
|
|
||||||
margin: theme.spacing(2, -3),
|
|
||||||
width: `calc(100% + ${theme.spacing(6)}px)`,
|
|
||||||
},
|
|
||||||
table: {
|
table: {
|
||||||
tableLayout: "fixed",
|
tableLayout: "fixed",
|
||||||
},
|
},
|
||||||
tableContainer: {
|
tableContainer: {
|
||||||
margin: theme.spacing(0, -3),
|
margin: theme.spacing(0, -4),
|
||||||
width: `calc(100% + ${theme.spacing(6)}px)`,
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
|
|
@ -95322,9 +95322,6 @@ exports[`Storyshots Views / Discounts / Voucher details default 1`] = `
|
||||||
<div
|
<div
|
||||||
class="FormSpacer-spacer-id"
|
class="FormSpacer-spacer-id"
|
||||||
/>
|
/>
|
||||||
<hr
|
|
||||||
class="Hr-root-id VoucherValue-hr-id"
|
|
||||||
/>
|
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id RadioGroupField-root-id"
|
class="MuiFormControl-root-id RadioGroupField-root-id"
|
||||||
>
|
>
|
||||||
|
@ -97677,9 +97674,6 @@ exports[`Storyshots Views / Discounts / Voucher details form errors 1`] = `
|
||||||
<div
|
<div
|
||||||
class="FormSpacer-spacer-id"
|
class="FormSpacer-spacer-id"
|
||||||
/>
|
/>
|
||||||
<hr
|
|
||||||
class="Hr-root-id VoucherValue-hr-id"
|
|
||||||
/>
|
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id RadioGroupField-root-id"
|
class="MuiFormControl-root-id RadioGroupField-root-id"
|
||||||
>
|
>
|
||||||
|
@ -100057,9 +100051,6 @@ exports[`Storyshots Views / Discounts / Voucher details loading 1`] = `
|
||||||
<div
|
<div
|
||||||
class="FormSpacer-spacer-id"
|
class="FormSpacer-spacer-id"
|
||||||
/>
|
/>
|
||||||
<hr
|
|
||||||
class="Hr-root-id VoucherValue-hr-id"
|
|
||||||
/>
|
|
||||||
<div
|
<div
|
||||||
class="MuiFormControl-root-id RadioGroupField-root-id"
|
class="MuiFormControl-root-id RadioGroupField-root-id"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue