forked from explosion/displacy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_mixins.jade
81 lines (51 loc) · 2.51 KB
/
_mixins.jade
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//- ----------------------------------
//- 💥 MIXINS
//- ----------------------------------
//- Error
mixin error(message)
#error.c-alert.c-alert--error.u-text-small(onclick="this.classList.add('c-alert--is-closing'); setTimeout(function() { this.style.display = 'none'; this.classList.remove('c-alert--is-closing') }.bind(this), 2500)")=message
//- Icon
mixin icon(name, size)
svg.o-icon(aria-hidden="true" viewBox="0 0 20 20" width="20" height="20" fill="currentColor")&attributes(attributes)
use(xlink:href="assets/img/icons.svg#icon-#{name}")
//- Input
mixin input(placeholder, label)
menu.c-input.c-input--full.u-text-medium
if label
label.c-input__label(for=id)=label
input.c-input__field(type="text" placeholder=placeholder autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" onfocus="this.select()")&attributes(attributes)
block
//- Textarea
mixin textarea(placeholder, label)
menu.c-input.c-input--full.u-text-medium
if label
label.c-input__label.u-label(for=id)=label
textarea.c-input__field.c-input__field--area(type="text" placeholder=placeholder autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" onfocus="this.select()")&attributes(attributes)
block
//- Search button
mixin search(size)
button.c-input__button(class=size ? "c-input__button--#{size}" : "" role="button")&attributes(attributes)
+icon("search").c-input__button__icon
+icon("spinner").c-input__button__spinner
//- Dropdown
mixin dropdown(type, name, label, options, checked)
menu.c-input&attributes(attributes)
label.c-input__label(for=name)=label
+icon("arrow-down").c-input__icon
input.c-dropdown__trigger(id=name type="checkbox" aria-hidden="true")
ul.c-dropdown.u-text-small
each option, id in options
li
input.c-dropdown__trigger(name=name value=id id="#{name}-#{id}" type=type checked=(checked.indexOf(id) != -1))
label.c-dropdown__option(for="#{name}-#{id}")=option
+icon("check").c-dropdown__option__icon
//- Button
mixin button(icon, label)
a.c-input(role="button" aria-label=label data-tooltip=label)&attributes(attributes)
if icon
+icon(icon).c-input__button
block
//- External Link
mixin a(url, trusted)
a(href=url target="_blank" rel=(!trusted) ? "noopener nofollow" : "")&attributes(attributes)
block