Skip to content

Commit bfbe9b3

Browse files
authored
made the banner respect themekind for shadows (#831)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> (when dark theme) <img width="232" height="195" alt="image" src="https://github.com/user-attachments/assets/755ddc4e-046e-4227-a361-eef0ad4717f0" /> <img width="247" height="195" alt="image" src="https://github.com/user-attachments/assets/faf6abdc-fd86-4f0a-9fd2-537fa083bfcd" /> (when light theme) <img width="250" height="191" alt="image" src="https://github.com/user-attachments/assets/615d13f8-42eb-43f9-be6e-da5acbfe4e16" /> <img width="225" height="195" alt="image" src="https://github.com/user-attachments/assets/48efd21f-03d1-414c-bd6f-cbd477aaac00" /> Fixes # #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
2 parents c79ecfb + 51eaef8 commit bfbe9b3

2 files changed

Lines changed: 65 additions & 13 deletions

File tree

src/app/pages/client/space/Space.tsx

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import {
1212
Line,
1313
Menu,
1414
MenuItem,
15+
Modal,
16+
Overlay,
17+
OverlayBackdrop,
18+
OverlayCenter,
1519
PopOut,
1620
Spinner,
1721
Text,
@@ -88,6 +92,8 @@ import { nameInitials } from '$utils/common';
8892
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
8993
import { CustomStateEvent } from '$types/matrix/room';
9094
import type { RoomBannerContent } from '$types/matrix-sdk-events';
95+
import { ModalWide } from '$styles/Modal.css';
96+
import { ImageViewer } from '$components/image-viewer';
9197
import * as css from './styles.css';
9298
import { ClientSideHoverFreeze } from '$components/ClientSideHoverFreeze';
9399

@@ -283,6 +289,11 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
283289
const bannerURI = mxcUrlToHttp(mx, bannerMXC ?? '', true);
284290
const hasBanner = !!(bannerURI && !hideText && showBanners);
285291

292+
const [bannerViewerOpen, setBannerViewerOpen] = useState(false);
293+
useEffect(() => {
294+
if (!hasBanner) setBannerViewerOpen(false);
295+
}, [hasBanner]);
296+
286297
return (
287298
<>
288299
<div className={hasBanner ? css.RoomCoverHeaderContainer : ''}>
@@ -310,7 +321,12 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
310321
</Box>
311322
) : (
312323
<Box grow="Yes" gap="300">
313-
<Box grow="Yes" alignItems="Center" gap="100">
324+
<Box
325+
grow="Yes"
326+
alignItems="Center"
327+
gap="100"
328+
style={hasBanner ? { color: '#fff' } : {}}
329+
>
314330
<Text size="H4" truncate>
315331
{spaceName}
316332
</Text>
@@ -320,7 +336,7 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
320336
<IconButton
321337
aria-pressed={!!menuAnchor}
322338
variant="Background"
323-
style={hasBanner ? { backgroundColor: '#0000' } : {}}
339+
style={hasBanner ? { backgroundColor: '#0000', color: '#fff' } : {}}
324340
onClick={handleOpenMenu}
325341
>
326342
<Icon src={Icons.VerticalDots} size="200" />
@@ -363,21 +379,57 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
363379
src={bannerURI}
364380
alt={`${spaceName}'s banner`}
365381
draggable="false"
382+
role="button"
383+
tabIndex={0}
384+
aria-label={`View ${spaceName} banner`}
385+
onClick={() => setBannerViewerOpen(true)}
386+
onKeyDown={(e) => {
387+
if (e.key === 'Enter' || e.key === ' ') {
388+
e.preventDefault();
389+
setBannerViewerOpen(true);
390+
}
391+
}}
392+
/>
393+
<SidebarResizer
394+
setCurWidth={setCurHeight}
395+
sidebarWidth={roomBannerHeight}
396+
setSidebarWidth={setRoomBannerHeight}
397+
instep={50}
398+
outstep={60}
399+
minValue={50}
400+
maxValue={500}
401+
topSided
366402
/>
367403
</ClientSideHoverFreeze>
368404
</div>
369-
<SidebarResizer
370-
setCurWidth={setCurHeight}
371-
sidebarWidth={roomBannerHeight}
372-
setSidebarWidth={setRoomBannerHeight}
373-
instep={50}
374-
outstep={60}
375-
minValue={50}
376-
maxValue={500}
377-
topSided
378-
/>
379405
</>
380406
)}
407+
{hasBanner && bannerViewerOpen && (
408+
<Overlay open backdrop={<OverlayBackdrop />}>
409+
<OverlayCenter>
410+
<FocusTrap
411+
focusTrapOptions={{
412+
initialFocus: false,
413+
onDeactivate: () => setBannerViewerOpen(false),
414+
clickOutsideDeactivates: true,
415+
escapeDeactivates: stopPropagation,
416+
}}
417+
>
418+
<Modal
419+
className={ModalWide}
420+
size="500"
421+
onContextMenu={(evt: React.MouseEvent) => evt.stopPropagation()}
422+
>
423+
<ImageViewer
424+
src={bannerURI}
425+
alt={`${spaceName} banner`}
426+
requestClose={() => setBannerViewerOpen(false)}
427+
/>
428+
</Modal>
429+
</FocusTrap>
430+
</OverlayCenter>
431+
</Overlay>
432+
)}
381433
</>
382434
);
383435
}

src/app/pages/client/space/styles.css.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const RoomCoverNavContainer = style({
88
width: '100%',
99
zIndex: '10000',
1010
top: '0',
11-
background: 'linear-gradient(0deg,#0000 0%, rgb(0, 0, 0) 120%)',
11+
background: 'linear-gradient(180deg, #000 0%, #0000 100%)',
1212
});
1313
export const RoomCoverlessNavContainer = recipe({
1414
base: {

0 commit comments

Comments
 (0)