From 9aab4fb3a2d2c8a214553f40929e79db170148fc Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 19 Jul 2022 13:58:00 +0200 Subject: [PATCH] Fix sales/voucher page styles and fix date tooltips styles (#2154) * Fix voucher sales page style * Update date tooltips in sales and vouchers --- src/components/Date/Date.tsx | 11 ++++++++++- src/components/Date/DateTime.tsx | 11 ++++++++++- src/components/Date/styles.ts | 14 ++++++++++++++ .../components/VoucherValue/VoucherValue.tsx | 2 -- src/discounts/components/VoucherValue/styles.ts | 7 +------ src/storybook/__snapshots__/Stories.test.ts.snap | 9 --------- 6 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 src/components/Date/styles.ts diff --git a/src/components/Date/Date.tsx b/src/components/Date/Date.tsx index 0b799ee39..0da4b0473 100644 --- a/src/components/Date/Date.tsx +++ b/src/components/Date/Date.tsx @@ -5,6 +5,7 @@ import React from "react"; import { LocaleConsumer } from "../Locale"; import { Consumer } from "./DateContext"; +import { useStyles } from "./styles"; interface DateProps { date: string; @@ -12,7 +13,10 @@ interface DateProps { } export const Date: React.FC = ({ date, plain }) => { + const classes = useStyles(); + const localizeDate = useDateLocalize(); + const getHumanized = (value: string, locale: string, currentDate: number) => moment(value) .locale(locale) @@ -26,7 +30,12 @@ export const Date: React.FC = ({ date, plain }) => { plain ? ( localizeDate(date) ) : ( - + diff --git a/src/components/Date/DateTime.tsx b/src/components/Date/DateTime.tsx index 3e71f78e0..a09e27a56 100644 --- a/src/components/Date/DateTime.tsx +++ b/src/components/Date/DateTime.tsx @@ -6,6 +6,7 @@ import ReactMoment from "react-moment"; import { LocaleConsumer } from "../Locale"; import { TimezoneConsumer } from "../Timezone"; import { Consumer } from "./DateContext"; +import { useStyles } from "./styles"; interface DateTimeProps { date: string; @@ -13,6 +14,8 @@ interface DateTimeProps { } export const DateTime: React.FC = ({ date, plain }) => { + const classes = useStyles(); + const getTitle = (value: string, locale?: string, tz?: string) => { let date = moment(value).locale(locale); if (tz !== undefined) { @@ -20,6 +23,7 @@ export const DateTime: React.FC = ({ date, plain }) => { } return date.format("lll"); }; + return ( {tz => ( @@ -30,7 +34,12 @@ export const DateTime: React.FC = ({ date, plain }) => { plain ? ( getTitle(date, locale, tz) ) : ( - + {date} diff --git a/src/components/Date/styles.ts b/src/components/Date/styles.ts new file mode 100644 index 000000000..9abe42a0f --- /dev/null +++ b/src/components/Date/styles.ts @@ -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", + }, +); diff --git a/src/discounts/components/VoucherValue/VoucherValue.tsx b/src/discounts/components/VoucherValue/VoucherValue.tsx index 3ded36db7..086a9c971 100644 --- a/src/discounts/components/VoucherValue/VoucherValue.tsx +++ b/src/discounts/components/VoucherValue/VoucherValue.tsx @@ -9,7 +9,6 @@ import { import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import { FormSpacer } from "@saleor/components/FormSpacer"; -import Hr from "@saleor/components/Hr"; import RadioGroupField from "@saleor/components/RadioGroupField"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; @@ -172,7 +171,6 @@ const VoucherValue: React.FC = props => { {variant === "update" && ( <> -
-
@@ -97677,9 +97674,6 @@ exports[`Storyshots Views / Discounts / Voucher details form errors 1`] = `
-
@@ -100057,9 +100051,6 @@ exports[`Storyshots Views / Discounts / Voucher details loading 1`] = `
-