diff --git a/common/changes/pcln-design-system/feature-PROT-4812-radio-toggle_2025-01-22-04-09.json b/common/changes/pcln-design-system/feature-PROT-4812-radio-toggle_2025-01-22-04-09.json new file mode 100644 index 0000000000..63984329c3 --- /dev/null +++ b/common/changes/pcln-design-system/feature-PROT-4812-radio-toggle_2025-01-22-04-09.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "pcln-design-system", + "comment": "adds backgroundColor to RadioCheckToggleCard", + "type": "minor" + } + ], + "packageName": "pcln-design-system" +} \ No newline at end of file diff --git a/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.spec.tsx b/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.spec.tsx index 413b7a040e..1d956b16e4 100644 --- a/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.spec.tsx +++ b/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.spec.tsx @@ -198,6 +198,7 @@ describe('RadioCheckToggleCard', () => { it('should render unchecked state UI correctly', () => { const { asFragment } = render( label > div { - background-color: ${getPaletteColor('background.lightest')} !important; border-color: transparent !important; & div.cardIcon > svg { @@ -53,7 +52,6 @@ const HoverStateCard = styled(Box)` flex: 1 1 30%; & > label > div { - background-color: ${getPaletteColor('background.lightest')} !important; border-color: ${getPaletteColor('primary.base')} !important; & div.cardIcon > svg { @@ -68,7 +66,6 @@ const FocusStateCard = styled(Box)` flex: 1 1 30%; & > label > div { - background-color: ${getPaletteColor('background.lightest')} !important; border-color: transparent !important; & div.cardIcon > svg { @@ -141,7 +138,7 @@ const DefaultDocPage = () => { options: { hPosition: THPositions vPosition: TVPositions - title: string + title: string | React.ReactElement value: string }[] } = { @@ -279,6 +276,45 @@ const DefaultDocPage = () => { + + Enabled - with backgroundColor} + value='example-1-1' + isSelected={false} + onChange={() => {}} + backgroundColor='success.light' + > + + + + + + {}} + backgroundColor='success.light' + > + + + + + + {}} + backgroundColor='success.light' + > + + + + { value='example-4' isSelected={true} onChange={() => {}} + backgroundColor='success.light' // set the backgroundColor, but ensure isSelected style overrides backgroundColor > diff --git a/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.tsx b/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.tsx index 2edb373852..4e8dd73ed5 100644 --- a/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.tsx +++ b/packages/core/src/RadioCheckToggleCard/RadioCheckToggleCard.tsx @@ -6,6 +6,7 @@ import { Box } from '../Box/Box' import { Flex } from '../Flex/Flex' import { Toggle } from '../Toggle/Toggle' import { getPaletteColor } from '../utils/utils' +import { type PaletteColor } from '../theme/theme' /** * @public @@ -41,17 +42,18 @@ export type TVPositions = (typeof RadioCheckToggleCardVPositions)[number] * @public */ export type RadioCheckToggleCardProps = { - children?: React.ReactNode + backgroundColor?: PaletteColor cardType?: TCardTypes + children?: React.ReactNode hPosition?: THPositions - vPosition?: TVPositions + isSelected: boolean isTakingFullHeightOfCard?: boolean - title: string isTitleBold?: boolean name: string - value: string onChange?: (e: React.ChangeEvent) => void - isSelected: boolean + title: string | React.ReactElement + value: string + vPosition?: TVPositions } const CombinedInput = styled.input` @@ -97,7 +99,6 @@ const CombinedInput = styled.input` ` const RCTCardContainer = styled(Flex)` - background-color: ${getPaletteColor('background.lightest')}; border: 1px solid transparent; border-radius: ${themeGet('borderRadii.action-lg')}; box-shadow: ${themeGet('shadows.sm')}; @@ -170,21 +171,20 @@ const buttonIcon = (cardType: TCardTypes) => { /** * @public */ -export function RadioCheckToggleCard(props: RadioCheckToggleCardProps) { - const { - children, - cardType, - hPosition, - vPosition, - isTakingFullHeightOfCard, - title, - isTitleBold, - name, - value, - onChange, - isSelected, - } = props - +export function RadioCheckToggleCard({ + backgroundColor = 'background.lightest', + cardType = 'radio', + children, + hPosition = 'right', + isSelected, + isTakingFullHeightOfCard = false, + isTitleBold = false, + name, + onChange = () => {}, + title, + value, + vPosition = 'top', +}: RadioCheckToggleCardProps) { const id = `${name}_${value}` const ButtonIcon = buttonIcon(cardType) @@ -199,7 +199,7 @@ export function RadioCheckToggleCard(props: RadioCheckToggleCardProps) { onChange={onChange} checked={isSelected} /> - + {}, -} diff --git a/packages/core/src/RadioCheckToggleCard/__snapshots__/RadioCheckToggleCard.spec.tsx.snap b/packages/core/src/RadioCheckToggleCard/__snapshots__/RadioCheckToggleCard.spec.tsx.snap index fa85f01614..1e1660e753 100644 --- a/packages/core/src/RadioCheckToggleCard/__snapshots__/RadioCheckToggleCard.spec.tsx.snap +++ b/packages/core/src/RadioCheckToggleCard/__snapshots__/RadioCheckToggleCard.spec.tsx.snap @@ -12,7 +12,7 @@ exports[`RadioCheckToggleCard Checkbox Card should render checked state UI corre box-sizing: border-box; } -.c9 { +.c10 { -webkit-flex: none; -ms-flex: none; flex: none; @@ -20,11 +20,16 @@ exports[`RadioCheckToggleCard Checkbox Card should render checked state UI corre width: 24; } -.c10 { +.c11 { outline: none; } .c2 { + background-color: #fff; + color: #001833; +} + +.c3 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -34,7 +39,7 @@ exports[`RadioCheckToggleCard Checkbox Card should render checked state UI corre flex-direction: column; } -.c4 { +.c5 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -93,8 +98,7 @@ exports[`RadioCheckToggleCard Checkbox Card should render checked state UI corre border-color: #049; } -.c3 { - background-color: #fff; +.c4 { border: 1px solid transparent; border-radius: 12px; box-shadow: 0 -1px 0 0 rgba(0,0,0,0.03),0 0 1px 0 rgba(0,0,0,0.24),0 2px 1px -1px rgba(0,0,0,0.16),0 2px 4px 0 rgba(0,0,0,0.12); @@ -102,37 +106,37 @@ exports[`RadioCheckToggleCard Checkbox Card should render checked state UI corre padding: 16px; } -.c5 { +.c6 { min-width: 0; width: 100%; } -.c5 + * { +.c6 + * { margin-top: 16px; } -.c7 { +.c8 { font-weight: 500; font-size: 14px; line-height: 24px; } -.c6 { +.c7 { -webkit-flex: 1; -ms-flex: 1; flex: 1; } -.c6 > :first-child + * { +.c7 > :first-child + * { margin-top: 16px; } -.c8 { +.c9 { line-height: 0px; margin: 0 0 0 16px; } -.c8 > svg { +.c9 > svg { border: 1px solid transparent; border-radius: 4px; color: #4f6f8f; @@ -156,29 +160,30 @@ exports[`RadioCheckToggleCard Checkbox Card should render checked state UI corre value="example-1" />
Title
Title
Title
Title
Title
Title
Title
Title
Title @@ -2038,11 +2083,11 @@ exports[`RadioCheckToggleCard common should render children next to title correc
Title
Title