2026-04-29 14:12:15 +02:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { ChevronLeft } from 'lucide-react';
|
|
|
|
|
import { useRouter, usePathname } from 'next/navigation';
|
|
|
|
|
|
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
import { useMobileChrome } from './mobile-layout-provider';
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-01 16:34:28 +02:00
|
|
|
* Fixed mobile topbar (56px + safe-area top inset). Marina-editorial premium:
|
|
|
|
|
* deep-navy gradient surface with white type, the brand "PN" mark on the
|
|
|
|
|
* left when there's no back affordance, and a soft glow shadow underneath
|
|
|
|
|
* for depth instead of a hard divider line.
|
|
|
|
|
*
|
2026-05-04 22:57:01 +02:00
|
|
|
* Slots: title (auto-truncating), back arrow, primary action - all driven by
|
2026-05-01 16:34:28 +02:00
|
|
|
* `useMobileChrome()` from the active page. When no page has set a title the
|
|
|
|
|
* URL's last segment is title-cased as a fallback.
|
2026-04-29 14:12:15 +02:00
|
|
|
*/
|
|
|
|
|
export function MobileTopbar() {
|
|
|
|
|
const { title, primaryAction, showBackButton } = useMobileChrome();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
|
chore(autonomous-session): consolidate uncommitted work from prior session
Bundles the prior autonomous-session output that was sitting unstaged:
- Em-dash sweep across src/ + tests/ (en-dash/em-dash to hyphen, ~2280 instances)
- country-flag-icons rollout (CountryFlag component, replaces emoji glyphs that
never rendered on Windows; lazy-loads the 3x2 SVG index as a single chunk
after the per-subpath dynamic-import approach silently failed in webpack)
- Admin IA Phase 1+2: 7-domain regroup, 41 to 38 pages, /admin/berths index,
redirects (ocr to ai, reports to dashboard, invitations to users),
docs/admin-ia-proposal.md
- Per-template email tester (registry + endpoint + UI on Email admin page)
- Cancel-document mode picker (delete-from-Documenso vs keep-for-audit)
- Dashboard PDF report: 25 widgets, SVG charts, date-range picker, 11 resolvers
- Customize-widgets per-region sortables at xl+ (charts/rails/feed); single
flat sortable below xl when the layout stacks; per-viewport saved orders
- Audit doc updates capturing each shipped item
- Lint fixes: react-compiler immutability in DonutChart (reduce instead of
let-reassign), set-state-in-effect disables in CountryFlag and
UploadForSigning preview-bytes effect, unused 'confirm' destructures in
interest contract + reservation tabs, unescaped apostrophe in test-template
card copy
2026-05-23 00:52:59 +02:00
|
|
|
// UUID detection - the URL's last segment on detail pages is the
|
2026-05-11 17:58:42 +02:00
|
|
|
// entity's UUID, and title-casing it produces an ugly "Abc 123 Uuid"
|
|
|
|
|
// flash before the page calls `useMobileChrome.setChrome({title: ...})`
|
|
|
|
|
// with the real entity name. When the segment matches the UUID shape,
|
|
|
|
|
// walk back to the parent collection segment ("clients", "yachts",
|
|
|
|
|
// "documents", …) which IS a clean, human-readable label.
|
|
|
|
|
const segments = pathname.split('/').filter(Boolean);
|
|
|
|
|
const last = segments[segments.length - 1] ?? '';
|
|
|
|
|
const isUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(last);
|
|
|
|
|
const fallbackSegment = isUuid ? segments[segments.length - 2] : last;
|
2026-05-20 15:54:10 +02:00
|
|
|
// Derive a sensible title from the current path slug when no
|
chore(autonomous-session): consolidate uncommitted work from prior session
Bundles the prior autonomous-session output that was sitting unstaged:
- Em-dash sweep across src/ + tests/ (en-dash/em-dash to hyphen, ~2280 instances)
- country-flag-icons rollout (CountryFlag component, replaces emoji glyphs that
never rendered on Windows; lazy-loads the 3x2 SVG index as a single chunk
after the per-subpath dynamic-import approach silently failed in webpack)
- Admin IA Phase 1+2: 7-domain regroup, 41 to 38 pages, /admin/berths index,
redirects (ocr to ai, reports to dashboard, invitations to users),
docs/admin-ia-proposal.md
- Per-template email tester (registry + endpoint + UI on Email admin page)
- Cancel-document mode picker (delete-from-Documenso vs keep-for-audit)
- Dashboard PDF report: 25 widgets, SVG charts, date-range picker, 11 resolvers
- Customize-widgets per-region sortables at xl+ (charts/rails/feed); single
flat sortable below xl when the layout stacks; per-viewport saved orders
- Audit doc updates capturing each shipped item
- Lint fixes: react-compiler immutability in DonutChart (reduce instead of
let-reassign), set-state-in-effect disables in CountryFlag and
UploadForSigning preview-bytes effect, unused 'confirm' destructures in
interest contract + reservation tabs, unescaped apostrophe in test-template
card copy
2026-05-23 00:52:59 +02:00
|
|
|
// page-level title is set. Avoids hardcoding a specific tenant name -
|
2026-05-20 15:54:10 +02:00
|
|
|
// a fresh deploy with port slug `marina-alpha` reads as "Marina Alpha"
|
|
|
|
|
// here without code edits.
|
|
|
|
|
const portSlug = segments[0] ?? '';
|
|
|
|
|
const portTitle = portSlug.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
2026-04-29 14:12:15 +02:00
|
|
|
const fallbackTitle =
|
2026-05-20 15:54:10 +02:00
|
|
|
fallbackSegment?.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()) ||
|
|
|
|
|
portTitle ||
|
|
|
|
|
'CRM';
|
|
|
|
|
|
|
|
|
|
// Brand-mark initials derived from the port slug
|
|
|
|
|
// ("port-nimara" → "PN", "marina-alpha" → "MA"). Cheap, self-contained,
|
|
|
|
|
// no extra DB round-trip.
|
|
|
|
|
const initials = portSlug
|
|
|
|
|
? portSlug
|
|
|
|
|
.split('-')
|
|
|
|
|
.map((part) => part[0]?.toUpperCase() ?? '')
|
|
|
|
|
.join('')
|
|
|
|
|
.slice(0, 2)
|
|
|
|
|
: 'CR';
|
2026-04-29 14:12:15 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<header
|
|
|
|
|
className={cn(
|
2026-05-01 16:34:28 +02:00
|
|
|
'fixed top-0 inset-x-0 z-40',
|
2026-05-12 22:14:38 +02:00
|
|
|
'bg-linear-to-b from-[#1e2844] to-[#171f35]',
|
2026-05-01 16:34:28 +02:00
|
|
|
'shadow-[0_4px_18px_-6px_rgba(15,23,42,0.45)]',
|
|
|
|
|
'h-[calc(56px+env(safe-area-inset-top))] pt-safe-top',
|
2026-04-29 14:12:15 +02:00
|
|
|
'flex items-center gap-2 px-3',
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{showBackButton ? (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => router.back()}
|
|
|
|
|
aria-label="Go back"
|
2026-05-01 16:34:28 +02:00
|
|
|
className={cn(
|
|
|
|
|
'size-11 inline-flex items-center justify-center rounded-full -ml-1',
|
|
|
|
|
'text-white/95 active:bg-white/10 transition-colors',
|
|
|
|
|
)}
|
2026-04-29 14:12:15 +02:00
|
|
|
>
|
fix(audit-wave-10): aria-hidden sweep on decorative Lucide icons (#69)
Mechanical codemod added \`aria-hidden\` to 444 self-closing single-line
Lucide icon JSX elements across 267 .tsx files in:
- shared/, layout/, dashboard/
- admin/ (all sections)
- clients/, berths/, yachts/, companies/, interests/, documents/
- reminders/, reservations/, residential/, expenses/, email/
The regex targeted only the safe pattern \`<IconName className="..." />\`
(no other props, self-closing, capitalized component name). Every match
inspected is a decorative companion to visible text or sits inside a
button whose accessible name comes from \`aria-label\` / sr-only text
— the icon itself should not be announced.
Screen readers no longer double-read the icon + the adjacent label
text (e.g. "Pencil Pencil Edit" → just "Edit"). The existing
@axe-core/playwright smoke test (\`20-accessibility.spec.ts\`) continues
to pass.
Test suite stays at 1315/1315 vitest. typescript clean.
Closes task #69 (aria-hidden sweep) from the AUDIT-2026-05-12 follow-ups
backlog.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 12:37:22 +02:00
|
|
|
<ChevronLeft className="size-[22px] stroke-[2.25]" aria-hidden />
|
2026-04-29 14:12:15 +02:00
|
|
|
</button>
|
|
|
|
|
) : (
|
2026-05-01 16:34:28 +02:00
|
|
|
<div
|
2026-05-20 15:54:10 +02:00
|
|
|
aria-label={portTitle || 'Home'}
|
2026-05-01 16:34:28 +02:00
|
|
|
className={cn(
|
|
|
|
|
'size-9 shrink-0 rounded-lg flex items-center justify-center',
|
|
|
|
|
'bg-[#3a7bc8] shadow-[inset_0_1px_0_rgba(255,255,255,0.18),0_1px_2px_rgba(0,0,0,0.25)]',
|
|
|
|
|
)}
|
|
|
|
|
>
|
2026-05-20 15:54:10 +02:00
|
|
|
<span className="text-white font-bold text-[13px] tracking-tight">{initials}</span>
|
2026-05-01 16:34:28 +02:00
|
|
|
</div>
|
2026-04-29 14:12:15 +02:00
|
|
|
)}
|
|
|
|
|
|
2026-05-01 16:34:28 +02:00
|
|
|
<h1
|
|
|
|
|
className={cn(
|
|
|
|
|
'flex-1 min-w-0 truncate text-center',
|
|
|
|
|
'text-[17px] font-semibold tracking-tight text-white',
|
|
|
|
|
)}
|
|
|
|
|
>
|
2026-04-29 14:12:15 +02:00
|
|
|
{title ?? fallbackTitle}
|
|
|
|
|
</h1>
|
|
|
|
|
|
2026-05-01 16:34:28 +02:00
|
|
|
<div className="size-11 inline-flex items-center justify-center text-white/95">
|
|
|
|
|
{primaryAction}
|
|
|
|
|
</div>
|
2026-04-29 14:12:15 +02:00
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|