improve sidebar mobile

This commit is contained in:
2023-05-23 23:01:02 +02:00
parent 117fff9b02
commit 79f81cb83f
3 changed files with 53 additions and 44 deletions

View File

@@ -28,7 +28,7 @@ const setViewMode = (viewMode: ViewMode) => {
<template> <template>
<div <div
id="sidebar" id="sidebar"
class="fixed bottom-0 top-0 flex w-sidebar flex-col gap-4 overflow-y-auto px-2 py-3 text-[90%] max-sm:text-[120%]" class="fixed bottom-0 top-0 flex max-sm:w-sidebar-mobile sm:w-sidebar flex-col gap-4 overflow-y-auto px-2 py-3 text-[90%] max-sm:text-[120%]"
> >
<SideBarMenu> <SideBarMenu>
<template #header>Root note</template> <template #header>Root note</template>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { activeNotesSource, notesSources } from '@/composables/useNotes' import { activeNotesSource, notesSources } from '@/composables/useNotes'
import { signOut as firebaseSignOut } from '@/composables/useFirebase' import { signOut as firebaseSignOut } from '@/composables/useFirebase'
import { OnClickOutside } from '@vueuse/components'
const sourceLabels: { [source: string]: string } = { const sourceLabels: { [source: string]: string } = {
local: 'Switch to local notes', local: 'Switch to local notes',
firebase: 'Switch to cloud notes' firebase: 'Switch to cloud notes'
@@ -19,50 +20,54 @@ const signOut = async (close: () => Promise<boolean>) => {
close() close()
} }
const blur = () => (document.activeElement as HTMLElement)?.blur()
const handleClick = (fn: (...args: any[]) => any) => { const handleClick = (fn: (...args: any[]) => any) => {
;(document.activeElement as HTMLElement)?.blur() blur()
fn() fn()
} }
</script> </script>
<template> <template>
<div class="search-active-hide dropdown-end dropdown"> <OnClickOutside @trigger="blur">
<label tabindex="0" class="btn-outline btn-sm btn py-1 text-white"> <div class="search-active-hide dropdown-end dropdown">
<i class="fa-fw fa-solid fa-user-gear" /> <label tabindex="0" class="btn-outline btn-sm btn py-1 text-white">
</label> <i class="fa-fw fa-solid fa-user-gear" />
<ul </label>
tabindex="0" <ul
class="dropdown-content menu rounded-box menu-compact mt-1 w-52 bg-base-100 p-2 text-base-content shadow" tabindex="0"
> class="dropdown-content menu rounded-box menu-compact mt-1 w-52 bg-base-100 p-2 text-base-content shadow"
<li
class="text-base"
v-for="{ source, label } in availableNoteSources"
:key="source"
@click="handleClick(() => (activeNotesSource = source))"
> >
<a> <li
<i class="fa-fw fa-solid fa-database" /> class="text-base"
{{ label }} v-for="{ source, label } in availableNoteSources"
</a> :key="source"
</li> @click="handleClick(() => (activeNotesSource = source))"
<Modal> >
<template #activator="{ open }"> <a>
<li @click="open" class="text-base"> <i class="fa-fw fa-solid fa-database" />
<a> {{ label }}
<i class="fa-fw fa-solid fa-right-from-bracket" /> </a>
Sign out </li>
</a> <Modal>
</li> <template #activator="{ open }">
</template> <li @click="open" class="text-base">
<template #title>Sign out</template> <a>
<template #default> <i class="fa-fw fa-solid fa-right-from-bracket" />
<p>Are you sure want to signout?</p> Sign out
<p>Your synchronized notes can't be accessed until you sign-in again.</p> </a>
</template> </li>
<template #actions="{ close }"> </template>
<button class="btn-sm btn" @click="close">Cancel</button> <template #title>Sign out</template>
<button class="btn-primary btn-sm btn" @click="signOut(close)">Sign out</button> <template #default>
</template> <p>Are you sure want to signout?</p>
</Modal> <p>Your synchronized notes can't be accessed until you sign-in again.</p>
</ul> </template>
</div> <template #actions="{ close }">
<button class="btn-sm btn" @click="close">Cancel</button>
<button class="btn-primary btn-sm btn" @click="signOut(close)">Sign out</button>
</template>
</Modal>
</ul>
</div>
</OnClickOutside>
</template> </template>

View File

@@ -1,6 +1,7 @@
const colors = require('tailwindcss/colors') const colors = require('tailwindcss/colors')
const appWidth = '1280px' const appWidth = '1280px'
const sideBarWidth = '220px' const sideBarWidth = '220px'
const sideBarWidthMobile ='320px'
const primary = '#1E4BC4' const primary = '#1E4BC4'
const secondary = colors.gray[500] const secondary = colors.gray[500]
@@ -15,13 +16,16 @@ export default {
}, },
maxWidth: { maxWidth: {
app: appWidth, app: appWidth,
sidebar: sideBarWidth sidebar: sideBarWidth,
'sidebar-mobile': sideBarWidthMobile
}, },
width: { width: {
sidebar: sideBarWidth sidebar: sideBarWidth,
'sidebar-mobile': sideBarWidthMobile
}, },
margin: { margin: {
sidebar: sideBarWidth sidebar: sideBarWidth,
'sidebar-mobile': sideBarWidthMobile
} }
} }
}, },