Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sticky-banner-shadcn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
leroa: patch
---

Restore the full-width sticky demo banner and replace native browser controls (confirm dialogs, details/summary) with shadcn-svelte AlertDialog and Collapsible components.
17 changes: 16 additions & 1 deletion src/lib/components/app/demo-banner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,25 @@
document.removeEventListener('visibilitychange', update);
};
});

let el: HTMLDivElement;
$effect(() => {
if (!el) return;
const set = () =>
document.documentElement.style.setProperty('--demo-banner-h', `${el.offsetHeight}px`);
set();
const ro = new ResizeObserver(set);
ro.observe(el);
return () => {
ro.disconnect();
document.documentElement.style.removeProperty('--demo-banner-h');
};
});
</script>

<div
class="absolute top-14 left-1/2 z-50 flex -translate-x-1/2 flex-wrap items-center justify-center gap-x-3 gap-y-1 rounded-full bg-primary/95 px-4 py-1.5 text-center text-xs text-primary-foreground shadow-lg backdrop-blur sm:top-2"
bind:this={el}
class="sticky top-0 z-50 flex w-full flex-wrap items-center justify-center gap-x-3 gap-y-1 bg-primary px-4 py-1.5 text-center text-xs text-primary-foreground"
>
<span>
Private demo · {remaining > 0 ? 'Session ends in' : 'Session ended'}
Expand Down
39 changes: 28 additions & 11 deletions src/lib/components/app/lease-agreements.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import FileSignature from '@lucide/svelte/icons/file-signature';
import Plus from '@lucide/svelte/icons/plus';
import Send from '@lucide/svelte/icons/send';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

let { leaseId }: { leaseId: string } = $props();

Expand Down Expand Up @@ -62,8 +63,16 @@
}
}

async function send(id: string) {
if (!confirm('Send for signature? The document can’t be edited after it’s sent.')) return;
function send(id: string) {
confirmDelete({
title: 'Send for signature?',
description: 'The document can’t be edited after it’s sent.',
confirm: { text: 'Send' },
onConfirm: () => sendNow(id)
});
}

async function sendNow(id: string) {
busy = true;
try {
const { unreachable } = await sendAgreement(id);
Expand All @@ -80,17 +89,25 @@
}
}

async function remove(id: string) {
if (!confirm('Delete this draft?')) return;
await deleteAgreement(id).catch((err) => fail(err, 'Could not delete'));
function remove(id: string) {
confirmDelete({
title: 'Delete this draft?',
description: 'The draft agreement will be removed.',
onConfirm: () => deleteAgreement(id).catch((err) => fail(err, 'Could not delete'))
});
}

async function voidIt(id: string) {
if (!confirm('Void this agreement? Tenants will no longer be able to sign it.')) return;
await voidAgreement(id).then(
() => toast.success('Agreement voided'),
(err) => fail(err, 'Could not void')
);
function voidIt(id: string) {
confirmDelete({
title: 'Void this agreement?',
description: 'Tenants will no longer be able to sign it.',
confirm: { text: 'Void' },
onConfirm: () =>
voidAgreement(id).then(
() => toast.success('Agreement voided'),
(err) => fail(err, 'Could not void')
)
});
}

const pdf = (id: string) => `/api/agreements/${id}/pdf`;
Expand Down
22 changes: 14 additions & 8 deletions src/lib/components/app/listing-editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import ImagePlus from '@lucide/svelte/icons/image-plus';
import X from '@lucide/svelte/icons/x';
import Plus from '@lucide/svelte/icons/plus';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

type Listing = Awaited<ReturnType<typeof getListing>>;
let { listing }: { listing: Listing } = $props();
Expand Down Expand Up @@ -160,14 +161,19 @@
toast.success('Link copied');
}

async function remove() {
if (!confirm('Delete this listing and its photos? Applications are kept.')) return;
try {
await deleteListing(listing.id);
await goto('/leasing?tab=listings');
} catch (err) {
fail(err, 'Could not delete');
}
function remove() {
confirmDelete({
title: 'Delete this listing and its photos?',
description: 'Applications are kept.',
onConfirm: async () => {
try {
await deleteListing(listing.id);
await goto('/leasing?tab=listings');
} catch (err) {
fail(err, 'Could not delete');
}
}
});
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/app/page-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<svelte:head><title>{title} · Leroa</title></svelte:head>

<header
class="sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background/80 px-4 backdrop-blur"
class="sticky top-[var(--demo-banner-h,0px)] z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background/80 px-4 backdrop-blur"
>
<Sidebar.Trigger class="-ml-1" />
<Separator orientation="vertical" class="mr-1 data-[orientation=vertical]:h-4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<AlertDialog.Title>
{dialogState.options?.title}
</AlertDialog.Title>
<AlertDialog.Description>
<AlertDialog.Description class="wrap-anywhere">
{dialogState.options?.description}
</AlertDialog.Description>
</AlertDialog.Header>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<Sidebar.Provider>
<AppSidebar user={data.user} org={data.org} onsearch={() => (paletteOpen = true)} />
<Sidebar.Inset class="min-w-0 {data.demo && data.demoExpiresAt ? 'max-sm:pt-10' : ''}">
<Sidebar.Inset class="min-w-0">
{#if data.demo && data.demoExpiresAt}
<DemoBanner
expiresAt={data.demoExpiresAt}
Expand Down
22 changes: 14 additions & 8 deletions src/routes/(app)/inspections/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import X from '@lucide/svelte/icons/x';
import Plus from '@lucide/svelte/icons/plus';
import MessageSquare from '@lucide/svelte/icons/message-square';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

const id = $derived(page.params.id!);
const i = $derived(await getInspection(id));
Expand Down Expand Up @@ -179,14 +180,19 @@
}
}

async function remove() {
if (!confirm('Delete this inspection and its photos?')) return;
try {
await deleteInspection(id);
await goto('/inspections');
} catch (err) {
fail(err, 'Could not delete');
}
function remove() {
confirmDelete({
title: 'Delete this inspection and its photos?',
description: 'This cannot be undone.',
onConfirm: async () => {
try {
await deleteInspection(id);
await goto('/inspections');
} catch (err) {
fail(err, 'Could not delete');
}
}
});
}
</script>

Expand Down
15 changes: 14 additions & 1 deletion src/routes/(app)/leasing/applications/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import Mail from '@lucide/svelte/icons/mail';
import Phone from '@lucide/svelte/icons/phone';
import Check from '@lucide/svelte/icons/check';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

const id = $derived(page.params.id!);
const a = $derived(await getApplication(id));
Expand All @@ -45,7 +46,19 @@
toast.error((err as { body?: { message?: string } })?.body?.message ?? fallback);

async function setStatus(status: 'new' | 'reviewing' | 'declined' | 'withdrawn') {
if (status === 'declined' && !confirm(`Decline ${name}'s application?`)) return;
if (status === 'declined') {
confirmDelete({
title: `Decline ${name}'s application?`,
description: 'They will be notified their application was declined.',
confirm: { text: 'Decline' },
onConfirm: () => setStatusNow(status)
});
return;
}
await setStatusNow(status);
}

async function setStatusNow(status: 'new' | 'reviewing' | 'declined' | 'withdrawn') {
try {
await updateApplication({ id, status });
toast.success(status === 'declined' ? 'Application declined' : `Marked ${status}`);
Expand Down
22 changes: 14 additions & 8 deletions src/routes/(app)/leasing/leads/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import Inbox from '@lucide/svelte/icons/inbox';
import ArrowRight from '@lucide/svelte/icons/arrow-right';
import CalendarClock from '@lucide/svelte/icons/calendar-clock';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

const id = $derived(page.params.id!);
const l = $derived(await getLead(id));
Expand Down Expand Up @@ -143,14 +144,19 @@
}
}

async function remove() {
if (!confirm(`Delete ${name} and their history? This can't be undone.`)) return;
try {
await deleteLead(id);
await goto('/leasing');
} catch (err) {
fail(err, 'Could not delete');
}
function remove() {
confirmDelete({
title: `Delete ${name} and their history?`,
description: "This can't be undone.",
onConfirm: async () => {
try {
await deleteLead(id);
await goto('/leasing');
} catch (err) {
fail(err, 'Could not delete');
}
}
});
}

async function tourStatus(tourId: string, status: 'completed' | 'no_show' | 'cancelled') {
Expand Down
18 changes: 11 additions & 7 deletions src/routes/(app)/messages/announcements/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import Megaphone from '@lucide/svelte/icons/megaphone';
import Trash from '@lucide/svelte/icons/trash-2';
import Mail from '@lucide/svelte/icons/mail';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

const items = $derived(await getAnnouncements());
let composing = $state(page.url.searchParams.has('new'));
Expand All @@ -18,13 +19,16 @@
if (page.url.searchParams.has('new')) composing = true;
});

async function remove(id: string, subject: string) {
if (
!confirm(
`Remove "${subject}" from the resident portal? Emails already sent can't be recalled.`
)
)
return;
function remove(id: string, subject: string) {
confirmDelete({
title: `Remove "${subject}" from the resident portal?`,
description: "Emails already sent can't be recalled.",
confirm: { text: 'Remove' },
onConfirm: () => removeNow(id)
});
}

async function removeNow(id: string) {
try {
await deleteAnnouncement(id);
toast.success('Announcement removed');
Expand Down
17 changes: 12 additions & 5 deletions src/routes/(app)/properties/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import Ellipsis from '@lucide/svelte/icons/ellipsis';
import Wrench from '@lucide/svelte/icons/wrench';
import FileSignature from '@lucide/svelte/icons/file-signature';
import { confirmDelete } from '#lib/components/ui/confirm-delete-dialog/index.js';

const id = $derived(page.params.id!);
const p = $derived(await getProperty(id));
Expand Down Expand Up @@ -89,11 +90,17 @@
}
}

async function archive() {
if (!confirm(`Archive ${p.name}? It will be hidden from lists.`)) return;
await archiveProperty(id);
toast.success('Property archived');
await goto('/properties');
function archive() {
confirmDelete({
title: `Archive ${p.name}?`,
description: 'It will be hidden from lists.',
confirm: { text: 'Archive' },
onConfirm: async () => {
await archiveProperty(id);
toast.success('Property archived');
await goto('/properties');
}
});
}
</script>

Expand Down
Loading
Loading