@operato/scene-gauge 0.0.16

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.
Files changed (86) hide show
  1. package/@types/global/index.d.ts +1 -0
  2. package/CHANGELOG.md +16 -0
  3. package/LICENSE +21 -0
  4. package/README.md +15 -0
  5. package/assets/gauge-circle.png +0 -0
  6. package/assets/gauge-horizontal.png +0 -0
  7. package/assets/gauge-vertical.png +0 -0
  8. package/dist/gauge-circle.d.ts +57 -0
  9. package/dist/gauge-circle.js +211 -0
  10. package/dist/gauge-circle.js.map +1 -0
  11. package/dist/gauge-horizon.d.ts +56 -0
  12. package/dist/gauge-horizon.js +145 -0
  13. package/dist/gauge-horizon.js.map +1 -0
  14. package/dist/gauge-properties.d.ts +39 -0
  15. package/dist/gauge-properties.js +114 -0
  16. package/dist/gauge-properties.js.map +1 -0
  17. package/dist/gauge-vertical.d.ts +56 -0
  18. package/dist/gauge-vertical.js +143 -0
  19. package/dist/gauge-vertical.js.map +1 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +7 -0
  22. package/dist/index.js.map +1 -0
  23. package/helps/scene/component/gauge-circle.ko.md +168 -0
  24. package/helps/scene/component/gauge-circle.md +167 -0
  25. package/helps/scene/component/gauge-circle.zh.md +164 -0
  26. package/helps/scene/component/gauge-horizon.ko.md +145 -0
  27. package/helps/scene/component/gauge-horizon.md +145 -0
  28. package/helps/scene/component/gauge-horizon.zh.md +145 -0
  29. package/helps/scene/component/gauge-vertical.ko.md +12 -0
  30. package/helps/scene/component/gauge-vertical.md +9 -0
  31. package/helps/scene/component/gauge-vertical.zh.md +10 -0
  32. package/helps/scene/images/gauge-circle-01.png +0 -0
  33. package/helps/scene/images/gauge-circle-02.png +0 -0
  34. package/helps/scene/images/gauge-circle-03.png +0 -0
  35. package/helps/scene/images/gauge-circle-04.png +0 -0
  36. package/helps/scene/images/gauge-circle-05.png +0 -0
  37. package/helps/scene/images/gauge-circle-06.png +0 -0
  38. package/helps/scene/images/gauge-circle-07.png +0 -0
  39. package/helps/scene/images/gauge-circle-08.png +0 -0
  40. package/helps/scene/images/gauge-circle-09.png +0 -0
  41. package/helps/scene/images/gauge-circle-10.png +0 -0
  42. package/helps/scene/images/gauge-circle-11.png +0 -0
  43. package/helps/scene/images/gauge-circle-12.png +0 -0
  44. package/helps/scene/images/gauge-circle-13.png +0 -0
  45. package/helps/scene/images/gauge-circle-14.png +0 -0
  46. package/helps/scene/images/gauge-circle-15.png +0 -0
  47. package/helps/scene/images/gauge-circle-16.png +0 -0
  48. package/helps/scene/images/gauge-circle-17.png +0 -0
  49. package/helps/scene/images/gauge-circle-18.png +0 -0
  50. package/helps/scene/images/gauge-circle-19.png +0 -0
  51. package/helps/scene/images/gauge-circle-20.png +0 -0
  52. package/helps/scene/images/gauge-circle-21.png +0 -0
  53. package/helps/scene/images/gauge-horizontal-01.png +0 -0
  54. package/helps/scene/images/gauge-vertical-01.png +0 -0
  55. package/helps/scene/images/gauge-vertical-02.png +0 -0
  56. package/helps/scene/images/gauge-vertical-03.png +0 -0
  57. package/helps/scene/images/gauge-vertical-04.png +0 -0
  58. package/helps/scene/images/gauge-vertical-05.png +0 -0
  59. package/helps/scene/images/gauge-vertical-06.png +0 -0
  60. package/helps/scene/images/gauge-vertical-07.png +0 -0
  61. package/helps/scene/images/gauge-vertical-08.png +0 -0
  62. package/helps/scene/images/gauge-vertical-09.png +0 -0
  63. package/helps/scene/images/gauge-vertical-10.png +0 -0
  64. package/helps/scene/images/gauge-vertical-11.png +0 -0
  65. package/helps/scene/images/gauge-vertical-12.png +0 -0
  66. package/helps/scene/images/gauge-vertical-13.png +0 -0
  67. package/helps/scene/images/gauge-vertical-14.png +0 -0
  68. package/helps/scene/images/gauge-vertical-15.png +0 -0
  69. package/helps/scene/images/gauge-vertical-16.png +0 -0
  70. package/helps/scene/images/gauge-vertical-17.png +0 -0
  71. package/helps/scene/images/gauge-vertical-18.png +0 -0
  72. package/package.json +61 -0
  73. package/src/gauge-circle.ts +310 -0
  74. package/src/gauge-horizon.ts +204 -0
  75. package/src/gauge-properties.ts +114 -0
  76. package/src/gauge-vertical.ts +203 -0
  77. package/src/index.ts +6 -0
  78. package/test/basic-test.html +67 -0
  79. package/test/index.html +22 -0
  80. package/things-scene.config.js +158 -0
  81. package/translations/en.json +3 -0
  82. package/translations/ko.json +3 -0
  83. package/translations/ms.json +3 -0
  84. package/translations/zh.json +3 -0
  85. package/tsconfig.json +22 -0
  86. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,204 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import {
6
+ Component,
7
+ RectPath,
8
+ Shape,
9
+ ValueHolder,
10
+ } from '@hatiolab/things-scene';
11
+
12
+ import { PROPERTIES } from './gauge-properties';
13
+
14
+ const NATURE = {
15
+ mutable: false,
16
+ resizable: true,
17
+ rotatable: true,
18
+ properties: [
19
+ ...PROPERTIES,
20
+ {
21
+ type: 'color',
22
+ label: 'text-fill-style',
23
+ name: 'textFillStyle',
24
+ property: 'textFillStyle'
25
+ },
26
+ {
27
+ type: 'color',
28
+ label: 'needle-fill-style',
29
+ name: 'needleFillStyle',
30
+ property: 'needleFillStyle'
31
+ },
32
+ {
33
+ type: 'number',
34
+ label: 'needle-size',
35
+ name: 'needleSize',
36
+ property: 'needleSize'
37
+ }
38
+ ],
39
+ help: 'scene/component/gauge-horizon'
40
+ }
41
+
42
+ export default class GaugeHorizon extends ValueHolder(RectPath(Shape)) {
43
+ _draw(context: CanvasRenderingContext2D) {
44
+ var {
45
+ startValue,
46
+ endValue,
47
+ step,
48
+ subStep,
49
+ colorStops,
50
+ needleFillStyle,
51
+ stepFillStyle,
52
+ textFillStyle,
53
+ needleSize,
54
+ stepNeedleSize,
55
+ stepTextSize,
56
+ showStepText = true,
57
+ showStartValue = true,
58
+ showEndValue = true,
59
+ showStepLine = true,
60
+ showSubStep = true,
61
+ width,
62
+ height,
63
+ top,
64
+ left,
65
+ animFromBase = false
66
+ } = this.model
67
+
68
+ startValue = Number(startValue)
69
+
70
+ this.animOnValueChange(this.value, animFromBase, startValue)
71
+
72
+ const totalValue = endValue - startValue // 게이지의 시작과 끝 값의 크기
73
+
74
+ context.translate(left, top) // top과 left의 좌표에 영향을 받지 않기 위해 transalate를 한다음 모든 탑과 레프트의 좌표를 0으로 줌
75
+
76
+ //// 메인 막대 그리기 ////
77
+ context.beginPath()
78
+
79
+ context.rect(0, 0, width, height)
80
+
81
+ this.drawFill(context)
82
+ this.drawStroke(context)
83
+ context.closePath()
84
+
85
+ //// 스텝별 색 칠하기 ////
86
+ if (colorStops) {
87
+ let beforeValue = 0
88
+ colorStops.forEach(function (v: {position: number; color: string;}, idx: number, arr: {position: number; color: string;}[]) {
89
+ context.beginPath()
90
+
91
+ let value = Math.max(Math.min(v.position - startValue, totalValue), 0) // v.position 범위의 최소값은 0, 최대값은 totalValue가 되야함.
92
+ let startStepPosition = (width * beforeValue) / totalValue
93
+ let endStepPosition
94
+ // console.log(startStepPosition + (width * value / totalValue));
95
+ if (idx == arr.length - 1 || startStepPosition + (width * value) / totalValue)
96
+ // 배열의 마지막 값이거나 중간 시작값 + 그려지는 값이 width 를 넘을 경우는 무조건 끝까지 채워주도록 한다
97
+ endStepPosition = width - startStepPosition
98
+ else endStepPosition = (width * value) / totalValue
99
+
100
+ if (beforeValue > totalValue || beforeValue > value)
101
+ // 값이 게이지의 최대 값을 넘어가거나 이전 값 보다 현재값이 작으면 다시 그릴 필요 없음
102
+ return false
103
+
104
+ context.rect(startStepPosition, 0, endStepPosition, height)
105
+
106
+ context.fillStyle = v.color
107
+ context.fill()
108
+
109
+ beforeValue = value
110
+ })
111
+ }
112
+
113
+ //// 스텝 선 그리기 ////
114
+ context.fillStyle = stepFillStyle
115
+ if (showStepLine) {
116
+ let count = totalValue / step
117
+ let stepSize = width * 0.06
118
+
119
+ // Draw StartValue
120
+ context.fillRect(0, height - stepSize, stepNeedleSize, stepSize)
121
+ // Draw StepValue
122
+ for (let num = 1; num < count; num++) {
123
+ let locate = (width / count) * num
124
+
125
+ context.fillRect(locate, height - stepSize, stepNeedleSize, stepSize)
126
+ }
127
+ // Draw EndValue
128
+ context.fillRect(width, height - stepSize, stepNeedleSize, stepSize)
129
+ }
130
+
131
+ //// 서브 스탭 그리기 ////
132
+ if (showSubStep) {
133
+ let count = totalValue
134
+ let subStepSize = width * 0.027
135
+ // Draw StartValue
136
+ context.fillRect(0, height - subStepSize, stepNeedleSize, subStepSize)
137
+
138
+ // Draw StepValue
139
+ for (let num = 1; num <= count; num++) {
140
+ if (num % step == 0 || num % subStep != 0) {
141
+ // 메인 스탭과 서브 스탭은 그리지 않음
142
+ continue
143
+ }
144
+ let locate = (width / count) * num
145
+ context.fillRect(locate, height - subStepSize, stepNeedleSize, subStepSize)
146
+ }
147
+ }
148
+
149
+ //// 스텝 텍스트 그리기 ////
150
+ let fontSize = (width * stepTextSize) / 150
151
+ context.fillStyle = textFillStyle
152
+ context.font = fontSize + 'px arial'
153
+ context.textBaseline = 'middle'
154
+ context.textAlign = 'center'
155
+ if (showStartValue) {
156
+ // Draw StartText
157
+ context.fillText(startValue, 0, height + fontSize * 0.75)
158
+ }
159
+
160
+ if (showEndValue) {
161
+ // Draw EndText
162
+ context.fillText(endValue, width, height + fontSize * 0.75)
163
+ }
164
+
165
+ if (showStepText) {
166
+ // Draw StepText
167
+ let count = totalValue / step
168
+
169
+ for (let num = 1; num < count; num++) {
170
+ let value = startValue + step * num
171
+ let locate = (width / count) * num
172
+
173
+ context.fillText(value, locate, height + fontSize * 0.75)
174
+ }
175
+ }
176
+
177
+ //// 바늘 그리기 ////
178
+ context.beginPath()
179
+ let drawingValue = this.animValue
180
+ drawingValue = Math.max(Math.min(drawingValue, endValue), startValue) // 그려지는 값은 startValue보다 작을 수 없고, endValue보다 클 수 없음.
181
+ let position = ((drawingValue - startValue) / totalValue) * width
182
+
183
+ needleSize *= 4
184
+ context.moveTo(position, height + fontSize * 1.4)
185
+ context.lineTo(position + needleSize / 2, height + needleSize + fontSize * 1.4)
186
+ context.lineTo(position - needleSize / 2, height + needleSize + fontSize * 1.4)
187
+
188
+ context.fillStyle = needleFillStyle
189
+ context.fill()
190
+ context.closePath()
191
+
192
+ context.translate(-left, -top)
193
+ }
194
+
195
+ _post_draw(context: CanvasRenderingContext2D) {
196
+ this.drawText(context)
197
+ }
198
+
199
+ get nature() {
200
+ return NATURE
201
+ }
202
+ }
203
+
204
+ Component.register('gauge-horizon', GaugeHorizon)
@@ -0,0 +1,114 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ export const PROPERTIES = [
6
+ {
7
+ type: 'string',
8
+ label: 'value',
9
+ name: 'value',
10
+ property: 'value'
11
+ },
12
+ {
13
+ type: 'number',
14
+ label: 'start-value',
15
+ name: 'startValue',
16
+ observe: function (this: HTMLElement, startValue: number) {
17
+ const colorStops: any = this.parentNode!.querySelector('[name=colorStops]')
18
+ colorStops.property.min = startValue
19
+ },
20
+ property: 'startValue'
21
+ },
22
+ {
23
+ type: 'number',
24
+ label: 'end-value',
25
+ name: 'endValue',
26
+ observe: function (this: HTMLElement, endValue: number) {
27
+ const colorStops: any = this.parentNode!.querySelector('[name=colorStops]')
28
+ colorStops.property.max = endValue
29
+ },
30
+ property: 'endValue'
31
+ },
32
+ {
33
+ type: 'number',
34
+ label: 'step',
35
+ name: 'step',
36
+ property: 'step'
37
+ },
38
+ {
39
+ type: 'number',
40
+ label: 'step-text-size',
41
+ name: 'stepTextSize',
42
+ property: 'stepTextSize'
43
+ },
44
+ {
45
+ type: 'number',
46
+ label: 'sub-step',
47
+ name: 'subStep',
48
+ property: 'subStep'
49
+ },
50
+ {
51
+ type: 'number',
52
+ label: 'step-needle-size',
53
+ name: 'stepNeedleSize',
54
+ property: 'stepNeedleSize'
55
+ },
56
+ {
57
+ type: 'color',
58
+ label: 'step-fill-style',
59
+ name: 'stepFillStyle',
60
+ property: 'stepFillStyle'
61
+ },
62
+ {
63
+ type: 'solid-color-stops',
64
+ label: 'color-stops',
65
+ name: 'colorStops',
66
+ property: {
67
+ min: 0,
68
+ max: 100
69
+ }
70
+ },
71
+ {
72
+ type: 'legend',
73
+ label: '',
74
+ name: 'toggleOption',
75
+ property: {
76
+ label: 'Toggle Option'
77
+ }
78
+ },
79
+ {
80
+ type: 'checkbox',
81
+ label: 'show-start-value',
82
+ name: 'showStartValue',
83
+ property: 'showStartValue'
84
+ },
85
+ {
86
+ type: 'checkbox',
87
+ label: 'show-end-value',
88
+ name: 'showEndValue',
89
+ property: 'showEndValue'
90
+ },
91
+ {
92
+ type: 'checkbox',
93
+ label: 'show-step-line',
94
+ name: 'showStepLine',
95
+ property: 'showStepLine'
96
+ },
97
+ {
98
+ type: 'checkbox',
99
+ label: 'show-step-text',
100
+ name: 'showStepText',
101
+ property: 'showStepText'
102
+ },
103
+ {
104
+ type: 'checkbox',
105
+ label: 'show-sub-step',
106
+ name: 'showSubStep',
107
+ property: 'showSubStep'
108
+ },
109
+ {
110
+ type: 'checkbox',
111
+ label: 'anim-from-base',
112
+ name: 'animFromBase'
113
+ }
114
+ ]
@@ -0,0 +1,203 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import {
6
+ Component,
7
+ RectPath,
8
+ Shape,
9
+ ValueHolder,
10
+ } from '@hatiolab/things-scene';
11
+
12
+ import { PROPERTIES } from './gauge-properties';
13
+
14
+ const NATURE = {
15
+ mutable: false,
16
+ resizable: true,
17
+ rotatable: true,
18
+ properties: [
19
+ ...PROPERTIES,
20
+ {
21
+ type: 'color',
22
+ label: 'text-fill-style',
23
+ name: 'textFillStyle',
24
+ property: 'textFillStyle'
25
+ },
26
+ {
27
+ type: 'color',
28
+ label: 'needle-fill-style',
29
+ name: 'needleFillStyle',
30
+ property: 'needleFillStyle'
31
+ },
32
+ {
33
+ type: 'number',
34
+ label: 'needle-size',
35
+ name: 'needleSize',
36
+ property: 'needleSize'
37
+ }
38
+ ],
39
+ help: 'scene/component/gauge-vertical'
40
+ }
41
+
42
+ export default class GaugeVertical extends ValueHolder(RectPath(Shape)) {
43
+ _draw(context: CanvasRenderingContext2D) {
44
+ var {
45
+ startValue,
46
+ endValue,
47
+ step,
48
+ subStep,
49
+ colorStops,
50
+ needleFillStyle,
51
+ stepFillStyle,
52
+ textFillStyle,
53
+ needleSize,
54
+ stepNeedleSize,
55
+ stepTextSize,
56
+ showStepText = true,
57
+ showStartValue = true,
58
+ showEndValue = true,
59
+ showStepLine = true,
60
+ showSubStep = true,
61
+ width,
62
+ height,
63
+ top,
64
+ left,
65
+ animFromBase = false
66
+ } = this.model
67
+
68
+ startValue = Number(startValue)
69
+
70
+ this.animOnValueChange(this.value, animFromBase, startValue)
71
+
72
+ const totalValue = endValue - startValue // 게이지의 시작과 끝 값의 크기
73
+
74
+ context.translate(left, top) // top과 left의 좌표에 영향을 받지 않기 위해 transalate를 한다음 모든 탑과 레프트의 좌표를 0으로 줌
75
+
76
+ //// 메인 막대 그리기 ////
77
+ context.beginPath()
78
+
79
+ context.rect(0, 0, width, height)
80
+
81
+ this.drawFill(context)
82
+ this.drawStroke(context)
83
+ context.closePath()
84
+
85
+ //// 스텝별 색 칠하기 ////
86
+ if (colorStops) {
87
+ let beforeValue = 0
88
+ colorStops.forEach(function (v: {position: number; color: string;}, idx: number, arr: {position: number; color: string;}[]) {
89
+ context.beginPath()
90
+
91
+ let value = Math.max(Math.min(v.position - startValue, totalValue), 0) // v.position 범위의 최소값은 0, 최대값은 totalValue가 되야함.
92
+ let startStepPosition = (height * beforeValue) / totalValue
93
+ let endStepPosition
94
+
95
+ // console.log(startStepPosition + (height * value / totalValue));
96
+ if (idx === arr.length - 1 || startStepPosition + (height * value) / totalValue)
97
+ // 배열의 마지막 값이거나 중간 시작값 + 그려지는 값이 height 를 넘을 경우는 무조건 끝까지 채워주도록 한다
98
+ endStepPosition = height - startStepPosition
99
+ else endStepPosition = height - (height * value) / totalValue
100
+
101
+ if (beforeValue > totalValue || beforeValue > value)
102
+ // 값이 게이지의 최대 값을 넘어가거나 이전 값 보다 현재값이 작으면 다시 그릴 필요 없음
103
+ return false
104
+
105
+ context.rect(0, height - startStepPosition, width, -endStepPosition)
106
+
107
+ context.fillStyle = v.color
108
+ context.fill()
109
+ beforeValue = value
110
+ })
111
+ }
112
+
113
+ //// 바늘 그리기 ////
114
+ context.beginPath()
115
+ let drawingValue = this.animValue
116
+ drawingValue = Math.max(Math.min(drawingValue, endValue), startValue) // 그려지는 값은 startValue보다 작을 수 없고, endValue보다 클 수 없음.
117
+ let position = height - ((drawingValue - startValue) / totalValue) * height
118
+
119
+ needleSize *= 4
120
+ context.moveTo(width * 1.05, position)
121
+ context.lineTo(width * 1.05 + needleSize, position + needleSize / 2)
122
+ context.lineTo(width * 1.05 + needleSize, position - needleSize / 2)
123
+
124
+ context.fillStyle = needleFillStyle
125
+ context.fill()
126
+ context.closePath()
127
+
128
+ //// 스텝 선 그리기 ////
129
+ context.fillStyle = stepFillStyle
130
+ if (showStepLine) {
131
+ let count = totalValue / step
132
+
133
+ // Draw StartValue
134
+ context.fillRect(0, height, height * 0.06, stepNeedleSize)
135
+ // Draw StepValue
136
+ for (let num = 1; num < count; num++) {
137
+ let locate = (height / count) * num
138
+
139
+ context.fillRect(0, locate, height * 0.06, stepNeedleSize)
140
+ }
141
+ // Draw EndValue
142
+ context.fillRect(0, 0, height * 0.06, stepNeedleSize)
143
+ }
144
+
145
+ //// 서브 스탭 그리기 ////
146
+ if (showSubStep) {
147
+ let count = totalValue
148
+
149
+ // Draw StartValue
150
+ context.fillRect(0, 0, height * 0.027, stepNeedleSize)
151
+
152
+ // Draw StepValue
153
+ for (let num = 1; num <= count; num++) {
154
+ if (num % step == 0 || num % subStep != 0) {
155
+ // 메인 스탭과 서브 스탭은 그리지 않음
156
+ continue
157
+ }
158
+ let locate = (height / count) * num
159
+ context.fillRect(0, locate, height * 0.027, stepNeedleSize)
160
+ }
161
+ }
162
+
163
+ //// 스텝 텍스트 그리기 ////
164
+ let fontSize = (height * stepTextSize) / 150
165
+ context.fillStyle = textFillStyle
166
+ context.font = fontSize + 'px arial'
167
+ context.textBaseline = 'middle'
168
+ context.textAlign = 'center'
169
+ if (showStartValue) {
170
+ // Draw StartText
171
+ context.fillText(startValue, -fontSize, height)
172
+ }
173
+
174
+ if (showEndValue) {
175
+ // Draw EndText
176
+ context.fillText(endValue, -fontSize, 0)
177
+ }
178
+
179
+ if (showStepText) {
180
+ // Draw StepText
181
+ let count = totalValue / step
182
+
183
+ for (let num = 1; num < count; num++) {
184
+ let value = startValue + Number(step) * num
185
+ let locate = height - (height / count) * num
186
+
187
+ context.fillText(value, -fontSize, locate)
188
+ }
189
+ }
190
+
191
+ context.translate(-left, -top)
192
+ }
193
+
194
+ _post_draw(context: CanvasRenderingContext2D) {
195
+ this.drawText(context)
196
+ }
197
+
198
+ get nature() {
199
+ return NATURE
200
+ }
201
+ }
202
+
203
+ Component.register('gauge-vertical', GaugeVertical)
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export { default as GaugeCircle } from './gauge-circle'
5
+ export { default as GaugeVertical } from './gauge-vertical'
6
+ export { default as GaugeHorizon } from './gauge-horizon'
@@ -0,0 +1,67 @@
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright © HatioLab Inc. All rights reserved.
5
+ -->
6
+ <html>
7
+ <head>
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
10
+
11
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
12
+ <script src="../../web-component-tester/browser.js"></script>
13
+
14
+ <!-- Step 1: import the element to test -->
15
+ <link rel="import" href="../things-scene-gauge.html">
16
+ </head>
17
+ <body>
18
+
19
+ <!-- You can use the document as a place to set up your fixtures. -->
20
+ <test-fixture id="things-scene-gauge-fixture">
21
+ <template>
22
+ <things-scene-gauge>
23
+ <h2>things-scene-gauge</h2>
24
+ </things-scene-gauge>
25
+ </template>
26
+ </test-fixture>
27
+
28
+ <script>
29
+ suite('<things-scene-gauge>', function() {
30
+
31
+ var myEl;
32
+
33
+ setup(function() {
34
+ myEl = fixture('things-scene-gauge-fixture');
35
+ });
36
+
37
+ test('defines the "author" property', function() {
38
+ assert.equal(myEl.author.name, 'Dimitri Glazkov');
39
+ assert.equal(myEl.author.image, 'http://addyosmani.com/blog/wp-content/uploads/2013/04/unicorn.jpg');
40
+ });
41
+
42
+ test('says hello', function() {
43
+ assert.equal(myEl.sayHello(), 'things-scene-gauge says, Hello World!');
44
+
45
+ var greetings = myEl.sayHello('greetings Earthlings');
46
+ assert.equal(greetings, 'things-scene-gauge says, greetings Earthlings');
47
+ });
48
+
49
+ test('fires lasers', function(done) {
50
+ myEl.addEventListener('things-scene-gauge-lasers', function(event) {
51
+ assert.equal(event.detail.sound, 'Pew pew!');
52
+ done();
53
+ });
54
+ myEl.fireLasers();
55
+ });
56
+
57
+ test('distributed children', function() {
58
+ var els = myEl.getContentChildren();
59
+ assert.equal(els.length, 1, 'one distributed node');
60
+ assert.equal(els[0], myEl.querySelector('h2'), 'content distributed correctly');
61
+ });
62
+
63
+ });
64
+ </script>
65
+
66
+ </body>
67
+ </html>
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright © HatioLab Inc. All rights reserved.
5
+ -->
6
+ <html><head>
7
+ <meta charset="utf-8">
8
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
9
+
10
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
11
+ <script src="../../web-component-tester/browser.js"></script>
12
+ </head>
13
+ <body>
14
+ <script>
15
+ // Load and run all tests (.html, .js):
16
+ WCT.loadSuites([
17
+ 'basic-test.html',
18
+ 'basic-test.html?dom=shadow'
19
+ ]);
20
+ </script>
21
+
22
+ </body></html>