|
28 | 28 | getCurrentLocation, |
29 | 29 | showPopup, |
30 | 30 | type AnySvelteComponent, |
31 | | - type CompAndProps |
| 31 | + type CompAndProps, |
| 32 | + resizeObserver |
32 | 33 | } from '@hcengineering/ui' |
33 | 34 | import view from '@hcengineering/view' |
34 | 35 | import plugin from '../plugin' |
|
51 | 52 | import CamSettingPopup from './CamSettingPopup.svelte' |
52 | 53 | import MicSettingPopup from './MicSettingPopup.svelte' |
53 | 54 | import RoomAccessPopup from './RoomAccessPopup.svelte' |
| 55 | + import { afterUpdate } from 'svelte' |
54 | 56 |
|
55 | 57 | export let room: Room |
56 | 58 | export let fullScreen: boolean = false |
|
59 | 61 | const allowShare: boolean = true |
60 | 62 | let allowLeave: boolean = false |
61 | 63 | 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 |
62 | 69 |
|
63 | 70 | $: allowCam = $currentRoom?.type === RoomType.Video |
64 | 71 | $: allowLeave = $myInfo?.room !== ($myOffice?._id ?? plugin.ids.Reception) |
|
149 | 156 |
|
150 | 157 | const camKeys = client.getModel().findAllSync(view.class.Action, { _id: plugin.action.ToggleVideo })?.[0]?.keyBinding |
151 | 158 | 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 | + }) |
152 | 171 | </script> |
153 | 172 |
|
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" /> |
155 | 175 | {#if room._id !== plugin.ids.Reception} |
156 | 176 | <ModernButton |
157 | 177 | icon={roomAccessIcon[room.access]} |
|
205 | 225 | /> |
206 | 226 | {/if} |
207 | 227 | {/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"> |
209 | 229 | {#if $isConnected} |
210 | 230 | <ModernButton |
211 | 231 | icon={$isFullScreen ? love.icon.ExitFullScreen : love.icon.FullScreen} |
|
232 | 252 | {#if allowLeave} |
233 | 253 | <ModernButton |
234 | 254 | icon={plugin.icon.LeaveRoom} |
235 | | - label={plugin.string.LeaveRoom} |
| 255 | + label={noLabel ? undefined : plugin.string.LeaveRoom} |
236 | 256 | tooltip={{ label: plugin.string.LeaveRoom, direction: 'top' }} |
237 | 257 | kind={'negative'} |
238 | 258 | size={'large'} |
239 | 259 | on:click={leave} |
240 | 260 | /> |
241 | 261 | {/if} |
242 | 262 | </div> |
| 263 | + <div class="flex-grow" /> |
243 | 264 | {#if popup && fullScreen} |
244 | 265 | <PopupInstance |
245 | 266 | is={popup.is} |
|
259 | 280 |
|
260 | 281 | <style lang="scss"> |
261 | 282 | .bar { |
| 283 | + overflow-x: auto; |
262 | 284 | position: relative; |
263 | 285 | padding: 1rem; |
264 | 286 | border-top: 1px solid var(--theme-divider-color); |
|
270 | 292 | right: 1rem; |
271 | 293 | height: 100%; |
272 | 294 | } |
| 295 | +
|
| 296 | + &.combinePanel .bar__left-panel { |
| 297 | + position: static; |
| 298 | + } |
273 | 299 | } |
274 | 300 | </style> |
0 commit comments