Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/sessions/browser/parts/mobile/mobileChatBarPart.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Parts } from '../../../../workbench/services/layout/browser/layoutService.js';
7
import { AbstractPaneCompositePart } from '../../../../workbench/browser/parts/paneCompositePart.js';
8
import { ChatBarPart } from '../chatBarPart.js';
9
import { isPhoneLayout } from './mobileLayout.js';
10
11
/**
12
* Mobile variant of ChatBarPart.
13
*
14
* On phone-sized viewports the chat bar fills the full grid cell without
15
* card margins, border insets, or session-bar height adjustments. When
16
* the viewport transitions to tablet/desktop (e.g., device rotation
17
* crossing the phone breakpoint) this delegates to the desktop
18
* implementation so layout math stays correct.
19
*/
20
export class MobileChatBarPart extends ChatBarPart {
21
22
override updateStyles(): void {
23
// Always run the desktop implementation first so inline styles are
24
// set on tablet/desktop transitions. In phone mode we then clear
25
// the card-specific inline styles so CSS can take over.
26
super.updateStyles();
27
28
if (!isPhoneLayout(this.layoutService)) {
29
return;
30
}
31
32
const container = this.getContainer();
33
if (container) {
34
container.style.backgroundColor = '';
35
container.style.removeProperty('--part-background');
36
container.style.removeProperty('--part-border-color');
37
container.style.color = '';
38
}
39
}
40
41
override layout(width: number, height: number, top: number, left: number): void {
42
if (!isPhoneLayout(this.layoutService)) {
43
super.layout(width, height, top, left);
44
return;
45
}
46
47
if (!this.layoutService.isVisible(Parts.CHATBAR_PART)) {
48
return;
49
}
50
51
this._lastLayout = { width, height, top, left };
52
53
// Full dimensions — no card margins or session-bar subtraction.
54
// AbstractPaneCompositePart.layout internally calls Part.layout so
55
// there is no need to invoke Part.prototype.layout separately.
56
AbstractPaneCompositePart.prototype.layout.call(this, width, height, top, left);
57
}
58
}
59
60