Skip to content

Commit 1836613

Browse files
committed
fix: fit modal to all screens
1 parent 29277ef commit 1836613

File tree

1 file changed

+38
-28
lines changed
  • website/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction

1 file changed

+38
-28
lines changed

website/src/components/InteractiveDiagrams/Timeboost/CentralizedAuction/Modal.tsx

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function Modal({ number }: { number: number }) {
7171
const renderModalContent = (style: any) => (
7272
<Content $isDark={isDarkTheme} forceMount style={style}>
7373
<DialogHeader>
74-
<CloseButton $isDark={isDarkTheme}>
74+
<CloseButton $isDark={isDarkTheme} onClick={() => setIsOpen(false)}>
7575
<CloseIcon />
7676
</CloseButton>
7777
</DialogHeader>
@@ -97,22 +97,29 @@ export function Modal({ number }: { number: number }) {
9797
style={{
9898
cursor: 'pointer',
9999
pointerEvents: 'all',
100-
position: 'relative',
101-
zIndex: 10,
102100
}}
103101
>
104102
<NumberComponent number={number} />
105103
</g>
106104
{typeof document !== 'undefined' &&
107105
createPortal(
108106
<Dialog.Root open={isOpen} onOpenChange={setIsOpen}>
109-
<Dialog.Portal forceMount>
110-
{transition((style, isOpen) => (
111-
<>
112-
{isOpen && <OverlayBackground style={{ opacity: style.opacity }} />}
113-
{isOpen && renderModalContent(style)}
114-
</>
115-
))}
107+
<Dialog.Portal>
108+
<OverlayBackground />
109+
<div style={{
110+
position: 'fixed',
111+
top: 0,
112+
left: 0,
113+
right: 0,
114+
bottom: 0,
115+
display: 'flex',
116+
alignItems: 'center',
117+
justifyContent: 'center',
118+
padding: '20px',
119+
zIndex: 10000,
120+
}}>
121+
{renderModalContent({})}
122+
</div>
116123
</Dialog.Portal>
117124
</Dialog.Root>,
118125
document.body,
@@ -134,38 +141,28 @@ const OverlayBackground = styled(animated(Dialog.Overlay))`
134141
width: 100vw;
135142
height: 100vh;
136143
background-color: rgba(0, 0, 0, 0.5);
137-
pointer-events: all;
138144
position: fixed;
139145
inset: 0;
140146
z-index: 9999;
141147
`;
142148

143149
const Content = styled(animated(Dialog.Content))<{ $isDark: boolean }>`
144-
position: fixed;
145-
top: 50%;
146-
left: 50%;
147-
transform: translate(-50%, -50%);
148-
min-width: min(400px, 95vw);
150+
position: relative;
151+
width: 100%;
149152
max-width: 800px;
150-
width: 95vw;
151153
min-height: 200px;
152-
max-height: 90vh;
153-
height: fit-content;
154+
max-height: calc(100vh - 40px);
154155
background-color: ${(props) => (props.$isDark ? 'rgb(33, 49, 71)' : 'rgb(255, 255, 255)')};
155156
border-radius: 4px;
156-
padding: 24px 24px 32px;
157-
z-index: 10000;
157+
padding: 24px;
158158
display: flex;
159159
flex-direction: column;
160160
color: ${(props) => (props.$isDark ? '#fff' : '#000')};
161161
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
162-
overflow-y: auto;
162+
overflow: hidden;
163163
164164
@media (max-width: 768px) {
165165
padding: 16px;
166-
width: 95vw;
167-
min-width: unset;
168-
max-height: 85vh;
169166
}
170167
`;
171168

@@ -180,10 +177,10 @@ const DialogBody = styled.div<{ $isDark: boolean }>`
180177
display: flex;
181178
flex-direction: column;
182179
gap: 16px;
183-
margin-bottom: 6px;
184180
overflow-y: auto;
185181
padding-right: 8px;
186182
flex: 1;
183+
-webkit-overflow-scrolling: touch;
187184
188185
pre {
189186
margin: 0 !important;
@@ -205,14 +202,21 @@ const DialogBody = styled.div<{ $isDark: boolean }>`
205202
206203
@media (max-width: 768px) {
207204
padding-right: 4px;
208-
205+
209206
pre {
210207
padding: 12px !important;
208+
margin: 0 -12px !important;
209+
border-radius: 0 !important;
211210
}
212-
211+
213212
code {
214213
font-size: 13px !important;
215214
}
215+
216+
ul {
217+
padding-left: 20px;
218+
margin: 8px 0;
219+
}
216220
}
217221
`;
218222

@@ -233,6 +237,12 @@ const CloseButton = styled(Dialog.Close)<{ $isDark: boolean }>`
233237
const Title = styled(Dialog.Title)<{ $isDark: boolean }>`
234238
font-size: 20px;
235239
margin-bottom: 16px;
240+
padding-right: 24px;
236241
flex-shrink: 0;
237242
color: ${(props) => (props.$isDark ? '#fff' : '#000')};
243+
244+
@media (max-width: 768px) {
245+
font-size: 18px;
246+
margin-bottom: 12px;
247+
}
238248
`;

0 commit comments

Comments
 (0)