Skip to content

Commit d36a09b

Browse files
committed
Minor UI changes for initial release
1 parent fb300ad commit d36a09b

5 files changed

Lines changed: 40 additions & 19 deletions

File tree

packages/app/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import './components/sidebar.js'
1111
import './components/workbench.js'
1212
import './components/onboarding/start.js'
1313

14-
const SIDEBAR_MIN_WIDTH = 200
14+
const SIDEBAR_MIN_WIDTH = 250
1515

1616
@customElement('wdio-devtools')
1717
export class WebdriverIODevtoolsApplication extends Element {

packages/app/src/components/workbench.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ export class DevtoolsWorkbench extends Element {
100100
return `flex:0 0 ${paneHeight}px; height:${paneHeight}px; max-height:70vh; min-height:0;`
101101
})()
102102

103-
const sidebarStyle = !this.#workbenchSidebarCollapsed
104-
? (() => {
103+
const sidebarStyle = this.#workbenchSidebarCollapsed
104+
? 'width:0; flex:0 0 0; overflow:hidden;'
105+
: (() => {
105106
const pos = this.#dragHorizontal.getPosition()
106107
const m = pos.match(/flex-basis:\s*([\d.]+)px/)
107108
const w = m ? m[1] : MIN_METATAB_WIDTH
108109
return `${pos}; flex:0 0 auto; min-width:${w}px; max-width:${w}px;`
109110
})()
110-
: ''
111111

112112
return html`
113113
<section data-horizontal-resizer-window class="flex relative w-full ${heightWorkbench} min-h-0 overflow-hidden" style="${styleWorkbench}">
@@ -129,7 +129,7 @@ export class DevtoolsWorkbench extends Element {
129129
html`
130130
<button
131131
@click="${() => this.#toggle('workbenchSidebar')}"
132-
class="absolute top-0 left-0 bg-sideBarBackground flex h-10 w-10 items-center justify-center cursor-pointer rounded-br-md hover:bg-toolbarHoverBackground border-r-[1px] border-r-panelBorder border-b-[1px] border-b-panelBorder">
132+
class="absolute top-2 left-2 bg-sideBarBackground flex h-10 w-10 items-center justify-center cursor-pointer rounded-md shadow hover:bg-toolbarHoverBackground border border-panelBorder">
133133
<icon-mdi-arrow-collapse-right></icon-mdi-arrow-collapse-right>
134134
</button>
135135
`
@@ -141,8 +141,8 @@ export class DevtoolsWorkbench extends Element {
141141
<wdio-devtools-browser></wdio-devtools-browser>
142142
</section>
143143
</section>
144-
${!this.#toolbarCollapsed ? this.#dragVertical.getSlider('z-20') : nothing}
145-
<wdio-devtools-tabs cacheId="activeWorkbenchTab" class="border-t-[1px] border-t-panelBorder ${this.#toolbarCollapsed ? 'hidden' : ''} flex-1 min-h-0">
144+
${!this.#toolbarCollapsed ? this.#dragVertical.getSlider('z-[999] -mt-[5px] pointer-events-auto') : nothing}
145+
<wdio-devtools-tabs cacheId="activeWorkbenchTab" class="relative z-10 border-t-[1px] border-t-panelBorder ${this.#toolbarCollapsed ? 'hidden' : ''} flex-1 min-h-0">
146146
<wdio-devtools-tab label="Source">
147147
<wdio-devtools-source></wdio-devtools-source>
148148
</wdio-devtools-tab>
@@ -165,7 +165,8 @@ export class DevtoolsWorkbench extends Element {
165165
html`
166166
<button
167167
@click="${() => this.#toggle('toolbar')}"
168-
class="absolute right-0 bottom-0 bg-sideBarBackground flex h-10 w-10 items-center justify-center cursor-pointer rounded-tl-md hover:bg-toolbarHoverBackground border-t-[1px] border-t-panelBorder border-l-[1px] border-l-panelBorder">
168+
class="fixed z-[9999] right-2 bottom-2 bg-sideBarBackground flex h-10 w-10 items-center justify-center cursor-pointer rounded-md shadow
169+
hover:bg-toolbarHoverBackground border border-panelBorder">
169170
<icon-mdi-arrow-collapse-up></icon-mdi-arrow-collapse-up>
170171
</button>
171172
`

packages/app/src/components/workbench/logs.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ export class DevtoolsSource extends Element {
7676
<wdio-devtools-list
7777
label="Parameters"
7878
class="text-xs"
79-
.list="${this.command.args.reduce((prev, val, i) => {
80-
if (this.#commandDefinition) {
81-
prev[this.#commandDefinition.parameters[i].name] = val
82-
} else {
83-
prev[i] = val
84-
}
85-
return prev
86-
}, {})}"></wdio-devtools-list>
79+
.list="${(this.command.args || []).reduce((acc, val, i) => {
80+
const def = this.#commandDefinition
81+
const paramName = def?.parameters?.[i]?.name ?? i
82+
acc[paramName] = val
83+
return acc
84+
}, {} as Record<string, unknown>)}"></wdio-devtools-list>
8785
<wdio-devtools-list
8886
label="Result"
8987
class="text-xs"

packages/app/src/utils/DragController.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ export class DragController implements ReactiveController {
128128
}
129129

130130
#init() {
131+
// stop previous tracker if element was re-created
132+
if (this.#pointerTracker) {
133+
this.#pointerTracker.stop()
134+
this.#pointerTracker = null
135+
}
136+
131137
const onDrag = this.#onDrag
132138
const onDragStart = this.#onDragStart
133139
const onDragEnd = this.#onDragEnd
@@ -156,6 +162,10 @@ export class DragController implements ReactiveController {
156162
this.#adjustPosition()
157163
}
158164

165+
hostUpdated() {
166+
this.#maybeReinit()
167+
}
168+
159169
hostDisconnected(): void {
160170
if (this.#pointerTracker) {
161171
this.#pointerTracker.stop()
@@ -224,6 +234,16 @@ export class DragController implements ReactiveController {
224234
el.removeAttribute('data-state')
225235
}
226236

237+
async #maybeReinit() {
238+
const draggableEl = await this.#getDraggableEl()
239+
if (!draggableEl) return
240+
// if slider was removed (collapsed) and re-added, re-init pointer tracker
241+
if (this.#draggableEl !== draggableEl) {
242+
this.#draggableEl = draggableEl as HTMLElement
243+
this.#init()
244+
}
245+
}
246+
227247
getSlider(className = '') {
228248
const anchor = this.#options.direction === Direction.horizontal
229249
? 'left'
@@ -251,11 +271,13 @@ export class DragController implements ReactiveController {
251271
return
252272
}
253273

254-
const slidingElem = (draggableEl.parentElement || this.#host.shadowRoot)?.querySelector(`*[style="${this.getPosition()}"]`)
274+
// allow matching when additional inline styles are present
275+
const slidingElem = (draggableEl.parentElement || this.#host.shadowRoot)
276+
?.querySelector(`*[style*="flex-basis: ${this.#getPosition()}px"]`)
255277
if (!slidingElem) {
256278
return
257279
}
258-
const rect = slidingElem.getBoundingClientRect()
280+
const rect = (slidingElem as HTMLElement).getBoundingClientRect()
259281
const direction = this.#options.direction === Direction.horizontal
260282
? 'width'
261283
: 'height'

packages/service/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const DEFAULT_LAUNCH_CAPS: WebdriverIO.Capabilities = {
1010
// production:
1111
// args: ['--window-size=1200,800']
1212
// development:
13-
args: ['--window-size=1600,1200', '--auto-open-devtools-for-tabs']
13+
args: ['--window-size=1600,1200']
1414
}
1515
}
1616

0 commit comments

Comments
 (0)