Skip to content

Commit 98c3e97

Browse files
ElenaBitireyjose
authored andcommitted
refactor: refactor checkbox
1 parent 230d74a commit 98c3e97

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/ui/checkbox.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ const CheckboxBase = ({
120120
...props
121121
}: RootProps & { label?: string }) => {
122122
return (
123-
<CheckboxRoot checked={checked} testID={`${testID}`} {...props}>
123+
<CheckboxRoot checked={checked} testID={testID} {...props}>
124124
<CheckboxIcon checked={checked} />
125125
{label ? (
126-
<Label text={label} testID={`${testID}-label`} className="pr-2" />
126+
<Label
127+
text={label}
128+
testID={testID ? `${testID}-label` : undefined}
129+
className="pr-2"
130+
/>
127131
) : null}
128132
</CheckboxRoot>
129133
);
@@ -178,9 +182,11 @@ const RadioBase = ({
178182
...props
179183
}: RootProps & { label?: string }) => {
180184
return (
181-
<RadioRoot checked={checked} testID={`${testID}`} {...props}>
185+
<RadioRoot checked={checked} testID={testID} {...props}>
182186
<RadioIcon checked={checked} />
183-
{label ? <Label text={label} testID={`${testID}-label`} /> : null}
187+
{label ? (
188+
<Label text={label} testID={testID ? `${testID}-label` : undefined} />
189+
) : null}
184190
</RadioRoot>
185191
);
186192
};
@@ -242,9 +248,11 @@ const SwitchBase = ({
242248
...props
243249
}: RootProps & { label?: string }) => {
244250
return (
245-
<SwitchRoot checked={checked} testID={`${testID}`} {...props}>
251+
<SwitchRoot checked={checked} testID={testID} {...props}>
246252
<SwitchIcon checked={checked} />
247-
{label ? <Label text={label} testID={`${testID}-label`} /> : null}
253+
{label ? (
254+
<Label text={label} testID={testID ? `${testID}-label` : undefined} />
255+
) : null}
248256
</SwitchRoot>
249257
);
250258
};

0 commit comments

Comments
 (0)