summaryrefslogtreecommitdiffstats
path: root/tpl/objects/field-label.pug
blob: fb9644303db7064c2befa95dffefbfcbf94e14e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
mixin field-label(label, hint=null)
    -
        let classes = {
            'o-field-label': true,
            'is-invalid':    attributes.invalid,
            'is-disabled':   attributes.disabled,
        }
        if (attributes.align) {
            classes['o-field-label--align-' + attributes.align] = true;
        }
        if (attributes.class) {
            classes[attributes.class] = true;
        }

        let needsLabelWidth = !!attributes.align;

        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