Skip to content

Commit dd8e2b1

Browse files
authored
Add disabled functionality and fix styling for RadioGroupSelector (#383)
* Adjust RadioGroupSelector label styling based on mockups * Add disabled support for Radio Group Selector options
1 parent 005e3b9 commit dd8e2b1

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

portal-ui/src/screens/Console/Common/FormComponents/RadioGroupSelector/RadioGroupSelector.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
import React from "react";
17+
import clsx from "clsx";
1718
import Grid from "@material-ui/core/Grid";
1819
import RadioGroup from "@material-ui/core/RadioGroup";
1920
import FormControlLabel from "@material-ui/core/FormControlLabel";
@@ -40,6 +41,7 @@ interface RadioGroupProps {
4041
id: string;
4142
name: string;
4243
tooltip?: string;
44+
disableOptions?: boolean;
4345
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
4446
classes: any;
4547
displayInColumn?: boolean;
@@ -58,8 +60,23 @@ const styles = (theme: Theme) =>
5860
paddingBottom: 10,
5961
marginTop: 11,
6062
},
63+
optionLabel: {
64+
"&.Mui-disabled": {
65+
"& .MuiFormControlLabel-label": {
66+
color: "#9c9c9c",
67+
},
68+
},
69+
"&:last-child": {
70+
marginRight: 0,
71+
},
72+
"& .MuiFormControlLabel-label": {
73+
fontSize: 12,
74+
color: "#000",
75+
},
76+
},
6177
checkedOption: {
6278
"& .MuiFormControlLabel-label": {
79+
fontSize: 12,
6380
color: "#000",
6481
fontWeight: 700,
6582
},
@@ -98,6 +115,7 @@ export const RadioGroupSelector = ({
98115
name,
99116
onChange,
100117
tooltip = "",
118+
disableOptions = false,
101119
classes,
102120
displayInColumn = false,
103121
}: RadioGroupProps) => {
@@ -128,14 +146,14 @@ export const RadioGroupSelector = ({
128146
return (
129147
<FormControlLabel
130148
key={`rd-${name}-${selectorOption.value}`}
131-
value={selectorOption.value}
149+
value={disableOptions ? "disabled" : selectorOption.value}
132150
control={<RadioButton />}
133151
label={selectorOption.label}
134-
className={
135-
selectorOption.value === currentSelection
136-
? classes.checkedOption
137-
: ""
138-
}
152+
disabled={disableOptions}
153+
className={clsx(classes.optionLabel, {
154+
[classes.checkedOption]:
155+
selectorOption.value === currentSelection,
156+
})}
139157
/>
140158
);
141159
})}

portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ const radioBasic = {
104104
width: 12,
105105
height: 12,
106106
borderRadius: "100%",
107+
'input:disabled ~ &': {
108+
border: "1px solid #9C9C9C",
109+
},
107110
};
108111

109112
export const radioIcons = {

0 commit comments

Comments
 (0)