Skip to content

Commit 1ce9d9e

Browse files
authored
feat(demo): enable pushContent on sidebar mode so panel pushes content left (#456)
1 parent d1dcfaa commit 1ce9d9e

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

examples/chat/angular/src/app/modes/sidebar-mode.component.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,47 @@ import { WelcomeSuggestionsComponent } from './welcome-suggestions.component';
1111
imports: [ChatSidebarComponent, WelcomeSuggestionsComponent],
1212
changeDetection: ChangeDetectionStrategy.OnPush,
1313
template: `
14-
<div class="sidebar-mode__background">
15-
<p class="sidebar-mode__hint">
16-
Use the launcher (right edge) to dismiss or re-open the chat panel.
17-
</p>
18-
</div>
1914
<chat-sidebar
2015
[agent]="agent"
2116
[views]="catalog"
2217
[modelOptions]="shell.modelOptions()"
2318
[selectedModel]="shell.model()"
2419
[open]="true"
20+
[pushContent]="true"
2521
(selectedModelChange)="shell.onModelChange($event)"
2622
(replayRequested)="shell.onTimelineReplay($event)"
2723
(forkRequested)="shell.onTimelineFork($event)"
2824
>
25+
<div class="sidebar-mode__background">
26+
<p class="sidebar-mode__hint">
27+
Use the launcher (right edge) to dismiss or re-open the chat panel.
28+
</p>
29+
</div>
2930
<welcome-suggestions chatWelcomeSuggestions (selected)="send($event)" />
3031
</chat-sidebar>
3132
`,
3233
styles: [`
33-
/* chat-sidebar's visible chrome is position: fixed (panel + launcher),
34-
* so its host element doesn't need to take layout space. Use
35-
* display: contents on the host to drop it from the flow, and let
36-
* the sibling .sidebar-mode__background fill the visible area. */
3734
:host { display: block; flex: 1; min-height: 0; position: relative; }
35+
/* Projected into chat-sidebar's default content slot so [pushContent]
36+
* applies its right-margin push to this background when the panel
37+
* opens. Sized to fill the visible area below the toolbar. */
3838
.sidebar-mode__background {
3939
display: grid;
4040
place-items: center;
41-
height: 100%;
41+
min-height: calc(100dvh - var(--demo-toolbar-height, 51px));
4242
color: #8a92a3;
4343
font-size: 14px;
4444
}
45-
:host ::ng-deep > chat-sidebar { display: contents; }
46-
/* The chat-sidebar default content slot (.chat-sidebar__content) is
47-
* meant for the consumer's page content when chat-sidebar is in
48-
* push mode. The demo uses .sidebar-mode__background instead, so
49-
* hide the default content slot — its min-height: 100vh would
50-
* otherwise stack below the background and overflow the page. */
51-
:host ::ng-deep .chat-sidebar__content { display: none; }
45+
/* chat-sidebar's default content slot sets min-height: 100vh which,
46+
* combined with the demo's flex column, would otherwise overflow the
47+
* page. The background div above provides the visible "page" so we
48+
* cap the chat-sidebar__content height to the available space. */
49+
:host ::ng-deep .chat-sidebar__content {
50+
/* Important: lib sets min-height: 100vh on this slot which would
51+
* push the page 51px below the viewport in our flex column under
52+
* the 51px toolbar. Override here. */
53+
min-height: 0 !important;
54+
}
5255
`],
5356
})
5457
export class SidebarMode {

0 commit comments

Comments
 (0)