From 535b04d60721dd4efd7ec2b6eda4a658767bde1b Mon Sep 17 00:00:00 2001 From: Andrea Pregnolato Date: Wed, 9 Oct 2024 15:38:41 +0200 Subject: [PATCH] fix: label spacing in inputs (#277) --- .../html/ds/src/file-upload/file-upload.html | 9 ++- packages/html/ds/src/hint-text/hint-text.html | 8 +-- packages/html/ds/src/select/select.html | 12 +++- packages/html/ds/src/tabs/helpers.html | 25 ++++---- packages/html/ds/src/tabs/tabs.html | 4 +- .../html/ds/src/text-input/text-input.html | 9 ++- packages/html/ds/src/textarea/textarea.html | 9 ++- packages/html/ds/styles.css | 58 +++++++++---------- .../react/ds/src/error-text/error-text.tsx | 2 +- .../react/ds/src/file-upload/file-upload.tsx | 23 +++++++- packages/react/ds/src/hint-text/hint-text.tsx | 8 +-- packages/react/ds/src/label/label.tsx | 4 +- packages/react/ds/src/select/select.tsx | 17 +++++- .../react/ds/src/text-input/text-input.tsx | 4 +- packages/react/ds/src/textarea/textarea.tsx | 5 +- 15 files changed, 130 insertions(+), 67 deletions(-) diff --git a/packages/html/ds/src/file-upload/file-upload.html b/packages/html/ds/src/file-upload/file-upload.html index b92812f5e..3635addb8 100644 --- a/packages/html/ds/src/file-upload/file-upload.html +++ b/packages/html/ds/src/file-upload/file-upload.html @@ -3,7 +3,12 @@ {% from 'hint-text/hint-text.html' import govieHintText %} {% from 'error-text/error-text.html' import govieErrorText %} {% set isError = props.error and props.error.content %} + {% set isHint = props.hint and props.hint.content %} {% set inputId = props.id or 'file-upload-id' %} + {% set marginTop = '' %} + {% if props.error and props.hint %} + {% set marginTop = 'gi-mt-1' %} + {% endif %} {# Conditionally render the wrapper div only if error content is available #} {# prettier-ignore-start #} @@ -24,7 +29,7 @@ }} {% endif %} - {% if props.hint %} + {% if isHint %} {{ govieHintText({ "content": props.hint.content, @@ -44,7 +49,7 @@ {{ props.content | safe | trim | indent(2) }}

diff --git a/packages/html/ds/src/select/select.html b/packages/html/ds/src/select/select.html index 276f11b5d..84667c289 100644 --- a/packages/html/ds/src/select/select.html +++ b/packages/html/ds/src/select/select.html @@ -4,6 +4,12 @@ {% macro govieSelect(props) %} {% set ariaLabel = props.label.content or props.id %} + {% set isError = props.error and props.error.content %} + {% set isHint = props.hint and props.hint.content %} + {% set marginTop = '' %} + {% if props.error and props.hint %} + {% set marginTop = 'gi-mt-1' %} + {% endif %}
{% if props.label %} @@ -15,7 +21,7 @@ }) }} {% endif %} - {% if props.hint %} + {% if isHint %} {{ govieHintText({ "content": props.hint.content, @@ -24,7 +30,7 @@ }) }} {% endif %} - {% if props.error %} + {% if isError %} {{ govieErrorText({ "content": props.error.content, @@ -36,7 +42,7 @@