fix styling

This commit is contained in:
Geriano
2022-07-23 15:11:25 +07:00
parent 6ebbfcb2ff
commit 4523dc01d2
3 changed files with 19 additions and 8 deletions

View File

@@ -11,16 +11,21 @@ export default defineComponent({
setup(props, { attrs }) { setup(props, { attrs }) {
return props => { return props => {
const { menus } = props const { menus } = props
const padding = (menu, initial = 0) => menu && menu.parent_id !== null ? padding(menu.parent, initial + 8) : initial
const generate = (menu, attrs = {}) => { const generate = (menu, attrs = {}) => {
if (menu.childs?.length > 0) { if (menu.childs?.length > 0) {
return h(Links, { return h(Links, {
...attrs, ...attrs,
padding: padding(menu),
menu, menu,
childs: menu.childs, childs: menu.childs,
}, menu.childs.map(child => generate(child, { class: 'pl-8' }))) }, menu.childs.map(child => generate(child, {
padding: padding(child)
})))
} }
return h(Link, { ...attrs, menu }) return h(Link, { ...attrs, padding: padding(menu), menu })
} }
return h('div', { class: 'flex flex-col' }, menus.map(menu => generate(menu))) return h('div', { class: 'flex flex-col' }, menus.map(menu => generate(menu)))
@@ -28,3 +33,7 @@ export default defineComponent({
}, },
}) })
</script> </script>
<template>
<div class="hidden pl-8 pl-16 pl-24 pl-32 pl-40 pl-48 pl-56 pl-64 pl-72 pl-80 pl-96"></div>
</template>

View File

@@ -5,6 +5,7 @@ import Icon from '@/Components/Icon.vue'
const { menu } = defineProps({ const { menu } = defineProps({
menu: Object, menu: Object,
padding: Number,
}) })
const active = route().current(menu.route_or_url) const active = route().current(menu.route_or_url)
@@ -12,7 +13,7 @@ const link = route().has(menu.route_or_url) ? route(menu.route_or_url) : menu.ro
</script> </script>
<template> <template>
<Link :href="link" class="w-full px-4 py-3" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${active && 'bg-slate-800'}`"> <Link :href="link" class="w-full px-4 py-3" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${active && 'bg-slate-800'} pl-${padding}`">
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<Icon :name="menu.icon" /> <Icon :name="menu.icon" />
<p class="uppercase font-semibold">{{ menu.name }}</p> <p class="uppercase font-semibold">{{ menu.name }}</p>

View File

@@ -1,10 +1,11 @@
<script setup> <script setup>
import { getCurrentInstance, ref } from 'vue' import { getCurrentInstance, onMounted, onUpdated, ref } from 'vue'
import Icon from '@/Components/Icon.vue' import Icon from '@/Components/Icon.vue'
const { menu, childs } = defineProps({ const { menu, childs } = defineProps({
menu: Object, menu: Object,
childs: Array, childs: Array,
padding: Number,
}) })
const trace = menu => { const trace = menu => {
@@ -26,7 +27,7 @@ const open = ref(active ? true : false)
<template> <template>
<div class="w-full flex flex-col"> <div class="w-full flex flex-col">
<button @click.prevent="open = ! open" class="w-full p-4" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${open && 'dark:bg-gray-800'}`"> <button @click.prevent="open = ! open" class="w-full p-4" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${open && 'dark:bg-gray-800'} pl-${padding}`">
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<Icon :name="menu.icon" /> <Icon :name="menu.icon" />
<p class="uppercase font-semibold w-full text-left">{{ menu.name }}</p> <p class="uppercase font-semibold w-full text-left">{{ menu.name }}</p>
@@ -34,7 +35,7 @@ const open = ref(active ? true : false)
</div> </div>
</button> </button>
<div v-if="open" class="flex flex-col"> <div v-if="open" class="flex flex-col" ref="container">
<slot /> <slot />
</div> </div>
</div> </div>