Skip to content

Commit

Permalink
Rewrite MenuButton component in TS
Browse files Browse the repository at this point in the history
  • Loading branch information
man90es committed Mar 7, 2024
1 parent 110b397 commit aaa6a6b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@babel/eslint-parser": "^7.23.10",
"@bakaso/fkclient": "^1.6.1",
"@types/node": "^20.11.16",
"@types/webpack-env": "^1.18.4",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-plugin-eslint": "^5.0.8",
"@vue/cli-plugin-pwa": "^5.0.8",
Expand Down
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

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

32 changes: 16 additions & 16 deletions src/components/misc/MenuButton.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<button @click="dispatchEvent">
<button @click="dispatchEvent" :class="$style.root">
<img class="icon" :src="src" />
</button>
</template>

<script setup>
<script setup lang="ts">
import { computed } from "vue"
import { useRoute, useRouter } from "vue-router"
import { useScroll } from "@/hooks/scroll"
import { useScroll } from "@/hooks"
import { useStore } from "vuex"
const props = defineProps({ icon: String })
const props = defineProps<{ icon: string }>()
const store = useStore()
const route = useRoute()
const router = useRouter()
Expand All @@ -20,15 +20,15 @@
const src = computed(() => images(`./${props.icon}.svg`))
function dispatchEvent() {
const boardName = Array.isArray(route.params.boardName) ? route.params.boardName[0] : route.params.boardName || undefined
const threadId = parseInt(Array.isArray(route.params.threadId) ? route.params.threadId[0] : route.params.threadId) || undefined
switch (props.icon) {
case "chat":
return window.emitter.emit("menu-chat-button-click", {
boardName: route.params.boardName,
threadId: parseInt(route.params.threadId),
threadNumber:
route.name === "thread"
? store.state.threads[parseInt(route.params.threadId)].head.number
: null,
boardName,
threadId,
threadNumber: route.name === "thread" && threadId ? store.state.threads[threadId].head.number : undefined,
})
case "star":
Expand All @@ -49,14 +49,14 @@
}
</script>

<style scoped>
button {
height: 3.5rem;
width: 3.5rem;
justify-content: center;
<style module>
.root {
align-items: center;
display: flex;
background-color: var(--card-color);
border: none;
display: flex;
height: 3.5rem;
justify-content: center;
width: 3.5rem;
}
</style>
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as useAPIHandlers } from "@/hooks/useAPIHandlers"
export * from "@/hooks/authHandler"
export * from "@/hooks/postLinkEventHandler"
export * from "@/hooks/scroll"
export * from "@/hooks/theme"

0 comments on commit aaa6a6b

Please sign in to comment.