ui-components icon indicating copy to clipboard operation
ui-components copied to clipboard

feat(#2936): update Radio component for V2

Open twjeffery opened this issue 5 months ago • 1 comments

Summary

Updates the Radio component (RadioGroup + RadioItem) to support V2 design system styling while maintaining full backward compatibility with V1. This is a Token+CSS+Logic implementation due to the fundamental visual pattern change requiring DOM structure updates.

Changes

RadioGroup Component

New Props:

  • version ("1" | "2", default "1"): Controls V1 vs V2 styling
  • size ("default" | "compact", default "default"): Controls spacing between radio items

Size Variants:

  • Default vertical gap: 16px (unchanged from V1)
  • Compact vertical gap: 12px (new)
  • Default horizontal gap: 32px (increased from 24px)
  • Compact horizontal gap: 24px (new)

Implementation:

  • Version and compact state passed to RadioItem children via event messaging
  • Reactive block ensures size/version changes propagate immediately
  • CSS scoped with .v2.compact for V2-only features

RadioItem Component

Visual Pattern Change (V1 → V2):

V1 Approach (Border-Based):

  • Uses thick 7px border to create "filled circle" appearance when checked
  • Simple DOM structure: .icon div directly in label

V2 Approach (Border + Inner Dot):

  • Uses thin 1.5px border + separate 16px inner dot element when checked
  • Enhanced DOM structure: .icon-wrapper > .icon + .icon-inner (conditional)
  • Inner dot absolutely positioned and centered using transform: translate(-50%, -50%)

New Props:

  • version (received from RadioGroup): Controls V1/V2 rendering
  • compact (received from RadioGroup): Controls typography sizing

State Styling Updates:

All interaction states properly tokenized across 12+ combinations:

  • Unchecked: default, hover, focus, hover+focus, disabled
  • Checked: default, hover, focus, hover+focus, disabled
  • Error states: unchecked + checked with all interaction combinations

V2-Specific Features:

  • Inner dot colors: Blue (default), dark blue (hover), grey (disabled), red (error)
  • Background colors: Light grey (disabled), light red (error), pink (error hover)
  • Gap spacing: 12px icon-to-label (default), 8px (compact)
  • Typography: Medium weight (500), 22px line-height

Size Variants:

  • Default: 18px label, medium weight
  • Compact: 16px label, medium weight

Related

twjeffery avatar Oct 15 '25 02:10 twjeffery

@bdfranck Thanks for the detailed review and changes. I've implemented everything you included and will squash into one commit.

One additional thing I saw was that we need after testing again:

.icon {
 flex: 0 0 auto;
}

(to prevent squishing of the radio button)

Before image

After image


I also noticed that the font-weight medium is also not showing correctly. (just shows regular weight). Seems to be the same issue we've been having as the semi-bold weight used in various components not showing up. I figure we'll fix that on the system level.

twjeffery avatar Nov 10 '25 17:11 twjeffery

:tada: This PR is included in version 1.40.0-dev.8 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tzuge avatar Nov 25 '25 21:11 tzuge

:tada: This PR is included in version 4.10.0-dev.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tzuge avatar Nov 26 '25 23:11 tzuge

:tada: This PR is included in version 6.10.0-dev.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tzuge avatar Nov 26 '25 23:11 tzuge

:tada: This PR is included in version 1.10.0-dev.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

tzuge avatar Nov 28 '25 17:11 tzuge