Skip to content

Commit e865633

Browse files
committed
fix(desk): breaking layout in ISingle page
1 parent 82302ef commit e865633

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

packages/desktop/components/VLayoutDrawer.vue

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ export default defineComponent({ inheritAttrs: false })
33
</script>
44

55
<script setup lang="ts">
6-
import { ref, computed, defineComponent, onMounted, onUnmounted } from 'vue'
76
import { useLayout, LayoutItem } from '@composables/layout'
8-
import { useVModel } from 'vue-wind/composables/v-model'
7+
import { useVModel } from '@vueuse/core'
98
109
// Props & Emits
1110
const props = defineProps({
@@ -59,21 +58,33 @@ const padding = computed(() => {
5958
})
6059
6160
// transform
62-
const transform = computed(() => {
63-
if (model.value) return 'translateX(0)'
61+
const model = useVModel(props, 'modelValue', emit)
6462
65-
return props.right ? 'translateX(200%)' : 'translateX(-100%)'
66-
})
63+
const style = computed(() => {
64+
let transform = 'translateX(0)'
65+
let width = `${props.width}px`
6766
68-
// v-model
69-
const model = useVModel(props, 'modelValue', emit)
67+
if (!model.value) {
68+
transform = props.right ? 'translateX(200%)' : 'translateX(-100%)'
69+
}
70+
71+
if (props.right && !model.value) {
72+
// width = `0px`
73+
}
74+
75+
return {
76+
padding,
77+
transform,
78+
width,
79+
}
80+
})
7081
</script>
7182
<template>
7283
<aside
7384
ref="root"
74-
class="absolute overflow-hidden top-0 transition-transform h-full"
85+
class="absolute overflow-hidden top-0 h-full transition-transform duration-300 ease-in-out"
7586
:class="[right ? 'right-0' : 'left-0']"
76-
:style="{ padding, transform, width: `${width}px` }"
87+
:style="(style as any)"
7788
>
7889
<div class="h-full w-full overflow-auto" v-bind="$attrs">
7990
<slot />

packages/desktop/modules/item/components/IValueText.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,5 @@ const editModel = useModelOrInnerValue(props, 'edit', emit)
4343
{{ payload }}
4444
</div>
4545

46-
<v-input
47-
v-else
48-
v-model="payload"
49-
autofocus
50-
@update:model-value="save"
51-
@blur="editModel = false"
52-
/>
46+
<v-input v-else v-model="payload" @update:model-value="save" @blur="editModel = false" />
5347
</template>

packages/desktop/modules/item/pages/ISingle.vue

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import { useRouter } from 'vue-router'
44
55
import { useStore } from '@store/global'
66
7-
import LLayout from '@modules/layout/LLayout.vue'
8-
import LToolbar from '@modules/layout/components/LToolbar.vue'
97
import EMarkdown from '@modules/entry/pages/EMarkdown.vue'
108
119
import IValue from '../components/IValue.vue'
1210
import Item from '@core/entities/item'
13-
import { useState } from '@composables/state'
1411
import DirectoryEntry from '@core/entities/directory-entry'
1512
import { useColumnStore } from '@modules/column/store'
13+
import { useLocalStorage } from '@vueuse/core'
1614
1715
// Props & Emit
1816
const props = defineProps({
@@ -36,11 +34,16 @@ const router = useRouter()
3634
3735
const item = ref<Item>()
3836
37+
const loading = ref(false)
38+
3939
async function setItem() {
40+
loading.value = true
41+
4042
await store.item
4143
.show(props.collectionId, props.itemId)
4244
.then((r) => (item.value = r ?? undefined))
4345
.catch(() => router.push('404'))
46+
.finally(() => (loading.value = false))
4447
}
4548
4649
watch(props, setItem, {
@@ -59,12 +62,10 @@ async function load() {
5962
}
6063
}
6164
62-
watch(() => props.collectionId, load, { deep: true })
65+
watch(() => props.collectionId, load)
6366
6467
// drawer
65-
const drawer = useState('app:item-drawer', true, {
66-
localStorage: true,
67-
})
68+
const drawer = useLocalStorage('app:item-drawer', true)
6869
6970
// content path
7071
@@ -84,22 +85,29 @@ watch(() => props.itemId, setContentPath, {
8485
</script>
8586
<template>
8687
<v-layout use-percentage>
87-
<v-layout-drawer v-if="item" v-model="drawer" class="border-l border-lines px-4 py-4" right>
88-
<i-value
89-
v-for="c in columnStore.columns"
90-
:key="c.id"
91-
:column-id="c.id"
92-
:collection-id="collectionId"
93-
:item-id="item.id"
94-
:label="c.label"
95-
:type="c.type"
96-
edit
97-
class="mb-4 last:mb-0"
98-
/>
88+
<v-layout-drawer :model-value="drawer" class="border-l border-lines px-4 py-4" right>
89+
<div v-if="item">
90+
<i-value
91+
v-for="c in columnStore.columns"
92+
:key="c.id"
93+
:column-id="c.id"
94+
:collection-id="collectionId"
95+
:item-id="item.id"
96+
:label="c.label"
97+
:type="c.type"
98+
edit
99+
class="mb-4 last:mb-0"
100+
/>
101+
</div>
99102
</v-layout-drawer>
100103

101-
<v-layout-content v-if="contentPath">
102-
<e-markdown ref="editorRef" :path="contentPath" :doc:scope="{ item }">
104+
<v-layout-content>
105+
<e-markdown
106+
v-if="contentPath"
107+
ref="editorRef"
108+
:path="contentPath"
109+
:doc:scope="{ item }"
110+
>
103111
<template #append-actions>
104112
<v-btn mode="text" size="sm" @click="drawer = !drawer">
105113
<v-icon name="cog" />

0 commit comments

Comments
 (0)