Skip to content

Commit edc2dcf

Browse files
authored
Update the popup to show properly (#23)
1 parent fc49531 commit edc2dcf

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/components/poll-modal.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import {
66
Dialog,
77
DialogClose,
88
DialogContent,
9-
DialogDescription,
109
DialogHeader,
1110
DialogTitle,
1211
} from '@/components/ui/dialog'
1312
import { getLinkedPollDetail, type LinkedPollDetail } from '@/lib/actions/loans'
1413
import { LinkedPollResults } from '@/components/linked-poll-results'
14+
import { MarkdownView } from '@/components/markdown-view'
1515

1616
type Variant = 'pill' | 'icon' | 'link'
1717

@@ -90,20 +90,23 @@ export function PollModal({ pollId, pollQuestion, variant = 'pill' }: Props) {
9090
</DialogClose>
9191
<DialogHeader className="shrink-0">
9292
<DialogTitle className="pr-8">{detail?.question ?? pollQuestion}</DialogTitle>
93-
{detail?.description ? (
94-
<DialogDescription className="whitespace-pre-line">
95-
{detail.description}
96-
</DialogDescription>
97-
) : null}
9893
</DialogHeader>
9994

100-
<div className="min-h-0 flex-1 overflow-y-auto">
95+
{/* Description + results scroll together; only the title stays
96+
pinned, so a long markdown description never squeezes the
97+
results out of view. */}
98+
<div className="min-h-0 flex-1 space-y-4 overflow-y-auto">
10199
{pending && !detail ? (
102100
<p className="text-sm text-gray-500">Loading poll…</p>
103101
) : error ? (
104102
<p className="text-sm text-rose-600">{error}</p>
105103
) : detail ? (
106-
<LinkedPollResults detail={detail} />
104+
<>
105+
{detail.description ? (
106+
<MarkdownView source={detail.description} />
107+
) : null}
108+
<LinkedPollResults detail={detail} />
109+
</>
107110
) : null}
108111
</div>
109112
</DialogContent>

src/components/ui/dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function DialogOverlay({
3131
<DialogPrimitive.Backdrop
3232
data-slot="dialog-overlay"
3333
className={cn(
34-
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
34+
"fixed inset-0 isolate z-50 bg-black/40 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
3535
className
3636
)}
3737
{...props}
@@ -53,7 +53,7 @@ function DialogContent({
5353
<DialogPrimitive.Popup
5454
data-slot="dialog-content"
5555
className={cn(
56-
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
56+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground shadow-2xl ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
5757
className
5858
)}
5959
{...props}

0 commit comments

Comments
 (0)