Skip to content

Commit 3a943a0

Browse files
committed
fix(linear-scale): add custom wrapper instead of CSS hack
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 6be7bdc commit 3a943a0

1 file changed

Lines changed: 19 additions & 29 deletions

File tree

src/components/Questions/QuestionLinearScale.vue

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,20 @@
7171
})
7272
}}
7373
</legend>
74-
<NcCheckboxRadioSwitch
75-
v-for="(option, index) in scaleOptions"
76-
:key="option"
77-
:aria-describedby="index === 0 ? labelId : undefined"
78-
:disabled="!readOnly"
79-
:checked="questionValues"
80-
:value="option.toString()"
81-
:name="`${id}-answer`"
82-
type="radio"
83-
:required="checkRequired(option)"
84-
@update:checked="onChange"
85-
@keydown.enter.exact.prevent="onKeydownEnter">
86-
{{ option }}
87-
</NcCheckboxRadioSwitch>
74+
<div v-for="(option, index) in scaleOptions" :key="option" class="linear-scale-option__wrapper">
75+
<label :for="`linear-scale-${id}-${option}`">{{ option }}</label>
76+
<NcCheckboxRadioSwitch
77+
:id="`linear-scale-${id}-${option}`"
78+
:aria-describedby="index === 0 ? labelId : undefined"
79+
:disabled="!readOnly"
80+
:model-value="questionValues"
81+
:value="option.toString()"
82+
:name="`${id}-answer`"
83+
type="radio"
84+
:required="checkRequired(option)"
85+
@update:modelValue="onChange"
86+
@keydown.enter.exact.prevent="onKeydownEnter" />
87+
</div>
8888
</fieldset>
8989
<NcTextArea
9090
v-if="!readOnly"
@@ -306,25 +306,15 @@ export default {
306306
}
307307
}
308308
309-
:deep(.checkbox-content) {
309+
.linear-scale-option__wrapper {
310310
display: flex;
311-
flex-direction: row; // Labels next to checkboxes by default
311+
flex-direction: column;
312+
gap: calc(var(--default-grid-baseline) / 2);
312313
align-items: center;
313-
text-align: center;
314-
315-
@media (min-width: 769px) {
316-
flex-direction: column; // Labels above checkboxes on larger screens
317-
align-items: center;
318-
}
319-
}
320-
321-
:deep(.checkbox-content__text) {
322-
position: absolute;
323-
margin-block-start: calc(-1 * var(--clickable-area-small));
314+
justify-content: center;
324315
325316
@media (max-width: 768px) {
326-
margin-block-start: 0;
327-
margin-inline-start: var(--default-clickable-area);
317+
flex-direction: row-reverse;
328318
}
329319
}
330320

0 commit comments

Comments
 (0)