Skip to content

Commit 7710ff8

Browse files
authored
Mobile layout fixes (#7077)
Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
1 parent da0da6b commit 7710ff8

File tree

7 files changed

+90
-25
lines changed

7 files changed

+90
-25
lines changed

packages/theme/styles/_layouts.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ a.no-line {
10531053
.bottom-divider { border-bottom: 1px solid var(--theme-divider-color); }
10541054
.left-divider { border-left: 1px solid var(--theme-divider-color); }
10551055
.right-divider { border-right: 1px solid var(--theme-divider-color); }
1056+
.right-navpanel-border { border-right: 1px solid var(--theme-navpanel-border); }
10561057
.bottom-highlight-select { border-bottom: 1px solid var(--highlight-select); }
10571058

10581059

packages/ui/src/components/Separator.svelte

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
3939
let sState: SeparatorState
4040
$: sState = typeof float === 'string' ? SeparatorState.FLOAT : float ? SeparatorState.HIDDEN : SeparatorState.NORMAL
41+
const checkFullWidth = (): boolean =>
42+
sState === SeparatorState.FLOAT && $deviceInfo.isMobile && $deviceInfo.isPortrait
4143
4244
const direction: 'horizontal' | 'vertical' = 'horizontal'
4345
let separators: SeparatedItem[] | null = null
@@ -67,6 +69,10 @@
6769
let disabled: boolean = false
6870
let side: 'start' | 'end' | undefined = undefined
6971
72+
$: fs = $deviceInfo.fontSize
73+
const remToPx = (rem: number): number => rem * fs
74+
const pxToRem = (px: number): number => px / fs
75+
7076
const fetchSeparators = (): void => {
7177
const res = getSeparators(name, float)
7278
if (res !== null && !Array.isArray(res)) panel = res
@@ -90,10 +96,6 @@
9096
checkSizes()
9197
}
9298
93-
$: fs = $deviceInfo.fontSize
94-
const remToPx = (rem: number): number => rem * fs
95-
const pxToRem = (px: number): number => px / fs
96-
9799
const convertSize = (prop: TSeparatedItem): string => (typeof prop === 'number' ? `${prop}px` : '')
98100
99101
const setSize = (element: HTMLElement, size: TSeparatedItem, next: boolean = false): void => {
@@ -229,6 +231,12 @@
229231
230232
const checkSizes = (): void => {
231233
if (sState === SeparatorState.FLOAT) {
234+
if (checkFullWidth() && panel != null) {
235+
const s = pxToRem(window.innerWidth)
236+
panel.size = s
237+
panel.maxSize = s
238+
panel.minSize = s
239+
}
232240
if (parentElement != null && panel != null) initSize(parentElement, panel)
233241
} else if (sState === SeparatorState.NORMAL) {
234242
if (prevElement != null && prevElSize != null) initSize(prevElement, prevElSize)
@@ -442,12 +450,13 @@
442450
}
443451
} else if (sState === SeparatorState.FLOAT && parentElement != null) {
444452
parentElement.style.pointerEvents = 'all'
445-
saveSeparator(name, float, panel)
453+
if (!checkFullWidth()) saveSeparator(name, float, panel)
446454
}
447455
document.body.style.cursor = ''
448456
}
449457
450458
function pointerDown (event: PointerEvent): void {
459+
if (checkFullWidth()) return
451460
prepareSeparation(event)
452461
document.addEventListener('pointermove', pointerMove)
453462
document.addEventListener('pointerup', pointerUp)

packages/ui/src/resize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function saveSeparator (
148148
}
149149

150150
export const panelSeparators: DefSeparators = [
151-
{ minSize: 30, size: 'auto', maxSize: 'auto' },
151+
{ minSize: 20, size: 'auto', maxSize: 'auto' },
152152
{ minSize: 17, size: 25, maxSize: 35, float: 'aside' }
153153
]
154154

plugins/love-resources/src/components/ControlBar.svelte

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
getCurrentLocation,
2929
showPopup,
3030
type AnySvelteComponent,
31-
type CompAndProps
31+
type CompAndProps,
32+
resizeObserver
3233
} from '@hcengineering/ui'
3334
import view from '@hcengineering/view'
3435
import plugin from '../plugin'
@@ -51,6 +52,7 @@
5152
import CamSettingPopup from './CamSettingPopup.svelte'
5253
import MicSettingPopup from './MicSettingPopup.svelte'
5354
import RoomAccessPopup from './RoomAccessPopup.svelte'
55+
import { afterUpdate } from 'svelte'
5456
5557
export let room: Room
5658
export let fullScreen: boolean = false
@@ -59,6 +61,11 @@
5961
const allowShare: boolean = true
6062
let allowLeave: boolean = false
6163
let popup: CompAndProps | undefined = undefined
64+
let grow: HTMLElement
65+
let leftPanel: HTMLElement
66+
let leftPanelSize: number = 0
67+
let noLabel: boolean = false
68+
let combinePanel: boolean = false
6269
6370
$: allowCam = $currentRoom?.type === RoomType.Video
6471
$: allowLeave = $myInfo?.room !== ($myOffice?._id ?? plugin.ids.Reception)
@@ -149,9 +156,22 @@
149156
150157
const camKeys = client.getModel().findAllSync(view.class.Action, { _id: plugin.action.ToggleVideo })?.[0]?.keyBinding
151158
const micKeys = client.getModel().findAllSync(view.class.Action, { _id: plugin.action.ToggleMic })?.[0]?.keyBinding
159+
160+
const checkBar = (): void => {
161+
if (grow === undefined || leftPanel === undefined) return
162+
if (!noLabel && leftPanel.clientWidth > leftPanelSize) leftPanelSize = leftPanel.clientWidth
163+
if (grow.clientWidth - 16 < leftPanel.clientWidth && !noLabel && !combinePanel) noLabel = true
164+
else if (grow.clientWidth - 16 < leftPanel.clientWidth && noLabel && !combinePanel) combinePanel = true
165+
else if (grow.clientWidth * 2 - 32 > leftPanel.clientWidth && noLabel && combinePanel) combinePanel = false
166+
else if (grow.clientWidth - 32 >= leftPanelSize && noLabel && !combinePanel) noLabel = false
167+
}
168+
afterUpdate(() => {
169+
checkBar()
170+
})
152171
</script>
153172

154-
<div class="bar w-full flex-center flex-gap-2 flex-no-shrink">
173+
<div class="bar w-full flex-center flex-gap-2 flex-no-shrink" class:combinePanel use:resizeObserver={checkBar}>
174+
<div bind:this={grow} class="flex-grow" />
155175
{#if room._id !== plugin.ids.Reception}
156176
<ModernButton
157177
icon={roomAccessIcon[room.access]}
@@ -205,7 +225,7 @@
205225
/>
206226
{/if}
207227
{/if}
208-
<div class="bar__left-panel flex-gap-2 flex-center">
228+
<div bind:this={leftPanel} class="bar__left-panel flex-gap-2 flex-center">
209229
{#if $isConnected}
210230
<ModernButton
211231
icon={$isFullScreen ? love.icon.ExitFullScreen : love.icon.FullScreen}
@@ -232,14 +252,15 @@
232252
{#if allowLeave}
233253
<ModernButton
234254
icon={plugin.icon.LeaveRoom}
235-
label={plugin.string.LeaveRoom}
255+
label={noLabel ? undefined : plugin.string.LeaveRoom}
236256
tooltip={{ label: plugin.string.LeaveRoom, direction: 'top' }}
237257
kind={'negative'}
238258
size={'large'}
239259
on:click={leave}
240260
/>
241261
{/if}
242262
</div>
263+
<div class="flex-grow" />
243264
{#if popup && fullScreen}
244265
<PopupInstance
245266
is={popup.is}
@@ -259,6 +280,7 @@
259280

260281
<style lang="scss">
261282
.bar {
283+
overflow-x: auto;
262284
position: relative;
263285
padding: 1rem;
264286
border-top: 1px solid var(--theme-divider-color);
@@ -270,5 +292,9 @@
270292
right: 1rem;
271293
height: 100%;
272294
}
295+
296+
&.combinePanel .bar__left-panel {
297+
position: static;
298+
}
273299
}
274300
</style>

plugins/love-resources/src/components/Room.svelte

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { personByIdStore } from '@hcengineering/contact-resources'
1818
import { Room as TypeRoom } from '@hcengineering/love'
1919
import { getMetadata } from '@hcengineering/platform'
20-
import { Label, Loading, resizeObserver } from '@hcengineering/ui'
20+
import { Label, Loading, resizeObserver, deviceOptionsStore as deviceInfo } from '@hcengineering/ui'
2121
import {
2222
LocalParticipant,
2323
LocalTrackPublication,
@@ -333,7 +333,7 @@
333333
$: if (((document.fullscreenElement && !$isFullScreen) || $isFullScreen) && roomEl) toggleFullscreen()
334334
</script>
335335

336-
<div bind:this={roomEl} class="flex-col-center w-full h-full" class:theme-dark={$isFullScreen}>
336+
<div bind:this={roomEl} class="flex-col-center w-full h-full right-navpanel-border" class:theme-dark={$isFullScreen}>
337337
{#if $isConnected && !$isCurrentInstanceConnected}
338338
<div class="flex justify-center error h-full w-full clear-mins">
339339
<Label label={love.string.AnotherWindowError} />
@@ -345,7 +345,13 @@
345345
{:else if loading}
346346
<Loading />
347347
{/if}
348-
<div class="room-container" class:sharing={$screenSharing} class:many={columns > 3} class:hidden={loading}>
348+
<div
349+
class="room-container"
350+
class:sharing={$screenSharing}
351+
class:many={columns > 3}
352+
class:hidden={loading}
353+
class:mobile={$deviceInfo.isMobile}
354+
>
349355
<div class="screenContainer">
350356
<video class="screen" bind:this={screen}></video>
351357
</div>
@@ -452,6 +458,15 @@
452458
gap: 0.5rem;
453459
}
454460
}
461+
462+
&.mobile {
463+
padding: var(--spacing-0_5);
464+
465+
&:not(.sharing) .videoGrid,
466+
&.sharing {
467+
gap: var(--spacing-0_5);
468+
}
469+
}
455470
}
456471
.hidden {
457472
display: none;

plugins/workbench-resources/src/components/Workbench.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,18 @@
647647
const checkOnHide = (): void => {
648648
if ($deviceInfo.navigator.visible && $deviceInfo.docWidth <= 1024) $deviceInfo.navigator.visible = false
649649
}
650+
let oldNavVisible: boolean = $deviceInfo.navigator.visible
651+
let oldASideVisible: boolean = $deviceInfo.aside.visible
652+
$: if (oldNavVisible !== $deviceInfo.navigator.visible || oldASideVisible !== $deviceInfo.aside.visible) {
653+
if ($deviceInfo.isMobile && $deviceInfo.isPortrait && $deviceInfo.navigator.float) {
654+
if ($deviceInfo.navigator.visible && $deviceInfo.aside.visible) {
655+
if (oldNavVisible) $deviceInfo.navigator.visible = false
656+
else $deviceInfo.aside.visible = false
657+
}
658+
}
659+
oldNavVisible = $deviceInfo.navigator.visible
660+
oldASideVisible = $deviceInfo.aside.visible
661+
}
650662
$: $deviceInfo.navigator.direction = $deviceInfo.isMobile && $deviceInfo.isPortrait ? 'horizontal' : 'vertical'
651663
let appsMini: boolean
652664
$: appsMini =

plugins/workbench-resources/src/components/WorkbenchTabs.svelte

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,25 @@
5757
</div>
5858
</div>
5959
{:else if !mini}
60-
<ScrollerBar bind:scroller padding={'.25rem 0'}>
60+
<div class="flex-row-center gap-1 py-1 overflow-x-auto">
6161
{#each $tabsStore as tab (tab._id)}
6262
<WorkbenchTabPresenter {tab} />
6363
{/each}
64-
</ScrollerBar>
64+
</div>
6565
{:else if selectedTab !== undefined}
6666
<WorkbenchTabPresenter tab={selectedTab} />
67-
<ButtonIcon
68-
bind:element
69-
icon={IconMoreH}
70-
iconProps={{ fill: 'var(--theme-dark-color)' }}
71-
size={'extra-small'}
72-
kind={'tertiary'}
73-
hasMenu
74-
{pressed}
75-
on:click={showTabs}
76-
/>
67+
{#if $tabsStore.length > 1}
68+
<ButtonIcon
69+
bind:element
70+
icon={IconMoreH}
71+
iconProps={{ fill: 'var(--theme-dark-color)' }}
72+
size={'extra-small'}
73+
kind={'tertiary'}
74+
hasMenu
75+
{pressed}
76+
on:click={showTabs}
77+
/>
78+
{/if}
7779
{/if}
7880
{#if !popup}
7981
<ButtonIcon

0 commit comments

Comments
 (0)