Skip to content

Commit

Permalink
update menu
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu committed Oct 24, 2023
1 parent a59b239 commit 09760f3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 48 deletions.
37 changes: 37 additions & 0 deletions src/components/MenuItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<div class="flex items-center rounded-lg bg-gray-200 px-4 py-2">
<router-link :to="localizedUrl(link)" v-if="link">
<div class="inline-flex items-center justify-center">
<span class="material-icons text-warmgray-600 mr-2 text-lg">{{
icon
}}</span>
<span class="text-warmgray-600 text-sm font-bold">{{ $t(title) }}</span>
</div>
</router-link>
<div class="inline-flex items-center justify-center" v-else>
<span class="material-icons text-warmgray-600 mr-2 text-lg">{{
icon
}}</span>
<span class="text-warmgray-600 text-sm font-bold">{{ $t(title) }}</span>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
props: {
link: {
type: String,
default: "",
},
icon: {
type: String,
required: true,
},
title: {
type: String,
required: true,
},
},
});
</script>
71 changes: 23 additions & 48 deletions src/components/MenuList.vue
Original file line number Diff line number Diff line change
@@ -1,58 +1,28 @@
<template>
<div class="flex flex-col space-y-1 bg-white p-4">
<div
class="flex items-center rounded-lg bg-gray-200 px-4 py-2"
<MenuItem
@click="handleClose"
link="/account"
icon="camera_alt"
title="menu.signin"
v-if="!store.state.user"
>
<router-link :to="localizedUrl('/account')">
<div class="inline-flex items-center justify-center">
<span class="material-icons text-warmgray-600 mr-2 text-lg"
>camera_alt</span
>
<span class="text-warmgray-600 text-sm font-bold">ログイン</span>
</div>
</router-link>
</div>
/>
<MenuItem @click="handleClose" link="/" icon="man" title="menu.top" />

<div
class="flex items-center rounded-lg bg-gray-200 px-4 py-2"
<MenuItem
@click="handleClose"
link="/mypage"
icon="camera_alt"
title="menu.mypage"
v-if="store.state.user"
>
<router-link :to="localizedUrl('/mypage')">
<div class="inline-flex items-center justify-center">
<span class="material-icons text-warmgray-600 mr-2 text-lg"
>camera_alt</span
>
<span class="text-warmgray-600 text-sm font-bold">マイページ</span>
</div>
</router-link>
</div>
/>

<div
class="flex items-center rounded-lg bg-gray-200 px-4 py-2"
@click="handleClose"
>
<router-link :to="localizedUrl('/')">
<div class="inline-flex items-center justify-center">
<span class="material-icons text-warmgray-600 mr-2 text-lg">man</span>
<span class="text-warmgray-600 text-sm font-bold">メニュー</span>
</div>
</router-link>
</div>

<div
class="flex items-center rounded-lg bg-gray-200 px-4 py-2"
<MenuItem
@click="logout"
>
<div class="inline-flex items-center justify-center">
<span class="material-icons text-warmgray-600 mr-2 text-lg"
>add_circle_outline</span
>
<span class="text-warmgray-600 text-sm font-bold">ログアウト</span>
</div>
</div>
icon="add_circle_outline"
title="menu.signout"
v-if="store.state.user"
/>
</div>
</template>

Expand All @@ -62,8 +32,13 @@ import { useStore } from "vuex";
import { auth } from "@/utils/firebase";
import { signOut } from "firebase/auth";
import MenuItem from "@/components/MenuItem.vue";
export default defineComponent({
emits: ["close-menu"],
components: {
MenuItem,
},
setup(_, ctx) {
const store = useStore();
Expand All @@ -76,8 +51,8 @@ export default defineComponent({
};
return {
handleClose,
logout,
store,
logout,
store,
};
},
});
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ const lang = {
message: {
hello: "hello world",
},
menu: {
top: "Home",
mypage: "MyPage",
signin: "SignIn",
signout: "SignOut",
about: "Abount",
},
languages,
};

Expand Down
7 changes: 7 additions & 0 deletions src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ const lang = {
message: {
hello: "こんにちは、世界",
},
menu: {
top: "Home",
mypage: "マイページ",
signin: "ログイン",
signout: "ログアウト",
about: "Abount",
},
languages,
};

Expand Down

0 comments on commit 09760f3

Please sign in to comment.