|
25 | 25 | FieldsetErrorRelayDetail, FieldsetResetFieldsMsg, |
26 | 26 | } from "../../types/relay-types"; |
27 | 27 |
|
28 | | - // Validator |
| 28 | + // Validators |
29 | 29 | const [Orientations, validateOrientation] = typeValidator("Radio group orientation", [ |
30 | 30 | "vertical", |
31 | 31 | "horizontal", |
32 | 32 | ]); |
| 33 | + const [Version, validateVersion] = typeValidator("Version", ["1", "2"]); |
| 34 | + const [Size, validateSize] = typeValidator("Size", ["default", "compact"]); |
33 | 35 |
|
34 | | - // Type |
| 36 | + // Types |
35 | 37 | type Orientation = (typeof Orientations)[number]; |
| 38 | + type VersionType = (typeof Version)[number]; |
| 39 | + type SizeType = (typeof Size)[number]; |
36 | 40 |
|
37 | 41 | // Public |
38 | 42 |
|
|
41 | 45 | export let orientation: Orientation = "vertical"; |
42 | 46 | export let disabled: string = "false"; |
43 | 47 | export let error: string = "false"; |
| 48 | + export let version: VersionType = "1"; |
| 49 | + export let size: SizeType = "default"; |
44 | 50 | export let testid: string = ""; |
45 | 51 | export let arialabel: string = ""; |
46 | 52 | export let mt: Spacing = null; |
|
55 | 61 | // Reactive |
56 | 62 |
|
57 | 63 | $: isDisabled = toBoolean(disabled); |
| 64 | + $: isCompact = size === "compact"; |
58 | 65 | $: { |
59 | 66 | isDisabled; |
| 67 | + version; |
| 68 | + isCompact; |
60 | 69 | bindOptions(); |
61 | 70 | } |
62 | 71 |
|
|
86 | 95 | // Hooks |
87 | 96 | onMount(() => { |
88 | 97 | validateOrientation(orientation); |
| 98 | + validateVersion(version); |
| 99 | + validateSize(size); |
89 | 100 | addRelayListener(); |
90 | 101 | sendMountedMessage(); |
91 | 102 | getChildren(); |
|
163 | 174 | name, |
164 | 175 | checked: props.value === value, |
165 | 176 | revealAriaLabel: props.revealAriaLabel, |
| 177 | + version: version, |
| 178 | + compact: version === "2" && isCompact, |
166 | 179 | }, |
167 | 180 | }), |
168 | 181 | ); |
|
212 | 225 | bind:this={_rootEl} |
213 | 226 | style={calculateMargin(mt, mr, mb, ml)} |
214 | 227 | class={`goa-radio-group--${orientation}`} |
| 228 | + class:v2={version === "2"} |
| 229 | + class:compact={isCompact} |
215 | 230 | data-testid={testid} |
216 | 231 | role="radiogroup" |
217 | 232 | aria-label={arialabel} |
|
233 | 248 | gap: var(--goa-radio-group-gap-horizontal); |
234 | 249 | } |
235 | 250 |
|
| 251 | + /* V2 compact size variant - V2-only feature */ |
| 252 | + .goa-radio-group--horizontal.v2.compact { |
| 253 | + gap: var(--goa-radio-group-gap-horizontal-compact); |
| 254 | + } |
| 255 | +
|
236 | 256 | .goa-radio-group--vertical { |
237 | 257 | display: flex; |
238 | 258 | flex-direction: column; /* Vertical stacking */ |
239 | 259 | gap: var(--goa-radio-group-gap-vertical); /* Adds spacing */ |
240 | 260 | width: 100%; |
241 | 261 | } |
242 | 262 |
|
| 263 | + /* V2 compact size variant - V2-only feature */ |
| 264 | + .goa-radio-group--vertical.v2.compact { |
| 265 | + gap: var(--goa-radio-group-gap-vertical-compact); |
| 266 | + } |
| 267 | +
|
243 | 268 | /* Focus styles */ |
244 | 269 | .goa-radio-group--horizontal:focus, |
245 | 270 | .goa-radio-group--vertical:focus { |
|
0 commit comments