material 0.7.7 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "A lightweight implementation of Material Design Components for the web - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
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
- if (text) {
20
- this.element.innerHTML = text
21
- } else {
22
- this.element.innerHTML = ''
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/form/build.js CHANGED
@@ -24,6 +24,8 @@ export default {
24
24
 
25
25
  this.buildLayout()
26
26
 
27
+ // console.log('optioins container', this.options)
28
+
27
29
  if (this.options.container) {
28
30
  this.options.container.appendChild(this.element)
29
31
  }
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,10 +18,13 @@ class Snackbar extends EventEmitter {
17
18
  close: false,
18
19
  layout: [
19
20
  [Text, 'message', { tag: 'span', class: 'message' }],
20
- [Button, 'action', { class: 'action', type: 'link' }]
21
+ [Element, 'action', { tag: 'span', class: 'action' },
22
+ [Button, 'callback', { class: 'callback', type: 'link' }],
23
+ [Button, 'close', { class: 'close', type: 'action' }]
24
+ ]
21
25
  ],
22
26
  events: [
23
- ['ui.action.click', 'action'],
27
+ ['ui.callback.click', 'action'],
24
28
  ['ui.close.click', 'destroy']
25
29
  ]
26
30
  }
@@ -69,12 +73,14 @@ class Snackbar extends EventEmitter {
69
73
  this.ui.message.set(this.options.message)
70
74
 
71
75
  if (this.options.action) {
72
- this.ui.action.set(this.options.action)
73
- this.ui.action.element.classList.add('show')
74
- } else if (this.options.close) {
75
- this.ui.action.element.classList.remove('style-link')
76
- this.ui.action.element.classList.add('style-action')
77
- this.ui.action.element.classList.add('close')
76
+ this.ui.callback.set(this.options.action)
77
+ this.ui.callback.element.classList.add('show')
78
+ this.ui.action.classList.add('show')
79
+ }
80
+
81
+ if (this.options.close) {
82
+ this.ui.close.element.classList.add('show')
83
+ this.ui.action.classList.add('show')
78
84
  }
79
85
  }
80
86
 
@@ -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