hippofish/packages/frontend/src/ui/_common_/navbar-for-mobile.vue

271 lines
6.6 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
2023-05-31 06:41:38 +02:00
<div :class="$style.root">
<div :class="$style.top">
<div :class="$style.banner" :style="{ backgroundImage: `url(${ instance.bannerUrl })` }"></div>
<button class="_button" :class="$style.instance" @click="openInstanceMenu">
<img :src="instance.iconUrl || instance.faviconUrl || '/favicon.ico'" alt="" :class="$style.instanceIcon"/>
</button>
</div>
<div :class="$style.middle">
<MkA :class="$style.item" :activeClass="$style.active" to="/" exact>
2023-09-30 21:53:52 +02:00
<i :class="$style.itemIcon" class="ph-house ph-bold ph-lg ti-fw"></i><span :class="$style.itemText">{{ i18n.ts.timeline }}</span>
2023-05-31 06:41:38 +02:00
</MkA>
<template v-for="item in menu">
<div v-if="item === '-'" :class="$style.divider"></div>
<component :is="navbarItemDef[item].to ? 'MkA' : 'button'" v-else-if="navbarItemDef[item] && (navbarItemDef[item].show !== false)" class="_button" :class="[$style.item, { [$style.active]: navbarItemDef[item].active }]" :activeClass="$style.active" :to="navbarItemDef[item].to" v-on="navbarItemDef[item].action ? { click: navbarItemDef[item].action } : {}">
<i class="ti-fw" :class="[$style.itemIcon, navbarItemDef[item].icon]"></i><span :class="$style.itemText">{{ navbarItemDef[item].title }}</span>
<span v-if="navbarItemDef[item].indicated" :class="$style.itemIndicator">
<span v-if="navbarItemDef[item].indicateValue" class="_indicateCounter" :class="$style.itemIndicateValueIcon">{{ navbarItemDef[item].indicateValue }}</span>
<i v-else class="_indicatorCircle"></i>
</span>
2023-05-31 06:41:38 +02:00
</component>
</template>
<div :class="$style.divider"></div>
<MkA v-if="$i.isAdmin || $i.isModerator" :class="$style.item" :activeClass="$style.active" to="/admin">
2023-09-30 21:53:52 +02:00
<i :class="$style.itemIcon" class="ph-gauge ph-bold pg-lg ti-fw"></i><span :class="$style.itemText">{{ i18n.ts.controlPanel }}</span>
2023-05-31 06:41:38 +02:00
</MkA>
<button :class="$style.item" class="_button" @click="more">
2023-10-01 00:46:42 +02:00
<i :class="$style.itemIcon" class="ph-dots-nine ph-bold ph-lg ti-fw"></i><span :class="$style.itemText">{{ i18n.ts.more }}</span>
2023-05-31 06:41:38 +02:00
<span v-if="otherMenuItemIndicated" :class="$style.itemIndicator"><i class="_indicatorCircle"></i></span>
</button>
<MkA :class="$style.item" :activeClass="$style.active" to="/settings">
2023-09-30 21:53:52 +02:00
<i :class="$style.itemIcon" class="ph-gear ph-bold pg-lg ti-fw"></i><span :class="$style.itemText">{{ i18n.ts.settings }}</span>
2023-05-31 06:41:38 +02:00
</MkA>
</div>
<div :class="$style.bottom">
<button class="_button" :class="$style.post" data-cy-open-post-form @click="os.post">
2023-09-30 21:53:52 +02:00
<i :class="$style.postIcon" class="ph-pencil ph-bold ph-lg ti-fw"></i><span style="position: relative;">{{ i18n.ts.note }}</span>
2023-05-31 06:41:38 +02:00
</button>
<button class="_button" :class="$style.account" @click="openAccountMenu">
<MkAvatar :user="$i" :class="$style.avatar"/><MkAcct :class="$style.acct" class="_nowrap" :user="$i"/>
</button>
</div>
</div>
</template>
2022-07-15 15:09:05 +02:00
<script lang="ts" setup>
import { computed, defineAsyncComponent, toRef } from 'vue';
2022-12-28 05:29:42 +01:00
import { openInstanceMenu } from './common';
2023-09-19 09:37:43 +02:00
import * as os from '@/os.js';
import { navbarItemDef } from '@/navbar';
2023-09-19 09:37:43 +02:00
import { $i, openAccountMenu as openAccountMenu_ } from '@/account.js';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
2022-07-15 15:09:05 +02:00
const menu = toRef(defaultStore.state, 'menu');
const otherMenuItemIndicated = computed(() => {
for (const def in navbarItemDef) {
if (menu.value.includes(def)) continue;
if (navbarItemDef[def].indicated) return true;
}
return false;
});
2022-07-15 15:09:05 +02:00
function openAccountMenu(ev: MouseEvent) {
openAccountMenu_({
withExtraOperation: true,
}, ev);
}
function more() {
os.popup(defineAsyncComponent(() => import('@/components/MkLaunchPad.vue')), {}, {
2022-07-15 15:09:05 +02:00
}, 'closed');
}
</script>
2023-05-31 06:41:38 +02:00
<style lang="scss" module>
.root {
display: flex;
flex-direction: column;
}
2023-05-31 06:41:38 +02:00
.top {
position: sticky;
top: 0;
z-index: 1;
padding: 20px 0;
background: var(--X14);
-webkit-backdrop-filter: var(--blur, blur(8px));
backdrop-filter: var(--blur, blur(8px));
}
2023-05-31 06:41:38 +02:00
.banner {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
background-position: center center;
-webkit-mask-image: linear-gradient(0deg, rgba(0,0,0,0) 15%, rgba(0,0,0,0.75) 100%);
mask-image: linear-gradient(0deg, rgba(0,0,0,0) 15%, rgba(0,0,0,0.75) 100%);
}
2023-05-31 06:41:38 +02:00
.instance {
position: relative;
display: block;
text-align: center;
width: 100%;
}
2023-05-31 06:41:38 +02:00
.instanceIcon {
display: inline-block;
width: 38px;
aspect-ratio: 1;
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.bottom {
position: sticky;
bottom: 0;
padding: 20px 0;
background: var(--X14);
-webkit-backdrop-filter: var(--blur, blur(8px));
backdrop-filter: var(--blur, blur(8px));
}
2023-05-31 06:41:38 +02:00
.post {
position: relative;
display: block;
width: 100%;
height: 40px;
color: var(--fgOnAccent);
font-weight: bold;
text-align: left;
2023-05-31 06:41:38 +02:00
&:before {
content: "";
display: block;
width: calc(100% - 38px);
height: 100%;
margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 999px;
2023-05-31 06:41:38 +02:00
background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB));
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
&:hover, &.active {
&:before {
background: var(--accentLighten);
}
}
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.postIcon {
position: relative;
margin-left: 30px;
margin-right: 8px;
width: 32px;
}
2023-05-31 06:41:38 +02:00
.account {
position: relative;
display: flex;
align-items: center;
padding-left: 30px;
width: 100%;
text-align: left;
box-sizing: border-box;
margin-top: 16px;
}
2023-05-31 06:41:38 +02:00
.avatar {
display: block;
flex-shrink: 0;
position: relative;
width: 32px;
aspect-ratio: 1;
margin-right: 8px;
}
2023-02-09 16:34:49 +01:00
2023-05-31 06:41:38 +02:00
.acct {
display: block;
flex-shrink: 1;
padding-right: 8px;
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.middle {
flex: 1;
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.divider {
margin: 16px 16px;
border-top: solid 0.5px var(--divider);
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.item {
position: relative;
display: block;
padding-left: 24px;
line-height: 2.85rem;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 100%;
text-align: left;
box-sizing: border-box;
color: var(--navFg);
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
&:hover {
text-decoration: none;
color: var(--navHoverFg);
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
&.active {
color: var(--navActive);
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
&:hover, &.active {
&:before {
content: "";
display: block;
width: calc(100% - 24px);
height: 100%;
margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 999px;
2023-05-31 06:41:38 +02:00
background: var(--accentedBg);
}
}
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.itemIcon {
position: relative;
width: 32px;
margin-right: 8px;
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.itemIndicator {
position: absolute;
top: 0;
left: 20px;
color: var(--navIndicator);
font-size: 8px;
animation: blink 1s infinite;
&:has(.itemIndicateValueIcon) {
animation: none;
left: auto;
right: 20px;
}
2023-05-31 06:41:38 +02:00
}
2022-07-15 15:09:05 +02:00
2023-05-31 06:41:38 +02:00
.itemText {
position: relative;
font-size: 0.9em;
}
</style>