material 0.7.6 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/badge.js +22 -5
- package/src/button.js +10 -0
- package/src/form/build.js +2 -0
- package/src/mixin/display.js +2 -0
- package/src/module/build.js +1 -1
- package/src/snackbar.js +13 -8
- package/src/styles/M3/components/badge.sass +19 -0
package/package.json
CHANGED
package/src/badge.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import build from './module/build'
|
|
2
|
+
import display from './mixin/display'
|
|
3
|
+
|
|
4
|
+
const isStringNumber = (str) => !isNaN(parseFloat(str)) && isFinite(str)
|
|
2
5
|
|
|
3
6
|
class Badge {
|
|
4
7
|
static defaults = {
|
|
@@ -12,15 +15,29 @@ class Badge {
|
|
|
12
15
|
|
|
13
16
|
init (options) {
|
|
14
17
|
this.options = Object.assign({}, Badge.defaults, options || {})
|
|
15
|
-
Object.assign(this, build)
|
|
18
|
+
Object.assign(this, build, display)
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
set (text) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
this.element.innerHTML = text || ''
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get () {
|
|
26
|
+
return this.element.innerHTML
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
inc (value) {
|
|
30
|
+
// console.log('inc', value)
|
|
31
|
+
let actual = this.element.innerHTML
|
|
32
|
+
|
|
33
|
+
if (actual === '') actual = '0'
|
|
34
|
+
|
|
35
|
+
if (isStringNumber(value) && isStringNumber(actual)) {
|
|
36
|
+
actual = (parseInt(value, 10) + parseInt(actual, 10)).toString()
|
|
23
37
|
}
|
|
38
|
+
|
|
39
|
+
this.element.innerHTML = actual
|
|
40
|
+
this.show()
|
|
24
41
|
}
|
|
25
42
|
}
|
|
26
43
|
|
package/src/button.js
CHANGED
|
@@ -147,6 +147,16 @@ class Button extends EventEmitter {
|
|
|
147
147
|
this.emit('click', ev)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
select (select) {
|
|
151
|
+
if (select === null) {
|
|
152
|
+
this.element.classList.remove('selected')
|
|
153
|
+
this.selected = null
|
|
154
|
+
} else {
|
|
155
|
+
this.element.classList.add('selected')
|
|
156
|
+
this.selected = true
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
150
160
|
mousedown (ev) {
|
|
151
161
|
this.element.classList.add('pushed')
|
|
152
162
|
}
|
package/src/form/build.js
CHANGED
package/src/mixin/display.js
CHANGED
|
@@ -50,9 +50,11 @@ export default {
|
|
|
50
50
|
|
|
51
51
|
setTimeout(() => {
|
|
52
52
|
dom.destroy(this.element)
|
|
53
|
+
if (this.underlay) dom.destroy(this.underlay)
|
|
53
54
|
}, this.options.transition)
|
|
54
55
|
} else {
|
|
55
56
|
dom.destroy(this.element)
|
|
57
|
+
if (this.underlay) dom.destroy(this.underlay)
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
this.emit?.('destroy')
|
package/src/module/build.js
CHANGED
package/src/snackbar.js
CHANGED
|
@@ -5,6 +5,7 @@ import build from './module/build'
|
|
|
5
5
|
import bindEvents from './module/events'
|
|
6
6
|
import display from './mixin/display'
|
|
7
7
|
// ui element
|
|
8
|
+
import Element from './element'
|
|
8
9
|
import Text from './text'
|
|
9
10
|
import Button from './button'
|
|
10
11
|
|
|
@@ -17,11 +18,13 @@ class Snackbar extends EventEmitter {
|
|
|
17
18
|
close: false,
|
|
18
19
|
layout: [
|
|
19
20
|
[Text, 'message', { tag: 'span', class: 'message' }],
|
|
20
|
-
[
|
|
21
|
-
|
|
21
|
+
[Element, 'action', { tag: 'span', class: 'action' },
|
|
22
|
+
[Button, 'callback', { class: 'callback', type: 'link' }],
|
|
23
|
+
[Button, 'close', { class: 'close', type: 'action' }]
|
|
24
|
+
]
|
|
22
25
|
],
|
|
23
26
|
events: [
|
|
24
|
-
['ui.
|
|
27
|
+
['ui.callback.click', 'action'],
|
|
25
28
|
['ui.close.click', 'destroy']
|
|
26
29
|
]
|
|
27
30
|
}
|
|
@@ -70,13 +73,15 @@ class Snackbar extends EventEmitter {
|
|
|
70
73
|
this.ui.message.set(this.options.message)
|
|
71
74
|
|
|
72
75
|
if (this.options.action) {
|
|
73
|
-
this.ui.
|
|
74
|
-
this.ui.
|
|
76
|
+
this.ui.callback.set(this.options.action)
|
|
77
|
+
this.ui.callback.element.classList.add('show')
|
|
78
|
+
this.ui.action.classList.add('show')
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
if (this.options.close)
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
if (this.options.close) {
|
|
82
|
+
this.ui.close.element.classList.add('show')
|
|
83
|
+
this.ui.action.classList.add('show')
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
action () {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.badge
|
|
2
|
+
opacity: .9
|
|
3
|
+
font-family: helvetica, arial, sans-serif
|
|
4
|
+
line-height: 1.5em
|
|
5
|
+
display: none
|
|
6
|
+
cursor: pointer
|
|
7
|
+
font-size: .7em
|
|
8
|
+
font-weight: 500
|
|
9
|
+
text-align: center
|
|
10
|
+
position: absolute
|
|
11
|
+
z-index: 4
|
|
12
|
+
right: 0px
|
|
13
|
+
top: 1px
|
|
14
|
+
height: 16px
|
|
15
|
+
min-width: 16px
|
|
16
|
+
padding: 1px 5px
|
|
17
|
+
border-radius: 8px
|
|
18
|
+
// border: 1px solid rgba(255,255,255,1)
|
|
19
|
+
background-color: #BB1A1B
|