Skip to content

Commit 8eb8238

Browse files
committed
move checkbox options outside of component
1 parent fbc03cb commit 8eb8238

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/components/Checkbox/Checkbox.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ const LabelText = styled.span`
177177
line-height: 1;
178178
`;
179179

180+
const CheckboxComponents = {
181+
flat: StyledFlatCheckbox,
182+
default: StyledCheckbox,
183+
menu: StyledMenuCheckbox
184+
};
185+
180186
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
181187
const {
182188
onChange,
@@ -202,11 +208,7 @@ const Checkbox = React.forwardRef(function Checkbox(props, ref) {
202208
if (onChange) onChange(e);
203209
};
204210

205-
const CheckboxComponent = {
206-
flat: StyledFlatCheckbox,
207-
default: StyledCheckbox,
208-
menu: StyledMenuCheckbox
209-
}[variant];
211+
const CheckboxComponent = CheckboxComponents[variant];
210212

211213
let Icon = null;
212214
if (indeterminate) {

src/components/Radio/Radio.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ const LabelText = styled.span`
127127
line-height: 1;
128128
`;
129129

130+
const CheckboxComponents = {
131+
flat: StyledFlatCheckbox,
132+
default: StyledCheckbox,
133+
menu: StyledMenuCheckbox
134+
};
135+
130136
const Radio = React.forwardRef(function Radio(props, ref) {
131137
const {
132138
onChange,
@@ -141,11 +147,7 @@ const Radio = React.forwardRef(function Radio(props, ref) {
141147
...otherProps
142148
} = props;
143149

144-
const CheckboxComponent = {
145-
flat: StyledFlatCheckbox,
146-
default: StyledCheckbox,
147-
menu: StyledMenuCheckbox
148-
}[variant];
150+
const CheckboxComponent = CheckboxComponents[variant];
149151

150152
return (
151153
<StyledLabel isDisabled={disabled} className={className} style={style}>

0 commit comments

Comments
 (0)