Change drawer state
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2022-04-19 13:50:54 +02:00
parent 4ff5692789
commit 7a99ad1887
6 changed files with 24 additions and 23 deletions

View File

@ -1,5 +1,3 @@
<script setup> <script setup>
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
@ -10,14 +8,15 @@ const state = useState();
const user = state.getUser(); const user = state.getUser();
const token = session.getToken(); const token = session.getToken();
defineEmits(['toggle-drawer']); function onToggleDrawer() {
state.drawer.value = !state.drawer.value;
}
</script> </script>
<template> <template>
<q-header class="bg-dark" color="white" elevated bordered> <q-header class="bg-dark" color="white" elevated bordered>
<q-toolbar class="q-py-sm q-px-md"> <q-toolbar class="q-py-sm q-px-md">
<q-btn flat @click="$emit('toggle-drawer')" round dense icon="menu" /> <q-btn flat @click="onToggleDrawer()" round dense icon="menu" />
<router-link to="/"> <router-link to="/">
<q-btn flat round class="q-ml-xs" v-if="$q.screen.gt.xs"> <q-btn flat round class="q-ml-xs" v-if="$q.screen.gt.xs">
<q-avatar square size="md"> <q-avatar square size="md">

View File

@ -8,6 +8,8 @@ const user = ref({
const roles = ref([]); const roles = ref([]);
const drawer = ref(true);
export function useState() { export function useState() {
function getUser() { function getUser() {
return computed(() => { return computed(() => {
@ -42,5 +44,6 @@ export function useState() {
setUser, setUser,
getRoles, getRoles,
setRoles, setRoles,
drawer
}; };
} }

View File

@ -1,21 +1,12 @@
<script setup> <script setup>
// import { ref } from 'vue';
import Navbar from 'src/components/Navbar.vue'; import Navbar from 'src/components/Navbar.vue';
//import LeftMenu from 'src/components/LeftMenu.vue';
// const drawer = ref(false);
// const miniState = ref(true);
// function onToggleDrawer() {
// drawer.value = !drawer.value;
// }
</script> </script>
<template> <template>
<q-layout view="hHh lpR fFf"> <q-layout view="hHh lpR fFf">
<Navbar @toggle-drawer="onToggleDrawer()" /> <Navbar />
<router-view></router-view> <router-view></router-view>
</q-layout> </q-layout>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped></style>
</style>

View File

@ -1,9 +1,14 @@
<script setup>
import { useState } from 'src/composables/useState';
const state = useState();
</script>
<template> <template>
<q-drawer v-model="drawer" show-if-above :width="200" :breakpoint="500"> <q-drawer v-model="state.drawer.value" show-if-above :width="200" :breakpoint="500">
<q-scroll-area class="fit text-grey-8"> <q-scroll-area class="fit text-grey-8">
<router-link :to="{ path: '/customer/list' }"> <router-link :to="{ path: '/customer/list' }">
<q-icon name="arrow_back" size="md" color="primary" /> <q-icon name="arrow_back" size="md" color="primary" />
</router-link>Descriptor </router-link>
</q-scroll-area> </q-scroll-area>
</q-drawer> </q-drawer>
<q-page-container> <q-page-container>

View File

@ -1,14 +1,15 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { useState } from 'src/composables/useState';
import LeftMenu from 'src/components/LeftMenu.vue'; import LeftMenu from 'src/components/LeftMenu.vue';
const drawer = ref(false); const state = useState();
const miniState = ref(true); const miniState = ref(true);
</script> </script>
<template> <template>
<q-drawer <q-drawer
v-model="drawer" v-model="state.drawer.value"
show-if-above show-if-above
:mini="miniState" :mini="miniState"
@mouseover="miniState = false" @mouseover="miniState = false"

View File

@ -1,16 +1,18 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { useState } from 'src/composables/useState';
import LeftMenu from 'src/components/LeftMenu.vue'; import LeftMenu from 'src/components/LeftMenu.vue';
const state = useState();
const miniState = ref(true);
const slide = ref('style'); const slide = ref('style');
const slideText = 'Description text'; const slideText = 'Description text';
const drawer = ref(false);
const miniState = ref(true);
</script> </script>
<template> <template>
<q-drawer <q-drawer
v-model="drawer" v-model="state.drawer.value"
show-if-above show-if-above
:mini="miniState" :mini="miniState"
@mouseover="miniState = false" @mouseover="miniState = false"