Skip to content

Commit 9ee09cf

Browse files
twjefferychrisolsen
authored andcommitted
feat(#2936): update radio to v2
1 parent 3c85542 commit 9ee09cf

File tree

2 files changed

+201
-41
lines changed

2 files changed

+201
-41
lines changed

libs/web-components/src/components/radio-group/RadioGroup.svelte

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@
2525
FieldsetErrorRelayDetail, FieldsetResetFieldsMsg,
2626
} from "../../types/relay-types";
2727
28-
// Validator
28+
// Validators
2929
const [Orientations, validateOrientation] = typeValidator("Radio group orientation", [
3030
"vertical",
3131
"horizontal",
3232
]);
33+
const [Version, validateVersion] = typeValidator("Version", ["1", "2"]);
34+
const [Size, validateSize] = typeValidator("Size", ["default", "compact"]);
3335
34-
// Type
36+
// Types
3537
type Orientation = (typeof Orientations)[number];
38+
type VersionType = (typeof Version)[number];
39+
type SizeType = (typeof Size)[number];
3640
3741
// Public
3842
@@ -41,6 +45,8 @@
4145
export let orientation: Orientation = "vertical";
4246
export let disabled: string = "false";
4347
export let error: string = "false";
48+
export let version: VersionType = "1";
49+
export let size: SizeType = "default";
4450
export let testid: string = "";
4551
export let arialabel: string = "";
4652
export let mt: Spacing = null;
@@ -55,8 +61,11 @@
5561
// Reactive
5662
5763
$: isDisabled = toBoolean(disabled);
64+
$: isCompact = size === "compact";
5865
$: {
5966
isDisabled;
67+
version;
68+
isCompact;
6069
bindOptions();
6170
}
6271
@@ -86,6 +95,8 @@
8695
// Hooks
8796
onMount(() => {
8897
validateOrientation(orientation);
98+
validateVersion(version);
99+
validateSize(size);
89100
addRelayListener();
90101
sendMountedMessage();
91102
getChildren();
@@ -163,6 +174,8 @@
163174
name,
164175
checked: props.value === value,
165176
revealAriaLabel: props.revealAriaLabel,
177+
version: version,
178+
compact: version === "2" && isCompact,
166179
},
167180
}),
168181
);
@@ -212,6 +225,8 @@
212225
bind:this={_rootEl}
213226
style={calculateMargin(mt, mr, mb, ml)}
214227
class={`goa-radio-group--${orientation}`}
228+
class:v2={version === "2"}
229+
class:compact={isCompact}
215230
data-testid={testid}
216231
role="radiogroup"
217232
aria-label={arialabel}
@@ -233,13 +248,23 @@
233248
gap: var(--goa-radio-group-gap-horizontal);
234249
}
235250
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+
236256
.goa-radio-group--vertical {
237257
display: flex;
238258
flex-direction: column; /* Vertical stacking */
239259
gap: var(--goa-radio-group-gap-vertical); /* Adds spacing */
240260
width: 100%;
241261
}
242262
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+
243268
/* Focus styles */
244269
.goa-radio-group--horizontal:focus,
245270
.goa-radio-group--vertical:focus {

0 commit comments

Comments
 (0)