about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2019-11-28 00:30:22 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2019-11-28 00:30:22 +0100
commita12cffe8d8a67658df93eec8286485247e5d7bff (patch)
tree3757440cfa77eb1c5e0e67b27b0862f761e79093
parent72549ed7b81fc01445fecdb7889bab4cf2a1590f (diff)
downloadpuszcza-a12cffe8d8a67658df93eec8286485247e5d7bff.tar.gz
puszcza-a12cffe8d8a67658df93eec8286485247e5d7bff.zip
Add ranking list
-rw-r--r--components/Ranking/RankingEntry.vue52
-rw-r--r--components/Ranking/RankingFirstEntry.vue49
-rw-r--r--components/Ranking/RankingList.vue56
m---------content0
-rw-r--r--pages/punktacja.vue33
-rw-r--r--static/assets/crown.svg4
6 files changed, 194 insertions, 0 deletions
diff --git a/components/Ranking/RankingEntry.vue b/components/Ranking/RankingEntry.vue
new file mode 100644
index 0000000..e10cf8d
--- /dev/null
+++ b/components/Ranking/RankingEntry.vue
@@ -0,0 +1,52 @@
+<template>
+  <li class="ranking-entry">
+    <div class="ranking-entry__troop">{{ troop }}</div>
+    <div class="ranking-entry__points">{{ points }}</div>
+  </li>
+</template>
+
+<script>
+export default {
+  name: 'RankingEntry',
+  props: {
+    troop: {
+      type: String,
+      required: true
+    },
+    points: {
+      type: Number,
+      required: true
+    }
+  }
+}
+</script>
+
+<style scoped>
+.ranking-entry {
+  width: 100%;
+  list-style: none;
+
+  margin: 5px;
+  padding: 10px 20px;
+
+  border: 2px solid #efefef;
+
+  display: grid;
+  grid-template-columns: 0% 75% 25%;
+
+  font-size: 20px;
+}
+
+.ranking-entry div {
+  display: inline-block;
+}
+
+.ranking-entry__troop {
+  text-align: left;
+  grid-column: 2;
+}
+
+.ranking-entry__points {
+  grid-column: 3;
+}
+</style>
diff --git a/components/Ranking/RankingFirstEntry.vue b/components/Ranking/RankingFirstEntry.vue
new file mode 100644
index 0000000..b7142ae
--- /dev/null
+++ b/components/Ranking/RankingFirstEntry.vue
@@ -0,0 +1,49 @@
+<template>
+  <li class="ranking-first-entry">
+    <img class="crown" src="/assets/crown.svg" />
+    <div class="ranking-first-entry__troop">{{ troop }}</div>
+    <div class="ranking-first-entry__points">{{ points }}</div>
+  </li>
+</template>
+
+<script>
+export default {
+  name: 'RankingFirstEntry',
+  props: {
+    troop: {
+      type: String,
+      required: true
+    },
+    points: {
+      type: Number,
+      required: true
+    }
+  }
+}
+</script>
+
+<style scoped>
+.ranking-first-entry {
+  list-style: none;
+  padding: 10px 20px;
+  display: grid;
+
+  width: 150%;
+  grid-template-columns: 15% 60% 25%;
+  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.25);
+
+  font-size: 26px;
+}
+
+.crown {
+  margin: auto;
+}
+
+.ranking-first-entry__troop {
+  grid-column: 2;
+}
+
+.ranking-first-entry__points {
+  grid-column: 3;
+}
+</style>
diff --git a/components/Ranking/RankingList.vue b/components/Ranking/RankingList.vue
new file mode 100644
index 0000000..68fdb16
--- /dev/null
+++ b/components/Ranking/RankingList.vue
@@ -0,0 +1,56 @@
+<template>
+  <ol class="ranking-list">
+    <ranking-first-entry
+      :troop="sortedScores[0].troop"
+      :points="sortedScores[0].points"
+    />
+    <ranking-entry
+      v-for="score in sortedScores.slice(1)"
+      :key="score.troop"
+      :troop="score.troop"
+      :points="score.points"
+    />
+  </ol>
+</template>
+
+<script>
+import RankingFirstEntry from './RankingFirstEntry'
+import RankingEntry from './RankingEntry'
+
+function compare(a, b) {
+  return b.points - a.points
+}
+
+export default {
+  name: 'RankingList',
+  components: {
+    RankingEntry,
+    RankingFirstEntry
+  },
+  props: {
+    scores: {
+      type: Array, //i.e. [{troop: "Troop 1", points: 12}, {troop: "Troop 2", points: 22}]
+      required: true
+    }
+  },
+  computed: {
+    sortedScores() {
+      return [...this.scores].sort(compare)
+    }
+  }
+}
+</script>
+
+<style scoped>
+.ranking-list {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  margin: 10px;
+  padding: 0;
+  padding-inline-start: 0;
+
+  width: 100%;
+  max-width: 200px;
+}
+</style>
diff --git a/content b/content
new file mode 160000
+Subproject db05ef2179b2c01c5af126bca697add39fc82a3
diff --git a/pages/punktacja.vue b/pages/punktacja.vue
new file mode 100644
index 0000000..d38749b
--- /dev/null
+++ b/pages/punktacja.vue
@@ -0,0 +1,33 @@
+<template>
+  <div style="max-width: 900px">
+    <h1>Punktacja</h1>
+    <ranking-list v-if="scores" :scores="scores" />
+    <p v-else>Loading...</p>
+  </div>
+</template>
+
+<script>
+import RankingList from '~/components/Ranking/RankingList'
+
+export default {
+  components: {
+    RankingList
+  },
+  data() {
+    return {
+      scores: undefined
+    }
+  },
+  mounted() {
+    this.getScores()
+  },
+  methods: {
+    getScores() {
+      this.scores = [
+        { troop: 'Toop 1', points: 1 },
+        { troop: 'Troop 2', points: 2 }
+      ]
+    }
+  }
+}
+</script>
diff --git a/static/assets/crown.svg b/static/assets/crown.svg
new file mode 100644
index 0000000..bc45029
--- /dev/null
+++ b/static/assets/crown.svg
@@ -0,0 +1,4 @@
+<svg width="32" height="22" viewBox="0 0 32 22" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect y="18" width="32" height="4" fill="#F1DB14"/>
+<path d="M31.9998 17.1674H0V0L7.99994 9.19683L15.9999 0L23.9998 9.19683L31.9998 0V17.1674Z" fill="#F1DB14"/>
+</svg>