Skip to content

Commit

Permalink
feat: added dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
juzraai committed Dec 12, 2021
1 parent 4a65773 commit e508869
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 39 deletions.
3 changes: 0 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# TODO list


## design: dark mode


## bug: chart tooltips use different date format


Expand Down
5 changes: 5 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div
class="d-flex flex-column"
:class="dark ? 'bg-dark text-light' : null"
style="min-height: 100%"
>
<Navbar />
Expand All @@ -14,6 +15,7 @@
</template>

<script>
import { mapState } from "vuex";
import Footer from "@/components/Footer.vue";
import Navbar from "@/components/Navbar.vue";
Expand All @@ -22,5 +24,8 @@ export default {
metaInfo: {
titleTemplate: "%s | TORN City Losers' Log",
},
computed: {
...mapState(["dark"]),
},
};
</script>
9 changes: 6 additions & 3 deletions src/components/BarChartWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
<Widget :cardTitle="cardTitle">
<div class="align-items-end d-flex flex-grow-1 position-relative">
<div
class="avg border border-info position-absolute w-100"
class="avg border position-absolute w-100"
:class="dark ? 'border-white' : 'border-info'"
:style="{ bottom: (100 * avg / max) + '%' }"
v-if="avg"
></div>
<div
class="bar flex-grow-1"
:class="bar.highlight ? 'bg-info' : null"
:class="bar.highlight && !dark ? 'bg-info' : null"
:key="i"
:style="{ backgroundColor: bar.color, height: 100 * bar.value / max + '%' }"
:title="bar.label"
Expand All @@ -20,15 +21,17 @@
</template>

<script>
import { mapState } from "vuex";
import Widget from "@/components/Widget.vue";
export default {
components: { Widget },
props: ["avg", "bars", "cardTitle"],
computed: {
...mapState(["dark"]),
barsAug() {
return this.bars.map((bar) => {
bar.color = `rgba(0, 123, 255, ${0.25 + 0.75 * bar.value / this.max})`;
bar.color = `rgba(${this.dark ? '255, 255, 255' : '0, 123, 255'}, ${0.25 + 0.75 * bar.value / this.max})`;
return bar;
});
},
Expand Down
10 changes: 9 additions & 1 deletion src/components/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="bg-dark text-light">
<div
class="bg-dark text-light"
:class="dark ? 'border-top border-secondary' : null"
>
<div class="container my-3">
<div class="row">
<div class="col-md-4 mb-4 mb-md-0">
Expand Down Expand Up @@ -40,13 +43,18 @@
</template>

<script>
import { mapState } from "vuex";
export default {
data() {
return {
buildTime: null,
version: APP_VERSION,
};
},
computed: {
...mapState(["dark"]),
},
mounted() {
const t =
document
Expand Down
6 changes: 5 additions & 1 deletion src/components/KpiWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h6 class="card-title">
<slot name="mainLabel" />
</h6>
<h1 class="border-bottom font-weight-bold pb-2">
<h1 class="border-bottom font-weight-bold pb-2" :class="dark ? 'border-secondary' : null">
<slot name="mainValue" />
</h1>
<div class="row">
Expand All @@ -24,10 +24,14 @@
</template>

<script>
import { mapState } from "vuex";
import Widget from "@/components/Widget.vue";
export default {
components: { Widget },
props: ["labels", "values"],
computed: {
...mapState(["dark"]),
},
};
</script>
33 changes: 28 additions & 5 deletions src/components/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
No results.
</div>
<div v-else>
<div class="border-bottom list-group list-group-flush">
<div
class="border-bottom list-group list-group-flush"
:class="dark ? 'border-secondary' : null"
>
<LogEntry
:entry="e"
:key="entryKey(e)"
v-for="e in entriesOnPage"
/>
</div>
<div class="bg-light d-flex flex-wrap justify-content-center pt-3">
<div
class="d-flex flex-wrap justify-content-center pt-3"
:class="dark ? 'bg-dark' : 'bg-light'"
>
<ul class="pagination">
<li
class="page-item"
Expand All @@ -23,6 +29,7 @@
>
<a
class="page-link"
:class="dark ? 'bg-secondary border-dark text-light' : null"
href="javascript:void(0)"
>First</a>
</li>
Expand All @@ -33,11 +40,15 @@
>
<a
class="page-link"
:class="dark ? 'bg-secondary border-dark text-light' : null"
href="javascript:void(0)"
>Previous</a>
</li>
<li class="disabled page-item">
<span class="page-link">{{ page + 1 }} / {{ pageCount }}</span>
<span
class="page-link"
:class="dark ? 'bg-secondary border-dark text-light' : null"
>{{ page + 1 }} / {{ pageCount }}</span>
</li>
<li
class="page-item"
Expand All @@ -46,6 +57,7 @@
>
<a
class="page-link"
:class="dark ? 'bg-secondary border-dark text-light' : null"
href="javascript:void(0)"
>Next</a>
</li>
Expand All @@ -56,6 +68,7 @@
>
<a
class="page-link"
:class="dark ? 'bg-secondary border-dark text-light' : null"
href="javascript:void(0)"
>Last</a>
</li>
Expand All @@ -70,6 +83,7 @@
>
<a
class="page-link"
:class="dark && o != limit ? 'bg-dark border-secondary text-light' : null"
href="#"
>{{ o }}</a>
</li>
Expand All @@ -96,7 +110,7 @@ export default {
};
},
computed: {
...mapState(["tab"]),
...mapState(["dark", "tab"]),
offset() {
return this.limit * this.page;
},
Expand All @@ -109,7 +123,16 @@ export default {
},
methods: {
entryKey(a) {
return "t" + this.tab + "a" + (a.code || a.attacks[0].code) + "p" + a.paid + "$" + a.price;
return (
"t" +
this.tab +
"a" +
(a.code || a.attacks[0].code) +
"p" +
a.paid +
"$" +
a.price
);
},
},
watch: {
Expand Down
7 changes: 5 additions & 2 deletions src/components/LogEntry.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="list-group-item px-2 py-1">
<div
class="list-group-item px-2 py-1"
:class="dark ? 'bg-dark text-light' : null"
>
<div class="align-items-center d-flex">
<LogEntryTimestamp
:entry="entry"
Expand Down Expand Up @@ -28,7 +31,7 @@ export default {
components: { LogEntryPaidButton, LogEntryText, LogEntryTimestamp, ProofBox },
props: ["entry"],
computed: {
...mapState(["tab"]),
...mapState(["dark", "tab"]),
proofBoxId() {
return this.entry.code || this.entry.attacks[0].code;
},
Expand Down
8 changes: 6 additions & 2 deletions src/components/LogEntryText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Player
class="font-weight-bold"
:id="entry.defender_id"
:variant="entry.paid ? 'muted' : 'dark'"
:variant="dark ? (entry.paid ? 'secondary' : 'light') : (entry.paid ? 'muted' : 'dark')"
/>
<span class="d-none d-md-inline mr-1">for</span>
<strong
Expand All @@ -34,6 +34,7 @@
</span>
<span
class="badge alert-success ml-2 px-2"
:class="dark ? 'bg-success' : 'alert-success'"
v-if="entry.paid"
>paid</span>
<span
Expand All @@ -46,13 +47,16 @@
</template>

<script>
import { mapActions } from "vuex";
import { mapActions, mapState } from "vuex";
import Player from "@/components/Player.vue";
import { formatPrice } from "@/services/tornFormat.js";
export default {
components: { Player },
props: ["entry"],
computed: {
...mapState(["dark"]),
},
methods: {
...mapActions(["setPrice"]),
doSetPrice() {
Expand Down
5 changes: 5 additions & 0 deletions src/components/LogEntryTimestamp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
>
<div
class="align-items-center d-none d-md-flex log-entry-timestamp mr-3 small text-primary"
:class="dark ? 'text-light' : 'text-primary'"
v-b-toggle="proofBoxId"
>
<div>
Expand All @@ -25,10 +26,14 @@
</template>

<script>
import { mapState } from "vuex";
import { formatTimestamp } from "@/services/tornFormat.js";
export default {
props: ["entry", "proofBoxId"],
computed: {
...mapState(["dark"]),
},
methods: {
formatTimestamp,
},
Expand Down
25 changes: 19 additions & 6 deletions src/components/LogWidget.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<template>
<Widget :card-body-class="'p-0'">
<ul class="bg-light mb-1 nav nav-tabs px-3 pt-3">
<ul
class="mb-1 nav nav-tabs px-3 pt-3"
:class="dark ? 'bg-dark border-secondary' : 'bg-light'"
>
<li
class="flex-grow-1 nav-item text-center"
:key="i"
Expand All @@ -10,7 +13,7 @@
>
<span
class="nav-link"
:class="i === tab ? 'active' : null"
:class="(i === tab ? 'active' : null) + ' ' + (dark && i === tab ? 'bg-secondary border-secondary text-white' : null)"
role="button"
@click="setTab(i)"
>
Expand All @@ -19,7 +22,10 @@
:class="t.icon"
></i>
<span class="d-none d-md-inline">{{ t.title }}</span>
<span class="font-weight-bold ml-1" v-if="i === 4">${{ formatPrice(unpaidTotal) }}</span>
<span
class="font-weight-bold ml-1"
v-if="i === 4"
>${{ formatPrice(unpaidTotal) }}</span>
</span>
</li>
</ul>
Expand Down Expand Up @@ -73,16 +79,23 @@ export default {
};
},
computed: {
...mapState(["tab"]),
...mapGetters(["losses", "sessions", "dailyClients", "clients", "unpaidClients", "unpaidTotal"]),
...mapState(["dark", "tab"]),
...mapGetters([
"losses",
"sessions",
"dailyClients",
"clients",
"unpaidClients",
"unpaidTotal",
]),
entries() {
const { losses, sessions, dailyClients, clients, unpaidClients } = this;
return [losses, sessions, dailyClients, clients, unpaidClients][this.tab];
},
},
methods: {
...mapMutations(["setTab"]),
formatPrice
formatPrice,
},
};
</script>
Expand Down
Loading

0 comments on commit e508869

Please sign in to comment.