Fix visual regression in datetime attribute (#2787)
This commit is contained in:
parent
018b93aaa6
commit
b98d5d57ef
3 changed files with 42 additions and 0 deletions
|
@ -10,6 +10,8 @@ import { joinDateTime, splitDateTime } from "@saleor/misc";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
|
import { useStyles } from "./styles";
|
||||||
|
|
||||||
type DateTimeFieldProps = Omit<TextFieldProps, "label" | "error"> & {
|
type DateTimeFieldProps = Omit<TextFieldProps, "label" | "error"> & {
|
||||||
onChange: (value: string) => void;
|
onChange: (value: string) => void;
|
||||||
error: ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment;
|
error: ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment;
|
||||||
|
@ -24,6 +26,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
||||||
value,
|
value,
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
const parsedValue = value ? splitDateTime(value) : { date: "", time: "" };
|
const parsedValue = value ? splitDateTime(value) : { date: "", time: "" };
|
||||||
|
|
||||||
|
@ -44,6 +47,11 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
||||||
type="date"
|
type="date"
|
||||||
value={parsedValue.date}
|
value={parsedValue.date}
|
||||||
InputLabelProps={{ shrink: true }}
|
InputLabelProps={{ shrink: true }}
|
||||||
|
InputProps={{
|
||||||
|
classes: {
|
||||||
|
root: classes.dateField,
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fullWidth
|
fullWidth
|
||||||
|
@ -60,6 +68,11 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
||||||
type="time"
|
type="time"
|
||||||
value={parsedValue.time}
|
value={parsedValue.time}
|
||||||
InputLabelProps={{ shrink: true }}
|
InputLabelProps={{ shrink: true }}
|
||||||
|
InputProps={{
|
||||||
|
classes: {
|
||||||
|
root: classes.timeField,
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
1
src/components/DateTimeField/index.ts
Normal file
1
src/components/DateTimeField/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from "./DateTimeField";
|
28
src/components/DateTimeField/styles.ts
Normal file
28
src/components/DateTimeField/styles.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
|
||||||
|
export const useStyles = makeStyles(
|
||||||
|
theme => ({
|
||||||
|
dateField: {
|
||||||
|
borderRadius: "4px 0 0 4px",
|
||||||
|
},
|
||||||
|
timeField: {
|
||||||
|
borderRadius: "0 4px 4px 0",
|
||||||
|
"& > fieldset": {
|
||||||
|
borderLeftWidth: "0 !important",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down("md")]: {
|
||||||
|
dateField: {
|
||||||
|
borderRadius: "4px 4px 0 0",
|
||||||
|
},
|
||||||
|
timeField: {
|
||||||
|
borderRadius: "0 0 4px 4px",
|
||||||
|
"& > fieldset": {
|
||||||
|
borderTopWidth: "0 !important",
|
||||||
|
borderLeftWidth: "1px !important",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
{ name: "DateTimeField" },
|
||||||
|
);
|
Loading…
Reference in a new issue