material 0.7.5 → 0.7.7
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/button.js +17 -33
- package/src/file.js +0 -10
- package/src/item.js +28 -78
- package/src/mixin/control.js +0 -35
- package/src/mixin/display.js +3 -16
- package/src/mixin/label.js +0 -4
- package/src/module/build.js +25 -0
- package/src/module/numabbr.js +5 -1
- package/src/module/observer.js +2 -2
- package/src/navigation.js +15 -8
- package/src/skin/material/control/snackbar.sass +1 -1
- package/src/snackbar.js +5 -6
- package/src/styles/M3/navigation/rail.sass +12 -33
- package/src/switch.js +2 -37
- package/src/text.js +8 -0
package/package.json
CHANGED
package/src/button.js
CHANGED
|
@@ -46,18 +46,12 @@ class Button extends EventEmitter {
|
|
|
46
46
|
setup () {
|
|
47
47
|
this.setAttributes()
|
|
48
48
|
this.styleAttributes()
|
|
49
|
-
this.buildElements()
|
|
50
49
|
|
|
51
50
|
if (this.options.text) {
|
|
52
51
|
this.element.innerHTML = this.element.innerHTML + this.options.text
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
buildElements () {
|
|
57
|
-
this.buildIcon()
|
|
58
|
-
this.buildLabel()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
55
|
setAttributes () {
|
|
62
56
|
const { type, name, value, title, text, label, tooltip, data, case: caseOption } = this.options
|
|
63
57
|
|
|
@@ -80,26 +74,6 @@ class Button extends EventEmitter {
|
|
|
80
74
|
if (bold) this.element.classList.add('bold')
|
|
81
75
|
}
|
|
82
76
|
|
|
83
|
-
buildLabel () {
|
|
84
|
-
if (!this.options.label) return
|
|
85
|
-
|
|
86
|
-
this.label = document.createElement('label')
|
|
87
|
-
this.label.classList.add('label')
|
|
88
|
-
this.label.innerHTML = this.options.label
|
|
89
|
-
|
|
90
|
-
this.element.appendChild(this.label)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
buildIcon () {
|
|
94
|
-
if (!this.options.icon) return
|
|
95
|
-
|
|
96
|
-
this.icon = document.createElement('i')
|
|
97
|
-
this.icon.classList.add('icon')
|
|
98
|
-
this.icon.innerHTML = this.options.icon
|
|
99
|
-
|
|
100
|
-
this.element.appendChild(this.icon)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
77
|
set (prop, value) {
|
|
104
78
|
// console.log('set', this.element, prop, value)
|
|
105
79
|
switch (prop) {
|
|
@@ -107,15 +81,15 @@ class Button extends EventEmitter {
|
|
|
107
81
|
this.element.value = value
|
|
108
82
|
break
|
|
109
83
|
case 'label':
|
|
110
|
-
if (!this.label) this.buildLabel()
|
|
111
|
-
this.label.innerHTML = value
|
|
84
|
+
if (!this.ui.label) this.buildLabel()
|
|
85
|
+
this.ui.label.innerHTML = value
|
|
112
86
|
break
|
|
113
87
|
case 'text':
|
|
114
88
|
this.element.innerHTML = value
|
|
115
89
|
break
|
|
116
90
|
case 'icon':
|
|
117
|
-
if (this.icon) {
|
|
118
|
-
this.icon.innerHTML = value
|
|
91
|
+
if (this.ui.icon) {
|
|
92
|
+
this.ui.icon.innerHTML = value
|
|
119
93
|
}
|
|
120
94
|
break
|
|
121
95
|
case 'enable':
|
|
@@ -133,13 +107,13 @@ class Button extends EventEmitter {
|
|
|
133
107
|
}
|
|
134
108
|
|
|
135
109
|
setLabel (value) {
|
|
136
|
-
if (this.label) {
|
|
137
|
-
this.label.innerHTML = value
|
|
110
|
+
if (this.ui.label) {
|
|
111
|
+
this.ui.label.innerHTML = value
|
|
138
112
|
}
|
|
139
113
|
}
|
|
140
114
|
|
|
141
115
|
setText (value) {
|
|
142
|
-
if (this.label) {
|
|
116
|
+
if (this.ui.label) {
|
|
143
117
|
this.setLabel(value)
|
|
144
118
|
} else {
|
|
145
119
|
this.element.innerHTML = value
|
|
@@ -173,6 +147,16 @@ class Button extends EventEmitter {
|
|
|
173
147
|
this.emit('click', ev)
|
|
174
148
|
}
|
|
175
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
|
+
|
|
176
160
|
mousedown (ev) {
|
|
177
161
|
this.element.classList.add('pushed')
|
|
178
162
|
}
|
package/src/file.js
CHANGED
|
@@ -13,7 +13,6 @@ class File {
|
|
|
13
13
|
constructor (options) {
|
|
14
14
|
this.init(options)
|
|
15
15
|
this.build()
|
|
16
|
-
this.buildLabel()
|
|
17
16
|
this.buildInput()
|
|
18
17
|
this.attach()
|
|
19
18
|
}
|
|
@@ -23,15 +22,6 @@ class File {
|
|
|
23
22
|
Object.assign(this, build)
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
buildLabel () {
|
|
27
|
-
if (this.options.label) {
|
|
28
|
-
this.label = document.createElement('label')
|
|
29
|
-
this.label.classList.add('label')
|
|
30
|
-
this.label.innerHTML = this.options.label
|
|
31
|
-
this.element.appendChild(this.label)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
25
|
buildInput () {
|
|
36
26
|
this.field = document.createElement('div')
|
|
37
27
|
this.field.classList.add('field')
|
package/src/item.js
CHANGED
|
@@ -1,93 +1,45 @@
|
|
|
1
|
-
import
|
|
1
|
+
import build from './module/build'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
caption: 'span'
|
|
3
|
+
class Item {
|
|
4
|
+
static defaults = {
|
|
5
|
+
prefix: 'material',
|
|
6
|
+
class: 'item',
|
|
7
|
+
type: 'default',
|
|
8
|
+
tag: 'span',
|
|
9
|
+
types: {
|
|
10
|
+
default: 'span',
|
|
11
|
+
display4: 'h1',
|
|
12
|
+
display3: 'h1',
|
|
13
|
+
display2: 'h1',
|
|
14
|
+
display1: 'h1',
|
|
15
|
+
headline: 'h1',
|
|
16
|
+
title: 'h2',
|
|
17
|
+
subheading2: 'h3',
|
|
18
|
+
subheading1: 'h4',
|
|
19
|
+
body: 'p',
|
|
20
|
+
body2: 'aside',
|
|
21
|
+
caption: 'span'
|
|
22
|
+
}
|
|
24
23
|
}
|
|
25
|
-
}
|
|
26
24
|
|
|
27
|
-
/**
|
|
28
|
-
* The class represents an item ie for list
|
|
29
|
-
*
|
|
30
|
-
* @class
|
|
31
|
-
* @return {Object} The class instance
|
|
32
|
-
* @example new Item(object);
|
|
33
|
-
*/
|
|
34
|
-
class Item {
|
|
35
|
-
/**
|
|
36
|
-
* init
|
|
37
|
-
* @return {Object} The class options
|
|
38
|
-
*/
|
|
39
25
|
constructor (options) {
|
|
40
26
|
this.init(options)
|
|
41
27
|
this.build()
|
|
28
|
+
this.setup()
|
|
29
|
+
}
|
|
42
30
|
|
|
43
|
-
|
|
31
|
+
setup () {
|
|
32
|
+
if (this.options.text) this.set(this.options.text)
|
|
33
|
+
if (this.options.name) this.element.setAttribute('name', this.options.name)
|
|
44
34
|
}
|
|
45
35
|
|
|
46
|
-
/**
|
|
47
|
-
* [init description]
|
|
48
|
-
* @param {?} options [description]
|
|
49
|
-
* @return {?} [description]
|
|
50
|
-
*/
|
|
51
36
|
init (options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// define class
|
|
56
|
-
|
|
57
|
-
// assign modules
|
|
58
|
-
Object.assign(this, insert)
|
|
59
|
-
}
|
|
37
|
+
this.options = Object.assign({}, Item.defaults, options || {})
|
|
38
|
+
Object.assign(this, build)
|
|
60
39
|
|
|
61
|
-
/**
|
|
62
|
-
* Build function for item
|
|
63
|
-
* @return {Object} This class instance
|
|
64
|
-
*/
|
|
65
|
-
build () {
|
|
66
|
-
// define main tag
|
|
67
40
|
this.options.tag = this.options.tag || this.options.types[this.options.type]
|
|
68
|
-
|
|
69
|
-
this.options.tag = this.options.tag
|
|
70
|
-
|
|
71
|
-
this.element = create(this.options)
|
|
72
|
-
|
|
73
|
-
if (this.options.text) {
|
|
74
|
-
this.set(this.options.text)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (this.options.layout) {
|
|
78
|
-
this.layout = new Layout(this.options.layout, this.element)
|
|
79
|
-
} else {
|
|
80
|
-
if (this.options.container) {
|
|
81
|
-
this.insert(this.options.container)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
41
|
}
|
|
85
42
|
|
|
86
|
-
/**
|
|
87
|
-
* Get or set text value of the element
|
|
88
|
-
* @param {string} value The text to set
|
|
89
|
-
* @returns {*}
|
|
90
|
-
*/
|
|
91
43
|
set (value) {
|
|
92
44
|
if (value) {
|
|
93
45
|
if (this.element.innerText) {
|
|
@@ -95,8 +47,6 @@ class Item {
|
|
|
95
47
|
} else {
|
|
96
48
|
this.element.textContent = value
|
|
97
49
|
}
|
|
98
|
-
|
|
99
|
-
return this
|
|
100
50
|
}
|
|
101
51
|
|
|
102
52
|
return this
|
package/src/mixin/control.js
CHANGED
|
@@ -8,10 +8,6 @@ const KEYCODE = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const control = {
|
|
11
|
-
/**
|
|
12
|
-
* [toggle description]
|
|
13
|
-
* @return {Object} The class instance
|
|
14
|
-
*/
|
|
15
11
|
toggle () {
|
|
16
12
|
if (this.disabled) return
|
|
17
13
|
|
|
@@ -26,10 +22,6 @@ const control = {
|
|
|
26
22
|
return this
|
|
27
23
|
},
|
|
28
24
|
|
|
29
|
-
/**
|
|
30
|
-
* Set checkbox value
|
|
31
|
-
* @param {boolean} value [description]
|
|
32
|
-
*/
|
|
33
25
|
check (checked) {
|
|
34
26
|
if (checked === true) {
|
|
35
27
|
css.add(this.element, 'is-checked')
|
|
@@ -45,10 +37,6 @@ const control = {
|
|
|
45
37
|
return this
|
|
46
38
|
},
|
|
47
39
|
|
|
48
|
-
/**
|
|
49
|
-
* [initLabel description]
|
|
50
|
-
* @return {?} [description]
|
|
51
|
-
*/
|
|
52
40
|
label (label, container) {
|
|
53
41
|
if (!label) return
|
|
54
42
|
|
|
@@ -65,11 +53,6 @@ const control = {
|
|
|
65
53
|
insert(this.element.label, container)
|
|
66
54
|
},
|
|
67
55
|
|
|
68
|
-
/**
|
|
69
|
-
* [_initIcon description]
|
|
70
|
-
* @param {string} type
|
|
71
|
-
* @return {string}
|
|
72
|
-
*/
|
|
73
56
|
icon (icon, container, position) {
|
|
74
57
|
if (!icon) return
|
|
75
58
|
|
|
@@ -88,10 +71,6 @@ const control = {
|
|
|
88
71
|
this.element.icon.innerHTML = icon
|
|
89
72
|
},
|
|
90
73
|
|
|
91
|
-
/**
|
|
92
|
-
* [initLabel description]
|
|
93
|
-
* @return {?} [description]
|
|
94
|
-
*/
|
|
95
74
|
error (error) {
|
|
96
75
|
error = error || this.options.error
|
|
97
76
|
if (this.options.error === null) return
|
|
@@ -137,12 +116,6 @@ const control = {
|
|
|
137
116
|
}
|
|
138
117
|
},
|
|
139
118
|
|
|
140
|
-
/**
|
|
141
|
-
* Setter
|
|
142
|
-
* @param {string} prop
|
|
143
|
-
* @param {string} value
|
|
144
|
-
* @return {Object} The class instance
|
|
145
|
-
*/
|
|
146
119
|
get (prop) {
|
|
147
120
|
switch (prop) {
|
|
148
121
|
case 'name':
|
|
@@ -165,10 +138,6 @@ const control = {
|
|
|
165
138
|
return this.element.dataset.name
|
|
166
139
|
},
|
|
167
140
|
|
|
168
|
-
/**
|
|
169
|
-
* [_onInputFocus description]
|
|
170
|
-
* @return {?} [description]
|
|
171
|
-
*/
|
|
172
141
|
focus () {
|
|
173
142
|
if (this.disabled === true) return this
|
|
174
143
|
|
|
@@ -177,10 +146,6 @@ const control = {
|
|
|
177
146
|
return this
|
|
178
147
|
},
|
|
179
148
|
|
|
180
|
-
/**
|
|
181
|
-
* [_onInputBlur description]
|
|
182
|
-
* @return {?} [description]
|
|
183
|
-
*/
|
|
184
149
|
blur () {
|
|
185
150
|
css.remove(this.element, 'is-focused')
|
|
186
151
|
return this
|
package/src/mixin/display.js
CHANGED
|
@@ -10,10 +10,7 @@ export default {
|
|
|
10
10
|
|
|
11
11
|
show () {
|
|
12
12
|
// console.log('show', this.visible)
|
|
13
|
-
|
|
14
|
-
// if (this.options.transition) {
|
|
15
|
-
// this.element.style.display = 'initial'
|
|
16
|
-
// }
|
|
13
|
+
if (!this.element) return
|
|
17
14
|
|
|
18
15
|
this.element.getBoundingClientRect()
|
|
19
16
|
|
|
@@ -29,11 +26,6 @@ export default {
|
|
|
29
26
|
},
|
|
30
27
|
|
|
31
28
|
hide () {
|
|
32
|
-
// console.log('hide')
|
|
33
|
-
// if (this.element.style.display === 'none') return
|
|
34
|
-
// clearTimeout(this.displayTimeout)
|
|
35
|
-
// this._display = getComputedStyle(this.element).display
|
|
36
|
-
|
|
37
29
|
if (!this.element) return
|
|
38
30
|
|
|
39
31
|
this.element.classList.remove('show')
|
|
@@ -43,13 +35,6 @@ export default {
|
|
|
43
35
|
this.underlay.classList.remove('show')
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
// if (this.options.transition) {
|
|
47
|
-
// this.displayTimeout = setTimeout(() => {
|
|
48
|
-
// console.log('display: none', this._display)
|
|
49
|
-
// this.element.style.display = 'none'
|
|
50
|
-
// }, this.options.transition)
|
|
51
|
-
// }
|
|
52
|
-
|
|
53
38
|
this.emit?.('hide')
|
|
54
39
|
return this
|
|
55
40
|
},
|
|
@@ -65,9 +50,11 @@ export default {
|
|
|
65
50
|
|
|
66
51
|
setTimeout(() => {
|
|
67
52
|
dom.destroy(this.element)
|
|
53
|
+
if (this.underlay) dom.destroy(this.underlay)
|
|
68
54
|
}, this.options.transition)
|
|
69
55
|
} else {
|
|
70
56
|
dom.destroy(this.element)
|
|
57
|
+
if (this.underlay) dom.destroy(this.underlay)
|
|
71
58
|
}
|
|
72
59
|
|
|
73
60
|
this.emit?.('destroy')
|
package/src/mixin/label.js
CHANGED
package/src/module/build.js
CHANGED
|
@@ -33,9 +33,34 @@ export default {
|
|
|
33
33
|
this.ui = this.layout.component
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
this.ui = this.ui || {}
|
|
37
|
+
|
|
38
|
+
if (this.options.icon) this.buildIcon()
|
|
39
|
+
if (this.options.label) this.buildLabel()
|
|
40
|
+
|
|
36
41
|
if (this.options.show === true && this.show) this.show()
|
|
37
42
|
},
|
|
38
43
|
|
|
44
|
+
buildLabel () {
|
|
45
|
+
if (!this.options.label) return
|
|
46
|
+
|
|
47
|
+
this.ui.label = document.createElement('label')
|
|
48
|
+
this.ui.label.classList.add('label')
|
|
49
|
+
this.ui.label.innerHTML = this.options.label
|
|
50
|
+
|
|
51
|
+
this.element.appendChild(this.ui.label)
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
buildIcon () {
|
|
55
|
+
if (!this.options.icon) return
|
|
56
|
+
|
|
57
|
+
this.ui.icon = document.createElement('i')
|
|
58
|
+
this.ui.icon.classList.add('icon')
|
|
59
|
+
this.ui.icon.innerHTML = this.options.icon
|
|
60
|
+
|
|
61
|
+
this.element.appendChild(this.ui.icon)
|
|
62
|
+
},
|
|
63
|
+
|
|
39
64
|
appendTo (container) {
|
|
40
65
|
container.appendChild(this.element)
|
|
41
66
|
}
|
package/src/module/numabbr.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
const numabbr = (number, decimals = 2) => {
|
|
2
|
+
if (typeof number !== 'number' || isNaN(number)) {
|
|
3
|
+
return null
|
|
4
|
+
}
|
|
5
|
+
|
|
2
6
|
const factor = Math.pow(10, decimals)
|
|
3
7
|
const abbrev = ['k', 'm', 'b', 't']
|
|
4
8
|
|
|
@@ -11,7 +15,7 @@ const numabbr = (number, decimals = 2) => {
|
|
|
11
15
|
// Handle special case where we round up to the next abbreviation
|
|
12
16
|
if (num === 1000 && i < abbrev.length - 1) {
|
|
13
17
|
num = 1
|
|
14
|
-
i
|
|
18
|
+
return `${num}${abbrev[i + 1]}`
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
return `${num}${abbrev[i]}`
|
package/src/module/observer.js
CHANGED
|
@@ -25,9 +25,9 @@ const observer = (() => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const notify = function (event, ...args) {
|
|
28
|
-
if (!
|
|
28
|
+
if (!this.events[event]) return this
|
|
29
29
|
|
|
30
|
-
for (const { context, callback } of
|
|
30
|
+
for (const { context, callback } of this.events[event]) {
|
|
31
31
|
callback.apply(context, args)
|
|
32
32
|
}
|
|
33
33
|
|
package/src/navigation.js
CHANGED
|
@@ -6,11 +6,15 @@ import attach from './module/attach'
|
|
|
6
6
|
import display from './mixin/display'
|
|
7
7
|
import Element from './element'
|
|
8
8
|
import Button from './button'
|
|
9
|
+
import Item from './item'
|
|
9
10
|
|
|
10
11
|
class Navigation extends EventEmitter {
|
|
11
12
|
static defaults = {
|
|
12
13
|
class: 'navigation',
|
|
13
14
|
tag: 'nav',
|
|
15
|
+
layout: [
|
|
16
|
+
[Element, 'body', { class: 'body' }]
|
|
17
|
+
],
|
|
14
18
|
events: [
|
|
15
19
|
['element.click', 'toggle']
|
|
16
20
|
]
|
|
@@ -28,6 +32,7 @@ class Navigation extends EventEmitter {
|
|
|
28
32
|
init (options) {
|
|
29
33
|
this.options = { ...Navigation.defaults, ...options }
|
|
30
34
|
Object.assign(this, build, attach, display)
|
|
35
|
+
this.items = []
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
setup () {
|
|
@@ -38,6 +43,7 @@ class Navigation extends EventEmitter {
|
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
render (items) {
|
|
46
|
+
console.log('render', items)
|
|
41
47
|
if (items && Array.isArray(items)) {
|
|
42
48
|
for (let i = 0; i < items.length; i++) {
|
|
43
49
|
this.add(items[i])
|
|
@@ -48,17 +54,18 @@ class Navigation extends EventEmitter {
|
|
|
48
54
|
add (obj) {
|
|
49
55
|
if (typeof obj !== 'object') return this
|
|
50
56
|
let item
|
|
51
|
-
if (obj.type === '
|
|
52
|
-
item = new Element({ tag: '
|
|
57
|
+
if (obj.type === 'header') {
|
|
58
|
+
item = new Element({ tag: 'span', class: 'header' })
|
|
53
59
|
} else if (obj.type === 'divider') {
|
|
54
|
-
item = new Element({ tag: '
|
|
60
|
+
item = new Element({ tag: 'span', class: 'divider' })
|
|
55
61
|
} else {
|
|
56
|
-
obj.container = this.ui.
|
|
62
|
+
obj.container = this.ui.body
|
|
57
63
|
obj.class = 'item'
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
obj.stopPropagation = true
|
|
65
|
+
obj.class = 'item'
|
|
66
|
+
item = new Item(obj)
|
|
67
|
+
console.log('item', item, this.items)
|
|
68
|
+
this.items.push(item)
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
return this
|
package/src/snackbar.js
CHANGED
|
@@ -17,8 +17,7 @@ class Snackbar extends EventEmitter {
|
|
|
17
17
|
close: false,
|
|
18
18
|
layout: [
|
|
19
19
|
[Text, 'message', { tag: 'span', class: 'message' }],
|
|
20
|
-
[Button, 'action', { class: 'action', type: 'link' }]
|
|
21
|
-
[Button, 'close', { class: 'close', type: 'action' }]
|
|
20
|
+
[Button, 'action', { class: 'action', type: 'link' }]
|
|
22
21
|
],
|
|
23
22
|
events: [
|
|
24
23
|
['ui.action.click', 'action'],
|
|
@@ -72,11 +71,11 @@ class Snackbar extends EventEmitter {
|
|
|
72
71
|
if (this.options.action) {
|
|
73
72
|
this.ui.action.set(this.options.action)
|
|
74
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')
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
if (this.options.close) this.ui.close.element.classList.add('show')
|
|
78
|
-
|
|
79
|
-
return this
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
action () {
|
|
@@ -1,46 +1,27 @@
|
|
|
1
1
|
.navigation.type-rail
|
|
2
2
|
flex: none
|
|
3
|
+
color: rgba(255, 255, 255, .87)
|
|
3
4
|
display: flex
|
|
5
|
+
overflow: hidden
|
|
4
6
|
flex-direction: column
|
|
5
7
|
width: 12px
|
|
6
|
-
background-color: #2D2F31
|
|
7
8
|
padding-top: 56px
|
|
9
|
+
background-color: #2D2F31
|
|
8
10
|
margin: 0
|
|
9
|
-
overflow: hidden
|
|
10
11
|
transition: .1s linear width
|
|
11
|
-
|
|
12
12
|
&.show
|
|
13
13
|
width: 92px
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
display: flex
|
|
18
|
-
&.first
|
|
19
|
-
transition: none
|
|
20
|
-
|
|
21
|
-
.head
|
|
22
|
-
flex: none
|
|
23
|
-
display: none
|
|
24
|
-
flex-direction: column
|
|
25
|
-
width: 92px
|
|
26
|
-
height: 56px
|
|
27
|
-
padding: 0 0
|
|
28
|
-
margin: 0
|
|
29
|
-
.button.apps
|
|
30
|
-
height: 56px
|
|
31
|
-
width: 56px
|
|
32
|
-
padding: 16px 10px
|
|
33
|
-
margin: 0 auto
|
|
34
|
-
align-items: center
|
|
35
|
-
justify-content: center
|
|
36
|
-
transition: .3s linear opacity
|
|
14
|
+
.body
|
|
15
|
+
opacity: 1
|
|
16
|
+
transition: .1s opacity linear
|
|
37
17
|
.body
|
|
38
|
-
|
|
18
|
+
opacity: 0
|
|
39
19
|
flex: 1
|
|
40
20
|
flex-direction: column
|
|
41
21
|
width: 92px
|
|
42
22
|
padding: 0 0
|
|
43
23
|
margin: 0
|
|
24
|
+
transition: .1s opacity linear
|
|
44
25
|
.item
|
|
45
26
|
flex: none
|
|
46
27
|
display: flex
|
|
@@ -50,11 +31,9 @@
|
|
|
50
31
|
border-radius: 0
|
|
51
32
|
text-align: center
|
|
52
33
|
padding: 10px 0 6px
|
|
53
|
-
// border-radius: 4px
|
|
54
34
|
font-size: 0.8rem
|
|
55
35
|
text-transform: none
|
|
56
36
|
text-align: center
|
|
57
|
-
// background-color: rgba(0, 0, 0, 0.3)
|
|
58
37
|
align-items: center
|
|
59
38
|
justify-content: center
|
|
60
39
|
&.selected, &.selected:hover
|
|
@@ -63,7 +42,7 @@
|
|
|
63
42
|
background-color: #004A77
|
|
64
43
|
svg
|
|
65
44
|
fill: #C2E8FF
|
|
66
|
-
|
|
45
|
+
.icon
|
|
67
46
|
width: 60px
|
|
68
47
|
pointer-events: none
|
|
69
48
|
padding: 0
|
|
@@ -75,7 +54,7 @@
|
|
|
75
54
|
justify-content: center
|
|
76
55
|
svg
|
|
77
56
|
fill: rgba(255,255,255,.7)
|
|
78
|
-
|
|
57
|
+
.label
|
|
79
58
|
pointer-events: none
|
|
80
59
|
align-items: center
|
|
81
60
|
justify-content: center
|
|
@@ -89,5 +68,5 @@
|
|
|
89
68
|
margin: 0
|
|
90
69
|
&:hover
|
|
91
70
|
background-color: transaprent
|
|
92
|
-
|
|
93
|
-
background-color: rgba(255,255,255,.05)
|
|
71
|
+
.icon
|
|
72
|
+
background-color: rgba(255,255,255,.05)
|
package/src/switch.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
// base
|
|
1
2
|
import EventEmitter from './mixin/emitter'
|
|
2
|
-
|
|
3
3
|
// module
|
|
4
4
|
import build from './module/build'
|
|
5
5
|
import dataset from './module/dataset'
|
|
6
6
|
import attach from './module/attach'
|
|
7
7
|
import attributes from './module/attributes'
|
|
8
|
-
|
|
9
8
|
// ui
|
|
10
|
-
import Layout from './layout'
|
|
11
9
|
import Element from './element'
|
|
12
10
|
|
|
13
11
|
class Switch extends EventEmitter {
|
|
@@ -33,6 +31,7 @@ class Switch extends EventEmitter {
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
constructor (options) {
|
|
34
|
+
// console.log('switch')
|
|
36
35
|
super()
|
|
37
36
|
|
|
38
37
|
this.init(options)
|
|
@@ -51,9 +50,6 @@ class Switch extends EventEmitter {
|
|
|
51
50
|
setup () {
|
|
52
51
|
this.styleAttributes()
|
|
53
52
|
|
|
54
|
-
this.buildIcon()
|
|
55
|
-
this.buildLabel()
|
|
56
|
-
|
|
57
53
|
if (this.options.data) {
|
|
58
54
|
dataset(this.element, this.options.data)
|
|
59
55
|
}
|
|
@@ -80,31 +76,6 @@ class Switch extends EventEmitter {
|
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
buildLabel () {
|
|
84
|
-
// console.log('buildLabel', this.options.label)
|
|
85
|
-
if (!this.options.label) return
|
|
86
|
-
|
|
87
|
-
this.ui.label = document.createElement('label')
|
|
88
|
-
this.ui.label.classList.add('label')
|
|
89
|
-
this.ui.label.innerHTML = this.options.label
|
|
90
|
-
|
|
91
|
-
if (this.options.name) {
|
|
92
|
-
this.ui.label.setAttribute('for', this.options.name)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
this.element.insertBefore(this.ui.label, this.ui.input)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
buildIcon () {
|
|
99
|
-
if (!this.options.icon) return
|
|
100
|
-
|
|
101
|
-
this.ui.icon = document.createElement('i')
|
|
102
|
-
this.ui.icon.classList.add('icon')
|
|
103
|
-
this.ui.icon.innerHTML = this.options.icon
|
|
104
|
-
|
|
105
|
-
this.element.insertBefore(this.ui.icon, this.ui.input)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
79
|
styleAttributes () {
|
|
109
80
|
if (this.options.style) {
|
|
110
81
|
this.element.classList.add('style-' + this.options.style)
|
|
@@ -123,12 +94,6 @@ class Switch extends EventEmitter {
|
|
|
123
94
|
}
|
|
124
95
|
}
|
|
125
96
|
|
|
126
|
-
/**
|
|
127
|
-
* Setter
|
|
128
|
-
* @param {string} prop
|
|
129
|
-
* @param {string} value
|
|
130
|
-
* @return {Object} The class instance
|
|
131
|
-
*/
|
|
132
97
|
set (prop, value, silent) {
|
|
133
98
|
switch (prop) {
|
|
134
99
|
case 'value':
|