From 1a0803cf6d1299876c8cf0f6d79be4fe54637bd1 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 8 Sep 2025 13:27:24 +0200 Subject: [PATCH] fix(linear-scale): add custom wrapper instead of CSS hack Also use proper BEM. Signed-off-by: Ferdinand Thiessen --- .../Questions/QuestionLinearScale.vue | 156 ++++++++---------- 1 file changed, 73 insertions(+), 83 deletions(-) diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue index ed993a11c..c3285a646 100644 --- a/src/components/Questions/QuestionLinearScale.vue +++ b/src/components/Questions/QuestionLinearScale.vue @@ -39,16 +39,15 @@
+ class="question__content question-linear-scale" + :class="{ + question__content__edit: !readOnly, + }"> + class="question-linear-scale__label question-linear-scale__label-lowest"> {{ optionsLabelLowest }}
-
+
{{ t('forms', 'From {firstOption} to {lastOption}', { @@ -71,26 +70,29 @@ }) }} - - {{ option }} - + class="question-linear-scale__option"> + + +
-
+
{{ optionsLabelHighest }}
@@ -281,23 +285,6 @@ export default { flex-wrap: wrap; // Allow wrapping for smaller screens } - @media (min-width: 769px) { - padding-block-start: var(--clickable-area-small); - } - - &__options { - width: 100%; - display: flex; - flex-direction: row; - justify-content: space-evenly; - flex-grow: 1; - - @media (max-width: 768px) { - flex-direction: column; // Stack options vertically on smaller screens - align-items: flex-start; // Align items to the left - } - } - &__edit { margin-inline-start: -12px; @@ -306,62 +293,65 @@ export default { } } - :deep(.checkbox-content) { - display: flex; - flex-direction: row; // Labels next to checkboxes by default - align-items: center; - text-align: center; + .question-linear-scale { + &__label { + width: 120px; + align-self: center; + flex-shrink: 0; - @media (min-width: 769px) { - flex-direction: column; // Labels above checkboxes on larger screens - align-items: center; - } - } + &-lowest { + text-align: start; + } - :deep(.checkbox-content__text) { - position: absolute; - margin-block-start: calc(-1 * var(--clickable-area-small)); + &-highest { + text-align: end; - @media (max-width: 768px) { - margin-block-start: 0; - margin-inline-start: var(--default-clickable-area); + @media (max-width: 768px) { + text-align: start; + } + } + + @media (max-width: 768px) { + width: 100%; // Full width on smaller screens + padding-block: var(--default-grid-baseline); + } } - } - .label-input-field { - width: 120px; - align-self: center; - min-height: fit-content; - flex-shrink: 0; + &__label-input { + width: 120px; + align-self: center; + min-height: fit-content; + flex-shrink: 0; - @media (max-width: 768px) { - width: 100%; // Full width on smaller screens - padding-block: var(--default-grid-baseline); + @media (max-width: 768px) { + width: 100%; // Full width on smaller screens + padding-block: var(--default-grid-baseline); + } } - } - .label-lowest { - width: 120px; - align-self: center; - text-align: start; - flex-shrink: 0; + &__options { + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-evenly; + flex-grow: 1; - @media (max-width: 768px) { - width: 100%; // Full width on smaller screens - padding-block: var(--default-grid-baseline); + @media (max-width: 768px) { + flex-direction: column; // Stack options vertically on smaller screens + align-items: flex-start; // Align items to the left + } } - } - .label-highest { - width: 120px; - align-self: center; - text-align: end; - flex-shrink: 0; + &__option { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; - @media (max-width: 768px) { - text-align: start; - width: 100%; // Full width on smaller screens - padding-block: var(--default-grid-baseline); + @media (max-width: 768px) { + flex-direction: row-reverse; + } } } }