Skip to content

Commit 2052bb0

Browse files
committed
Fix login modal transparency and center positioning
- Use solid background colors (white/black) instead of transparent theme.background - Fix light/dark mode detection by checking text color instead of background - Center modal horizontally and vertically in terminal window
1 parent cd1d58a commit 2052bb0

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

cli/src/components/login-modal.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,28 @@ export const LoginModal = ({
219219
}
220220
}, [hasOpenedBrowser, loginUrl, copyToClipboard])
221221

222-
// Determine if we're in light mode by checking background color luminance
223-
const isLightMode = useMemo(
224-
() => isLightModeColor(theme.background),
225-
[theme.background],
226-
)
222+
// Determine if we're in light mode by checking text colors
223+
// Note: We check text color instead of background because theme.background is 'transparent'
224+
// In light mode: text is dark (#1f2937)
225+
// In dark mode: text is light (#ffffff)
226+
const isLightMode = useMemo(() => {
227+
const textColor = theme.messageAiText
228+
if (textColor && textColor !== 'default' && textColor.startsWith('#')) {
229+
const textIsLight = isLightModeColor(textColor)
230+
// Light text = dark background = dark mode
231+
// Dark text = light background = light mode
232+
return !textIsLight
233+
}
234+
// Fallback to dark mode if we can't determine
235+
return false
236+
}, [theme.messageAiText])
227237

228238
// Use pure black/white for logo
229239
const logoColor = isLightMode ? '#000000' : '#ffffff'
230240

241+
// Use solid background colors for the modal (instead of transparent theme.background)
242+
const modalBackground = isLightMode ? '#ffffff' : '#000000'
243+
231244
// Calculate terminal width and height for responsive display
232245
const terminalWidth = renderer?.width || 80
233246
const terminalHeight = renderer?.height || 24
@@ -288,20 +301,25 @@ export const LoginModal = ({
288301
WARNING_BANNER_HEIGHT,
289302
)
290303

304+
// Calculate modal width and center position
305+
const modalWidth = Math.floor(terminalWidth * 0.95)
306+
const modalLeft = Math.floor((terminalWidth - modalWidth) / 2)
307+
const modalTop = Math.floor((terminalHeight - modalHeight) / 2)
308+
291309
// Format URL for display (wrap if needed)
292310
return (
293311
<box
294312
position="absolute"
295-
left={Math.floor(terminalWidth * 0.025)}
296-
top={1}
313+
left={modalLeft}
314+
top={modalTop}
297315
border
298316
borderStyle="double"
299317
borderColor={theme.statusAccent}
300318
style={{
301-
width: Math.floor(terminalWidth * 0.95),
319+
width: modalWidth,
302320
height: modalHeight,
303321
maxHeight: modalHeight,
304-
backgroundColor: theme.background,
322+
backgroundColor: modalBackground,
305323
padding: 0,
306324
flexDirection: 'column',
307325
}}
@@ -334,7 +352,7 @@ export const LoginModal = ({
334352
alignItems: 'center',
335353
width: '100%',
336354
height: '100%',
337-
backgroundColor: theme.background,
355+
backgroundColor: modalBackground,
338356
padding: containerPadding,
339357
gap: 0,
340358
}}

0 commit comments

Comments
 (0)