Skip to content

Commit edb2340

Browse files
authored
fix: Adjust modal height in window view to occupy entire screen height
1 parent 95a7ca0 commit edb2340

File tree

7 files changed

+57
-14
lines changed

7 files changed

+57
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [0.0.1] - 2024-03-26
5+
## [1.0.0] - 2024-03-26
66

77
### Added
88

src/components/SirenInbox.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,26 @@ const SirenInbox: FC<SirenProps> = ({
144144
setIsModalOpen((prevState: boolean) => !prevState);
145145
};
146146

147+
const modalStyle = useMemo(() => {
148+
if (windowViewOnly)
149+
return {
150+
width: "100%",
151+
height: "100%",
152+
};
153+
else
154+
return {
155+
...styles.windowShadow,
156+
...modalPosition,
157+
width: updatedModalWidth,
158+
};
159+
160+
}, [windowViewOnly, updatedModalWidth, styles.windowShadow]);
161+
162+
147163
return (
148164
<div
149165
ref={modalRef}
150-
className={`${!windowViewOnly && "siren-sdk-inbox-container"}`}
166+
className={`${!windowViewOnly ? "siren-sdk-inbox-container" : "siren-sdk-inbox-window-container"}`}
151167
>
152168
{!windowViewOnly && (
153169
<div ref={iconRef}>
@@ -165,11 +181,9 @@ const SirenInbox: FC<SirenProps> = ({
165181
{(isModalOpen || windowViewOnly) && (
166182
<div
167183
style={{
168-
...styles.container,
169-
...(!windowViewOnly && styles.windowShadow),
170184
position: windowViewOnly ? "initial" : "absolute",
171-
width: windowViewOnly ? "100%" : updatedModalWidth,
172-
...modalPosition,
185+
...styles.container,
186+
...modalStyle,
173187
}}
174188
data-testid="siren-panel"
175189
>

src/components/SirenPanel.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { SirenPanelProps } from "../types";
2020
import {
2121
filterDataProperty,
2222
generateFilterParams,
23+
getModalContentHeightInFullScreen,
2324
isEmptyArray,
2425
isValidResponse,
2526
mergeArrays,
@@ -437,6 +438,10 @@ const SirenPanel: FC<SirenPanelProps> = ({
437438
};
438439
}, [fullScreen, styles, modalWidth]);
439440

441+
const contentContainerHeightInFullScreen = useMemo(() => {
442+
return getModalContentHeightInFullScreen(styles?.headerContainer?.height);
443+
}, [styles?.headerContainer?.height]);
444+
440445
return (
441446
<div
442447
className={
@@ -445,7 +450,7 @@ const SirenPanel: FC<SirenPanelProps> = ({
445450
style={panelStyle}
446451
data-testid="siren-panel"
447452
>
448-
<div>
453+
<div className={fullScreen ? 'siren-sdk-panel-modal-fullscreen' : ''}>
449454
{!hideHeader &&
450455
(customHeader || (
451456
<Header
@@ -460,16 +465,19 @@ const SirenPanel: FC<SirenPanelProps> = ({
460465
<div
461466
style={{
462467
...(!fullScreen && styles.windowBottomBorder),
468+
...(fullScreen && {height: contentContainerHeightInFullScreen}),
463469
...styles.contentContainer,
464470
}}
465471
>
466472
<div
467473
id="contentContainer"
468474
style={{
469-
...(!fullScreen && styles.windowBottomBorder),
470-
...styles.body,
475+
...(fullScreen ? { height: contentContainerHeightInFullScreen } : {
476+
...styles.windowBottomBorder,
477+
...styles.body
478+
}),
471479
}}
472-
className={containerClassNames}
480+
className={`siren-sdk-panel-content-container ${containerClassNames}`}
473481
aria-label="siren-notification-list"
474482
>
475483
{renderList()}

src/styles/sirenInbox.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
.siren-sdk-inbox-container {
33
width: fit-content;
44
position: relative;
5+
}
6+
.siren-sdk-inbox-window-container {
7+
height: 100%;
58
}

src/styles/sirenPanel.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
.siren-sdk-list-loader-container{
22
width: 100%;
33
}
4+
.siren-sdk-panel-modal-fullscreen {
5+
height: 100%;
6+
}
47
.siren-sdk-panel-modal {
58
position:absolute;
69
box-shadow: rgb(0 0 0 / 30%) 0px 8px 24px;
@@ -12,8 +15,12 @@
1215
margin: 10px;
1316

1417
}
18+
.siren-sdk-panel-content-container {
19+
overflow: auto;
20+
}
1521
.siren-sdk-panel-container {
1622
width: 100% !important;
23+
height: 100%;;
1724
border-radius: 20px;
1825
background-color: #FFFFFF;
1926
display: flex;

src/utils/commonUtils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export const applyTheme = (
157157
}`,
158158
},
159159
body: {
160-
overflow: "auto",
161160
height: customStyle.windowContainer?.contentHeight || "700px",
162161
},
163162
headerContainer: {
@@ -442,3 +441,13 @@ export const debounce = <F extends (...args: unknown[]) => void>(
442441
}, delay);
443442
};
444443
};
444+
445+
export const getModalContentHeightInFullScreen = (headerHeight: DimensionValue | undefined) => {
446+
let updatedHeight = 0;
447+
448+
if (typeof headerHeight === "string")
449+
updatedHeight = parseInt(headerHeight.slice(0, -2));
450+
else if (typeof headerHeight === "number") updatedHeight = headerHeight;
451+
452+
return `calc(100% - ${updatedHeight}px)`
453+
}

tests/components/__snapshots__/sirenPanel.spec.tsx.snap

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ exports[`matches snapshot 1`] = `
77
data-testid="siren-panel"
88
style="border-top-left-radius: 10px; border-top-right-radius: 10px; width: 500px; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; max-width: 100;"
99
>
10-
<div>
10+
<div
11+
class=""
12+
>
1113
<div
1214
class="siren-sdk-header-container"
1315
data-testid="header"
@@ -51,9 +53,9 @@ exports[`matches snapshot 1`] = `
5153
>
5254
<div
5355
aria-label="siren-notification-list"
54-
class="false "
56+
class="siren-sdk-panel-content-container false "
5557
id="contentContainer"
56-
style="border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; overflow: auto; height: 700px;"
58+
style="border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; height: 700px;"
5759
>
5860
<div
5961
class="siren-sdk-list-loader-container"

0 commit comments

Comments
 (0)