Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit f41309c

Browse files
authored
fix: update medium size checkboxes and radios vertical alignment (#201)
1 parent 937b9fe commit f41309c

File tree

6 files changed

+208
-164
lines changed

6 files changed

+208
-164
lines changed

src/govie/components/checkboxes/Checkboxes.stories.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export default {
2828
"When 'none' would be a valid answer, give users the option to check a box to say none of the other options apply to them — without this option, users would have to leave all of the boxes unchecked. Giving users this option also makes sure they do not skip the question by accident.",
2929
},
3030
noneOptionLabel: { control: 'text' },
31+
useMediumBoxes: {
32+
control: 'boolean',
33+
description:
34+
'Medium-sized checkboxes offer a balanced visual presence, making them ideal for forms and settings where clarity and ease of interaction are important. They are larger than small checkboxes, providing a more noticeable target area for users to click, but not as large as standard checkboxes, which makes them perfect for situations where moderate prominence is needed.\n' +
35+
'For example, in a settings menu or preference panel, medium checkboxes can help users easily identify and select options without overwhelming the interface. They strike the right balance between visibility and subtlety, ensuring a user-friendly experience without dominating the layout.',
36+
},
3137
useSmallerBoxes: {
3238
control: 'boolean',
3339
description:
@@ -44,6 +50,7 @@ export default {
4450
args: {
4551
fieldId: 'checkboxes-default',
4652
legendAsHeading: true,
53+
useMediumBoxes: false,
4754
useSmallerBoxes: false,
4855
haveNoneOption: false,
4956
items: [],
@@ -59,6 +66,12 @@ const createLegendNode = (args) => {
5966
classNames.push('govie-fieldset__legend--l');
6067
}
6168

69+
if (args.useMediumBoxes) {
70+
classNames.push('govie-fieldset__legend--m');
71+
} else if (args.legendAsHeading) {
72+
classNames.push('govie-fieldset__legend--l');
73+
}
74+
6275
const legend = document.createElement('legend');
6376
legend.className = classNames.join(' ');
6477

@@ -127,7 +140,7 @@ const createInputNode = (fieldId, index, itemData, isExclusive) => {
127140

128141
const createInputLabelNode = (fieldId, index, itemData, hiddenLabel) => {
129142
const label = document.createElement('label');
130-
label.className = 'govie-label--s govie-checkboxes__label';
143+
label.className = 'govie-label govie-checkboxes__label';
131144
label.setAttribute('for', createInputId(fieldId, index));
132145
if (hiddenLabel) {
133146
label.innerHTML = `<span class="govie-visually-hidden">${itemData.label}</span>`;
@@ -218,6 +231,10 @@ const createCheckboxesNode = (args) => {
218231
classNames.push('govie-checkboxes--small');
219232
}
220233

234+
if (args.useMediumBoxes) {
235+
classNames.push('govie-checkboxes--medium');
236+
}
237+
221238
const checkboxes = document.createElement('div');
222239
checkboxes.className = classNames.join(' ');
223240
checkboxes.setAttribute('data-module', 'govie-checkboxes');
@@ -367,6 +384,24 @@ WithNormalLegend.args = {
367384
],
368385
};
369386

387+
export const WithMediumCheckbox = Template.bind({});
388+
WithMediumCheckbox.args = {
389+
fieldId: 'organisation',
390+
legend: 'Organisation',
391+
useMediumBoxes: true,
392+
items: [
393+
{
394+
label: 'Employment Tribunal',
395+
value: 'employment-tribunal',
396+
},
397+
{
398+
label: 'Ministry of Defence',
399+
value: 'MOD',
400+
},
401+
{ label: 'Department for Transport', value: 'DfT' },
402+
],
403+
};
404+
370405
export const WithSmallCheckbox = Template.bind({});
371406
WithSmallCheckbox.args = {
372407
fieldId: 'organisation',

0 commit comments

Comments
 (0)