mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
- Replace bordered cards with compact flat rows and maintenance sections - Add shared SettingsDisclosure for config, maintenance, and sandbox sections - Auto-scroll expanded sections into view when outside the scrollport - Make agent file editor and agent form full-height and keyboard-aware on mobile
32 lines
961 B
TypeScript
32 lines
961 B
TypeScript
interface RectLike {
|
|
top: number
|
|
bottom: number
|
|
}
|
|
|
|
export function isSectionFullyVisible(section: RectLike, scroller: RectLike): boolean {
|
|
return section.top >= scroller.top && section.bottom <= scroller.bottom
|
|
}
|
|
|
|
function findScrollContainer(element: HTMLElement): HTMLElement | null {
|
|
let node = element.parentElement
|
|
while (node) {
|
|
const { overflowY } = getComputedStyle(node)
|
|
if ((overflowY === 'auto' || overflowY === 'scroll') && node.scrollHeight > node.clientHeight) {
|
|
return node
|
|
}
|
|
node = node.parentElement
|
|
}
|
|
return null
|
|
}
|
|
|
|
export function scrollSectionIntoView(header: HTMLElement | null) {
|
|
if (!header) return
|
|
const section = header.parentElement
|
|
if (!section) return
|
|
const scroller = findScrollContainer(section)
|
|
if (scroller && isSectionFullyVisible(section.getBoundingClientRect(), scroller.getBoundingClientRect())) {
|
|
return
|
|
}
|
|
header.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
}
|