Files
accounted/components/branding/BrandHomeLink.tsx
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

72 lines
2.8 KiB
TypeScript

'use client'
/**
* Dashboard sidebar brand mark: the top-left home link (WL-12 slice A3).
*
* On a branded host with an uploaded logo it renders that logo; on every
* other host it renders exactly the legacy `getBranding().logoPath` image
* with the same dimensions, classes and aria-label as before, keeping
* default hosts byte-identical.
*
* With `showLabel` (expanded sidebar) a branded host without an uploaded
* logo renders the brand's app name beside the mark (byra-editable in the
* Varumärke settings). With an uploaded logo the logo carries the brand
* alone (same founder call as BrandWordmark, 2026-08-05: byrå logos usually
* carry their own name, so logo + text read as a duplicate). Unbranded
* hosts never show a label.
*/
import Link from 'next/link'
import Image from 'next/image'
import { useBranding } from '@/lib/branding/brand-context'
import { useCompanyOptional } from '@/contexts/CompanyContext'
export function BrandHomeLink({ showLabel = false }: { showLabel?: boolean }) {
const { appName, logoUrl, logoPath, brand } = useBranding()
const label = brand && !logoUrl ? brand.appName : null
// Byrå team members (any role) home to the cockpit, never to "/" (which
// would open whatever client company happens to be active). Everyone
// outside a byrå keeps the legacy home link.
const byraTeam = useCompanyOptional()?.byraTeam
const homeHref = byraTeam ? '/byra' : '/'
return (
<Link href={homeHref} aria-label={appName} className="flex items-center gap-2 rounded-lg">
{logoUrl ? (
<Image
src={logoUrl}
alt=""
width={26}
height={26}
className="h-[26px] w-[26px] rounded-lg object-contain"
// Tenant logos live on the deployment's Supabase Storage host, and
// the image optimizer only allows that host when
// NEXT_PUBLIC_SUPABASE_URL was known at BUILD time. The generic
// Docker image bakes a sentinel and substitutes the real URL at
// container start, so on self-hosted installs /_next/image answered
// 400 '"url" parameter is not allowed' and the sidebar mark rendered
// broken while the favicon (same URL, no optimizer) worked (issue
// #2203). The browser fetches the public object directly instead; at
// 26px there is nothing to optimize anyway.
unoptimized
/>
) : (
<Image
src={logoPath}
alt=""
width={26}
height={26}
className="h-[26px] w-[26px] rounded-lg"
/>
)}
{showLabel && label && (
<span
className="truncate font-display text-base tracking-tight text-foreground"
style={{ fontWeight: 700 }}
>
{label}
</span>
)}
</Link>
)
}