beyond-rails 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/src/js/components/BarChart.js +19 -7
  3. data/src/js/components/LineChart.js +18 -8
  4. data/src/js/components/PieChart.js +16 -6
  5. data/src/js/components/SearchDropdown.js +8 -5
  6. data/src/js/consts/index.js +42 -0
  7. data/src/js/decorators/chartCommon.js +4 -1
  8. data/src/js/index.js +0 -1
  9. data/src/sass/_base.scss +170 -0
  10. data/src/sass/_beyond-dark.scss +3 -0
  11. data/src/sass/_beyond.scss +0 -54
  12. data/src/sass/_main.scss +56 -176
  13. data/src/sass/abstracts/_mixins.scss +2 -4
  14. data/src/sass/abstracts/_placeholders.scss +3 -3
  15. data/src/sass/abstracts/_post-variables.scss +85 -0
  16. data/src/sass/abstracts/_variables.scss +301 -188
  17. data/src/sass/base/_background.scss +2 -3
  18. data/src/sass/base/_typography.scss +17 -17
  19. data/src/sass/components/_alert.scss +8 -14
  20. data/src/sass/components/_autocomplete.scss +4 -5
  21. data/src/sass/components/_badge.scss +2 -4
  22. data/src/sass/components/_breadcrumb.scss +3 -2
  23. data/src/sass/components/_btn-group.scss +1 -1
  24. data/src/sass/components/_btn.scss +34 -19
  25. data/src/sass/components/_card.scss +12 -6
  26. data/src/sass/components/_chart.scss +5 -5
  27. data/src/sass/components/_checkbox.scss +8 -8
  28. data/src/sass/components/_date-menu.scss +10 -10
  29. data/src/sass/components/_date-time-ranger.scss +9 -3
  30. data/src/sass/components/_dropdown.scss +11 -14
  31. data/src/sass/components/_form.scss +17 -18
  32. data/src/sass/components/_input.scss +4 -4
  33. data/src/sass/components/_modal.scss +5 -6
  34. data/src/sass/components/_month-menu.scss +11 -11
  35. data/src/sass/components/_nav.scss +5 -5
  36. data/src/sass/components/_navbar.scss +26 -33
  37. data/src/sass/components/_pagination.scss +9 -8
  38. data/src/sass/components/_radio.scss +2 -4
  39. data/src/sass/components/_search-dropdown.scss +3 -2
  40. data/src/sass/components/_select.scss +15 -23
  41. data/src/sass/components/_sidebar.scss +1 -1
  42. data/src/sass/components/_spinner.scss +0 -1
  43. data/src/sass/components/_switch.scss +5 -5
  44. data/src/sass/components/_tabbox.scss +19 -32
  45. data/src/sass/components/_table.scss +13 -14
  46. data/src/sass/components/_tag-input.scss +2 -4
  47. data/src/sass/components/_tag.scss +4 -4
  48. data/src/sass/components/_time-menu.scss +4 -4
  49. data/src/sass/components/_toast.scss +4 -3
  50. data/src/sass/components/_tooltip.scss +11 -14
  51. data/src/sass/themes/_dark.scss +309 -0
  52. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9c1c444d24ac393edf6187bf49dbab065d1a954240d97d0587853a6b7096436
4
- data.tar.gz: 7f815486ea5910defbf2803223f8d619c510a96de7cea741173891ea77207eab
3
+ metadata.gz: c1804f518e40f24b57bb76c5d0739a063d9f91400963e7467cb61dd8cb28af2d
4
+ data.tar.gz: 76c17444b4c4e614e9e637f1da0ac12d07d03a986f542d0de067a4ed9ca7cfe8
5
5
  SHA512:
6
- metadata.gz: 7abca7cb1233ffb736fcb6aa3456209b6fcf0c743ddf27f017d5c2fc12610802ee1b557449a599d778bc127d822c1a0541f102a4d1e19d38130308bf9d0ea574
7
- data.tar.gz: a3273d931fd2311e668c1074c6576d997d6bf8c5c0bb1ee8128f38b6e5d047333c5ca27cd0b33bc3ef03f4df1e941d19d6078366c21537fd132f66be6146f430
6
+ metadata.gz: 6eff3dfc7511bb2c89c86f54817b3175b5710bb1bb9384ac3d7a9473a50a38f41e812d325accafc1d7b12ba9724f4e8438e93d3f77a5400139b252bf226352d5
7
+ data.tar.gz: a7e0eb9127f29f277849e8f8dcb7664540d2033817491b742e51161497e8af1fe59aaf87abd35a5dfbebbd5b088c95f2adc8e2e687880874a6157d406f2b02f7
@@ -4,7 +4,7 @@ import isDef from '../utils/isDef'
4
4
  import isUndef from '../utils/isUndef'
5
5
  import isInt from '../utils/isInt'
6
6
  import { mem, range, sortBy, throttle, uniqBy } from '../utils'
7
- import { DEFAULT_CHART_STYLES } from '../consts'
7
+ import { THEME_DEFAULT, CHART_STYLE } from '../consts'
8
8
 
9
9
  @supportDom
10
10
  @chartCommon
@@ -30,8 +30,7 @@ export default class BarChart {
30
30
  this.yLabelMargin = isDef(options.yLanelMargin) ? options.yLabelMargin : 14
31
31
 
32
32
  this.fontSize = options.fontSize || 12
33
- this.bg = options.bg || '#fff'
34
- this.barStyles = options.barStyles || DEFAULT_CHART_STYLES
33
+ this.setTheme(options)
35
34
 
36
35
  this.yLabelRows = []
37
36
  this.barPosMap = new Map()
@@ -48,6 +47,19 @@ export default class BarChart {
48
47
  this.bindBarVisible()
49
48
  }
50
49
 
50
+ setTheme(opts) {
51
+ const options = Object.assign({}, this.options, opts)
52
+ const theme = options.theme || THEME_DEFAULT
53
+ const style = CHART_STYLE[theme]
54
+ this.theme = theme
55
+ this.bg = options.bg || style.bg
56
+ this.line = options.line || style.line
57
+ this.txt = options.txt || style.txt
58
+ this.glowAlpha = options.glowAlpha || style.glowAlpha
59
+ this.barStyles = options.barStyles || style.variants
60
+ this.setBg()
61
+ }
62
+
51
63
  get contentWidth() {
52
64
  return this.width - (this.xPadding * 2) - this.yLabelMargin -
53
65
  this.yLabelWidth - this.halfXLabelWidth
@@ -140,7 +152,7 @@ export default class BarChart {
140
152
  const xStart = this.xPadding
141
153
  const xEnd = this.width - this.xPadding - this.yLabelWidth - this.yLabelMargin
142
154
 
143
- ctx.strokeStyle = 'rgba(224, 224, 224, .5)'
155
+ ctx.strokeStyle = this.line
144
156
  ctx.lineWidth = 1
145
157
 
146
158
  yLabelRows.forEach(row => {
@@ -164,7 +176,7 @@ export default class BarChart {
164
176
  let x = xAxisStart
165
177
 
166
178
  ctx.textBaseline = 'top'
167
- ctx.fillStyle = '#3c4257'
179
+ ctx.fillStyle = this.txt
168
180
 
169
181
  xLabelRows.forEach((row, i) => {
170
182
  ctx.fillText(row.label, x, y)
@@ -177,7 +189,7 @@ export default class BarChart {
177
189
  const x = this.width - this.xPadding
178
190
  const delta = yLabelHeight * .45
179
191
 
180
- ctx.fillStyle = '#3c4257'
192
+ ctx.fillStyle = this.txt
181
193
  ctx.textAlign = 'right'
182
194
 
183
195
  yLabelRows.forEach(row => {
@@ -210,7 +222,7 @@ export default class BarChart {
210
222
  const glowHeight = ((glowWidth - width) / 2) + height
211
223
  const glowX = x - ((glowWidth - width) / 2)
212
224
  const glowY = y - (glowHeight - height)
213
- ctx.globalAlpha = 0.2
225
+ ctx.globalAlpha = this.glowAlpha
214
226
  ctx.fillStyle = this.barStyles[res.index]
215
227
  ctx.fillRect(glowX, glowY, glowWidth, glowHeight)
216
228
  ctx.restore()
@@ -3,7 +3,7 @@ import chartCommon from '../decorators/chartCommon'
3
3
  import isDef from '../utils/isDef'
4
4
  import isUndef from '../utils/isUndef'
5
5
  import { mem, range, sortBy, throttle, uniqBy } from '../utils'
6
- import { DEFAULT_CHART_STYLES } from '../consts'
6
+ import { THEME_DEFAULT, CHART_STYLE } from '../consts'
7
7
 
8
8
  /**
9
9
  * -------------------------------------------------------------------------------------------------
@@ -52,10 +52,8 @@ export default class LineChart {
52
52
  this.xLabelMargin = isDef(options.xLabelMargin) ? options.xLabelMargin : 10
53
53
  this.yLabelMargin = isDef(options.yLanelMargin) ? options.yLabelMargin : 10
54
54
 
55
- this.lineStyles = options.lineStyles || DEFAULT_CHART_STYLES
56
-
57
- this.bg = options.bg || '#fff'
58
55
  this.fontSize = options.fontSize || 12
56
+ this.setTheme(options)
59
57
 
60
58
  this.xStep = options.xStep
61
59
  this.yStep = options.yStep
@@ -79,6 +77,18 @@ export default class LineChart {
79
77
  this.bindPointMouseOver()
80
78
  }
81
79
 
80
+ setTheme(opts) {
81
+ const options = Object.assign({}, this.options, opts)
82
+ const theme = options.theme || THEME_DEFAULT
83
+ const style = CHART_STYLE[theme]
84
+ this.theme = theme
85
+ this.bg = options.bg || style.bg
86
+ this.line = options.line || style.line
87
+ this.txt = options.txt || style.txt
88
+ this.lineStyles = options.lineStyles || style.variants
89
+ this.setBg()
90
+ }
91
+
82
92
  get noData() {
83
93
  return (this.xLabelRows.length === 0) && (this.yLabelRows.length === 0)
84
94
  }
@@ -175,7 +185,7 @@ export default class LineChart {
175
185
 
176
186
  const { ctx, yLabelRows, contentWidth, firstY, xAxisStart, yAxisStart, yRatio } = this
177
187
 
178
- ctx.strokeStyle = 'rgba(224, 224, 224, .5)'
188
+ ctx.strokeStyle = this.line
179
189
  ctx.lineWidth = 1
180
190
 
181
191
  yLabelRows.forEach(row => {
@@ -247,10 +257,10 @@ export default class LineChart {
247
257
  const scaleEnd = y - scaleMargin
248
258
 
249
259
  ctx.textBaseline = 'top'
250
- ctx.fillStyle = '#3c4257'
260
+ ctx.fillStyle = this.txt
251
261
  ctx.textAlign = 'center'
252
262
 
253
- ctx.strokeStyle = '#3c4257'
263
+ ctx.strokeStyle = this.txt
254
264
 
255
265
  let x = this.xAxisMiddle
256
266
 
@@ -274,7 +284,7 @@ export default class LineChart {
274
284
  const x = this.width - this.xPadding
275
285
  const halfYLabelHeight = this.yLabelHeight / 2
276
286
 
277
- ctx.fillStyle = '#3c4257'
287
+ ctx.fillStyle = this.txt
278
288
  ctx.textAlign = 'right'
279
289
 
280
290
  let y = this.yAxisMiddle
@@ -4,7 +4,7 @@ import isFn from '../utils/isFn'
4
4
  import isDef from '../utils/isDef'
5
5
  import isUndef from '../utils/isUndef'
6
6
  import { throttle } from '../utils'
7
- import { DEFAULT_CHART_STYLES } from '../consts'
7
+ import { THEME_DEFAULT, CHART_STYLE } from '../consts'
8
8
 
9
9
  @supportDom
10
10
  @chartCommon
@@ -20,8 +20,7 @@ export default class PieChart {
20
20
  this.height = options.height
21
21
  this.width = options.width
22
22
  this.padding = isDef(options.padding) ? options.padding : 30
23
- this.styles = options.styles || DEFAULT_CHART_STYLES
24
- this.bg = options.bg || '#fff'
23
+ this.setTheme(options)
25
24
 
26
25
  this.init()
27
26
  }
@@ -36,6 +35,17 @@ export default class PieChart {
36
35
  this.bindPointMouseOver()
37
36
  }
38
37
 
38
+ setTheme(opts) {
39
+ const options = Object.assign({}, this.options, opts)
40
+ const theme = options.theme || THEME_DEFAULT
41
+ const style = CHART_STYLE[theme]
42
+ this.theme = theme
43
+ this.bg = options.bg || style.bg
44
+ this.glowAlpha = options.glowAlpha || style.glowAlpha
45
+ this.styles = options.styles || style.variants
46
+ this.setBg()
47
+ }
48
+
39
49
  get x() {
40
50
  return this.width / 2
41
51
  }
@@ -99,7 +109,7 @@ export default class PieChart {
99
109
  distance += ratio
100
110
  })
101
111
 
102
- this.fillCircle(ctx, x, y, centerCircleRadius, '#fff')
112
+ this.fillCircle(ctx, x, y, centerCircleRadius, this.bg)
103
113
  }
104
114
 
105
115
  handleDprChange() {
@@ -177,11 +187,11 @@ export default class PieChart {
177
187
 
178
188
  const options = {
179
189
  style: this.styles[index],
180
- alpha: .3
190
+ alpha: this.glowAlpha
181
191
  }
182
192
  const radiusDelta = (radius - centerCircleRadius) * .3
183
193
  this.fillArc(ctx, x, y, radius + radiusDelta, startAngle, endAngle, options)
184
- this.fillCircle(this.firstLayer.ctx, x, y, centerCircleRadius, '#fff')
194
+ this.fillCircle(this.firstLayer.ctx, x, y, centerCircleRadius, this.bg)
185
195
  }
186
196
 
187
197
  clearSliceGlow() {
@@ -335,9 +335,10 @@ export default class SearchDropdown {
335
335
  if (! this.isMenuVisible) {
336
336
  return
337
337
  }
338
- const isBackdrop = (event.target !== this.dom) &&
339
- (! this.dom.contains(event.target)) &&
340
- (! this.menu.contains(event.target))
338
+ const { target } = event
339
+ const isBackdrop = (target !== this.dom) &&
340
+ (! this.dom.contains(target)) &&
341
+ (! this.menu.contains(target))
341
342
 
342
343
  if (isBackdrop) {
343
344
  this.hideMenu()
@@ -388,8 +389,10 @@ export default class SearchDropdown {
388
389
  }
389
390
 
390
391
  destroy() {
391
- this.menu.remove()
392
- this.menu = null
392
+ if (this.menu) {
393
+ this.menu.remove()
394
+ this.menu = null
395
+ }
393
396
  this.input = null
394
397
  this.menuContent = null
395
398
  this.loader = null
@@ -4,6 +4,48 @@ export const DEFAULT_TIMEZONE = 'Asia/Taipei'
4
4
 
5
5
  export const DEFAULT_LOCALE = locale
6
6
 
7
+ export const THEME_DEFAULT = 'default'
8
+
9
+ export const THEME_DARK = 'dark'
10
+
11
+ export const THEMES = [
12
+ { text: 'Default', value: THEME_DEFAULT },
13
+ { text: 'Dark', value: THEME_DARK }
14
+ ]
15
+
16
+ export const CHART_STYLE = {
17
+ [THEME_DEFAULT]: {
18
+ bg: '#fff',
19
+ txt: '#3c4257',
20
+ line: 'rgba(224, 224, 224, .5)',
21
+ glowAlpha: .2,
22
+ variants: [
23
+ '#5469d4',
24
+ '#7c54d4',
25
+ '#a254d4',
26
+ '#c040a2',
27
+ '#ff5604',
28
+ '#0be4e3',
29
+ '#00d924'
30
+ ]
31
+ },
32
+ [THEME_DARK]: {
33
+ bg: '#070B1F',
34
+ txt: '#fff',
35
+ line: 'rgba(255, 255, 255, .3)',
36
+ glowAlpha: .3,
37
+ variants: [
38
+ '#769aff',
39
+ '#9e72ff',
40
+ '#c66cff',
41
+ '#ff5ed9',
42
+ '#ff5604',
43
+ '#0be4e3',
44
+ '#00d924'
45
+ ]
46
+ }
47
+ }
48
+
7
49
  export const DEFAULT_CHART_STYLES = [
8
50
  '#5469d4',
9
51
  '#7c54d4',
@@ -213,12 +213,15 @@ export default function chartCommon(target) {
213
213
  this.dom.appendChild(box)
214
214
  }
215
215
 
216
+ setBg() {
217
+ this.dom.style.backgroundColor = this.bg
218
+ }
219
+
216
220
  drawLabels(labels, styles = DEFAULT_CHART_STYLES) {
217
221
  if (labels.length <= 0) {
218
222
  return
219
223
  }
220
224
  const { labelBox, handleLabelMouseOver, handleLabelMouseLeave } = this
221
- this.dom.style.backgroundColor = this.bg
222
225
 
223
226
  this.offLabels.forEach(off => off())
224
227
  labelBox.innerHTML = ''
data/src/js/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import './../sass/_beyond.scss'
2
1
  import 'core-js/stable'
3
2
  import 'regenerator-runtime/runtime'
4
3
  import './polyfills/classList'
@@ -0,0 +1,170 @@
1
+ html {
2
+ height: 100%;
3
+ }
4
+ body {
5
+ color: $txt;
6
+ box-sizing: border-box;
7
+ font-family: 'Noto Sans CJK TC', 'PingFang TC', 'Microsoft JhengHei',
8
+ 'Helvetica Neue', Helvetica, Verdana, 'Open Sans', sans-serif;
9
+ font-size: 16px;
10
+
11
+ .content {
12
+ flex: 1;
13
+ }
14
+ &.with-footer {
15
+ min-height: 100%;
16
+ display: flex;
17
+ flex-direction: column;
18
+ }
19
+ }
20
+ *,
21
+ *:before,
22
+ *:after {
23
+ box-sizing: inherit;
24
+ }
25
+
26
+ :focus {
27
+ outline: 1px solid $bg-outline;
28
+ outline-offset: 2px;
29
+ }
30
+
31
+ // for ie11
32
+ body:focus {
33
+ outline: 0;
34
+ }
35
+
36
+ h1, h2, h3, h4, h5, h6 {
37
+ margin-top: 0;
38
+ margin-bottom: 8px;
39
+ }
40
+
41
+ ul {
42
+ list-style-type: none;
43
+ padding: 0;
44
+ margin: 0;
45
+ }
46
+
47
+ p {
48
+ line-height: 2.1em;
49
+ margin-top: 0;
50
+ margin-bottom: 1rem;
51
+ }
52
+ small {
53
+ font-size: 70%;
54
+ }
55
+ blockquote {
56
+ margin: 0 0 1rem;
57
+ }
58
+
59
+ th, td {
60
+ padding: 7px;
61
+ }
62
+
63
+ a {
64
+ cursor: pointer;
65
+ color: $txt-anchor;
66
+ text-decoration: none;
67
+ &:hover {
68
+ color: $txt-anchor-ex;
69
+ }
70
+ }
71
+
72
+ // active style
73
+ $color-active: #5469d4;
74
+
75
+ .select,
76
+ .select.select-outline,
77
+ .select.select-outline-strong,
78
+ .btn.btn-dropdown,
79
+ .search-input,
80
+ .input {
81
+ &.active {
82
+ color: $color-active;
83
+ box-shadow: 0 1px 1px 0 rgba(54, 59, 255, .6),
84
+ rgba(14, 48, 173, .3) 0 0 0 1px,
85
+ rgba(14, 26, 62, .12) 0 2px 5px 0;
86
+ }
87
+ }
88
+ .search-input.active .input,
89
+ .search-input.active .icon-search:before {
90
+ color: $color-active;
91
+ }
92
+
93
+ .input,
94
+ .select,
95
+ .select.select-outline,
96
+ .select.select-outline-strong {
97
+ &:focus.active {
98
+ color: $color-active;
99
+ box-shadow: 0 1px 1px 0 rgba(54, 59, 255, .6),
100
+ rgba(14, 48, 173, .3) 0 0 0 1px,
101
+ rgba(14, 26, 62, .12) 0 2px 5px 0,
102
+ 0 0 0 4px rgba(58, 151, 212, .28);
103
+ }
104
+ }
105
+ .search-input.active.outline {
106
+ color: $color-active;
107
+ box-shadow: 0 1px 1px 0 rgba(54, 59, 255, .6),
108
+ rgba(14, 48, 173, .3) 0 0 0 1px,
109
+ rgba(14, 26, 62, .12) 0 2px 5px 0,
110
+ 0 0 0 4px rgba(58, 151, 212, .28);
111
+ }
112
+
113
+ .scrollable {
114
+ overflow-y: scroll;
115
+ -webkit-overflow-scrolling: touch;
116
+ }
117
+
118
+ .align-left {
119
+ text-align: left !important;
120
+ }
121
+ .align-right {
122
+ text-align: right !important;
123
+ }
124
+ .align-center {
125
+ text-align: center !important;
126
+ }
127
+
128
+ .float-left {
129
+ float: left !important;
130
+ }
131
+ .float-right {
132
+ float: right !important;
133
+ }
134
+ .float-none {
135
+ float: none !important;
136
+ }
137
+
138
+ .sr-only {
139
+ position: absolute;
140
+ width: 1px;
141
+ height: 1px;
142
+ padding: 0;
143
+ overflow: hidden;
144
+ clip: rect(0, 0, 0, 0);
145
+ white-space: nowrap;
146
+ clip-path: inset(50%);
147
+ border: 0;
148
+ }
149
+
150
+ .full-width {
151
+ width: 100% !important;
152
+ }
153
+
154
+ hr {
155
+ margin-top: 20px;
156
+ margin-bottom: 20px;
157
+ border-top: 1px solid $hr-border;
158
+ border-left: 0;
159
+ border-right: 0;
160
+ border-bottom: 0;
161
+ }
162
+
163
+ input[type=file], /* FF, IE7+, chrome (except button) */
164
+ input[type=file]::-webkit-file-upload-button { /* chromes and blink button */
165
+ cursor: pointer;
166
+ }
167
+
168
+ .nowrap {
169
+ white-space: nowrap !important;
170
+ }
@@ -0,0 +1,3 @@
1
+ @import './abstracts/_variables';
2
+ @import './themes/_dark';
3
+ @import './_main';
@@ -1,56 +1,2 @@
1
1
  @import './abstracts/_variables';
2
- @import './abstracts/_placeholders';
3
- @import './abstracts/_mixins';
4
- @import './vendor/_normalize';
5
- @import './vendor/_turbolink';
6
- @import './base/_background';
7
- @import './base/_typography';
8
- @import './_animations';
9
2
  @import './_main';
10
- @import './layout/_border-util';
11
- @import './layout/_col';
12
- @import './layout/_container';
13
- @import './layout/_offset-util';
14
- @import './layout/_sizing-util';
15
- @import './layout/_spacing-util';
16
- @import './layout/_visibility-util';
17
- @import './layout/_flex-util';
18
- @import './components/_alert';
19
- @import './components/_autocomplete';
20
- @import './components/_avatar';
21
- @import './components/_badge';
22
- @import './components/_breadcrumb';
23
- @import './components/_btn';
24
- @import './components/_btn-group';
25
- @import './components/_card';
26
- @import './components/_checkbox';
27
- @import './components/_date-input';
28
- @import './components/_date-menu';
29
- @import './components/_month-menu';
30
- @import './components/_date-time-ranger';
31
- @import './components/_datepicker';
32
- @import './components/_dropdown';
33
- @import './components/_form';
34
- @import './components/_icon';
35
- @import './components/_input';
36
- @import './components/_list';
37
- @import './components/_modal';
38
- @import './components/_nav';
39
- @import './components/_navbar';
40
- @import './components/_pagination';
41
- @import './components/_radio';
42
- @import './components/_search-dropdown';
43
- @import './components/_select';
44
- @import './components/_sidebar';
45
- @import './components/_spinner';
46
- @import './components/_tabbox';
47
- @import './components/_table';
48
- @import './components/_tag';
49
- @import './components/_tag-input';
50
- @import './components/_time-input';
51
- @import './components/_time-menu';
52
- @import './components/_toast';
53
- @import './components/_tooltip';
54
- @import './components/_switch';
55
- @import './components/_mega-menu';
56
- @import './components/_chart';