MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / calculateResponsiveLayout

Function calculateResponsiveLayout

cli/src/login/utils.ts:111–149  ·  view source on GitHub ↗
(
  terminalWidth: number,
  terminalHeight: number,
)

Source from the content-addressed store, hash-verified

109 * Calculates responsive layout dimensions based on terminal size
110 */
111export function calculateResponsiveLayout(
112 terminalWidth: number,
113 terminalHeight: number,
114) {
115 // Responsive breakpoints based on terminal height
116 const isVerySmall = terminalHeight < 15 // Minimal UI
117 const isSmall = terminalHeight >= 15 && terminalHeight < 20 // Compact UI
118 const isMedium = terminalHeight >= 20 && terminalHeight < 30 // Standard UI
119 const isLarge = terminalHeight >= 30 // Spacious UI
120
121 // Responsive breakpoints based on terminal width
122 const isNarrow = terminalWidth < 60
123
124 // Dynamic spacing based on terminal size - compressed to prevent scrolling
125 const containerPadding = isVerySmall ? 0 : 1
126 const headerMarginTop = 0
127 const headerMarginBottom = isVerySmall ? 0 : 1
128 const sectionMarginBottom = isVerySmall ? 0 : 1
129 const contentMaxWidth = Math.max(
130 10,
131 Math.min(terminalWidth - (containerPadding * 2 + 4), 80),
132 )
133
134 const maxUrlWidth = Math.min(terminalWidth - 10, 100)
135
136 return {
137 isVerySmall,
138 isSmall,
139 isMedium,
140 isLarge,
141 isNarrow,
142 containerPadding,
143 headerMarginTop,
144 headerMarginBottom,
145 sectionMarginBottom,
146 contentMaxWidth,
147 maxUrlWidth,
148 }
149}
150
151/**
152 * Calculates modal height based on terminal size and whether credentials are invalid

Callers 1

LoginModalFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected