2018-02-14 06:53:52 +01:00
|
|
|
<template>
|
2018-02-23 15:30:30 +01:00
|
|
|
<div class="nav">
|
|
|
|
<transition name="back">
|
|
|
|
<div class="backdrop"
|
|
|
|
v-if="isOpen"
|
|
|
|
@click="$parent.isDrawerOpening = false"
|
|
|
|
@touchstart="$parent.isDrawerOpening = false"
|
|
|
|
></div>
|
|
|
|
</transition>
|
|
|
|
<transition name="nav">
|
|
|
|
<div class="body" v-if="isOpen">
|
2018-05-27 06:49:09 +02:00
|
|
|
<router-link class="me" v-if="$store.getters.isSignedIn" :to="`/@${$store.state.i.username}`">
|
2018-07-24 16:43:14 +02:00
|
|
|
<img class="avatar" :src="$store.state.i.avatarUrl" alt="avatar"/>
|
2018-12-06 08:09:33 +01:00
|
|
|
<p class="name"><mk-user-name :user="$store.state.i"/></p>
|
2018-02-23 15:30:30 +01:00
|
|
|
</router-link>
|
|
|
|
<div class="links">
|
|
|
|
<ul>
|
2018-11-23 22:56:30 +01:00
|
|
|
<li><router-link to="/" :data-active="$route.name == 'index'"><i><fa icon="home" fixed-width/></i>{{ $t('timeline') }}<i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li><router-link to="/i/notifications" :data-active="$route.name == 'notifications'"><i><fa :icon="['far', 'bell']" fixed-width/></i>{{ $t('notifications') }}<i v-if="hasUnreadNotification" class="circle"><fa icon="circle"/></i><i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li><router-link to="/i/messaging" :data-active="$route.name == 'messaging'"><i><fa :icon="['far', 'comments']" fixed-width/></i>{{ $t('@.messaging') }}<i v-if="hasUnreadMessagingMessage" class="circle"><fa icon="circle"/></i><i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li v-if="$store.getters.isSignedIn && ($store.state.i.isLocked || $store.state.i.carefulBot)"><router-link to="/i/received-follow-requests" :data-active="$route.name == 'received-follow-requests'"><i><fa :icon="['far', 'envelope']" fixed-width/></i>{{ $t('follow-requests') }}<i v-if="$store.getters.isSignedIn && $store.state.i.pendingReceivedFollowRequestsCount" class="circle"><fa icon="circle"/></i><i><fa icon="angle-right"/></i></router-link></li>
|
2019-02-14 22:31:03 +01:00
|
|
|
<li><router-link to="/featured" :data-active="$route.name == 'featured'"><i><fa :icon="faNewspaper" fixed-width/></i>{{ $t('@.featured-notes') }}<i><fa icon="angle-right"/></i></router-link></li>
|
2019-02-15 22:50:58 +01:00
|
|
|
<li><router-link to="/explore" :data-active="$route.name == 'explore'"><i><fa :icon="faHashtag" fixed-width/></i>{{ $t('@.explore') }}<i><fa icon="angle-right"/></i></router-link></li>
|
2019-01-21 07:19:43 +01:00
|
|
|
<li><router-link to="/games/reversi" :data-active="$route.name == 'reversi'"><i><fa icon="gamepad" fixed-width/></i>{{ $t('game') }}<i v-if="hasGameInvitation" class="circle"><fa icon="circle"/></i><i><fa icon="angle-right"/></i></router-link></li>
|
2018-02-23 15:30:30 +01:00
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-11-23 22:56:30 +01:00
|
|
|
<li><router-link to="/i/widgets" :data-active="$route.name == 'widgets'"><i><fa :icon="['far', 'calendar-alt']" fixed-width/></i>{{ $t('widgets') }}<i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li><router-link to="/i/favorites" :data-active="$route.name == 'favorites'"><i><fa icon="star" fixed-width/></i>{{ $t('favorites') }}<i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li><router-link to="/i/lists" :data-active="$route.name == 'user-lists'"><i><fa icon="list" fixed-width/></i>{{ $t('user-lists') }}<i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li><router-link to="/i/drive" :data-active="$route.name == 'drive'"><i><fa icon="cloud" fixed-width/></i>{{ $t('@.drive') }}<i><fa icon="angle-right"/></i></router-link></li>
|
2018-02-23 15:30:30 +01:00
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-11-23 22:56:30 +01:00
|
|
|
<li><a @click="search"><i><fa icon="search" fixed-width/></i>{{ $t('search') }}<i><fa icon="angle-right"/></i></a></li>
|
|
|
|
<li><router-link to="/i/settings" :data-active="$route.name == 'settings'"><i><fa icon="cog" fixed-width/></i>{{ $t('settings') }}<i><fa icon="angle-right"/></i></router-link></li>
|
|
|
|
<li v-if="$store.getters.isSignedIn && ($store.state.i.isAdmin || $store.state.i.isModerator)"><a href="/admin"><i><fa icon="terminal" fixed-width/></i><span>{{ $t('admin') }}</span><i><fa icon="angle-right"/></i></a></li>
|
|
|
|
<li @click="dark"><p><template v-if="$store.state.device.darkmode"><i><fa icon="moon" fixed-width/></i></template><template v-else><i><fa :icon="['far', 'moon']"/></i></template><span>{{ $t('darkmode') }}</span></p></li>
|
2018-02-23 15:30:30 +01:00
|
|
|
</ul>
|
|
|
|
</div>
|
2018-09-06 17:52:13 +02:00
|
|
|
<div class="announcements" v-if="announcements && announcements.length > 0">
|
2018-09-05 10:43:31 +02:00
|
|
|
<article v-for="announcement in announcements">
|
|
|
|
<span v-html="announcement.title" class="title"></span>
|
|
|
|
<div v-html="announcement.text"></div>
|
|
|
|
</article>
|
|
|
|
</div>
|
2018-11-08 19:44:35 +01:00
|
|
|
<a :href="aboutUrl"><p class="about">{{ $t('about') }}</p></a>
|
2018-02-14 06:53:52 +01:00
|
|
|
</div>
|
2018-02-23 15:30:30 +01:00
|
|
|
</transition>
|
2018-02-14 06:53:52 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../i18n';
|
2018-08-22 02:31:35 +02:00
|
|
|
import { lang } from '../../../config';
|
2019-02-15 22:50:58 +01:00
|
|
|
import { faNewspaper, faHashtag } from '@fortawesome/free-solid-svg-icons';
|
2018-02-14 06:53:52 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('mobile/views/components/ui.nav.vue'),
|
2018-02-21 23:06:47 +01:00
|
|
|
props: ['isOpen'],
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
data() {
|
|
|
|
return {
|
2018-05-28 18:22:39 +02:00
|
|
|
hasGameInvitation: false,
|
2018-02-14 06:53:52 +01:00
|
|
|
connection: null,
|
2018-09-05 10:43:31 +02:00
|
|
|
aboutUrl: `/docs/${lang}/about`,
|
2018-12-19 17:09:35 +01:00
|
|
|
announcements: [],
|
|
|
|
searching: false,
|
2019-02-15 22:50:58 +01:00
|
|
|
faNewspaper, faHashtag
|
2018-02-14 06:53:52 +01:00
|
|
|
};
|
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-05-28 18:22:39 +02:00
|
|
|
computed: {
|
|
|
|
hasUnreadNotification(): boolean {
|
|
|
|
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadNotification;
|
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-05-28 18:22:39 +02:00
|
|
|
hasUnreadMessagingMessage(): boolean {
|
|
|
|
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadMessagingMessage;
|
|
|
|
}
|
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
mounted() {
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.getMeta().then(meta => {
|
2018-09-05 10:43:31 +02:00
|
|
|
this.announcements = meta.broadcasts;
|
|
|
|
});
|
|
|
|
|
2018-05-27 06:49:09 +02:00
|
|
|
if (this.$store.getters.isSignedIn) {
|
2018-11-09 00:13:34 +01:00
|
|
|
this.connection = this.$root.stream.useSharedConnection('main');
|
2018-02-14 06:53:52 +01:00
|
|
|
|
2018-10-07 04:06:17 +02:00
|
|
|
this.connection.on('reversiInvited', this.onReversiInvited);
|
2018-12-09 15:10:02 +01:00
|
|
|
this.connection.on('reversiNoInvites', this.onReversiNoInvites);
|
2018-02-14 06:53:52 +01:00
|
|
|
}
|
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
beforeDestroy() {
|
2018-05-27 06:49:09 +02:00
|
|
|
if (this.$store.getters.isSignedIn) {
|
2018-10-07 04:06:17 +02:00
|
|
|
this.connection.dispose();
|
2018-02-14 06:53:52 +01:00
|
|
|
}
|
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
methods: {
|
|
|
|
search() {
|
2018-12-19 17:09:35 +01:00
|
|
|
if (this.searching) return;
|
|
|
|
|
2018-12-03 01:41:22 +01:00
|
|
|
this.$root.dialog({
|
|
|
|
title: this.$t('search'),
|
|
|
|
input: true
|
2018-12-19 17:09:35 +01:00
|
|
|
}).then(async ({ canceled, result: query }) => {
|
2018-12-03 01:41:22 +01:00
|
|
|
if (canceled) return;
|
2018-12-16 00:45:10 +01:00
|
|
|
|
2018-12-27 12:34:30 +01:00
|
|
|
const q = query.trim();
|
2018-12-16 00:45:10 +01:00
|
|
|
if (q.startsWith('@')) {
|
|
|
|
this.$router.push(`/${q}`);
|
|
|
|
} else if (q.startsWith('#')) {
|
|
|
|
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
2018-12-19 17:09:35 +01:00
|
|
|
} else if (q.startsWith('https://')) {
|
|
|
|
this.searching = true;
|
|
|
|
try {
|
|
|
|
const res = await this.$root.api('ap/show', {
|
|
|
|
uri: q
|
|
|
|
});
|
|
|
|
if (res.type == 'User') {
|
|
|
|
this.$router.push(`/@${res.object.username}@${res.object.host}`);
|
|
|
|
} else if (res.type == 'Note') {
|
|
|
|
this.$router.push(`/notes/${res.object.id}`);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
this.searching = false;
|
2018-12-16 00:45:10 +01:00
|
|
|
} else {
|
|
|
|
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
|
|
|
}
|
2018-12-03 01:41:22 +01:00
|
|
|
});
|
2018-02-14 06:53:52 +01:00
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-06-17 01:10:54 +02:00
|
|
|
onReversiInvited() {
|
2018-05-28 18:22:39 +02:00
|
|
|
this.hasGameInvitation = true;
|
2018-03-11 10:08:26 +01:00
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-06-17 01:10:54 +02:00
|
|
|
onReversiNoInvites() {
|
2018-05-28 18:22:39 +02:00
|
|
|
this.hasGameInvitation = false;
|
2018-04-27 19:29:17 +02:00
|
|
|
},
|
2018-09-05 10:43:31 +02:00
|
|
|
|
2018-04-27 19:29:17 +02:00
|
|
|
dark() {
|
2018-05-23 22:28:46 +02:00
|
|
|
this.$store.commit('device/set', {
|
|
|
|
key: 'darkmode',
|
|
|
|
value: !this.$store.state.device.darkmode
|
|
|
|
});
|
2018-02-14 06:53:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 04:23:30 +02:00
|
|
|
.nav
|
|
|
|
$color = var(--text)
|
2018-04-27 19:29:17 +02:00
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
.backdrop
|
|
|
|
position fixed
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1025
|
|
|
|
width 100%
|
|
|
|
height 100%
|
2018-09-28 04:23:30 +02:00
|
|
|
background var(--mobileNavBackdrop)
|
2018-02-14 06:53:52 +01:00
|
|
|
|
|
|
|
.body
|
|
|
|
position fixed
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1026
|
|
|
|
width 240px
|
|
|
|
height 100%
|
|
|
|
overflow auto
|
|
|
|
-webkit-overflow-scrolling touch
|
2018-09-28 04:23:30 +02:00
|
|
|
background var(--secondary)
|
2019-02-06 18:28:08 +01:00
|
|
|
font-size 15px
|
2018-02-14 06:53:52 +01:00
|
|
|
|
|
|
|
.me
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
.avatar
|
|
|
|
display inline
|
|
|
|
max-width 64px
|
|
|
|
border-radius 32px
|
|
|
|
vertical-align middle
|
|
|
|
|
|
|
|
.name
|
|
|
|
display block
|
|
|
|
margin 0 16px
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
left 80px
|
|
|
|
padding 0
|
|
|
|
width calc(100% - 112px)
|
2018-04-27 19:29:17 +02:00
|
|
|
color $color
|
2018-02-14 06:53:52 +01:00
|
|
|
line-height 96px
|
|
|
|
overflow hidden
|
|
|
|
text-overflow ellipsis
|
|
|
|
white-space nowrap
|
|
|
|
|
|
|
|
ul
|
|
|
|
display block
|
|
|
|
margin 16px 0
|
|
|
|
padding 0
|
|
|
|
list-style none
|
|
|
|
|
|
|
|
&:first-child
|
|
|
|
margin-top 0
|
|
|
|
|
2018-05-29 21:45:27 +02:00
|
|
|
&:last-child
|
|
|
|
margin-bottom 0
|
|
|
|
|
|
|
|
> li
|
2018-02-14 06:53:52 +01:00
|
|
|
display block
|
|
|
|
font-size 1em
|
|
|
|
line-height 1em
|
|
|
|
|
2018-04-27 19:29:17 +02:00
|
|
|
a, p
|
2018-02-14 06:53:52 +01:00
|
|
|
display block
|
2018-04-27 19:29:17 +02:00
|
|
|
margin 0
|
2018-02-14 06:53:52 +01:00
|
|
|
padding 0 20px
|
|
|
|
line-height 3rem
|
|
|
|
line-height calc(1rem + 30px)
|
2018-04-27 19:29:17 +02:00
|
|
|
color $color
|
2018-02-14 06:53:52 +01:00
|
|
|
text-decoration none
|
|
|
|
|
2018-04-27 19:29:17 +02:00
|
|
|
&[data-active]
|
2018-09-26 13:19:35 +02:00
|
|
|
color var(--primaryForeground)
|
|
|
|
background var(--primary)
|
2018-04-27 19:29:17 +02:00
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> i:last-child
|
2018-09-26 13:19:35 +02:00
|
|
|
color var(--primaryForeground)
|
2018-04-27 19:29:17 +02:00
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> i:first-child
|
2018-02-14 06:53:52 +01:00
|
|
|
margin-right 0.5em
|
2018-05-29 12:03:03 +02:00
|
|
|
width 20px
|
|
|
|
text-align center
|
2018-02-14 06:53:52 +01:00
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> i.circle
|
2018-02-14 06:53:52 +01:00
|
|
|
margin-left 6px
|
|
|
|
font-size 10px
|
2018-12-30 17:15:32 +01:00
|
|
|
color var(--notificationIndicator)
|
2018-02-14 06:53:52 +01:00
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> i:last-child
|
2018-02-14 06:53:52 +01:00
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
right 0
|
|
|
|
padding 0 20px
|
|
|
|
font-size 1.2em
|
|
|
|
line-height calc(1rem + 30px)
|
2018-04-27 19:29:17 +02:00
|
|
|
color $color
|
2018-04-28 05:00:58 +02:00
|
|
|
opacity 0.5
|
2018-02-14 06:53:52 +01:00
|
|
|
|
2018-09-05 10:43:31 +02:00
|
|
|
.announcements
|
|
|
|
> article
|
2018-09-27 18:05:09 +02:00
|
|
|
background var(--mobileAnnouncement)
|
|
|
|
color var(--mobileAnnouncementFg)
|
2018-09-05 10:43:31 +02:00
|
|
|
padding 16px
|
|
|
|
margin 8px 0
|
|
|
|
font-size 12px
|
|
|
|
|
|
|
|
> .title
|
|
|
|
font-weight bold
|
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
.about
|
2018-05-29 21:45:27 +02:00
|
|
|
margin 0 0 8px 0
|
2018-02-14 06:53:52 +01:00
|
|
|
padding 1em 0
|
|
|
|
text-align center
|
|
|
|
font-size 0.8em
|
2018-04-27 19:29:17 +02:00
|
|
|
color $color
|
2018-02-14 06:53:52 +01:00
|
|
|
opacity 0.5
|
|
|
|
|
2018-02-23 15:30:30 +01:00
|
|
|
.nav-enter-active,
|
|
|
|
.nav-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transform: translateX(0);
|
|
|
|
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.nav-enter,
|
|
|
|
.nav-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(-240px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.back-enter-active,
|
|
|
|
.back-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.back-enter,
|
|
|
|
.back-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2018-02-14 06:53:52 +01:00
|
|
|
</style>
|