UNPKG

3.07 kBTypeScriptView Raw
1import { Color } from '../color';
2export type Parsed<V> = {
3 start: number;
4 end: number;
5 value: V;
6};
7export type URL = string;
8export type Angle = number;
9export interface Unit<T> {
10 value: number;
11 unit: string;
12}
13export type Length = Unit<'px' | 'dip'>;
14export type Percentage = Unit<'%'>;
15export type LengthPercentage = Length | Percentage;
16export type Keyword = string;
17export interface ColorStop {
18 color: Color;
19 offset?: LengthPercentage;
20}
21export interface LinearGradient {
22 angle: number;
23 colors: ColorStop[];
24}
25export interface Background {
26 readonly color?: number | Color;
27 readonly image?: URL | LinearGradient;
28 readonly repeat?: BackgroundRepeat;
29 readonly position?: BackgroundPosition;
30 readonly size?: BackgroundSize;
31}
32export type BackgroundRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
33export type BackgroundSize = 'auto' | 'cover' | 'contain' | {
34 x: LengthPercentage;
35 y: 'auto' | LengthPercentage;
36};
37export type HorizontalAlign = 'left' | 'center' | 'right';
38export type VerticalAlign = 'top' | 'center' | 'bottom';
39export interface HorizontalAlignWithOffset {
40 readonly align: 'left' | 'right';
41 readonly offset: LengthPercentage;
42}
43export interface VerticalAlignWithOffset {
44 readonly align: 'top' | 'bottom';
45 readonly offset: LengthPercentage;
46}
47export interface BackgroundPosition {
48 readonly x: HorizontalAlign | HorizontalAlignWithOffset;
49 readonly y: VerticalAlign | VerticalAlignWithOffset;
50 text?: string;
51}
52export declare function parseURL(text: string, start?: number): Parsed<URL>;
53export declare function parseHexColor(text: string, start?: number): Parsed<Color>;
54export declare function parseCssColor(text: string, start?: number): Parsed<Color>;
55export declare function convertHSLToRGBColor(hue: number, saturation: number, lightness: number): {
56 r: number;
57 g: number;
58 b: number;
59};
60export declare function parseColorKeyword(value: any, start: number, keyword?: Parsed<string>): Parsed<Color>;
61export declare function parseColor(value: string, start?: number, keyword?: Parsed<string>): Parsed<Color>;
62export declare function parseRepeat(value: string, start?: number, keyword?: Parsed<string>): Parsed<BackgroundRepeat>;
63export declare function parseUnit(text: string, start?: number): Parsed<Unit<string>>;
64export declare function parsePercentageOrLength(text: string, start?: number): Parsed<LengthPercentage>;
65export declare function parseAngle(value: string, start?: number): Parsed<Angle>;
66export declare function parseBackgroundSize(value: string, start?: number, keyword?: Parsed<string>): Parsed<BackgroundSize>;
67export declare function parseBackgroundPosition(text: string, start?: number, keyword?: Parsed<string>): Parsed<BackgroundPosition>;
68export declare function parseColorStop(text: string, start?: number): Parsed<ColorStop>;
69export declare function parseLinearGradient(text: string, start?: number): Parsed<LinearGradient>;
70export declare function parseBackground(text: string, start?: number): Parsed<Background>;