Browse Source

Twitch rivals individual scoreboard

Alan Colon 6 years ago
parent
commit
22b2c8a754
7 changed files with 94 additions and 18 deletions
  1. 1 1
      README.md
  2. BIN
      app/assets/twitch-rivals.png
  3. 1 1
      app/index.html
  4. 3 3
      app/main.js
  5. 84 8
      app/main.vue
  6. 1 1
      package-lock.json
  7. 4 4
      webpack.config.js

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-# **CHANGEME**
+# **Twitch Rivals**
 
 ## Development
 

BIN
app/assets/twitch-rivals.png


+ 1 - 1
app/index.html

@@ -1,6 +1,6 @@
 <html>
 <head>
-  <title>CHANGEME</title>
+  <title>Twitch Rivals</title>
   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
   <link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">
 </head>

+ 3 - 3
app/main.js

@@ -32,9 +32,9 @@ Vue.use(Vuetify, {
     Ripple
   },
   theme: {
-    primary: colors.red.darken1, // #E53935
-    secondary: colors.red.lighten4, // #FFCDD2
-    accent: colors.indigo.base // #3F51B5
+    primary: colors.deepPurple.darken1, // #E53935
+    secondary: colors.deepPurple.lighten4, // #FFCDD2
+    accent: colors.green.base // #3F51B5
   }
 })
 

+ 84 - 8
app/main.vue

@@ -1,21 +1,97 @@
+<script>
+export default {
+  data() {
+    return {
+      history: [],
+      state: {
+        completes: 0,
+        skips: 0
+      }
+    }
+  },
+  methods: {
+    keydown(event) {
+      if (event.code === 'Escape') this.skip()
+      if (event.code === 'Backspace') this.undo()
+      if (event.code === 'Space') this.complete()
+    },
+    newState(state) {
+      this.history.push(this.state)
+      this.state = {
+        ...this.state,
+        ...state
+      }
+    },
+    complete() {
+      this.newState({
+        completes: this.state.completes + 1
+      })
+    },
+    skip() {
+      this.newState({
+        skips: this.state.skips + 1
+      })
+    },
+    undo() {
+      this.state = this.history.pop() || this.state
+    }
+  }
+}
+</script>
+
 <template>
+  <div @keydown="keydown" tabindex="0">
     <v-app>
       <v-content>
         <v-toolbar color="primary">
           <v-toolbar-side-icon />
-          <v-toolbar-title>Change Me</v-toolbar-title>
+          <v-toolbar-title>Twitch Rivals</v-toolbar-title>
         </v-toolbar>
-        <v-container>Hello world</v-container>
+        <v-container>
+          <div class="score">
+            <div class="skips-label">Skips <strong>({{state.skips}} / 15)</strong></div>
+            <div class="skips">
+              <div class="skip" v-for="(_, i) in Array(Math.max(15, state.skips)).fill()" :key="i" :class="{ used: i < state.skips, extra: i >= 15 }" />
+            </div>
+            <div class="completes-label">Completes <strong>({{state.completes}})</strong>:</div>
+            <div class="completes">
+              <div class="complete" v-for="(_, i) in Array(state.completes).fill()" :key="i" />
+            </div>
+          </div>
+        </v-container>
       </v-content>
     </v-app>
+  </div>
 </template>
 
-<script>
-export default {
+<style lang="less" scoped>
+.score {
+  display: grid;
+  margin: 10px;
+  box-sizing: border-box;
+  width: calc(100% - 20px);
+  grid-template: 'skips-label skips' 'completes-label completes' / 100px auto;
 
+  .skip, .complete {
+    display: inline-block;
+    width: 15px;
+    margin: 2.5px;
+    height: 15px;
+    border-radius: 7.5px;
+  }
+  .skip {
+    border: solid 1px darkmagenta;
+    &.used {
+      background-color: purple;
+    }
+    &.extra {
+      background-color: red;
+    }
+  }
+  .complete {
+    border: solid 1px green;
+    background-color: greenyellow;
+  }
+  
 }
-</script>
-
-<style>
-
 </style>

+ 1 - 1
package-lock.json

@@ -1,5 +1,5 @@
 {
-  "name": "**CHANGEME**",
+  "name": "twitch-rivals",
   "version": "1.0.0",
   "lockfileVersion": 1,
   "requires": true,

+ 4 - 4
webpack.config.js

@@ -48,13 +48,13 @@ module.exports = {
       templateParameters: { }
     }),
     new WebpackPwaManifest({
-      name: 'CHANGEME',
-      short_name: 'changeme',
-      description: 'This is an installable app.',
+      name: 'Twitch Rivals',
+      short_name: 'Rivals',
+      description: 'This tracks and shares levels and skips',
       background_color: '#ffffff',
       icons: [
         {
-          src: Path.resolve('app/assets/placeholder_icon.png'),
+          src: Path.resolve('app/assets/twitch-rivals.png'),
           sizes: [96, 128, 192, 256, 384, 512]
         }
       ],