Skip to content

Commit 5307bd9

Browse files
authored
Office: Meeting control bar with large buttons (#9946)
Signed-off-by: Anton Alexeyev <[email protected]>
1 parent 973339c commit 5307bd9

File tree

2 files changed

+66
-9
lines changed

2 files changed

+66
-9
lines changed

plugins/love-resources/src/components/meeting/ControlBarContainer.svelte

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,62 @@
1313
// limitations under the License.
1414
-->
1515
<script lang="ts">
16+
import { onDestroy, onMount } from 'svelte'
17+
1618
export let size: 'small' | 'big' = 'big'
19+
20+
let barContainer: HTMLDivElement | undefined
21+
let rowContainer: HTMLDivElement | undefined
22+
let scale = 1
23+
24+
let resizeObserver: ResizeObserver | undefined
25+
const HORIZONTAL_PADDING = 60
26+
const SCALE_CHANGE_THRESHOLD = 0.001
27+
28+
function measureWidths (): { barWidth: number, rowWidth: number } {
29+
if (barContainer === undefined || rowContainer === undefined) {
30+
return { barWidth: 0, rowWidth: 0 }
31+
}
32+
33+
const availableWidth = barContainer.clientWidth - HORIZONTAL_PADDING
34+
const barWidth = availableWidth > 0 ? availableWidth : 0
35+
const rowWidth = rowContainer.scrollWidth
36+
37+
return { barWidth, rowWidth }
38+
}
39+
40+
function updateScale (): void {
41+
const { barWidth: containerWidth, rowWidth } = measureWidths()
42+
43+
if (containerWidth === 0 || rowWidth === 0) {
44+
if (scale !== 1) scale = 1
45+
return
46+
}
47+
48+
const nextScale = Math.min(1, containerWidth / rowWidth)
49+
50+
if (Math.abs(nextScale - scale) > SCALE_CHANGE_THRESHOLD) {
51+
scale = Number(nextScale.toFixed(3))
52+
}
53+
}
54+
55+
onMount(() => {
56+
resizeObserver = new ResizeObserver(() => {
57+
updateScale()
58+
})
59+
if (barContainer !== undefined) resizeObserver.observe(barContainer)
60+
if (rowContainer !== undefined) resizeObserver.observe(rowContainer)
61+
updateScale()
62+
})
63+
64+
onDestroy(() => {
65+
resizeObserver?.disconnect()
66+
resizeObserver = undefined
67+
})
1768
</script>
1869

19-
<div class="bar" data-size={size}>
20-
<div class="row">
70+
<div class="bar" data-size={size} bind:this={barContainer}>
71+
<div class="row" bind:this={rowContainer} style={`--row-scale:${scale};`}>
2172
<div class="left"><slot name="left" /></div>
2273
<div class="center"><slot name="center" /></div>
2374
<div class="right"><slot name="right" /></div>
@@ -35,14 +86,19 @@
3586
border-top: 1px solid var(--theme-divider-color);
3687
container-type: inline-size;
3788
width: 100%;
89+
overflow: hidden;
3890
}
3991
4092
.row {
93+
--row-scale: 1;
4194
position: relative;
4295
display: flex;
4396
align-items: center;
4497
justify-content: space-between;
4598
gap: var(--g);
99+
transform-origin: center center;
100+
transform: scale(var(--row-scale));
101+
will-change: transform;
46102
}
47103
.left,
48104
.center,
@@ -52,14 +108,15 @@
52108
gap: var(--g);
53109
white-space: nowrap;
54110
min-width: 0;
111+
flex-shrink: 0;
55112
}
56113
.center {
57114
position: absolute;
58115
left: 50%;
59116
transform: translateX(-50%);
60117
}
61118
62-
@container (max-width: 350px) {
119+
@container (max-width: 440px) {
63120
.bar[data-size='small'] .row {
64121
justify-content: center;
65122
gap: var(--g);

plugins/love-resources/src/components/meeting/widget/MeetingWidget.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@
113113
<InviteEmployeeButton
114114
kind="secondary"
115115
type="type-button-icon"
116-
size="small"
116+
size="large"
117117
iconSize="medium"
118118
withBackground={false}
119119
/>
120120
</svelte:fragment>
121121
<svelte:fragment slot="center">
122-
<SendReactionButton size="small" />
123-
<MicrophoneButton size="small" />
124-
<CameraButton size="small" />
125-
<ShareScreenButton size="small" />
122+
<SendReactionButton />
123+
<MicrophoneButton />
124+
<CameraButton />
125+
<ShareScreenButton />
126126
</svelte:fragment>
127127
<svelte:fragment slot="right">
128-
<LeaveRoomButton {room} noLabel={true} size="small" />
128+
<LeaveRoomButton {room} noLabel={true} />
129129
</svelte:fragment>
130130
</ControlBarContainer>
131131
{/if}

0 commit comments

Comments
 (0)