11import React from 'react' ;
22
3- import { classNames } from '../../utilities/css' ;
43import { useUniqueId } from '../../utilities/unique-id' ;
54import type { Error } from '../../types' ;
65import { Checkbox } from '../Checkbox' ;
76import { RadioButton } from '../RadioButton' ;
87import { InlineError , errorTextID } from '../InlineError' ;
98import { Text } from '../Text' ;
9+ import { AlphaStack } from '../AlphaStack' ;
10+ import { Box } from '../Box' ;
11+ import { Bleed } from '../Bleed' ;
1012
1113import styles from './ChoiceList.scss' ;
1214
@@ -66,17 +68,16 @@ export function ChoiceList({
6668 const name = useUniqueId ( 'ChoiceList' , nameProp ) ;
6769 const finalName = allowMultiple ? `${ name } []` : name ;
6870
69- const className = classNames (
70- styles . ChoiceList ,
71- titleHidden && styles . titleHidden ,
72- ) ;
73-
7471 const titleMarkup = title ? (
75- < legend className = { styles . Title } >
72+ < Box
73+ as = "legend"
74+ paddingBlockEnd = { { xs : '5' , md : '1' } }
75+ visuallyHidden = { titleHidden }
76+ >
7677 < Text as = "span" variant = "bodyMd" >
7778 { title }
7879 </ Text >
79- </ legend >
80+ </ Box >
8081 ) : null ;
8182
8283 const choicesMarkup = choices . map ( ( choice ) => {
@@ -101,41 +102,57 @@ export function ChoiceList({
101102 ? choice . renderChildren ( isSelected )
102103 : null ;
103104 const children = renderedChildren ? (
104- < div className = { styles . ChoiceChildren } > { renderedChildren } </ div >
105+ < div className = { styles . ChoiceChildren } >
106+ < Box paddingBlockStart = { { xs : '4' , md : '0' } } paddingBlockEnd = "2" >
107+ { renderedChildren }
108+ </ Box >
109+ </ div >
105110 ) : null ;
106-
107111 return (
108- < li key = { value } className = { styles . ChoiceItem } >
109- < ControlComponent
110- name = { finalName }
111- value = { value }
112- id = { id }
113- label = { label }
114- disabled = { choiceDisabled || disabled }
115- checked = { choiceIsSelected ( choice , selected ) }
116- helpText = { helpText }
117- onChange = { handleChange }
118- ariaDescribedBy = {
119- error && describedByError ? errorTextID ( finalName ) : null
120- }
121- />
122- { children }
112+ < li key = { value } >
113+ < Bleed
114+ marginInline = "0"
115+ marginBlockEnd = { helpText ? { xs : '1' , md : '0' } : { xs : '0' } }
116+ >
117+ < ControlComponent
118+ name = { finalName }
119+ value = { value }
120+ id = { id }
121+ label = { label }
122+ disabled = { choiceDisabled || disabled }
123+ checked = { choiceIsSelected ( choice , selected ) }
124+ helpText = { helpText }
125+ onChange = { handleChange }
126+ ariaDescribedBy = {
127+ error && describedByError ? errorTextID ( finalName ) : null
128+ }
129+ />
130+ { children }
131+ </ Bleed >
123132 </ li >
124133 ) ;
125134 } ) ;
126135
127136 const errorMarkup = error && (
128- < div className = { styles . ChoiceError } >
137+ < Box paddingBlockStart = { { xs : '0' , md : '1' } } paddingBlockEnd = "2" >
129138 < InlineError message = { error } fieldID = { finalName } />
130- </ div >
139+ </ Box >
131140 ) ;
132141
133142 return (
134- < fieldset className = { className } id = { finalName } aria-invalid = { error != null } >
143+ < AlphaStack
144+ as = "fieldset"
145+ gap = { { xs : '4' , md : '0' } }
146+ fullWidth
147+ aria-invalid = { error != null }
148+ id = { finalName }
149+ >
135150 { titleMarkup }
136- < ul className = { styles . Choices } > { choicesMarkup } </ ul >
151+ < AlphaStack as = "ul" gap = { { xs : '4' , md : '0' } } fullWidth >
152+ { choicesMarkup }
153+ </ AlphaStack >
137154 { errorMarkup }
138- </ fieldset >
155+ </ AlphaStack >
139156 ) ;
140157}
141158
0 commit comments