From ebe813e7d3393b34928176cf90f4b847a2fc9d8a Mon Sep 17 00:00:00 2001 From: Eugene Serb <46799701+eugene-serb@users.noreply.github.com> Date: Sun, 7 Aug 2022 21:29:22 +0300 Subject: [PATCH] - Added component and view for manual configuring and playing patterns. - Added component NavigationList for routing over vue-router views. - Rename component WaveloversApp, now is a AppPatterns. - Rename HomeView, now is a PatternView. - Modified function vibrate in MGamepads and change function in index vuex. - Root component App now has mounted and unmounted event listeners for gamepads adding and deleteting functions. - Fixed CSS rules for inputs and input[type=range]. - Added new rules for input[type=range]. --- public/css/styles.css | 113 ++++++++++++++++++++- src/App.vue | 43 +++++++- src/components/AppManual.vue | 84 +++++++++++++++ src/components/AppPatterns.vue | 46 +++++++++ src/components/NavigationList.vue | 32 ++++++ src/components/PatternItem.vue | 2 +- src/components/WaveloversApp.vue | 82 --------------- src/router/index.ts | 12 ++- src/store/index.ts | 12 ++- src/store/modules/MGamepads.ts | 5 +- src/views/{HomeView.vue => ManualView.vue} | 8 +- src/views/PatternsView.vue | 16 +++ 12 files changed, 358 insertions(+), 97 deletions(-) create mode 100644 src/components/AppManual.vue create mode 100644 src/components/AppPatterns.vue create mode 100644 src/components/NavigationList.vue delete mode 100644 src/components/WaveloversApp.vue rename src/views/{HomeView.vue => ManualView.vue} (53%) create mode 100644 src/views/PatternsView.vue diff --git a/public/css/styles.css b/public/css/styles.css index 87dd3ee..8fcc6d4 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -1,6 +1,6 @@ /* ------------------------------ */ /* Wavelovers styles */ -/* version: dated 2022.07.25 */ +/* version: dated 2022.08.07 */ /* author: Eugene Serb */ /* ------------------------------ */ @@ -205,7 +205,7 @@ fieldset { padding: 8px; } -button, input, textarea, select { +button, textarea, select, input { padding: 4px 8px; border: 2px solid var(--color-link); border-radius: var(--number-border-radius); @@ -215,7 +215,6 @@ button, input, textarea, select { line-height: 1.382em; white-space: nowrap; } - button:hover, input:hover, textarea:hover, select:hover { border: 2px solid var(--color-link-hover); @@ -234,6 +233,114 @@ option { color: var(--color-white); } +input[type=range] { + width: 100%; + margin: 8px 0; + padding: 0; + border: 0px solid var(--color-link); + -webkit-appearance: none; +} + + input[type=range]:hover { + margin: 8px 0; + padding: 0; + border: 0px solid var(--color-link-hover); + } + + input[type=range]:focus { + outline: none; + } + + input[type=range]::-webkit-slider-runnable-track { + width: 100%; + height: 8px; + cursor: pointer; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + background: var(--color-b); + border-radius: 8px; + border: 0px solid #000101; + } + + input[type=range]::-webkit-slider-thumb { + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + border: 0px solid #000000; + height: 16px; + width: 16px; + border-radius: 8px; + background: var(--color-a); + cursor: pointer; + -webkit-appearance: none; + margin-top: -4px; + } + + input[type=range]:focus::-webkit-slider-runnable-track { + background: var(--color-b); + } + + input[type=range]::-moz-range-track { + width: 100%; + height: 8px; + cursor: pointer; + animate: 0.2s; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + background: var(--color-b); + border-radius: 8px; + border: 0px solid #000101; + } + + input[type=range]::-moz-range-thumb { + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + border: 0px solid #000000; + height: 16px; + width: 16px; + border-radius: 8px; + background: var(--color-a); + cursor: pointer; + } + + input[type=range]::-ms-track { + width: 100%; + height: 8px; + cursor: pointer; + animate: 0.2s; + background: transparent; + border-color: transparent; + border-width: 8px 0; + color: transparent; + } + + input[type=range]::-ms-fill-lower { + background: var(--color-b); + border: 0px solid #000101; + border-radius: 8px; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + } + + input[type=range]::-ms-fill-upper { + background: var(--color-b); + border: 0px solid #000101; + border-radius: 8px; + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + } + + input[type=range]::-ms-thumb { + box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d; + border: 0px solid #000000; + height: 16px; + width: 16px; + border-radius: 8px; + background: var(--color-a); + cursor: pointer; + } + + input[type=range]:focus::-ms-fill-lower { + background: var(--color-b); + } + + input[type=range]:focus::-ms-fill-upper { + background: var(--color-b); + } + /* ------ */ /* TABLES */ /* ------ */ diff --git a/src/App.vue b/src/App.vue index c0cca97..471fcd8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,12 +1,53 @@ + + diff --git a/src/components/AppManual.vue b/src/components/AppManual.vue new file mode 100644 index 0000000..0cec669 --- /dev/null +++ b/src/components/AppManual.vue @@ -0,0 +1,84 @@ + + + + + + diff --git a/src/components/AppPatterns.vue b/src/components/AppPatterns.vue new file mode 100644 index 0000000..908b22e --- /dev/null +++ b/src/components/AppPatterns.vue @@ -0,0 +1,46 @@ + + + + diff --git a/src/components/NavigationList.vue b/src/components/NavigationList.vue new file mode 100644 index 0000000..4ec1feb --- /dev/null +++ b/src/components/NavigationList.vue @@ -0,0 +1,32 @@ + + + + + + diff --git a/src/components/PatternItem.vue b/src/components/PatternItem.vue index 311ad5f..ef3a749 100644 --- a/src/components/PatternItem.vue +++ b/src/components/PatternItem.vue @@ -52,7 +52,7 @@ align-items: center; text-align: center; overflow: hidden; - cursor: default; + cursor: pointer; } @media only screen and (min-width: 540px) { diff --git a/src/components/WaveloversApp.vue b/src/components/WaveloversApp.vue deleted file mode 100644 index 1f079b8..0000000 --- a/src/components/WaveloversApp.vue +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - diff --git a/src/router/index.ts b/src/router/index.ts index 0f30dc4..547ed7a 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,11 +1,17 @@ import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'; -import HomeView from '@/views/HomeView.vue'; +import PatternsView from '@/views/PatternsView.vue'; +import ManualView from '@/views/ManualView.vue'; const routes: Array = [ { path: '/', - name: 'home', - component: HomeView, + name: 'patterns-view', + component: PatternsView, + }, + { + path: '/manual', + name: 'manual-view', + component: ManualView, }, ]; diff --git a/src/store/index.ts b/src/store/index.ts index 78239b5..5b487ed 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -2,6 +2,7 @@ import { createStore, Store } from 'vuex'; import IRootState from './models/IRootState'; import MGamepads from '@/store/modules/MGamepads'; import MPatterns from '@/store/modules/MPatterns'; +import TPatternUnit from '../models/TPatternUnit'; const store: Store = createStore({ state: () => ({ @@ -46,11 +47,20 @@ const store: Store = createStore({ } if (context.getters.isActive === true) { context.dispatch('reset'); - context.dispatch('vibrate'); + context.dispatch( + 'vibrate', + context.getters.patterns[context.getters.mode].pattern + ); } else { context.dispatch('reset'); } }, + startCustom: function (context, pattern: TPatternUnit[]): void { + context.dispatch('setIsActive', false); + context.dispatch('setMode', 0); + context.dispatch('reset'); + context.dispatch('vibrate', pattern); + }, }, modules: { MGamepads: MGamepads, diff --git a/src/store/modules/MGamepads.ts b/src/store/modules/MGamepads.ts index 4732627..f0a3780 100644 --- a/src/store/modules/MGamepads.ts +++ b/src/store/modules/MGamepads.ts @@ -46,10 +46,11 @@ const MGamepads: Module = { }); }, vibrate: function ( - context: ActionContext + context: ActionContext, + pattern: TPatternUnit[] ): void { context.getters.gamepads.forEach((gamepad: Vibrator) => { - gamepad.vibrate(context.getters.patterns[context.getters.mode].pattern as TPatternUnit[]); + gamepad.vibrate(pattern); }); }, reset: function ( diff --git a/src/views/HomeView.vue b/src/views/ManualView.vue similarity index 53% rename from src/views/HomeView.vue rename to src/views/ManualView.vue index cde62a2..e49503d 100644 --- a/src/views/HomeView.vue +++ b/src/views/ManualView.vue @@ -1,15 +1,15 @@ diff --git a/src/views/PatternsView.vue b/src/views/PatternsView.vue new file mode 100644 index 0000000..d25f36d --- /dev/null +++ b/src/views/PatternsView.vue @@ -0,0 +1,16 @@ + + + +