11import type { File , Task } from '@vitest/runner'
22import type { Params } from './params'
33import { useLocalStorage , watchOnce } from '@vueuse/core'
4- import { computed , reactive , ref , watch } from 'vue'
4+ import { computed , nextTick , reactive , ref , watch } from 'vue'
55import { viewport } from './browser'
66import { browserState , client , config , findById } from './client'
77import { testRunState } from './client/state'
@@ -35,6 +35,31 @@ export const detailSizes = useLocalStorage<[left: number, right: number]>(
3535 ] ,
3636)
3737
38+ export const detailsPanelVisible = useLocalStorage < boolean > (
39+ 'vitest-ui_details-panel-visible' ,
40+ true ,
41+ )
42+
43+ export const detailsPosition = ref < 'right' | 'bottom' > ( 'right' )
44+
45+ nextTick ( ( ) => {
46+ watch ( config , ( ) => {
47+ if ( config . value ?. browser ?. detailsPanelPosition ) {
48+ detailsPosition . value = config . value . browser . detailsPanelPosition
49+ }
50+ } )
51+ } )
52+
53+ export function hideDetailsPanel ( ) {
54+ // setTimeout is used to avoid splitpanes throwing a race condition error
55+ setTimeout ( ( ) => {
56+ detailsPanelVisible . value = false
57+ } , 0 )
58+ }
59+ export function showDetailsPanel ( ) {
60+ detailsPanelVisible . value = true
61+ }
62+
3863// live sizes of panels in percentage
3964export const panels = reactive ( {
4065 navigation : mainSizes . value [ 0 ] ,
@@ -147,12 +172,6 @@ export function showCoverage() {
147172 activeFileId . value = ''
148173}
149174
150- export function hideRightPanel ( ) {
151- panels . details . browser = 100
152- panels . details . main = 0
153- detailSizes . value = [ 100 , 0 ]
154- }
155-
156175function calculateBrowserPanel ( ) {
157176 // we don't scale webdriverio provider because it doesn't support scaling
158177 // TODO: find a way to make this universal - maybe show browser separately(?)
@@ -165,15 +184,6 @@ function calculateBrowserPanel() {
165184 return 33
166185}
167186
168- export function showRightPanel ( ) {
169- panels . details . browser = calculateBrowserPanel ( )
170- panels . details . main = 100 - panels . details . browser
171- detailSizes . value = [
172- panels . details . browser ,
173- panels . details . main ,
174- ]
175- }
176-
177187export function showNavigationPanel ( ) {
178188 panels . navigation = 33
179189 panels . details . size = 67
@@ -195,3 +205,12 @@ export function updateBrowserPanel() {
195205 panels . details . main ,
196206 ]
197207}
208+
209+ export function toggleDetailsPosition ( ) {
210+ detailsPosition . value = detailsPosition . value === 'right' ? 'bottom' : 'right'
211+ // Reset to default sizes when changing orientation
212+ const defaultSize = detailsPosition . value === 'bottom' ? 33 : 50
213+ detailSizes . value = [ defaultSize , 100 - defaultSize ]
214+ panels . details . browser = defaultSize
215+ panels . details . main = 100 - defaultSize
216+ }
0 commit comments