From e53f820272513d128da2c489281bc31c9b15f590 Mon Sep 17 00:00:00 2001 From: bc-nick <99336044+bc-nick@users.noreply.github.com> Date: Wed, 4 Jan 2023 19:20:16 +0200 Subject: [PATCH] feat(component): add Badge props to Checkbox component (#1080) * feat(component): add Badge props to Checkbox component --- .../src/components/Checkbox/Checkbox.tsx | 6 ++- .../Checkbox/__snapshots__/spec.tsx.snap | 50 +++++++++---------- .../src/components/Checkbox/spec.tsx | 17 +++++++ .../docs/PropTables/CheckboxPropTable.tsx | 13 +++++ packages/docs/pages/checkbox.tsx | 45 +++++++++++++++++ 5 files changed, 105 insertions(+), 26 deletions(-) diff --git a/packages/big-design/src/components/Checkbox/Checkbox.tsx b/packages/big-design/src/components/Checkbox/Checkbox.tsx index 67b70a9c8..85add3620 100644 --- a/packages/big-design/src/components/Checkbox/Checkbox.tsx +++ b/packages/big-design/src/components/Checkbox/Checkbox.tsx @@ -10,6 +10,7 @@ import React, { } from 'react'; import { typedMemo, warning } from '../../utils'; +import { Badge, BadgeProps } from '../Badge'; import { FormControlDescription, FormControlDescriptionLinkProps } from '../Form'; import { CheckboxLabel } from './Label'; @@ -25,6 +26,7 @@ interface Props { isIndeterminate?: boolean; label: React.ReactChild; description?: CheckboxDescription | string; + badge?: BadgeProps; } interface CheckboxDescription { @@ -48,6 +50,7 @@ const RawCheckbox: React.FC = ({ label, forwardedRef, style, + badge, ...props }) => { const uniqueCheckboxId = useId(); @@ -69,6 +72,7 @@ const RawCheckbox: React.FC = ({ id={labelId} > {label} + {badge ? : null} ); } @@ -85,7 +89,7 @@ const RawCheckbox: React.FC = ({ } warning('label must be either a string or a CheckboxLabel component.'); - }, [disabled, hiddenLabel, id, label, labelId]); + }, [badge, disabled, hiddenLabel, id, label, labelId]); const renderedDescription = useMemo(() => { if (!description) { diff --git a/packages/big-design/src/components/Checkbox/__snapshots__/spec.tsx.snap b/packages/big-design/src/components/Checkbox/__snapshots__/spec.tsx.snap index df4a201b8..c7bb6aa35 100644 --- a/packages/big-design/src/components/Checkbox/__snapshots__/spec.tsx.snap +++ b/packages/big-design/src/components/Checkbox/__snapshots__/spec.tsx.snap @@ -248,18 +248,18 @@ exports[`render Checkbox disabled checked 1`] = ` > @@ -397,17 +397,17 @@ exports[`render Checkbox disabled indeterminate 1`] = ` class="c0" > @@ -546,17 +546,17 @@ exports[`render Checkbox disabled unchecked 1`] = ` > @@ -694,15 +694,15 @@ exports[`render Checkbox indeterminate 1`] = ` class="c0" >