UNPKG

@wikimedia/wvui

Version:

Wikimedia Vue UI (WVUI) – Wikimedia Foundation's Vue.js shared user-interface components for Wikipedia, MediaWiki, and beyond.

55 lines (54 loc) 1.73 kB
declare type SvgPath = string; /** * An icon with a single path. * * This icon will never be flipped horizontally in RTL mode. */ export declare type Icon = SvgPath; /** * An icon with a single path that should flip horizontally in RTL mode. */ export interface IconFlipForRtl { /** SVG path string. */ path: SvgPath; /** Indicates that the icon should be flipped via CSS in RTL mode. */ shouldFlip: true; /** * Language codes that are exceptions to the above property (e.g. the help * icon should flip in RTL mode, but not for Hebrew or Yiddish). */ shouldFlipExceptions?: string[]; } /** * An icon that varies per language. */ export interface IconVariedByLang { /** HTMLElement.lang code with corresponding icon. */ langCodeMap: Record<string, Icon | IconFlipForRtl>; /** The default icon. */ default: Icon | IconFlipForRtl; } /** * An icon that varies per text direction (but can't just be flipped). */ export interface IconVariedByDir { /** Icon for RTL dir. */ rtl: Icon; /** The default icon. */ default: Icon; } export declare type AnyIcon = Icon | IconFlipForRtl | IconVariedByLang | IconVariedByDir; /** * @param icon The icon string or object. * @param langCode The HTMLElement.lang code. * @param dir The HTMLElement.dir (ltr, rtl, or auto). * @return The appropriate SVG path. */ export declare function getIconPath(icon: AnyIcon, langCode: string, dir: string): string; /** * @param icon The icon string or object. * @param langCode The HTMLElement.lang code. * @return Whether the icon should be flipped horizontally in RTL mode. */ export declare function shouldFlip(icon: AnyIcon, langCode: string): boolean; export {};