Move navbar to buefy component

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-09-20 18:22:25 +02:00
parent abf3a58657
commit 525e379c67
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
4 changed files with 82 additions and 83 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="has-navbar-fixed-top"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">

View File

@ -1,86 +1,67 @@
<template> <template>
<nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation"> <b-navbar type="is-secondary" shadow wrapper-class="container">
<div class="container"> <template slot="brand">
<div class="navbar-brand"> <b-navbar-item tag="router-link" :to="{ name: 'Home' }"><logo /></b-navbar-item>
<router-link class="navbar-item" :to="{ name: 'Home' }"><logo /></router-link> </template>
<template slot="start">
<b-navbar-item tag="router-link" :to="{ name: EventRouteName.MY_EVENTS }">{{ $t('Events') }}</b-navbar-item>
</template>
<template slot="end">
<b-navbar-item tag="div">
<search-field />
</b-navbar-item>
<a <b-navbar-dropdown v-if="currentUser.isLoggedIn" right>
role="button" <template slot="label" v-if="currentActor" class="navbar-dropdown-profile">
class="navbar-burger burger" <figure class="image is-32x32" v-if="currentActor.avatar">
aria-label="menu" <img class="is-rounded" alt="avatarUrl" :src="currentActor.avatar.url">
aria-expanded="false" </figure>
data-target="navbarBasicExample" <span>{{ currentActor.preferredUsername }}</span>
@click="showNavbar = !showNavbar" :class="{ 'is-active': showNavbar }" </template>
>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div class="navbar-menu" :class="{ 'is-active': showNavbar }"> <b-navbar-item tag="span" v-for="identity in identities" v-if="identities.length > 0" :active="identity.id === currentActor.id">
<div class="navbar-end"> <span @click="setIdentity(identity)">
<div class="navbar-item"> <div class="media-left">
<search-field /> <figure class="image is-32x32" v-if="identity.avatar">
</div> <img class="is-rounded" :src="identity.avatar.url" alt="" />
<div class="navbar-item has-dropdown is-hoverable" v-if="currentUser.isLoggedIn">
<a
class="navbar-link"
v-if="currentActor"
>
<figure class="image is-24x24" v-if="currentActor.avatar">
<img alt="avatarUrl" :src="currentActor.avatar.url">
</figure> </figure>
<span>{{ currentActor.preferredUsername }}</span>
</a>
<div class="navbar-dropdown is-boxed">
<div v-for="identity in identities" v-if="identities.length > 0">
<a class="navbar-item" @click="setIdentity(identity)" :class="{ 'is-active': identity.id === currentActor.id }">
<div class="media-left">
<figure class="image is-24x24" v-if="identity.avatar">
<img class="is-rounded" :src="identity.avatar.url">
</figure>
</div>
<div class="media-content">
<h3>{{ identity.displayName() }}</h3>
</div>
</a>
<hr class="navbar-divider">
</div>
<a class="navbar-item">
<router-link :to="{ name: 'UpdateIdentity' }">{{ $t('My account') }}</router-link>
</a>
<a class="navbar-item">
<router-link :to="{ name: ActorRouteName.CREATE_GROUP }">{{ $t('Create group') }}</router-link>
</a>
<a class="navbar-item" v-if="currentUser.role === ICurrentUserRole.ADMINISTRATOR">
<router-link :to="{ name: AdminRouteName.DASHBOARD }">{{ $t('Administration') }}</router-link>
</a>
<a class="navbar-item" v-on:click="logout()">{{ $t('Log out') }}</a>
</div> </div>
</div>
<div class="navbar-item" v-else> <div class="media-content">
<div class="buttons"> <span>{{ identity.displayName() }}</span>
<router-link class="button is-primary" v-if="config && config.registrationsOpen" :to="{ name: 'Register' }">
<strong>{{ $t('Sign up') }}</strong>
</router-link>
<router-link class="button is-primary" :to="{ name: 'Login' }">{{ $t('Log in') }}</router-link>
</div> </div>
</div> </span>
<hr class="navbar-divider">
</b-navbar-item>
<b-navbar-item>
<router-link :to="{ name: 'UpdateIdentity' }">{{ $t('My account') }}</router-link>
</b-navbar-item>
<b-navbar-item>
<router-link :to="{ name: ActorRouteName.CREATE_GROUP }">{{ $t('Create group') }}</router-link>
</b-navbar-item>
<b-navbar-item v-if="currentUser.role === ICurrentUserRole.ADMINISTRATOR">
<router-link :to="{ name: AdminRouteName.DASHBOARD }">{{ $t('Administration') }}</router-link>
</b-navbar-item>
<b-navbar-item v-on:click="logout()">{{ $t('Log out') }}</b-navbar-item>
</b-navbar-dropdown>
<b-navbar-item v-else tag="div">
<div class="buttons">
<router-link class="button is-primary" v-if="config && config.registrationsOpen" :to="{ name: 'Register' }">
<strong>{{ $t('Sign up') }}</strong>
</router-link>
<router-link class="button is-light" :to="{ name: 'Login' }">{{ $t('Log in') }}</router-link>
</div> </div>
</div> </b-navbar-item>
</div> </template>
</nav> </b-navbar>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -97,6 +78,7 @@ import SearchField from '@/components/SearchField.vue';
import { ActorRouteName } from '@/router/actor'; import { ActorRouteName } from '@/router/actor';
import { AdminRouteName } from '@/router/admin'; import { AdminRouteName } from '@/router/admin';
import { RouteName } from '@/router'; import { RouteName } from '@/router';
import {EventRouteName} from "@/router/event";
@Component({ @Component({
apollo: { apollo: {
@ -133,6 +115,7 @@ export default class NavBar extends Vue {
ActorRouteName = ActorRouteName; ActorRouteName = ActorRouteName;
AdminRouteName = AdminRouteName; AdminRouteName = AdminRouteName;
EventRouteName = EventRouteName;
@Watch('currentActor') @Watch('currentActor')
async initializeListOfIdentities() { async initializeListOfIdentities() {
@ -167,6 +150,7 @@ export default class NavBar extends Vue {
} }
async setIdentity(identity: IPerson) { async setIdentity(identity: IPerson) {
console.log('setIdentity');
return await changeIdentity(this.$apollo.provider.defaultClient, identity); return await changeIdentity(this.$apollo.provider.defaultClient, identity);
} }
} }
@ -175,10 +159,26 @@ export default class NavBar extends Vue {
@import "../variables.scss"; @import "../variables.scss";
nav { nav {
border-bottom: solid 1px #0a0a0a; /*border-bottom: solid 1px #0a0a0a;*/
.navbar-item img { .navbar-dropdown .navbar-item {
max-height: 2.5em; cursor: pointer;
span {
display: inherit;
}
&.is-active {
background: $secondary;
}
img {
max-height: 2.5em;
}
}
.navbar-item.has-dropdown a.navbar-link figure {
margin-right: 0.75rem;
} }
} }
</style> </style>

View File

@ -24,7 +24,6 @@
<span>{{ $t('Create') }}</span> <span>{{ $t('Create') }}</span>
<b-icon icon="menu-down"></b-icon> <b-icon icon="menu-down"></b-icon>
</button> </button>
.organizerActor.id
<b-dropdown-item aria-role="listitem"> <b-dropdown-item aria-role="listitem">
<router-link :to="{ name: RouteName.CREATE_EVENT }">{{ $t('Event') }}</router-link> <router-link :to="{ name: RouteName.CREATE_EVENT }">{{ $t('Event') }}</router-link>
</b-dropdown-item> </b-dropdown-item>

View File

@ -2193,9 +2193,9 @@ browserslist@^4.0.0, browserslist@^4.3.4, browserslist@^4.5.4, browserslist@^4.6
node-releases "^1.1.29" node-releases "^1.1.29"
buefy@^0.8.2: buefy@^0.8.2:
version "0.8.2" version "0.8.4"
resolved "https://registry.yarnpkg.com/buefy/-/buefy-0.8.2.tgz#26bfc931c8c7fbe5a90d4b814a8205501eee816a" resolved "https://registry.yarnpkg.com/buefy/-/buefy-0.8.4.tgz#0c62d559e63aee8a18876ff90056f9a8b90f686f"
integrity sha512-fS4sXYE0ge7fN5tP9k67j1fSCS/yxbTrnEhJ5MBt89gcbmVe5x8/SAXdADjx5W4SdERtjKjE9mzoIoRb+ZC29Q== integrity sha512-hDUUKbKxQmtYlo/IPH9H+ewEN6KulpDxfNFIPvO5z3ukYqEG29psW6oFbJGisZDEIYGxqE2jMPcBOOjm8LxJVQ==
dependencies: dependencies:
bulma "0.7.5" bulma "0.7.5"