Skip to content

Commit eb24c04

Browse files
authored
Merge pull request #377 from chungjac/radiogroup
fix: radiogroup toggle will always stack vertically
2 parents 7ef309b + cce50d5 commit eb24c04

File tree

9 files changed

+27
-4
lines changed

9 files changed

+27
-4
lines changed
Loading
Loading
Loading
Loading
-181 KB
Loading

src/components/form-items/radio-group.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,23 @@ export class RadioGroupInternal extends RadioGroupAbstract {
4343
constructor (props: RadioGroupProps) {
4444
StyleLoader.getInstance().load('components/_form-input.scss');
4545
super();
46+
// Only add vertical classes for radiogroup type
47+
const isRadioGroup = props.type === 'radiogroup';
4648
this.radioGroupElement = DomBuilder.getInstance().build({
4749
type: 'div',
4850
testId: props.wrapperTestId,
49-
classNames: [ 'mynah-form-input', ...(props.classNames ?? []) ],
51+
classNames: [
52+
'mynah-form-input',
53+
...(props.classNames ?? []),
54+
...(isRadioGroup ? [ 'mynah-form-input-vertical' ] : [])
55+
],
5056
children:
5157
props.options?.map((option, index) => ({
5258
type: 'div',
53-
classNames: [ 'mynah-form-input-radio-wrapper' ],
59+
classNames: [
60+
'mynah-form-input-radio-wrapper',
61+
...(isRadioGroup ? [ 'mynah-form-input-radio-wrapper-vertical' ] : [])
62+
],
5463
children: [ {
5564
type: 'label',
5665
testId: props.optionTestId,

src/styles/components/form-items/_radio-group.scss

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
justify-content: center;
1414
align-items: center;
1515
position: relative;
16-
gap: var(--mynah-sizing-1);
16+
gap: var(--mynah-sizing-2);
1717
cursor: pointer;
1818

1919
box-sizing: border-box;
@@ -57,7 +57,7 @@
5757
> .mynah-ui-icon {
5858
position: relative;
5959
transition: inherit;
60-
opacity: 0.25;
60+
opacity: 0;
6161
font-size: 85%;
6262
z-index: var(--mynah-z-2);
6363
}
@@ -68,3 +68,17 @@
6868
}
6969
}
7070
}
71+
72+
/* Vertical radio group styles */
73+
.mynah-form-input-vertical {
74+
display: flex;
75+
flex-direction: column;
76+
}
77+
78+
.mynah-form-input-radio-wrapper-vertical {
79+
display: block;
80+
81+
&:not(:last-child) {
82+
margin-bottom: var(--mynah-sizing-2);
83+
}
84+
}

0 commit comments

Comments
 (0)