Rework css on room view to avoid losing input visibility

This commit is contained in:
Jon Staab
2025-03-03 17:46:15 -08:00
parent db203bf00d
commit 3a42a1b560
4 changed files with 123 additions and 82 deletions

View File

@@ -329,3 +329,27 @@ emoji-picker {
progress[value]::-webkit-progress-value { progress[value]::-webkit-progress-value {
transition: width 0.5s; transition: width 0.5s;
} }
/* content width for fixed elements */
.cw {
@apply w-full md:w-[calc(100%-18.5rem)];
}
/* chat view */
.chat__page-bar {
@apply cw !fixed top-0;
}
.chat__messages {
@apply cw fixed top-12 flex h-[calc(100%-10rem)] flex-col-reverse overflow-y-auto overflow-x-hidden md:h-[calc(100%-6rem)];
}
.chat__compose {
@apply cw fixed bottom-14 md:bottom-0;
}
.chat__scroll-down {
@apply fixed bottom-28 right-4 md:bottom-16;
}

View File

@@ -9,7 +9,7 @@
const {...props}: Props = $props() const {...props}: Props = $props()
</script> </script>
<div class="relative z-feature mx-2 rounded-xl pt-2 {props.class}"> <div class="relative z-feature rounded-xl px-2 pt-2 {props.class}">
<div <div
class="flex min-h-12 items-center justify-between gap-4 rounded-xl bg-base-100 px-4 shadow-xl"> class="flex min-h-12 items-center justify-between gap-4 rounded-xl bg-base-100 px-4 shadow-xl">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">

View File

@@ -125,6 +125,7 @@
</div> </div>
{/if} {/if}
</div> </div>
<Divider>Your Rooms</Divider>
<div class="grid grid-cols-3 gap-2"> <div class="grid grid-cols-3 gap-2">
<Link href={threadsPath} class="btn btn-primary"> <Link href={threadsPath} class="btn btn-primary">
<div class="relative flex items-center gap-2"> <div class="relative flex items-center gap-2">
@@ -167,6 +168,9 @@
{/if} {/if}
</Link> </Link>
{/each} {/each}
</div>
<Divider>Other Rooms</Divider>
<div class="grid grid-cols-3 gap-2">
{#each $otherRooms as room (room)} {#each $otherRooms as room (room)}
<Link href={makeRoomPath(url, room)} class="btn btn-neutral"> <Link href={makeRoomPath(url, room)} class="btn btn-neutral">
<div class="relative flex min-w-0 items-center gap-2 overflow-hidden text-nowrap"> <div class="relative flex min-w-0 items-center gap-2 overflow-hidden text-nowrap">

View File

@@ -134,6 +134,8 @@
let parent: TrustedEvent | undefined = $state() let parent: TrustedEvent | undefined = $state()
let element: HTMLElement | undefined = $state() let element: HTMLElement | undefined = $state()
let newMessages: HTMLElement | undefined = $state() let newMessages: HTMLElement | undefined = $state()
let parentPreview: HTMLElement | undefined = $state()
let dynamicPadding: HTMLElement | undefined = $state()
let newMessagesSeen = false let newMessagesSeen = false
let showFixedNewMessages = $state(false) let showFixedNewMessages = $state(false)
let showScrollButton = $state(false) let showScrollButton = $state(false)
@@ -208,6 +210,16 @@
loadingEvents = false loadingEvents = false
}, },
})) }))
const observer = new ResizeObserver(() => {
dynamicPadding!.style.minHeight = `${parentPreview!.offsetHeight}px`
})
observer.observe(parentPreview!)
return () => {
observer.unobserve(parentPreview!)
}
}) })
onDestroy(() => { onDestroy(() => {
@@ -220,8 +232,7 @@
}) })
</script> </script>
<div class="relative flex h-full flex-col"> <PageBar class="chat__page-bar">
<PageBar>
{#snippet icon()} {#snippet icon()}
<div class="center"> <div class="center">
<Icon icon="hashtag" /> <Icon icon="hashtag" />
@@ -255,10 +266,9 @@
</div> </div>
{/snippet} {/snippet}
</PageBar> </PageBar>
<div
class="scroll-container -mt-2 flex flex-grow flex-col-reverse overflow-y-auto overflow-x-hidden py-2" <div class="chat__messages scroll-container" onscroll={onScroll} bind:this={element}>
onscroll={onScroll} <div bind:this={dynamicPadding}></div>
bind:this={element}>
{#each elements as { type, id, value, showPubkey } (id)} {#each elements as { type, id, value, showPubkey } (id)}
{#if type === "new-messages"} {#if type === "new-messages"}
<div <div
@@ -290,6 +300,27 @@
{/if} {/if}
</p> </p>
</div> </div>
<div class="chat__compose bg-base-200">
<div bind:this={parentPreview}>
{#if parent}
<ChannelComposeParent event={parent} clear={clearParent} verb="Replying to" />
{/if}
{#if share}
<ChannelComposeParent event={share} clear={clearShare} verb="Sharing" />
{/if}
</div>
<ChannelCompose bind:this={compose} {onSubmit} />
</div>
{#if showScrollButton}
<div in:fade class="chat__scroll-down">
<Button class="btn btn-circle btn-neutral" onclick={scrollToBottom}>
<Icon icon="alt-arrow-down" />
</Button>
</div>
{/if}
{#if showFixedNewMessages} {#if showFixedNewMessages}
<div class="relative z-feature flex justify-center"> <div class="relative z-feature flex justify-center">
<div transition:fly={{duration: 200}} class="fixed top-12"> <div transition:fly={{duration: 200}} class="fixed top-12">
@@ -299,21 +330,3 @@
</div> </div>
</div> </div>
{/if} {/if}
<div>
{#if parent}
<ChannelComposeParent event={parent} clear={clearParent} verb="Replying to" />
{/if}
{#if share}
<ChannelComposeParent event={share} clear={clearShare} verb="Sharing" />
{/if}
<ChannelCompose bind:this={compose} {onSubmit} />
</div>
</div>
{#if showScrollButton}
<div in:fade class="fixed bottom-14 right-4">
<Button class="btn btn-circle btn-neutral" onclick={scrollToBottom}>
<Icon icon="alt-arrow-down" />
</Button>
</div>
{/if}