summaryrefslogtreecommitdiffstats
path: root/tpl/objects/message.pug
blob: d64434752e405999ad1c8be1a39e20bdad39fa5e (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
49
50
51
52
53
54
mixin message(user)
    - const slots = {}

    mixin slot(key)
        - slots[key] = block

    -
        block ? block() : undefined

        let classes = {
            'o-message':                true,
            'o-message--bubble':        attributes.bubble || !!attributes.theme,
            'o-message--75':            attributes.compact,
            'o-message--highlight':     attributes.highlight,
            'l-message-group__message': attributes.group
        }
        if (attributes.class) {
            classes[attributes.class] = true
        }
        if (attributes.theme) {
            classes[attributes.theme] = true
        }

        let headerClasses = {
            'o-message__header':           true,
            'l-message-group__merge-hide': true,
            'u-mb-50':                    !attributes.compact,
        }

    mixin content 
        if slots.header
            header(class=headerClasses)
                - slots.header()
        else if user
            header(class=headerClasses)
                strong= user
        span.s-links.s-links--colored
            - slots.body()
        if slots.time
            small.o-message__suffix
                - slots.time()
        if slots.footer
            footer.o-message__footer
                - slots.footer()

    article(class=classes)
        if user && attributes.avatar
            .l-media.l-media--flush.l-flex--align-start
                .l-media__block.u-mt-50.u-p-sticky-top
                    +avatar= user.slice(0, 2)
                .l-media__block.l-media__block--main
                    +content
        else
            +content