Skip to content

Commit 696780d

Browse files
committedFeb 4, 2024
feat: layout settings
1 parent cf40e22 commit 696780d

File tree

5 files changed

+100
-15
lines changed

5 files changed

+100
-15
lines changed
 

‎packages/app-frontend/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@vue-devtools/shared-utils": "^0.0.0",
99
"@vue/devtools-api": "^6.0.0-beta.9",
1010
"@vue/ui": "^0.12.5",
11+
"@vueuse/core": "^10.7.2",
1112
"circular-json-es6": "^2.0.2",
1213
"d3": "^5.16.0",
1314
"floating-vue": "^5.2.2",

‎packages/app-frontend/src/features/layout/SplitPane.vue

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { ref, computed, defineComponent, PropType, watch } from 'vue'
3+
import { useLocalStorage } from '@vueuse/core'
34
import { useOrientation } from './orientation'
4-
import { useSavedRef } from '@front/util/reactivity'
55
66
export default defineComponent({
77
props: {
@@ -45,19 +45,9 @@ export default defineComponent({
4545
setup (props, { emit }) {
4646
const { orientation } = useOrientation()
4747
48-
const split = ref(props.defaultSplit)
49-
const leftCollapsed = ref(false)
50-
const rightCollapsed = ref(false)
51-
52-
if (props.saveId) {
53-
useSavedRef(split, `split-pane-${props.saveId}`)
54-
if (props.collapsableLeft) {
55-
useSavedRef(leftCollapsed, `split-pane-collapsed-left-${props.saveId}`)
56-
}
57-
if (props.collapsableRight) {
58-
useSavedRef(rightCollapsed, `split-pane-collapsed-right-${props.saveId}`)
59-
}
60-
}
48+
const split = props.saveId ? useLocalStorage(`split-pane-${props.saveId}`, props.defaultSplit) : ref(props.defaultSplit)
49+
const leftCollapsed = props.saveId ? useLocalStorage(`split-pane-collapsed-left-${props.saveId}`, false) : ref(false)
50+
const rightCollapsed = props.saveId ? useLocalStorage(`split-pane-collapsed-right-${props.saveId}`, false) : ref(false)
6151
6252
watch(leftCollapsed, value => {
6353
emit('left-collapsed', value)

‎packages/app-frontend/src/features/settings/GlobalSettings.vue

+24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<script lang="ts" setup>
22
import { ref } from 'vue'
3+
import { useLocalStorage } from '@vueuse/core'
34
import { supportsScreenshot } from '../timeline/composable/screenshot'
45
56
type Tab = 'global' | 'components' | 'timeline'
67
78
const tab = ref<Tab>('global')
9+
10+
const hideAppSelector = useLocalStorage('split-pane-collapsed-left-app-select-pane', false)
11+
const hideTimelineCanvas = useLocalStorage('split-pane-collapsed-left-timeline-right', false)
12+
const hideEvents = useLocalStorage('split-pane-collapsed-right-timeline-right', false)
813
</script>
914

1015
<template>
@@ -68,6 +73,14 @@ const tab = ref<Tab>('global')
6873
</VueGroup>
6974
</VueFormField>
7075

76+
<VueFormField
77+
title="Main layout"
78+
>
79+
<VueSwitch v-model="hideAppSelector">
80+
Collapse app selector
81+
</VueSwitch>
82+
</VueFormField>
83+
7184
<VueFormField
7285
title="Menu Step Scrolling"
7386
>
@@ -156,6 +169,17 @@ const tab = ref<Tab>('global')
156169
</div>
157170

158171
<div v-if="tab === 'timeline'" class="preferences flex flex-wrap gap-8">
172+
<VueFormField
173+
title="Layout"
174+
>
175+
<VueSwitch v-model="hideTimelineCanvas">
176+
Hide timeline canvas
177+
</VueSwitch>
178+
<VueSwitch v-model="hideEvents">
179+
Hide events explorer
180+
</VueSwitch>
181+
</VueFormField>
182+
159183
<VueFormField
160184
title="Time grid"
161185
>

‎packages/app-frontend/src/features/timeline/Timeline.vue

+39-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import TimelineEventList from './TimelineEventList.vue'
88
import TimelineEventInspector from './TimelineEventInspector.vue'
99
import AskScreenshotPermission from './AskScreenshotPermission.vue'
1010
11-
import { computed, onMounted, ref, watch, defineComponent, onUnmounted } from 'vue'
11+
import { computed, onMounted, ref, watch, defineComponent, onUnmounted, nextTick } from 'vue'
12+
import { useLocalStorage } from '@vueuse/core'
1213
import { getStorage, SharedData } from '@vue-devtools/shared-utils'
1314
import { onSharedDataChange } from '@front/util/shared-data'
1415
import { formatTime } from '@front/util/format'
@@ -297,6 +298,27 @@ export default defineComponent({
297298
}
298299
})
299300
301+
// Layout settings
302+
303+
const hideTimelineCanvas = useLocalStorage('split-pane-collapsed-left-timeline-right', false)
304+
const hideEvents = useLocalStorage('split-pane-collapsed-right-timeline-right', false)
305+
306+
// We shouldn't hide both at the same time
307+
watch(() => [hideTimelineCanvas.value, hideEvents.value], ([a, b], old) => {
308+
if (a && a === b) {
309+
nextTick(() => {
310+
if (old?.[0]) {
311+
hideTimelineCanvas.value = false
312+
} else {
313+
hideEvents.value = false
314+
}
315+
})
316+
}
317+
}, {
318+
immediate: true,
319+
deep: true,
320+
})
321+
300322
return {
301323
fontsLoaded,
302324
startTime,
@@ -322,6 +344,8 @@ export default defineComponent({
322344
zoomOut,
323345
moveLeft,
324346
moveRight,
347+
hideTimelineCanvas,
348+
hideEvents,
325349
}
326350
},
327351
})
@@ -403,6 +427,20 @@ export default defineComponent({
403427
/>
404428
</template>
405429

430+
<VueSwitch
431+
v-model="hideTimelineCanvas"
432+
class="w-full px-3 py-1 extend-left"
433+
>
434+
Hide timeline canvas
435+
</VueSwitch>
436+
437+
<VueSwitch
438+
v-model="hideEvents"
439+
class="w-full px-3 py-1 extend-left"
440+
>
441+
Hide events explorer
442+
</VueSwitch>
443+
406444
<VueSwitch
407445
v-model="$shared.timelineTimeGrid"
408446
class="w-full px-3 py-1 extend-left"

‎yarn.lock

+32
Original file line numberDiff line numberDiff line change
@@ -2596,6 +2596,11 @@
25962596
resolved "https://registry.yarnpkg.com/@types/speakingurl/-/speakingurl-13.0.3.tgz#cbfe3d0182c7af92ebac7e587bb9228472e05133"
25972597
integrity sha512-nBHZAaNTEw1YG3ROL7HtTp7HjW8HD7DuFYbWoonUKTZHj7eyOt4vPzyMcc3+xgWNv7xi2rziaiBXHIq6wBeyrw==
25982598

2599+
"@types/web-bluetooth@^0.0.20":
2600+
version "0.0.20"
2601+
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597"
2602+
integrity sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==
2603+
25992604
"@types/webpack-env@^1.15.1":
26002605
version "1.18.0"
26012606
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.18.0.tgz#ed6ecaa8e5ed5dfe8b2b3d00181702c9925f13fb"
@@ -2913,6 +2918,28 @@
29132918
v-tooltip "^3.0.0-alpha.20"
29142919
vue-resize "^1.0.0"
29152920

2921+
"@vueuse/core@^10.7.2":
2922+
version "10.7.2"
2923+
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-10.7.2.tgz#78917803a29a0bca1803a6521fdf7ff873f6e72c"
2924+
integrity sha512-AOyAL2rK0By62Hm+iqQn6Rbu8bfmbgaIMXcE3TSr7BdQ42wnSFlwIdPjInO62onYsEMK/yDMU8C6oGfDAtZ2qQ==
2925+
dependencies:
2926+
"@types/web-bluetooth" "^0.0.20"
2927+
"@vueuse/metadata" "10.7.2"
2928+
"@vueuse/shared" "10.7.2"
2929+
vue-demi ">=0.14.6"
2930+
2931+
"@vueuse/metadata@10.7.2":
2932+
version "10.7.2"
2933+
resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-10.7.2.tgz#ba0187ce138c287fd80301afc5b0d6a97e563633"
2934+
integrity sha512-kCWPb4J2KGrwLtn1eJwaJD742u1k5h6v/St5wFe8Quih90+k2a0JP8BS4Zp34XUuJqS2AxFYMb1wjUL8HfhWsQ==
2935+
2936+
"@vueuse/shared@10.7.2":
2937+
version "10.7.2"
2938+
resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-10.7.2.tgz#746441fbc08072371dd600a55883422c83fd0cab"
2939+
integrity sha512-qFbXoxS44pi2FkgFjPvF4h7c9oMDutpyBdcJdMYIMg9XyXli2meFMuaKn+UMgsClo//Th6+beeCgqweT/79BVA==
2940+
dependencies:
2941+
vue-demi ">=0.14.6"
2942+
29162943
"@webassemblyjs/ast@1.11.1":
29172944
version "1.11.1"
29182945
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
@@ -11336,6 +11363,11 @@ vitepress@^0.22.3:
1133611363
vite "^2.9.7"
1133711364
vue "^3.2.33"
1133811365

11366+
vue-demi@>=0.14.6:
11367+
version "0.14.7"
11368+
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.7.tgz#8317536b3ef74c5b09f268f7782e70194567d8f2"
11369+
integrity sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==
11370+
1133911371
vue-eslint-parser@^7.0.0:
1134011372
version "7.11.0"
1134111373
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.11.0.tgz#214b5dea961007fcffb2ee65b8912307628d0daf"

0 commit comments

Comments
 (0)