SPB Git

spb/qc26

Public
2.5 KB · 50 lines tsx
1import Image from "next/image";2import { OTHERS, party, partyColor, partyLabel, partyName } from "@/lib/parties";3import { cls } from "@/lib/format";45/** Logo officiel du parti, jamais déformé ni recoloré. Le PCQ (logo blanc) est posé sur sa pastille marine officielle. */6export function PartyLogo({ id, height = 20, className, white = false }: { id: string | null | undefined; height?: number; className?: string; white?: boolean }) {7  const p = party(id);8  if (!p) return <PartyBadge id={id} className={className} />;9  const width = Math.round(height * p.logoRatio);10  const src = white && p.logoWhite ? p.logoWhite : p.logo;11  const img = (12    <Image src={src} alt={`Logo officiel — ${p.officialName}`} width={width} height={height} className="object-contain" style={{ height, width: "auto", maxWidth: width }} unoptimized />13  );14  if (p.logoBackdrop && !white) {15    return (16      <span className={cls("inline-flex items-center rounded-[6px] px-2 py-1", className)} style={{ background: p.logoBackdrop }} title={p.officialName}>17        {img}18      </span>19    );20  }21  return <span className={cls("inline-flex items-center", className)} title={p.officialName}>{img}</span>;22}2324/** Pastille sigle + couleur (accessibilité : texte toujours présent). */25export function PartyBadge({ id, className, size = "md" }: { id: string | null | undefined; className?: string; size?: "sm" | "md" | "lg" }) {26  const color = partyColor(id);27  const label = partyLabel(id);28  const sz = size === "sm" ? "text-[10px] px-1.5 py-[2px]" : size === "lg" ? "text-sm px-2.5 py-1" : "text-[11px] px-2 py-[3px]";29  return (30    <span className={cls("inline-flex items-center gap-1.5 rounded-[6px] font-semibold tracking-wide text-white num", sz, className)} style={{ background: color }} title={partyName(id)} aria-label={partyName(id)}>31      {label}32    </span>33  );34}3536export function PartyDot({ id, size = 8, className }: { id: string | null | undefined; size?: number; className?: string }) {37  return <span aria-hidden className={cls("inline-block rounded-full shrink-0", className)} style={{ width: size, height: size, background: partyColor(id) }} />;38}3940export function PartyText({ id, full = false, className }: { id: string | null | undefined; full?: boolean; className?: string }) {41  return (42    <span className={cls("inline-flex items-center gap-1.5", className)}>43      <PartyDot id={id} />44      <span className="font-semibold">{full ? partyName(id) : partyLabel(id)}</span>45    </span>46  );47}4849export { OTHERS };50
Files · 08f5606551574077c8600a5faf68d3daef5dbc10
Menu

Theme