|
5 | 5 | <span class="title">Volume</span>
|
6 | 6 | <span class="volume">{{decimalToPercent(volume)}}%</span>
|
7 | 7 | </h4>
|
8 |
| - <PodloveSlider min="0" max="1" :value="volume" step="0.001" :onInput="setVolume" :thumbColor="theme.settings.slider.thumb"></PodloveSlider> |
| 8 | + <div class="input-slider"> |
| 9 | + <PodloveButton class="slider-button" :click="changeVolume(volume, -5)" :style="buttonStyle(theme)">-</PodloveButton> |
| 10 | + <PodloveButton class="slider-button" :click="changeVolume(volume, 5)" :style="buttonStyle(theme)">+</PodloveButton> |
| 11 | + <PodloveSlider class="input-slider" min="0" max="1" :value="volume" step="0.001" :onInput="setVolume" :thumbColor="theme.tabs.slider.thumb"></PodloveSlider> |
| 12 | + </div> |
9 | 13 | </div>
|
10 | 14 | <div class="input">
|
11 | 15 | <h4 class="label">
|
12 | 16 | <span class="title">Speed</span>
|
13 | 17 | <span class="rate">{{decimalToPercent(rate)}}%</span>
|
14 | 18 | </h4>
|
15 |
| - <div class="input--rate"> |
16 |
| - <PodloveButton class="rate-button" :click="decreaseRate(rate)" :style="buttonStyle(theme)">-</PodloveButton> |
17 |
| - <PodloveButton class="rate-button" :click="increaseRate(rate)" :style="buttonStyle(theme)">+</PodloveButton> |
18 |
| - <PodloveSlider class="rate--slider" min="0.5" max="4" :value="rate" step="0.001" :onInput="setRate" :thumbColor="theme.settings.slider.thumb"></PodloveSlider> |
| 19 | + <div class="input-slider"> |
| 20 | + <PodloveButton class="slider-button" :click="changeRate(rate, -5)" :style="buttonStyle(theme)">-</PodloveButton> |
| 21 | + <PodloveButton class="slider-button" :click="changeRate(rate, 5)" :style="buttonStyle(theme)">+</PodloveButton> |
| 22 | + <PodloveSlider class="input-slider" min="0.5" max="4" :value="rate" step="0.001" :onInput="setRate" :thumbColor="theme.tabs.slider.thumb"></PodloveSlider> |
19 | 23 | </div>
|
20 | 24 | </div>
|
21 | 25 | <div class="footer">
|
|
39 | 43 | }
|
40 | 44 |
|
41 | 45 | const buttonStyle = (theme) => ({
|
42 |
| - color: theme.settings.slider.text, |
43 |
| - background: theme.settings.slider.button |
| 46 | + color: theme.tabs.button.text, |
| 47 | + background: theme.tabs.button.background |
44 | 48 | })
|
45 | 49 |
|
46 | 50 | const setVolume = volume => {
|
|
52 | 56 | }
|
53 | 57 |
|
54 | 58 | const roundUp = (base, number) => {
|
55 |
| - if (number % base == 0) { |
| 59 | + if (number % base === 0) { |
56 | 60 | return number + base
|
57 | 61 | }
|
58 | 62 |
|
59 | 63 | return number + (base - number % base)
|
60 | 64 | }
|
61 | 65 |
|
62 |
| - const increaseRate = (rate) => { |
63 |
| - let reference = Date.now() |
64 |
| -
|
65 |
| - rate = decimalToPercent(rate) |
66 |
| - return () => { |
67 |
| - let now = Date.now() |
68 |
| -
|
69 |
| - if ((now - reference) < 500) { |
70 |
| - store.dispatch(store.actions.setRate(roundUp(10, rate) / 100)) |
71 |
| - } else { |
72 |
| - store.dispatch(store.actions.setRate(roundUp(5, rate) / 100)) |
73 |
| - } |
74 |
| -
|
75 |
| - reference = now |
76 |
| - } |
| 66 | + const changeRate = (rate, offset) => () => { |
| 67 | + store.dispatch(store.actions.setRate(roundUp(offset, (rate * 100)) / 100)) |
77 | 68 | }
|
78 | 69 |
|
79 |
| - const decreaseRate = (rate) => { |
80 |
| - let reference = Date.now() |
81 |
| -
|
82 |
| - rate = decimalToPercent(rate) |
83 |
| - return () => { |
84 |
| - let now = Date.now() |
85 |
| -
|
86 |
| - if ((now - reference) < 500) { |
87 |
| - store.dispatch(store.actions.setRate(roundUp(-10, rate) / 100)) |
88 |
| - } else { |
89 |
| - store.dispatch(store.actions.setRate(roundUp(-5, rate) / 100)) |
90 |
| - } |
91 |
| -
|
92 |
| - reference = now |
93 |
| - } |
| 70 | + const changeVolume = (volume, offset) => () => { |
| 71 | + store.dispatch(store.actions.setVolume(roundUp(offset, (volume * 100)) / 100)) |
94 | 72 | }
|
95 | 73 |
|
96 | 74 | export default {
|
97 | 75 | data() {
|
98 | 76 | return {
|
99 | 77 | volume: this.$select('volume'),
|
100 | 78 | rate: this.$select('rate'),
|
101 |
| - version: this.$select('debug.version'), |
| 79 | + version: this.$select('runtime.version'), |
102 | 80 | theme: this.$select('theme')
|
103 | 81 | }
|
104 | 82 | },
|
105 | 83 | methods: {
|
106 | 84 | exportStore,
|
107 | 85 | setVolume,
|
108 | 86 | setRate,
|
109 |
| - increaseRate, |
110 |
| - decreaseRate, |
| 87 | + changeRate, |
| 88 | + changeVolume, |
111 | 89 | buttonStyle,
|
112 | 90 | decimalToPercent
|
113 | 91 | },
|
|
120 | 98 |
|
121 | 99 | <style lang="scss">
|
122 | 100 | @import 'variables';
|
| 101 | + @import 'inputs'; |
123 | 102 |
|
124 | 103 | $preset-width: 40px;
|
125 | 104 | $button-size: 30px;
|
|
135 | 114 | color: rgba($accent-color, 0.25)
|
136 | 115 | }
|
137 | 116 |
|
138 |
| - .input { |
139 |
| - border-bottom: 1px dashed rgba($accent-color, 0.2); |
140 |
| - padding-bottom: $padding * 2; |
141 |
| - } |
142 |
| -
|
143 | 117 | .footer {
|
144 | 118 | margin-top: $margin;
|
145 | 119 | text-align: right;
|
|
159 | 133 | width: $preset-width;
|
160 | 134 | }
|
161 | 135 |
|
162 |
| - .input--rate { |
| 136 | + .input-slider { |
163 | 137 | display: flex;
|
164 | 138 | align-items: center;
|
165 | 139 | }
|
166 | 140 |
|
167 |
| - .rate--slider { |
| 141 | + .input-slider { |
168 | 142 | width: 100%;
|
169 | 143 | margin-left: $margin / 2;
|
170 | 144 | }
|
171 | 145 |
|
172 |
| - .rate-button { |
| 146 | + .slider-button { |
173 | 147 | font-weight: bold;
|
174 | 148 | font-size: 1.2em;
|
175 | 149 | height: $button-size;
|
|
0 commit comments