Merge branch 'master' into feat/history-page-by-date

This commit is contained in:
2020-10-11 18:22:04 +02:00
committed by GitHub
20 changed files with 561 additions and 250 deletions

View File

@@ -104,6 +104,7 @@ const byEpochDate = (req, res) => {
const byName = (req, res) => { const byName = (req, res) => {
const { name } = req.params; const { name } = req.params;
const regexName = new RegExp(name, "i"); // lowercase regex of the name
return Highscore.find({ name }) return Highscore.find({ name })
.then(highscore => { .then(highscore => {

View File

@@ -7,7 +7,7 @@ async function sendWineSelectMessage(winnerObject) {
winnerObject.timestamp_limit = new Date().getTime() * 600000; winnerObject.timestamp_limit = new Date().getTime() * 600000;
await winnerObject.save(); await winnerObject.save();
let url = new URL(`/#/winner/${winnerObject.id}`, "https://lottis.vin"); let url = new URL(`/winner/${winnerObject.id}`, "https://lottis.vin");
return sendMessageToUser( return sendMessageToUser(
winnerObject.phoneNumber, winnerObject.phoneNumber,

View File

@@ -35,7 +35,7 @@ const submitWines = async (req, res) => {
const message = JSON.stringify({ const message = JSON.stringify({
message: "Dagens vin er lagt til, se den på lottis.vin/dagens!", message: "Dagens vin er lagt til, se den på lottis.vin/dagens!",
title: "Ny vin!", title: "Ny vin!",
link: "/#/dagens" link: "/dagens"
}); });
try { try {

View File

@@ -1,56 +1,24 @@
<template> <template>
<div> <div class="container">
<h1 class="text-center">Vinlottis highscore 🏆🍷</h1> <h1>Vinlottis highscore</h1>
<div class="content-container">
<div class="highscore">
<div>
<h3 >Finn ditt navn:</h3>
<input type="text" v-model="highscoreFilter" placeholder="Filtrer på navn" class="margin-bottom-sm" />
</div>
<ol v-if="highscore.length > 0">
<li v-for="person in highscore" :key="person" @click="selectWinner(person)">
{{ person.name }} - {{ person.wins.length }}
</li>
</ol>
<div v-if="highscore.length != highscoreResponse.length" class="flex justify-center align-center"> <div class="filter flex el-spacing">
<i @click="resetFilter" @keyup.space="resetFilter" <input type="text" v-model="filterInput" placeholder="Filtrer på navn" />
role="button" aria-pressed="false" tabindex="0">reset filter</i> <button v-if="filterInput" @click="resetFilter" class="vin-button auto-height margin-left-sm">
</div> Reset
</div> </button>
</div>
<div class="winners-vines" v-if="selectedWinner"> <p class="highscore-header margin-bottom-md"><b>Plassering.</b> Navn - Antall vinn</p>
<h1>{{ selectedWinner.name }}</h1>
<h2>Vinnende farger:</h2> <ol v-if="highscore.length > 0" class="highscore-list">
<div class="winning-colors"> <li v-for="person in filteredResults" @click="selectWinner(person)" @keydown.enter="selectWinner(person)" tabindex="0">
<div v-for="win in selectedWinner.wins" <b>{{ person.rank }}.</b>&nbsp;&nbsp;&nbsp;{{ person.name }} - {{ person.wins.length }}
class="color-box" :class="win.color" </li>
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }"> </ol>
</div>
</div>
<h2>Flasker vunnet:</h2> <div class="center desktop-only">
<div v-for="win in selectedWinner.wins" class="single-win"> 👈 Se dine vin(n), trykk navnet ditt
<div class="date-won"><b>{{ humanReadableDate(win.date) }}</b> - {{ daysAgo(win.date) }} dager siden</div>
<br/>
<div class="left">
<h3>Vunnet med:</h3>
<div class="color-box" :class="win.color"
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }"></div>
</div>
<div class="left">
<Wine :wine="win.wine"></Wine>
</div>
</div>
</div>
<div v-else class="center">
<h1>👈 Se dine vin(n), trykk navnet ditt</h1>
</div>
</div> </div>
</div> </div>
</template> </template>
@@ -58,16 +26,15 @@
<script> <script>
import { highscoreStatistics } from "@/api"; import { highscoreStatistics } from "@/api";
import { humanReadableDate, daysAgo } from "@/utils";
import Wine from "@/ui/Wine"; import Wine from "@/ui/Wine";
export default { export default {
components: { Wine }, components: { Wine },
data() { data() {
return { return {
highscoreResponse: [],
highscore: [], highscore: [],
highscoreFilter: '', filterInput: ''
selectedWinner: null
} }
}, },
async mounted() { async mounted() {
@@ -78,177 +45,128 @@ export default {
response = response.filter( response = response.filter(
person => person.name != null && person.name != "" person => person.name != null && person.name != ""
); );
this.highscoreResponse = response this.highscore = this.generateScoreBoard(response);
this.highscore = this.highscoreResponse;
}, },
watch: { computed: {
highscoreFilter(val) { filteredResults() {
let highscore = this.highscore;
let val = this.filterInput;
if (val.length) { if (val.length) {
val = val.toLowerCase(); const nameIncludesString = (person) => person.name.toLowerCase().includes(val);
this.highscore = this.highscoreResponse.filter(person => person.name.toLowerCase().includes(val)) highscore = highscore.filter(nameIncludesString)
} else {
this.highscore = this.highscoreResponse
} }
return highscore
} }
}, },
methods: { methods: {
generateScoreBoard(highscore=this.highscore) {
let place = 0;
let highestWinCount = -1;
return highscore.map(win => {
const wins = win.wins.length
if (wins != highestWinCount) {
place += 1
highestWinCount = wins
}
const placeString = place.toString().padStart(2, "0");
win.rank = placeString;
return win
})
},
resetFilter() { resetFilter() {
this.highscore = this.highscoreResponse; this.filterInput = '';
this.highscoreFilter = '';
document.getElementsByTagName('input')[0].focus(); document.getElementsByTagName('input')[0].focus();
}, },
humanReadableDate(date) {
const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(date).toLocaleDateString(undefined, options);
},
daysAgo(date) {
const day = 24 * 60 * 60 * 1000;
return Math.round(Math.abs((new Date() - new Date(date)) / day));
},
selectWinner(winner) { selectWinner(winner) {
if (this.selectedWinner != null && this.selectedWinner["name"] == winner["name"]) { const path = "/highscore/" + encodeURIComponent(winner.name)
this.selectedWinner = null; this.$router.push(path);
} else {
let newestFirst = winner.wins.sort((a, b) => a.date < b.date);
winner.wins = newestFirst;
this.selectedWinner = { ...winner };
}
}, },
getRotation: function() { humanReadableDate: humanReadableDate,
let num = Math.floor(Math.random() * 12.5); daysAgo: daysAgo
let neg = Math.floor(Math.random() * 2);
return neg == 0 ? -num : num;
}
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../styles/media-queries.scss"; @import "./src/styles/media-queries.scss";
@import "../styles/variables.scss"; @import "./src/styles/variables.scss";
$elementSpacing: 3.5rem;
.el-spacing {
margin-bottom: $elementSpacing;
}
.container {
width: 90vw;
margin: 3rem auto;
max-width: 1200px;
margin-bottom: 0;
padding-bottom: 3rem;
@include desktop {
width: 80vw;
}
}
h1 { h1 {
text-align: center; font-size: 3rem;
font-family: "knowit";
color: $matte-text-color;
font-weight: normal;
} }
input[type="text"] { .filter input {
width: 100%; font-size: 1rem;
color: black; width: 30%;
border-radius: 4px; border-color: black;
padding: 1rem 1rem; border-width: 1.5px;
border: 1px solid black; padding: 0.75rem 1rem;
max-width: 200px;
} }
.date-won { .highscore-header {
margin-bottom: 2rem;
font-size: 1.3rem; font-size: 1.3rem;
margin-top: 2rem; color: $matte-text-color;
} }
.color-box { .highscore-list {
width: 100px;
height: 100px;
margin: 10px;
-webkit-mask-image: url(/../../public/assets/images/lodd.svg);
background-repeat: no-repeat;
mask-image: url(/../../public/assets/images/lodd.svg);
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
@include mobile {
width: 60px;
height: 60px;
margin: 10px;
}
}
.single-win {
border-bottom: 1px solid rgb(237, 237, 237);
.left {
display: flex;
align-items: center;
}
}
.green {
background-color: $light-green;
}
.blue {
background-color: $light-blue;
}
.yellow {
background-color: $light-yellow;
}
.red {
background-color: $light-red;
}
.content-container {
display: flex; display: flex;
flex-direction: column-reverse; flex-direction: column;
margin: 2em; padding-left: 0;
.center { li {
align-self: center; width: intrinsic;
h1 { display: inline-block;
background-color: $primary; margin-bottom: calc(1rem - 2px);
padding: 0.5rem 1rem; font-size: 1.25rem;
border-radius: 8px; color: $matte-text-color;
font-style: italic; cursor: pointer;
border-bottom: 2px solid transparent;
&:hover, &:focus {
border-color: $link-color;
} }
} }
.winning-colors {
display: flex;
}
@include mobile {
.center {
display: none;
}
}
@include tablet {
display: grid;
grid-template-columns: .3fr 1fr;
grid-template-rows: auto-flow min-content;
justify-items: center;
width: 80%;
margin: auto;
grid-gap: 1em;
max-width: 1600px;
}
} }
ol { .center {
padding-left: 1.375rem !important; position: absolute;
margin-left: 0; top: 40%;
margin: 0 0 1.5em; right: 10vw;
padding: 0; max-width: 50vw;
counter-reset: item;
& > li {
cursor: pointer;
padding: 2.5px 0;
width: max-content;
margin: 0 0 0 -1.25rem;
padding: 0;
list-style-type: none;
counter-increment: item;
&:before {
display: inline-block;
width: 1em;
padding-right: 0.5rem;
font-weight: bold;
text-align: right;
content: counter(item) ".";
}
@include mobile { font-size: 2.5rem;
padding: 5px 0; background-color: $primary;
} padding: 1rem 1rem;
border-radius: 8px;
font-style: italic;
@include widescreen {
right: 20vw;
} }
} }
</style> </style>

View File

@@ -0,0 +1,273 @@
<template>
<div class="container">
<h1>Vinlottis highscore</h1>
<div class="backdrop">
<a @click="navigateBack" @keydown.enter="navigateBack" tabindex="0">
<span class="vin-link navigate-back">Tilbake til {{ previousRoute.name }}</span>
</a>
<section v-if="winner">
<h2 class="name">{{ winner.name }}</h2>
<p class="win-count el-spacing">{{ numberOfWins }} vinn</p>
<h4 class="margin-bottom-0">Vinnende farger:</h4>
<div class="raffle-container el-spacing">
<div class="raffle-element" :class="color + `-raffle`" v-for="[color, occurences] in Object.entries(winningColors)">
{{ occurences }}
</div>
</div>
<h4 class="el-spacing">Flasker vunnet:</h4>
<div v-for="win in winner.highscore">
<router-link :to="winDateUrl(win.date)" class="days-ago">
{{ humanReadableDate(win.date) }} - {{ daysAgo(win.date) }} dager siden
</router-link>
<div class="won-wine">
<img :src="smallerWineImage(win.wine.image)">
<div class="won-wine-details">
<h3>{{ win.wine.name }}</h3>
<a :href="win.wine.vivinoLink" class="vin-link no-margin">
Les mer vinmonopolet.no
</a>
</div>
<div class="raffle-element small" :class="win.color + `-raffle`"></div>
</div>
</div>
</section>
<h2 v-else-if="error" class="error">
{{ error }}
</h2>
</div>
</div>
</template>
<script>
import { getWinnerByName } from "@/api";
import { humanReadableDate, daysAgo } from "@/utils";
export default {
data() {
return {
winner: undefined,
error: undefined,
previousRoute: {
default: true,
name: "topplisten",
path: "/highscore"
}
}
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.name !== null)
vm.previousRoute = from
})
},
computed: {
numberOfWins() {
return this.winner.highscore.length
}
},
created() {
const nameFromURL = this.$route.params.name;
getWinnerByName(nameFromURL)
.then(winner => this.setWinner(winner))
.catch(err => this.error = `Ingen med navn: "${nameFromURL}" funnet.`)
},
methods: {
setWinner(winner) {
this.winner = {
name: winner.name,
highscore: [],
...winner
}
this.winningColors = this.findWinningColors()
},
smallerWineImage(image) {
if (image && image.includes(`515x515`))
return image.replace(`515x515`, `175x175`)
return image
},
findWinningColors() {
const colors = this.winner.highscore.map(win => win.color)
const colorOccurences = {}
colors.forEach(color => {
if (colorOccurences[color] == undefined) {
colorOccurences[color] = 1
} else {
colorOccurences[color] += 1
}
})
return colorOccurences
},
winDateUrl(date) {
const timestamp = new Date(date).getTime();
return `/history/${timestamp}`
},
navigateBack() {
if (this.previousRoute.default) {
this.$router.push({ path: this.previousRoute.path });
} else {
this.$router.go(-1);
}
},
humanReadableDate: humanReadableDate,
daysAgo: daysAgo
}
}
</script>
<style lang="scss" scoped>
@import "./src/styles/variables";
@import "./src/styles/media-queries";
$elementSpacing: 3rem;
.el-spacing {
margin-bottom: $elementSpacing;
}
.navigate-back {
font-weight: normal;
font-size: 1.2rem;
border-width: 2px;
border-color: gray;
}
.container {
width: 90vw;
margin: 3rem auto;
margin-bottom: 0;
padding-bottom: 3rem;
max-width: 1200px;
@include desktop {
width: 80vw;
}
}
h1 {
font-size: 3rem;
font-family: "knowit";
font-weight: normal;
}
.name {
text-transform: capitalize;
font-size: 3.5rem;
font-family: "knowit";
font-weight: normal;
margin: 2rem 0 1rem 0;
}
.error {
font-size: 2.5rem;
font-weight: normal;
}
.win-count {
font-size: 1.5rem;
margin-top: 0;
}
.raffle-container {
display: flex;
margin-top: 1rem;
div:not(:last-of-type) {
margin-right: 1.5rem;
}
}
.raffle-element {
width: 5rem;
height: 4rem;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5rem;
margin-top: 0;
&.small {
height: 40px;
width: 40px;
}
}
.days-ago {
color: $matte-text-color;
border-bottom: 2px solid transparent;
&:hover {
border-color: $link-color;
}
}
.won-wine {
--spacing: 1rem;
background-color: white;
margin: var(--spacing) 0 3rem 0;
padding: var(--spacing);
position: relative;
@include desktop {
flex-direction: row;
}
img {
margin: 0 3rem;
height: 160px;
}
&-details {
vertical-align: top;
display: inline-block;
@include tablet {
width: calc(100% - 160px - 80px);
}
& > * {
width: 100%;
}
h3 {
font-size: 1.5rem;
font-weight: normal;
color: $matte-text-color;
}
a {
font-size: 1.2rem;
border-width: 2px;
font-weight: normal;
}
}
.raffle-element {
position: absolute;
top: calc(var(--spacing) * 2);
right: calc(var(--spacing) * 2);
margin: 0;
}
}
.backdrop {
$background: rgb(244,244,244);
--padding: 2rem;
@include desktop {
--padding: 5rem;
}
background-color: $background;
padding: var(--padding);
}
</style>

View File

@@ -11,6 +11,7 @@
<script> <script>
import { page, event } from "vue-analytics"; import { page, event } from "vue-analytics";
import { prelottery } from "@/api";
import Banner from "@/ui/Banner"; import Banner from "@/ui/Banner";
import Wine from "@/ui/Wine"; import Wine from "@/ui/Wine";
@@ -25,8 +26,7 @@ export default {
}; };
}, },
async mounted() { async mounted() {
const _wines = await fetch("/api/wines/prelottery"); prelottery().then(wines => this.wines = wines);
this.wines = await _wines.json();
} }
}; };
</script> </script>

View File

@@ -13,7 +13,7 @@
/> />
</section> </section>
<div class="to-lottery-container"> <div class="to-lottery-container">
<a href="#/lottery" class="to-lottery">Vil du til lotteriet?<span class="vin-link">Trykk her</span></a> <router-link to="/lottery" class="to-lottery">Vil du til lotteriet?<span class="vin-link">Trykk her</span></router-link>
</div> </div>
<section class="chart-container"> <section class="chart-container">
<PurchaseGraph class="purchase" /> <PurchaseGraph class="purchase" />

View File

@@ -18,7 +18,7 @@
<h2 v-if="winners.length > 0">Vinnere</h2> <h2 v-if="winners.length > 0">Vinnere</h2>
<div class="winners" v-if="winners.length > 0"> <div class="winners" v-if="winners.length > 0">
<div class="winner" v-for="(winner, index) in winners" :key="index"> <div class="winner" v-for="(winner, index) in winners" :key="index">
<div :class="winner.color + '-ballot'" class="ballot-element"> <div :class="winner.color + '-raffle'" class="raffle-element">
<span>{{ winner.name }}</span> <span>{{ winner.name }}</span>
<span>{{ winner.phoneNumber }}</span> <span>{{ winner.phoneNumber }}</span>
<span>Rød: {{ winner.red }}</span> <span>Rød: {{ winner.red }}</span>
@@ -47,11 +47,11 @@
<span class="name">{{ attendee.name }}</span> <span class="name">{{ attendee.name }}</span>
<span class="phoneNumber">{{ attendee.phoneNumber }}</span> <span class="phoneNumber">{{ attendee.phoneNumber }}</span>
</div> </div>
<div class="ballots-container"> <div class="raffles-container">
<div class="red-ballot ballot-element small">{{ attendee.red }}</div> <div class="red-raffle raffle-element small">{{ attendee.red }}</div>
<div class="blue-ballot ballot-element small">{{ attendee.blue }}</div> <div class="blue-raffle raffle-element small">{{ attendee.blue }}</div>
<div class="green-ballot ballot-element small">{{ attendee.green }}</div> <div class="green-raffle raffle-element small">{{ attendee.green }}</div>
<div class="yellow-ballot ballot-element small">{{ attendee.yellow }}</div> <div class="yellow-raffle raffle-element small">{{ attendee.yellow }}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -140,7 +140,7 @@ export default {
blue: 0, blue: 0,
green: 0, green: 0,
yellow: 0, yellow: 0,
ballots: 0, raffles: 0,
randomColors: false, randomColors: false,
attendees: [], attendees: [],
winners: [], winners: [],
@@ -197,7 +197,7 @@ export default {
blue: this.blue, blue: this.blue,
green: this.green, green: this.green,
yellow: this.yellow, yellow: this.yellow,
ballots: this.ballots raffles: this.raffles
}); });
if (response == true) { if (response == true) {
@@ -354,7 +354,7 @@ hr {
} }
} }
.ballot-element { .raffle-element {
width: 140px; width: 140px;
height: 150px; height: 150px;
margin: 20px 0; margin: 20px 0;
@@ -378,19 +378,19 @@ hr {
font-size: 1rem; font-size: 1rem;
} }
&.green-ballot { &.green-raffle {
background-color: $light-green; background-color: $light-green;
} }
&.blue-ballot { &.blue-raffle {
background-color: $light-blue; background-color: $light-blue;
} }
&.yellow-ballot { &.yellow-raffle {
background-color: $light-yellow; background-color: $light-yellow;
} }
&.red-ballot { &.red-raffle {
background-color: $light-red; background-color: $light-red;
} }
} }
@@ -422,7 +422,7 @@ button {
margin: 0 auto; margin: 0 auto;
& .name-and-phone, & .name-and-phone,
& .ballots-container { & .raffles-container {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
@@ -431,7 +431,7 @@ button {
flex-direction: column; flex-direction: column;
} }
& .ballots-container { & .raffles-container {
flex-direction: row; flex-direction: row;
} }
} }

View File

@@ -29,7 +29,7 @@
</template> </template>
<script> <script>
import { getAmIWinner, postWineChosen } from "@/api"; import { getAmIWinner, postWineChosen, prelottery } from "@/api";
import Wine from "@/ui/Wine"; import Wine from "@/ui/Wine";
export default { export default {
components: { Wine }, components: { Wine },
@@ -60,8 +60,7 @@ export default {
} }
this.turn = true; this.turn = true;
this.name = winnerObject.name; this.name = winnerObject.name;
const _wines = await fetch("/api/wines/prelottery"); this.wines = await prelottery();
this.wines = await _wines.json();
}, },
methods: { methods: {
chosenWine: async function(name) { chosenWine: async function(name) {

View File

@@ -1,3 +1,5 @@
import VueRouter from "vue-router";
import VinlottisPage from "@/components/VinlottisPage"; import VinlottisPage from "@/components/VinlottisPage";
import GeneratePage from "@/components/GeneratePage"; import GeneratePage from "@/components/GeneratePage";
import TodaysPage from "@/components/TodaysPage"; import TodaysPage from "@/components/TodaysPage";
@@ -12,6 +14,7 @@ import WinnerPage from "@/components/WinnerPage";
import LotteryPage from "@/components/LotteryPage"; import LotteryPage from "@/components/LotteryPage";
import HistoryPage from "@/components/HistoryPage"; import HistoryPage from "@/components/HistoryPage";
import HighscorePage from "@/components/HighscorePage"; import HighscorePage from "@/components/HighscorePage";
import PersonalHighscorePage from "@/components/PersonalHighscorePage";
import RequestWine from "@/components/RequestWine"; import RequestWine from "@/components/RequestWine";
import AllRequestedWines from "@/components/AllRequestedWines"; import AllRequestedWines from "@/components/AllRequestedWines";
@@ -19,30 +22,37 @@ import AllRequestedWines from "@/components/AllRequestedWines";
const routes = [ const routes = [
{ {
path: "*", path: "*",
name: "Hjem",
component: VinlottisPage component: VinlottisPage
}, },
{ {
path: "/lottery", path: "/lottery",
name: "Lotteri",
component: LotteryPage component: LotteryPage
}, },
{ {
path: "/dagens", path: "/dagens",
name: "Dagens vin",
component: TodaysPage component: TodaysPage
}, },
{ {
path: "/viner", path: "/viner",
name: "Alle viner",
component: AllWinesPage component: AllWinesPage
}, },
{ {
path: "/login", path: "/login",
name: "Login",
component: LoginPage component: LoginPage
}, },
{ {
path: "/create", path: "/create",
name: "Registrer",
component: CreatePage component: CreatePage
}, },
{ {
path: "/admin", path: "/admin",
name: "Admin",
component: AdminPage component: AdminPage
}, },
{ {
@@ -54,21 +64,40 @@ const routes = [
component: WinnerPage component: WinnerPage
}, },
{ {
path: "/history", path: "/history/:date",
name: "Historie for dato",
component: HistoryPage component: HistoryPage
}, },
{
path: "/history/",
name: "Historie",
component: HistoryPage
},
{
path: "/highscore/:name",
name: "Personlig toppliste",
component: PersonalHighscorePage
},
{ {
path: "/highscore", path: "/highscore",
name: "Topplisten",
component: HighscorePage component: HighscorePage
}, },
{ {
path: "/request", path: "/request",
name: "Etterspør vin",
component: RequestWine component: RequestWine
}, },
{ {
path: "/requested-wines", path: "/requested-wines",
name: "Etterspurte viner",
component: AllRequestedWines component: AllRequestedWines
} }
]; ];
export { routes }; const router = new VueRouter({
routes: routes,
mode: "history"
});
export default router;

View File

@@ -18,6 +18,10 @@ body {
margin: 0; margin: 0;
} }
a {
text-decoration: none;
}
.title { .title {
text-align: center; text-align: center;
width: fit-content; width: fit-content;
@@ -129,6 +133,15 @@ textarea {
// disable-dbl-tap-zoom // disable-dbl-tap-zoom
touch-action: manipulation; touch-action: manipulation;
&.auto-height {
height: auto;
}
&.danger {
background-color: $red;
color: white;
}
&::after { &::after {
content: ""; content: "";
position: absolute; position: absolute;
@@ -172,7 +185,14 @@ textarea {
font-weight: bold; font-weight: bold;
border-bottom: 1px solid $link-color; border-bottom: 1px solid $link-color;
font-size: 1rem; font-size: 1rem;
margin-left: 15px; cursor: pointer;
text-decoration: none;
color: $matte-text-color;
&:focus, &:hover {
border-color: $link-color;
}
} }
@@ -180,8 +200,35 @@ textarea {
&-md { &-md {
margin-top: 3rem; margin-top: 3rem;
} }
&-sm {
margin-top: 1rem;
}
&-0 {
margin-top: 0;
}
}
.margin-left {
&-md {
margin-left: 3rem;
}
&-sm {
margin-left: 1rem;
}
&-0 {
margin-left: 0;
}
}
.margin-right {
&-md {
margin-right: 3rem;
}
&-sm {
margin-right: 1rem;
}
&-0 {
margin-right: 0;
}
} }
.margin-bottom { .margin-bottom {
&-md { &-md {
margin-bottom: 3rem; margin-bottom: 3rem;
@@ -199,7 +246,7 @@ textarea {
margin: 0 !important; margin: 0 !important;
} }
.ballot-element { .raffle-element {
margin: 20px 0; margin: 20px 0;
-webkit-mask-image: url(/../../public/assets/images/lodd.svg); -webkit-mask-image: url(/../../public/assets/images/lodd.svg);
background-repeat: no-repeat; background-repeat: no-repeat;
@@ -208,19 +255,31 @@ textarea {
mask-repeat: no-repeat; mask-repeat: no-repeat;
color: #333333; color: #333333;
&.green-ballot { &.green-raffle {
background-color: $light-green; background-color: $light-green;
} }
&.blue-ballot { &.blue-raffle {
background-color: $light-blue; background-color: $light-blue;
} }
&.yellow-ballot { &.yellow-raffle {
background-color: $light-yellow; background-color: $light-yellow;
} }
&.red-ballot { &.red-raffle {
background-color: $light-red; background-color: $light-red;
} }
} }
.desktop-only {
@include mobile {
display: none;
}
}
.mobile-only {
@include desktop {
display: none;
}
}

View File

@@ -1,6 +1,6 @@
$mobile-width: 768px; $mobile-width: 768px;
$tablet-max: 1200px; $tablet-max: 1200px;
$desktop-max: 1704; $desktop-max: 2004px;
@mixin mobile { @mixin mobile {
@@ -15,7 +15,6 @@ $desktop-max: 1704;
} }
} }
@mixin desktop { @mixin desktop {
@media (min-width: #{$tablet-max + 1px}) { @media (min-width: #{$tablet-max + 1px}) {
@content; @content;

View File

@@ -1,23 +1,46 @@
.flex { .flex {
display: flex; display: flex;
& .column { &.column {
flex-direction: column; flex-direction: column;
} }
& .row { &.row {
flex-direction: row; flex-direction: row;
} }
& .wrap { &.wrap {
flex-wrap: wrap; flex-wrap: wrap;
} }
&.justify-center { &.justify-center {
justify-content: center; justify-content: center;
} }
&.justify-space-between {
justify-content: space-between;
}
&.justify-end {
justify-content: flex-end;
}
&.justify-start {
justify-content: flex-start;
}
&.align-center { &.align-center {
align-items: center; align-items: center;
} }
}
.inline-block {
display: inline-block;
}
.float {
&-left {
float: left;
}
&-right {
float: right;
}
} }

View File

@@ -1,4 +1,4 @@
$primary: #dbeede; $primary: #b7debd;
$light-green: #c8f9df; $light-green: #c8f9df;
$green: #0be881; $green: #0be881;
@@ -16,4 +16,6 @@ $light-red: #fbd7de;
$red: #ef5878; $red: #ef5878;
$dark-red: #ec3b61; $dark-red: #ec3b61;
$link-color: #ff5fff; $link-color: #ff5fff;
$matte-text-color: #333333;

View File

@@ -4,10 +4,10 @@
<div class="attendees-container" ref="attendees"> <div class="attendees-container" ref="attendees">
<div class="attendee" v-for="(attendee, index) in flipList(attendees)" :key="index"> <div class="attendee" v-for="(attendee, index) in flipList(attendees)" :key="index">
<span class="attendee-name">{{ attendee.name }}</span> <span class="attendee-name">{{ attendee.name }}</span>
<div class="red-ballot ballot-element small">{{ attendee.red }}</div> <div class="red-raffle ballot-element small">{{ attendee.red }}</div>
<div class="blue-ballot ballot-element small">{{ attendee.blue }}</div> <div class="blue-raffle ballot-element small">{{ attendee.blue }}</div>
<div class="green-ballot ballot-element small">{{ attendee.green }}</div> <div class="green-raffle ballot-element small">{{ attendee.green }}</div>
<div class="yellow-ballot ballot-element small">{{ attendee.yellow }}</div> <div class="yellow-raffle ballot-element small">{{ attendee.yellow }}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -46,7 +46,7 @@ export default {
width: 60%; width: 60%;
} }
.ballot-element { .raffle-element {
font-size: 0.75rem; font-size: 0.75rem;
width: 45px; width: 45px;
height: 45px; height: 45px;

View File

@@ -8,7 +8,7 @@
color.name + color.name +
'-container ' + '-container ' +
color.name + color.name +
'-ballot inner-bought-container ballot-element' '-raffle inner-bought-container ballot-element'
" "
:key="color.name" :key="color.name"
> >
@@ -24,7 +24,7 @@
</div> </div>
</div> </div>
<div class="inner-bought-container total-ballots"> <div class="inner-bought-container total-raffles">
<div class="total-container"> <div class="total-container">
Totalt&nbsp; Totalt&nbsp;
<div> <div>
@@ -136,7 +136,7 @@ export default {
align-items: center; align-items: center;
} }
.ballot-element { .raffle-element {
width: 140px; width: 140px;
height: 150px; height: 150px;
margin: 20px 0; margin: 20px 0;
@@ -166,7 +166,7 @@ export default {
} }
} }
.total-ballots { .total-raffles {
width: 150px; width: 150px;
height: 150px; height: 150px;
margin: 20px 0; margin: 20px 0;

View File

@@ -3,7 +3,7 @@
<div class="current-draw" v-if="drawing"> <div class="current-draw" v-if="drawing">
<h2>TREKKER</h2> <h2>TREKKER</h2>
<div <div
:class="currentColor + '-ballot'" :class="currentColor + '-raffle'"
class="ballot-element center-new-winner" class="ballot-element center-new-winner"
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }" :style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
> >
@@ -19,7 +19,7 @@
<div class="current-draw" v-if="drawingDone"> <div class="current-draw" v-if="drawingDone">
<h2>VINNER</h2> <h2>VINNER</h2>
<div <div
:class="currentColor + '-ballot'" :class="currentColor + '-raffle'"
class="ballot-element center-new-winner" class="ballot-element center-new-winner"
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }" :style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
> >
@@ -204,7 +204,7 @@ h2 {
align-items: center; align-items: center;
} }
.ballot-element { .raffle-element {
width: 140px; width: 140px;
height: 140px; height: 140px;
font-size: 1.2rem; font-size: 1.2rem;

View File

@@ -42,7 +42,7 @@ h2 {
flex-wrap: wrap; flex-wrap: wrap;
} }
.ballot-element { .raffle-element {
font-size: 1rem; font-size: 1rem;
width: 145px; width: 145px;
height: 145px; height: 145px;

View File

@@ -7,6 +7,18 @@ const dateString = (date) => {
return `${ye}-${mo}-${da}` return `${ye}-${mo}-${da}`
} }
module.exports = { function humanReadableDate(date) {
dateString const options = { year: 'numeric', month: 'long', day: 'numeric' };
return new Date(date).toLocaleDateString(undefined, options);
}
function daysAgo(date) {
const day = 24 * 60 * 60 * 1000;
return Math.round(Math.abs((new Date() - new Date(date)) / day));
}
module.exports = {
dateString,
humanReadableDate,
daysAgo
} }

View File

@@ -1,6 +1,6 @@
import Vue from "vue"; import Vue from "vue";
import VueRouter from "vue-router"; import VueRouter from "vue-router";
import { routes } from "@/router.js"; import VinlottisRouter from "@/router.js";
import Vinlottis from "@/Vinlottis"; import Vinlottis from "@/Vinlottis";
import VueAnalytics from "vue-analytics"; import VueAnalytics from "vue-analytics";
@@ -9,13 +9,9 @@ Vue.use(VueAnalytics, {
id: "UA-156846886-1" id: "UA-156846886-1"
}); });
const router = new VueRouter({
routes: routes
});
new Vue({ new Vue({
el: "#app", el: "#app",
router, router: VinlottisRouter,
components: { Vinlottis }, components: { Vinlottis },
template: "<Vinlottis/>", template: "<Vinlottis/>",
render: h => h(Vinlottis) render: h => h(Vinlottis)