diff options
Diffstat (limited to 'tpl/objects/field-label.pug')
-rw-r--r-- | tpl/objects/field-label.pug | 23 |
1 files changed, 23 insertions, 0 deletions
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 @@ | |||
1 | mixin field-label(label, hint=null) | ||
2 | - | ||
3 | let classes = { | ||
4 | 'o-field-label': true, | ||
5 | 'o-field-label--left': attributes.align === 'left', | ||
6 | 'o-field-label--right': attributes.align === 'right', | ||
7 | 'is-invalid': attributes.invalid, | ||
8 | 'is-disabled': attributes.disabled, | ||
9 | } | ||
10 | if (attributes.class) { | ||
11 | classes[attributes.class] = true; | ||
12 | } | ||
13 | |||
14 | let needsLabelWidth = attributes.align === 'left' || attributes.align === 'right'; | ||
15 | |||
16 | let labelStyle = needsLabelWidth ? 'width: ' + attributes.labelWidth : ''; | ||
17 | |||
18 | div(class=classes) | ||
19 | .o-field-label__label(style=labelStyle class=attributes.labelClass)= label | ||
20 | .o-field-label__content(class=attributes.contentClass) | ||
21 | block | ||
22 | if hint | ||
23 | .o-field-label__hint= hint | ||