summaryrefslogtreecommitdiffstats
path: root/tpl/objects/button.pug
blob: b9b4cbd3741b5b7e79e4ed267b3c3fee4b58909e (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
include icon.pug

mixin button
    -
        let classes = {
            'o-button':            true,
            'u-d-block':                  attributes.block,
            'o-button--secondary': attributes.secondary,
            'o-button--quiet':     attributes.quiet,
            'o-button--pill':      attributes.pill,
            'o-button--static':    attributes.static,
            'o-button--icon':      !!attributes.icon && !block,
            'is-selected':                attributes.selected,
        }
        if (attributes.theme) {
            classes['o-button--' + attributes.theme] = true
        }
        if (attributes.size) {
            classes['o-button--' + attributes.size] = true
        }
        if (attributes.class) {
            classes[attributes.class] = true;
        }

        let href = attributes.disabled ? null : '#';

    if attributes.badge
        span(class=classes href=href)
            if attributes.icon
                +icon(attributes.icon)
                = ' '
            if block
                span.o-button__label
                    block
            if attributes.postIcon
                = ' '
                +icon(attributes.postIcon)
    else
        a(class=classes href=href)
            if attributes.icon
                +icon(attributes.icon)
                = ' '
            if block
                span.o-button__label
                    block
            if attributes.postIcon
                = ' '
                +icon(attributes.postIcon)