Skip to content

Commit 59e1ba4

Browse files
committed
refactor(demo): remove anchoring div around system notification
1 parent 5495575 commit 59e1ba4

4 files changed

Lines changed: 84 additions & 68 deletions

File tree

examples/vite/src/App.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -415,29 +415,31 @@ const App = () => {
415415
data-variant={messageUiVariant ?? undefined}
416416
>
417417
<SystemNotification />
418-
<PanelLayoutStyleSync layoutRef={appLayoutRef} />
419-
<ChatViewSelectorWidthSync
420-
iconOnly={chatView.iconOnly}
421-
layoutRef={appLayoutRef}
422-
/>
423-
<ChatView>
424-
<DialogManagerProvider id={globalDialogManager}>
425-
<ChatStateSync initialChatView={initialChatView} />
426-
<SidebarLayoutSync />
427-
<ChannelsPanels
428-
filters={filters}
429-
iconOnly={chatView.iconOnly}
430-
initialChannelId={initialChannelId ?? undefined}
431-
itemSet={chatViewSelectorItemSet}
432-
options={options}
433-
sort={sort}
434-
/>
435-
<ThreadsPanels
436-
iconOnly={chatView.iconOnly}
437-
itemSet={chatViewSelectorItemSet}
438-
/>
439-
</DialogManagerProvider>
440-
</ChatView>
418+
<div className='app-chat-layout__body'>
419+
<PanelLayoutStyleSync layoutRef={appLayoutRef} />
420+
<ChatViewSelectorWidthSync
421+
iconOnly={chatView.iconOnly}
422+
layoutRef={appLayoutRef}
423+
/>
424+
<ChatView>
425+
<DialogManagerProvider id={globalDialogManager}>
426+
<ChatStateSync initialChatView={initialChatView} />
427+
<SidebarLayoutSync />
428+
<ChannelsPanels
429+
filters={filters}
430+
iconOnly={chatView.iconOnly}
431+
initialChannelId={initialChannelId ?? undefined}
432+
itemSet={chatViewSelectorItemSet}
433+
options={options}
434+
sort={sort}
435+
/>
436+
<ThreadsPanels
437+
iconOnly={chatView.iconOnly}
438+
itemSet={chatViewSelectorItemSet}
439+
/>
440+
</DialogManagerProvider>
441+
</ChatView>
442+
</div>
441443
</div>
442444
</Chat>
443445
</SidebarProvider>

examples/vite/src/SystemNotification/SystemNotification.scss

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
.str-chat__system-notification-anchor {
2-
position: relative;
3-
}
4-
51
.str-chat__system-notification {
62
display: flex;
3+
flex-shrink: 0;
74
align-items: center;
85
justify-content: center;
96
gap: var(--spacing-xs, 8px);
@@ -20,9 +17,7 @@
2017
line-height: var(--typography-line-height-tight, 16px);
2118
animation: str-chat__system-notification-slide-in 300ms ease-out both;
2219
overflow: hidden;
23-
position: fixed;
24-
inset-block-start: 0;
25-
inset-inline: 0;
20+
width: 100%;
2621
z-index: 2;
2722
}
2823

examples/vite/src/SystemNotification/SystemNotification.tsx

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,43 @@ export const SystemNotification = ({ className, filter }: SystemNotificationProp
6666
const action = rendered.actions?.[0];
6767

6868
return (
69-
<div className='str-chat__system-notification-anchor'>
70-
<div
71-
aria-live='polite'
72-
className={clsx(
73-
'str-chat__system-notification',
74-
{
75-
'str-chat__system-notification--exiting': isExiting,
76-
'str-chat__system-notification--interactive': action,
77-
[`str-chat__system-notification--${rendered.severity}`]: rendered.severity,
78-
},
79-
className,
80-
)}
81-
data-testid='system-notification'
82-
onAnimationEnd={(e) => {
83-
if (e.animationName === SLIDE_OUT_ANIMATION_NAME) {
84-
setRetainedNotification(undefined);
85-
}
86-
}}
87-
onClick={action?.handler}
88-
onKeyDown={
89-
action
90-
? (event) => {
91-
if (event.key === 'Enter' || event.key === ' ') {
92-
event.preventDefault();
93-
action.handler();
94-
}
95-
}
96-
: undefined
69+
<div
70+
aria-live='polite'
71+
className={clsx(
72+
'str-chat__system-notification',
73+
{
74+
'str-chat__system-notification--exiting': isExiting,
75+
'str-chat__system-notification--interactive': action,
76+
[`str-chat__system-notification--${rendered.severity}`]: rendered.severity,
77+
},
78+
className,
79+
)}
80+
data-testid='system-notification'
81+
onAnimationEnd={(e) => {
82+
if (e.animationName === SLIDE_OUT_ANIMATION_NAME) {
83+
setRetainedNotification(undefined);
9784
}
98-
role={action ? 'button' : 'status'}
99-
tabIndex={action ? 0 : undefined}
100-
>
101-
{Icon && (
102-
<span aria-hidden className='str-chat__system-notification-icon'>
103-
<Icon />
104-
</span>
105-
)}
106-
<span className='str-chat__system-notification-message'>{rendered.message}</span>
107-
</div>
85+
}}
86+
onClick={action?.handler}
87+
onKeyDown={
88+
action
89+
? (event) => {
90+
if (event.key === 'Enter' || event.key === ' ') {
91+
event.preventDefault();
92+
action.handler();
93+
}
94+
}
95+
: undefined
96+
}
97+
role={action ? 'button' : 'status'}
98+
tabIndex={action ? 0 : undefined}
99+
>
100+
{Icon && (
101+
<span aria-hidden className='str-chat__system-notification-icon'>
102+
<Icon />
103+
</span>
104+
)}
105+
<span className='str-chat__system-notification-message'>{rendered.message}</span>
108106
</div>
109107
);
110108
};

examples/vite/src/index.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,39 @@ body {
1818

1919
#root {
2020
display: flex;
21+
flex-direction: column;
2122
height: 100vh;
23+
min-height: 0;
2224
}
2325

2426
@layer stream-overrides {
2527
.app-chat-layout {
2628
--app-left-panel-width: 360px;
2729
--app-thread-panel-width: 360px;
2830

31+
display: flex;
32+
flex: 1 1 auto;
33+
flex-direction: column;
34+
min-height: 0;
2935
height: 100%;
3036
width: 100%;
3137
}
3238

39+
/* Fills viewport minus in-flow `.str-chat__system-notification` when present */
40+
.app-chat-layout__body {
41+
display: flex;
42+
flex: 1 1 auto;
43+
flex-direction: column;
44+
min-height: 0;
45+
min-width: 0;
46+
}
47+
48+
/* ChatView root is the only in-DOM child of __body (sync components return null) */
49+
.app-chat-layout__body > .str-chat__chat-view {
50+
flex: 1 1 auto;
51+
min-height: 0;
52+
}
53+
3354
.app-chat-layout .str-chat {
3455
--str-chat__channel-list-width: var(--app-left-panel-width);
3556
--str-chat__thread-list-width: var(--app-left-panel-width);

0 commit comments

Comments
 (0)