mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
fix(app): keep composer fades off visible text
This commit is contained in:
parent
71a1b10ba4
commit
324356582e
2 changed files with 14 additions and 8 deletions
|
|
@ -2,13 +2,13 @@
|
|||
content: "\200B";
|
||||
}
|
||||
|
||||
/* Matches the 16px session title fade. The top fade only covers the editor's 16px top padding until text scrolls
|
||||
under it; the mask sits on the viewport so the thumb stays solid. */
|
||||
/* Matches the 16px session title fade. The editor sets each depth from the text hidden past that edge; the mask
|
||||
sits on the viewport so the thumb stays solid. */
|
||||
[data-component="composer-scroll"] > .scroll-view__viewport {
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
black 16px,
|
||||
black var(--composer-fade-top, 0px),
|
||||
black calc(100% - var(--composer-fade-bottom, 0px)),
|
||||
transparent
|
||||
);
|
||||
|
|
|
|||
|
|
@ -109,12 +109,18 @@ export function ComposerEditor(props: ComposerEditorProps) {
|
|||
})
|
||||
}
|
||||
|
||||
// The bottom fade shrinks with the remaining scroll so the last line ends clear of it.
|
||||
const [fadeBottom, setFadeBottom] = createSignal(0)
|
||||
// Each fade is only as deep as the text hidden past its edge, so the editor's padding alone never fades the
|
||||
// line being typed at max height.
|
||||
const [fade, setFade] = createStore({ top: 0, bottom: 0 })
|
||||
|
||||
const updateScroll = () => {
|
||||
if (!viewport) return
|
||||
setFadeBottom(Math.min(16, Math.max(0, viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop)))
|
||||
if (!viewport || !editor) return
|
||||
const style = getComputedStyle(editor)
|
||||
const below = viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop
|
||||
setFade({
|
||||
top: Math.min(16, Math.max(0, viewport.scrollTop - parseFloat(style.paddingTop))),
|
||||
bottom: Math.min(16, Math.max(0, below - parseFloat(style.paddingBottom))),
|
||||
})
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
|
@ -239,7 +245,7 @@ export function ComposerEditor(props: ComposerEditorProps) {
|
|||
<ScrollView
|
||||
data-component="composer-scroll"
|
||||
class="min-h-[60px] max-h-[180px]"
|
||||
style={{ "--composer-fade-bottom": `${fadeBottom()}px` }}
|
||||
style={{ "--composer-fade-top": `${fade.top}px`, "--composer-fade-bottom": `${fade.bottom}px` }}
|
||||
onScroll={updateScroll}
|
||||
viewportRef={(element) => {
|
||||
viewport = element
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue