Skip to content

Commit

Permalink
Get rid of lodash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
man90es committed Jan 21, 2024
1 parent 33ff0e2 commit 1f37680
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"date-fns": "^3.2.0",
"eslint": "^8.56.0",
"eslint-plugin-vue": "^9.20.1",
"lodash": "^4.17.21",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"sass": "^1.69.7",
Expand Down
32 changes: 14 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/pages/home/components/SearchHistoryCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<ContentCard v-if="store.history.length > 0">
<button :class="$style.button" :key="h.ts" @click="() => navigateToLeaderboard(h.region, h.name)" v-for="h of store.history">
{{ h.region }}
{{ capitalize(h.name) }}
{{ capitalise(h.name) }}
({{ formatDistanceToNow(h.ts) }} ago)
</button>
</ContentCard>
</template>

<script lang="ts" setup>
import { capitalize } from "lodash"
import { capitalise } from "@/utils"
import { ContentCard } from "@/components"
import { formatDistanceToNow } from "date-fns"
import { type RegionEnum } from "@/data"
Expand Down
4 changes: 2 additions & 2 deletions src/pages/leaderboard/LeaderboardPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup>
import { AddToCustomCard, LeaderboardCard, NavCard } from "./components"
import { capitalize } from "lodash"
import { capitalise } from "@/utils"
import { computed } from "vue"
import { FooterCard, HeaderCard } from "@/components"
import { routeNameEnum } from "@/router"
Expand All @@ -28,7 +28,7 @@
const store = useMainStore()
useHead({
title: computed(() => {
const guildName = capitalize(route.name === routeNameEnum.CUSTOM_LEADERBOARD ? "Custom" : route.params.guildName)
const guildName = capitalise(route.name === routeNameEnum.CUSTOM_LEADERBOARD ? "Custom" : route.params.guildName)
const discipline = ({
age: "account age",
characters: "number of characters",
Expand Down
4 changes: 1 addition & 3 deletions src/stores/useMainStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineStore } from "pinia"
import { RegionEnum } from "@/data"
import { take } from "lodash"

const useMainStore = defineStore("main", {
state: (): {
Expand Down Expand Up @@ -45,8 +44,7 @@ const useMainStore = defineStore("main", {
this.history.unshift({ ts, name, region })
}

const sortedHistory = this.history.toSorted((a, b) => a.ts < b.ts ? 1 : -1)
this.history = take(sortedHistory, 5)
this.history = this.history.toSorted((a, b) => a.ts < b.ts ? 1 : -1).slice(0, 5)
}
},
persist: { key: "leaderboards-vuex" },
Expand Down
3 changes: 3 additions & 0 deletions src/utils/capitalise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function capitalise(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as capitalise } from "./capitalise"

0 comments on commit 1f37680

Please sign in to comment.