@madie/madie-design-system 1.0.44 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/RadioButton/RadioButton.jsx +110 -0
- package/components/RadioButton/RadioButton.stories.jsx +59 -0
- package/components/Tabs/Tab.js +9 -5
- package/components/Tabs/Tabs.stories.js +9 -0
- package/components/Tabs/index.js +6 -2
- package/components/index.js +2 -0
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/test/components/Tabs.test.js +41 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
FormControl,
|
|
4
|
+
FormHelperText,
|
|
5
|
+
FormControlLabel,
|
|
6
|
+
Radio,
|
|
7
|
+
RadioGroup,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import PropTypes from "prop-types";
|
|
10
|
+
import InputLabel from "../InputLabel";
|
|
11
|
+
|
|
12
|
+
const RadioButton = ({
|
|
13
|
+
id,
|
|
14
|
+
dataTestId,
|
|
15
|
+
options = [],
|
|
16
|
+
disabled = false,
|
|
17
|
+
label,
|
|
18
|
+
required = false,
|
|
19
|
+
error = false,
|
|
20
|
+
helperText,
|
|
21
|
+
...rest
|
|
22
|
+
}) => {
|
|
23
|
+
return (
|
|
24
|
+
<FormControl error={error} fullWidth>
|
|
25
|
+
<InputLabel
|
|
26
|
+
htmlFor={`${id}`}
|
|
27
|
+
id={`${id}-label`}
|
|
28
|
+
disabled={disabled}
|
|
29
|
+
required={required}
|
|
30
|
+
shrink
|
|
31
|
+
style={{marginBottom: 0, height: 16}} // force a height
|
|
32
|
+
sx={[
|
|
33
|
+
{
|
|
34
|
+
backgroundColor: "transparent",
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: "row-reverse",
|
|
37
|
+
alignSelf: "baseline",
|
|
38
|
+
textTransform: "none",
|
|
39
|
+
// force it outside the select box
|
|
40
|
+
position: "initial",
|
|
41
|
+
transform: "translateX(0px) translateY(0px)",
|
|
42
|
+
fontFamily: "Rubik",
|
|
43
|
+
fontWeight: 500,
|
|
44
|
+
fontSize: 14,
|
|
45
|
+
color: "#333",
|
|
46
|
+
"& .MuiInputLabel-asterisk": {
|
|
47
|
+
color: "#AE1C1C !important",
|
|
48
|
+
marginRight: "3px !important", //this was
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required && {
|
|
52
|
+
transform: "translateX(-12px) translateY(0px)",
|
|
53
|
+
"& .MuiInputLabel-asterisk": {
|
|
54
|
+
color: "#D92F2",
|
|
55
|
+
marginRight: "3px !important", //this was
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
disabled && {
|
|
59
|
+
color: "rgba(0,0,0,0.6)",
|
|
60
|
+
},
|
|
61
|
+
error && {
|
|
62
|
+
color: "#AE1C1C !important",
|
|
63
|
+
},
|
|
64
|
+
]}
|
|
65
|
+
>
|
|
66
|
+
{label}
|
|
67
|
+
</InputLabel>
|
|
68
|
+
{helperText && (<FormHelperText
|
|
69
|
+
tabIndex={0}
|
|
70
|
+
aria-live="polite"
|
|
71
|
+
id={`${id}-helper-text`}
|
|
72
|
+
data-testid={`${id}-helper-text`}
|
|
73
|
+
error={error}
|
|
74
|
+
sx={[{
|
|
75
|
+
margin: "4px 0px 0px 0px",
|
|
76
|
+
color: "#515151",
|
|
77
|
+
lineHeight: 1
|
|
78
|
+
},
|
|
79
|
+
error && {
|
|
80
|
+
color: "#AE1C1C !important",
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
>
|
|
84
|
+
{helperText}
|
|
85
|
+
</FormHelperText>)}
|
|
86
|
+
<RadioGroup
|
|
87
|
+
aria-labelledby={`${id}-radio-buttons-group`}
|
|
88
|
+
data-testid={`${id}-radio-buttons-group`}
|
|
89
|
+
{...rest}
|
|
90
|
+
>
|
|
91
|
+
{options.map((option, index) => (
|
|
92
|
+
<FormControlLabel key={index} value={option.value} control={<Radio />} label={option.label} />
|
|
93
|
+
))}
|
|
94
|
+
</RadioGroup>
|
|
95
|
+
</FormControl>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
RadioButton.propTypes = {
|
|
100
|
+
id: PropTypes.string,
|
|
101
|
+
dataTestId: PropTypes.string,
|
|
102
|
+
required: PropTypes.bool,
|
|
103
|
+
disabled: PropTypes.bool,
|
|
104
|
+
error: PropTypes.bool,
|
|
105
|
+
label: PropTypes.string,
|
|
106
|
+
helperText: PropTypes.string,
|
|
107
|
+
options: PropTypes.arrayOf(PropTypes.any),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default RadioButton;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import RadioButton from "./RadioButton";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "RadioButton",
|
|
6
|
+
component: RadioButton,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const options = [
|
|
10
|
+
{ label: "option 1", value: true },
|
|
11
|
+
{ label: "option 2", value: false},
|
|
12
|
+
{ label: "options 3", value: "options 3"},
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const TemplateRadioButton = (args) => {
|
|
16
|
+
const [value, setValue] = useState("test");
|
|
17
|
+
const handleChange = (id, selectedVal) => {
|
|
18
|
+
console.log("Handle change triggered", id, selectedVal);
|
|
19
|
+
setValue(selectedVal);
|
|
20
|
+
};
|
|
21
|
+
return (
|
|
22
|
+
<div className="qpp-u-padding--16">
|
|
23
|
+
<RadioButton
|
|
24
|
+
id="RadioButton"
|
|
25
|
+
dataTestId="v"
|
|
26
|
+
label="Radio Button"
|
|
27
|
+
options={options}
|
|
28
|
+
onChange={handleChange}
|
|
29
|
+
value={value}
|
|
30
|
+
{...args}
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const RadioButtonWithLabel = TemplateRadioButton.bind({});
|
|
37
|
+
RadioButtonWithLabel.args = {};
|
|
38
|
+
|
|
39
|
+
export const RadioButtonWithLabelDisabled = TemplateRadioButton.bind({});
|
|
40
|
+
RadioButtonWithLabelDisabled.args = {
|
|
41
|
+
disabled: true,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const RadioButtonWithHelperText = TemplateRadioButton.bind({});
|
|
45
|
+
RadioButtonWithHelperText.args = {
|
|
46
|
+
helperText: "Helper text goes here",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const RadioButtonRequired = TemplateRadioButton.bind({});
|
|
50
|
+
RadioButtonRequired.args = {
|
|
51
|
+
required: true,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const RadioButtonWithError = TemplateRadioButton.bind({});
|
|
55
|
+
RadioButtonWithError.args = {
|
|
56
|
+
required: true,
|
|
57
|
+
helperText: "This field is required",
|
|
58
|
+
error: true,
|
|
59
|
+
};
|
package/components/Tabs/Tab.js
CHANGED
|
@@ -4,13 +4,15 @@ import { Tab as MuiTab } from "@mui/material";
|
|
|
4
4
|
|
|
5
5
|
const typeA = {
|
|
6
6
|
color: "#fff",
|
|
7
|
+
borderRadius: "4px 4px 0px 0px !important",
|
|
8
|
+
backgroundColor: "#003366",
|
|
7
9
|
"&:hover":{
|
|
8
10
|
background: "#001F3D"
|
|
9
11
|
},
|
|
10
12
|
"&:focus":{
|
|
11
13
|
background: "#125496",
|
|
12
14
|
boxShadow: "0px 0px 0px 4px #CBE4FF",
|
|
13
|
-
}
|
|
15
|
+
},
|
|
14
16
|
};
|
|
15
17
|
const typeB = {
|
|
16
18
|
color: "#515151",
|
|
@@ -27,7 +29,7 @@ const typeC = {
|
|
|
27
29
|
color: "#333",
|
|
28
30
|
background: "#EDEDED",
|
|
29
31
|
"&:hover":{
|
|
30
|
-
|
|
32
|
+
background: "#FAFAFA",
|
|
31
33
|
color: "#515151"
|
|
32
34
|
},
|
|
33
35
|
"&:focus":{
|
|
@@ -37,7 +39,7 @@ const typeC = {
|
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
|
|
40
|
-
const Tab = ({ type, size, ...rest }) => {
|
|
42
|
+
const Tab = ({ type, orientation, size, ...rest }) => {
|
|
41
43
|
const baseStyle = {
|
|
42
44
|
height: size === 'standard' ? '48px' : '60px',
|
|
43
45
|
fontFamily: "Rubik, sans serif",
|
|
@@ -45,10 +47,11 @@ const Tab = ({ type, size, ...rest }) => {
|
|
|
45
47
|
padding: size === 'standard' ? "14.5px 24.5px" : "20.5px 24px",
|
|
46
48
|
textTransform: "none",
|
|
47
49
|
fontSize: "16px",
|
|
48
|
-
'
|
|
50
|
+
alignItems: orientation === 'vertical' && "flex-start",
|
|
51
|
+
'& .Mui-disabled': {
|
|
49
52
|
background: "#DDDDDD",
|
|
50
53
|
color: "#717171"
|
|
51
|
-
}
|
|
54
|
+
},
|
|
52
55
|
}
|
|
53
56
|
const style = ((type) => {
|
|
54
57
|
if (type === "A") {
|
|
@@ -71,6 +74,7 @@ const Tab = ({ type, size, ...rest }) => {
|
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
Tab.propTypes = {
|
|
77
|
+
orientation: PropTypes.string,
|
|
74
78
|
type: PropTypes.oneOf(["A", "B", "C", "D"]),
|
|
75
79
|
size: PropTypes.oneOf(["standard", "large"]),
|
|
76
80
|
};
|
|
@@ -79,6 +79,15 @@ export const TypeA = () => {
|
|
|
79
79
|
<Tab type="C" size="large" label="disabled" value={4} disabled/>
|
|
80
80
|
</Tabs>
|
|
81
81
|
</div>
|
|
82
|
+
<div>
|
|
83
|
+
Vertical Standard: C
|
|
84
|
+
<Tabs type="C" value={selected} onChange={handleChange} orientation="vertical">
|
|
85
|
+
<Tab type="C" size="standard" label="Item One" value={1} orientation="vertical"/>
|
|
86
|
+
<Tab type="C" size="standard" label="Item Two" value={2} orientation="vertical"/>
|
|
87
|
+
<Tab type="C" size="standard" label="Item Three"value={3} orientation="vertical"/>
|
|
88
|
+
<Tab type="C" size="standard" label="disabled" value={4} disabled orientation="vertical"/>
|
|
89
|
+
</Tabs>
|
|
90
|
+
</div>
|
|
82
91
|
<div style={{ width: "fit-content"}}>
|
|
83
92
|
Standard: D
|
|
84
93
|
<Tabs type="D" value={selected} onChange={handleChange}>
|
package/components/Tabs/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import { Tabs as MuiTabs } from "@mui/material";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
5
|
const typeA = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
"& .MuiTabs-flexContainer": {
|
|
7
|
+
columnGap: "4px !important",
|
|
8
|
+
},
|
|
8
9
|
"& .MuiTabs-indicator": {
|
|
9
10
|
display: "none !important"
|
|
10
11
|
},
|
|
@@ -49,6 +50,7 @@ const Tabs = ({
|
|
|
49
50
|
fontFamily: "Rubik, sans Sarif",
|
|
50
51
|
fontWeight: 400,
|
|
51
52
|
lineHeight: 19,
|
|
53
|
+
backgroundColor: "transparent",
|
|
52
54
|
"& .Mui-selected": {
|
|
53
55
|
outline: "none",
|
|
54
56
|
fontWeight: 500,
|
|
@@ -78,6 +80,7 @@ const Tabs = ({
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
Tabs.propTypes = {
|
|
83
|
+
orientatin: PropTypes.string,
|
|
81
84
|
type: PropTypes.oneOf(["A", "B", "C", "D"]),
|
|
82
85
|
size: PropTypes.oneOf(["standard", "large"]),
|
|
83
86
|
ariaLabel: PropTypes.string,
|
|
@@ -88,6 +91,7 @@ Tabs.propTypes = {
|
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
Tabs.defaultProps = {
|
|
94
|
+
orientation: "horizontal",
|
|
91
95
|
type: "A",
|
|
92
96
|
size: "standard",
|
|
93
97
|
selected: null,
|
package/components/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import MadieSpinner from "./MadieSpinner";
|
|
|
17
17
|
import Modal from "./Modal";
|
|
18
18
|
import Popover from "./Popover";
|
|
19
19
|
import { Pagination } from "./Pagination";
|
|
20
|
+
import RadioButton from "./RadioButton/RadioButton";
|
|
20
21
|
import ReadOnlyTextField from "./ReadOnlyTextField";
|
|
21
22
|
import Select from "./Select";
|
|
22
23
|
import Spinner from "./UnwrappedSpinner";
|
|
@@ -136,6 +137,7 @@ export {
|
|
|
136
137
|
MadieSpinner,
|
|
137
138
|
Pagination,
|
|
138
139
|
Popover,
|
|
140
|
+
RadioButton,
|
|
139
141
|
ReadOnlyTextField,
|
|
140
142
|
Search,
|
|
141
143
|
Select,
|