Skip to content

Commit c4e9dd2

Browse files
authoredJul 10, 2023
Merge pull request #182 from MeasureAuthoringTool/MAT-5828_timeField_2
MAT-5828 time field
2 parents f7f3583 + db091c6 commit c4e9dd2

File tree

4 files changed

+254
-748
lines changed

4 files changed

+254
-748
lines changed
 
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import React from "react";
2+
import { TimePicker } from "@mui/x-date-pickers";
3+
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
4+
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
5+
import InputLabel from "../InputLabel";
6+
import { kebabCase } from "lodash";
7+
import PropTypes from "prop-types";
8+
9+
export const timeFieldStyle = {
10+
width: "134px",
11+
borderRadius: "3px",
12+
height: 40,
13+
border: "1px solid #B0B0B0",
14+
marginTop: "8px",
15+
"& .MuiOutlinedInput-notchedOutline": {
16+
borderRadius: "3px",
17+
"& legend": {
18+
width: 0,
19+
},
20+
},
21+
"& .MuiOutlinedInput-root": {
22+
"&&": {
23+
borderRadius: "3px",
24+
},
25+
},
26+
"& .MuiInputBase-input": {
27+
color: "#333333",
28+
fontFamily: "Rubik",
29+
fontSize: 14,
30+
borderRadius: "3px",
31+
padding: "9px",
32+
Width: "170px",
33+
"&::placeholder": {
34+
opacity: 1,
35+
color: "#717171",
36+
fontFamily: "Rubik",
37+
fontSize: 14,
38+
},
39+
},
40+
};
41+
42+
const TimeField = ({
43+
label,
44+
value,
45+
handleTimeChange,
46+
disabled,
47+
required,
48+
error,
49+
}) => {
50+
return (
51+
<LocalizationProvider dateAdapter={AdapterDayjs}>
52+
<InputLabel
53+
data-testid={`${kebabCase(label)}`}
54+
style={{ marginBottom: 0, height: 16 }}
55+
sx={[
56+
{
57+
backgroundColor: "transparent",
58+
textTransform: "none",
59+
height: 17,
60+
left: 0,
61+
right: 0,
62+
top: 0,
63+
fontFamily: "Rubik",
64+
fontStyle: "normal",
65+
fontWeight: 500,
66+
fontSize: 14,
67+
color: "#333333",
68+
},
69+
]}
70+
required={required}
71+
disabled={disabled}
72+
error={error}
73+
>
74+
{`${label}`}
75+
</InputLabel>
76+
<TimePicker
77+
sx={timeFieldStyle}
78+
disableOpenPicker
79+
disabled={disabled}
80+
value={value ? value : null}
81+
onChange={handleTimeChange}
82+
slotProps={{
83+
textField: {
84+
id: "time",
85+
},
86+
}}
87+
/>
88+
</LocalizationProvider>
89+
);
90+
};
91+
92+
TimeField.propTypes = {
93+
label: PropTypes.string.isRequired,
94+
value: PropTypes.object,
95+
handleTimeChange: PropTypes.func.isRequired,
96+
disabled: PropTypes.bool,
97+
required: PropTypes.bool,
98+
error: PropTypes.string,
99+
};
100+
101+
export default TimeField;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { useState } from "react";
2+
import TimeField from "./TimeField";
3+
import { withKnobs } from "@storybook/addon-knobs";
4+
5+
export default {
6+
title: "TimeField",
7+
component: TimeField,
8+
decorators: [withKnobs],
9+
};
10+
export const TimeFieldComponent = (args) => {
11+
const [value, setValue] = useState("");
12+
const handleTimeChange = (newValue, v) => {
13+
console.log("Time changed: newValue = ", newValue);
14+
setValue(newValue);
15+
};
16+
return (
17+
<div className="qpp-u-padding--16">
18+
<TimeField
19+
disabled={false}
20+
label="Result Time"
21+
handleTimeChange={handleTimeChange}
22+
value={value}
23+
/>
24+
</div>
25+
);
26+
};

‎react/package-lock.json

+123-746
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎react/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@madie/madie-design-system",
3-
"version": "1.0.51",
3+
"version": "1.0.52",
44
"description": "Shared style guide across the Madie program.",
55
"main": "dist/index.js",
66
"homepage": "https://github.com/MeasureAuthoringTool/madie-design-system",
@@ -139,6 +139,8 @@
139139
"trim": ">=0.0.3",
140140
"webpack": "^5.70.0",
141141
"trim-newlines": "^3.0.1",
142-
"glob-parent": "^6.0.1"
142+
"glob-parent": "^6.0.1",
143+
"semver": "^7.5.3",
144+
"optionator": "0.9.3"
143145
}
144146
}

0 commit comments

Comments
 (0)
Please sign in to comment.