Toggle the new sidebar
This commit is contained in:
parent
08b816f3fd
commit
879db2000b
|
|
@ -1,8 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="user-widget" :class="{'user-widget--is-profile': isProfile}">
|
<div class="user-widget" :class="{'user-widget--is-profile': isProfile}">
|
||||||
<div class="user-widget__avatar" @click="toggleShowPopover()">
|
<div class="user-widget__avatar" @click="openSidebar()">
|
||||||
<avatar :avatar-url="avatarUrl" :icon-highlighted="isProfile"/>
|
<avatar :avatar-url="avatarUrl" :icon-highlighted="isProfile"/>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- todo: migrate and remove -->
|
||||||
<widget-popover v-if="showPopover && showMenu"
|
<widget-popover v-if="showPopover && showMenu"
|
||||||
@hide-me="showPopover = false"
|
@hide-me="showPopover = false"
|
||||||
:mobile="mobile"
|
:mobile="mobile"
|
||||||
|
|
@ -27,6 +28,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LOGOUT_MUTATION from '@/graphql/gql/mutations/logoutUser.gql';
|
import LOGOUT_MUTATION from '@/graphql/gql/mutations/logoutUser.gql';
|
||||||
|
import TOGGLE_SIDEBAR from '@/graphql/gql/local/mutations/toggleSidebar.gql';
|
||||||
import Avatar from '@/components/profile/Avatar';
|
import Avatar from '@/components/profile/Avatar';
|
||||||
import WidgetPopover from '@/components/WidgetPopover';
|
import WidgetPopover from '@/components/WidgetPopover';
|
||||||
|
|
||||||
|
|
@ -58,6 +60,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
openSidebar() {
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: TOGGLE_SIDEBAR,
|
||||||
|
variables: {
|
||||||
|
open: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// todo: remove
|
||||||
toggleShowPopover() {
|
toggleShowPopover() {
|
||||||
if (this.showMenu) {
|
if (this.showMenu) {
|
||||||
this.showPopover = !this.showPopover;
|
this.showPopover = !this.showPopover;
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,10 @@ export default function (uri) {
|
||||||
scrollPosition: {
|
scrollPosition: {
|
||||||
__typename: 'ScrollPosition',
|
__typename: 'ScrollPosition',
|
||||||
scrollTo: ''
|
scrollTo: ''
|
||||||
|
},
|
||||||
|
sidebar: {
|
||||||
|
__typename: 'Sidebar',
|
||||||
|
open: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
mutation($open: Boolean!) {
|
||||||
|
toggleSidebar(open: $open) @client
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
query Sidebar {
|
||||||
|
sidebar @client {
|
||||||
|
open
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import SCROLL_POSITION from '@/graphql/gql/local/scrollPosition.gql';
|
import SCROLL_POSITION from '@/graphql/gql/local/scrollPosition.gql';
|
||||||
|
import SIDEBAR from '@/graphql/gql/local/sidebar.gql';
|
||||||
|
|
||||||
export const resolvers = {
|
export const resolvers = {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
|
|
@ -7,6 +8,12 @@ export const resolvers = {
|
||||||
data.scrollPosition.scrollTo = scrollTo;
|
data.scrollPosition.scrollTo = scrollTo;
|
||||||
cache.writeQuery({query: SCROLL_POSITION, data});
|
cache.writeQuery({query: SCROLL_POSITION, data});
|
||||||
return data.scrollPosition;
|
return data.scrollPosition;
|
||||||
|
},
|
||||||
|
toggleSidebar: (_, {open}, {cache}) => {
|
||||||
|
const data = cache.readQuery({query: SIDEBAR});
|
||||||
|
data.sidebar.open = open;
|
||||||
|
cache.writeQuery({query: SIDEBAR, data});
|
||||||
|
return data.sidebar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ export const typeDefs = gql`
|
||||||
scrollTo: String!
|
scrollTo: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Sidebar {
|
||||||
|
open: Boolean!
|
||||||
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
scrollTo(scrollTo: String!): ScrollPosition
|
scrollTo(scrollTo: String!): ScrollPosition
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue