UNPKG

@oslokommune/punkt-elements

Version:

Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo

35 lines (34 loc) 1.64 kB
/** * Renames from legacy oslo.kommune.no design-system icon names ("ods") * to current Punkt icon names. Only entries where the name actually * changed are listed — `mapOdsIcon` returns the input unchanged for any * name not in this map, so identity entries would just be noise. */ export declare const ICON_MAP_ODS_TO_PUNKT: Readonly<Record<string, string>>; /** * Translate a legacy ODS icon name to a Punkt icon name. Falls back to * the input string when no mapping exists, so unknown icons render as-is * rather than blowing up. */ export declare function mapOdsIcon(name: string): string; /** * Map of known social-media hostnames to Punkt icon names. Hostnames are * stored without the `www.` / `m.` subdomain prefix — `deriveSocialIcon` * normalises before looking up. */ export declare const SOCIAL_HOSTNAME_TO_ICON: Readonly<Record<string, string>>; /** * The header/footer API ships social-media entries as `{ text, url }` only * (no `icon` field). Resolve an icon name from the entry — preferring the * URL's hostname because it's stable across locales (`facebook.com` is the * same regardless of how the link is labelled). * * If the URL doesn't parse or its host isn't a known platform, fall back * to deriving from the label: lower-case, slugify, run through * `mapOdsIcon` so legacy spellings like "LinkedIn" / "linked-in" still * resolve to `linkedin`. * * Returns `undefined` when neither input yields a usable icon — callers * should then skip the icon rather than rendering a broken one. */ export declare function deriveSocialIcon(url?: string, text?: string): string | undefined;