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