Skip to content

Commit

Permalink
Remove element when label is not provided (#28)
Browse files Browse the repository at this point in the history
This Pull Request adds new logic in the `CheckboxGroup` component that
handles the element for the label. If the label is not provided, it now
will not render the element in the DOM.
  • Loading branch information
tfirdaus authored Dec 14, 2024
1 parent 9612011 commit 0d512e0
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions packages/kubrick/src/CheckboxGroup/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,27 @@ export const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(
aria-invalid={isInvalid}
ref={ref}
>
<span
{...labelProps}
className={clsx({
classNames: classes.label,
prefixedNames: 'label',
})}
>
{label}
{isRequired ?
<span
className={clsx({
classNames: classes.markedRequired,
prefixedNames: 'marked-required',
})}
>
*
</span>
: ''}
</span>
{label && (
<span
{...labelProps}
className={clsx({
classNames: classes.label,
prefixedNames: 'label',
})}
>
{label}
{isRequired ?
<span
className={clsx({
classNames: classes.markedRequired,
prefixedNames: 'marked-required',
})}
>
*
</span>
: ''}
</span>
)}
<CheckboxGroupContext.Provider value={state}>
<div
className={clsx({
Expand Down

0 comments on commit 0d512e0

Please sign in to comment.