From 3b7e35551b499a7b8887adb068d3a80e4088b0c2 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 19:23:14 +0100 Subject: Added field-label --- tpl/objects/button.pug | 2 +- tpl/objects/field-label.pug | 23 +++++++++++++++++++++++ tpl/objects/text-field.pug | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tpl/objects/field-label.pug (limited to 'tpl/objects') diff --git a/tpl/objects/button.pug b/tpl/objects/button.pug index 243ff58..3b10ea0 100644 --- a/tpl/objects/button.pug +++ b/tpl/objects/button.pug @@ -12,5 +12,5 @@ mixin a-button let href = attributes.disabled ? null : '#'; - a(class=classes href=href) + a(class=classes href=href aria-disabled=attributes.disabled && String(attributes.disabled)) block diff --git a/tpl/objects/field-label.pug b/tpl/objects/field-label.pug new file mode 100644 index 0000000..151e084 --- /dev/null +++ b/tpl/objects/field-label.pug @@ -0,0 +1,23 @@ +mixin field-label(label, hint=null) + - + let classes = { + 'o-field-label': true, + 'o-field-label--left': attributes.align === 'left', + 'o-field-label--right': attributes.align === 'right', + 'is-invalid': attributes.invalid, + 'is-disabled': attributes.disabled, + } + if (attributes.class) { + classes[attributes.class] = true; + } + + let needsLabelWidth = attributes.align === 'left' || attributes.align === 'right'; + + let labelStyle = needsLabelWidth ? 'width: ' + attributes.labelWidth : ''; + + div(class=classes) + .o-field-label__label(style=labelStyle class=attributes.labelClass)= label + .o-field-label__content(class=attributes.contentClass) + block + if hint + .o-field-label__hint= hint diff --git a/tpl/objects/text-field.pug b/tpl/objects/text-field.pug index 9bbe0a1..9069200 100644 --- a/tpl/objects/text-field.pug +++ b/tpl/objects/text-field.pug @@ -8,6 +8,6 @@ mixin text-field 'is-disabled': attributes.disabled, } - div(class=classes) + div(class=classes aria-disabled=attributes.disabled && String(attributes.disabled)) input(class='o-text-field__input')&attributes(attributes) .o-text-field__bg -- cgit v1.2.3-70-g09d2