UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

48 lines (47 loc) 2.11 kB
/** * Checks if the system prefers dark mode. * Falls back safely if matchMedia is not supported. * @returns True if system is in dark mode. */ export declare const systemIsInDarkMode: () => boolean; /** * Checks if on Safari. * @returns True if on Safari. */ export declare const isSafari: () => boolean; /** * Checks if on Firefox. * @returns True if on Firefox. */ export declare const isFirefox: () => boolean; /** * Returns a valid index within the given maximum index. * Out of bound index loops back to the first valid index. * @param index - The index to validate. * @param maxIndex - The maximum index. If not provided or 0, returns 0. * @returns The valid index. */ export declare const getValidIndex: (index: number, maxIndex?: number) => number; /** * Returns a value bounded between a minimum and maximum limit. * @returns The bounded value. */ export declare const minMax: (value: number, minLimit: number, maxLimit: number) => number; /** * Transforms a hex string into rgba values. * @param hex - A hex color, starting with '#' and including 3 (=shorthand), 6 (=default) or 8 (=including alpha) values. * @returns an array of rgba values: R, G, B [0-255], alpha [0-1]. Or null if the hex color is invalid. */ export declare const hexToRgbaArray: (hex: string) => [number, number, number, number] | null; /** * Transforms a rgb string into rgba values. * @param rgbaStr - A rgb or rgba color, starting with 'rgb' and including 3 or 4 (=including alpha) values. * @returns an array of rgba values: R, G, B [0-255] and alpha [0-1]. Or null if the rgb string is invalid. */ export declare const rgbStrToRgbaArray: (rgbaStr: string) => [number, number, number, number] | null; /** * Transform a color string to an array of rgba values. * @param color A string representing a color. Can be of type hex ('#0033ff') or rgb(a) ('rgba(255, 23, 15, 0.5)'). * @returns an array of rgba values: R, G, B [0-255] and alpha [0-1]. Or null if the color isn't in a valid format. */ export declare const colorToRgbaArray: (color: string) => [number, number, number, number] | null;