fix(styling-gradient): introduce gradient definition file (#5828)

This commit is contained in:
Alexander Djenkov
2018-05-17 15:44:40 +03:00
committed by GitHub
parent bbe25d7ec1
commit 3f8af4cc0e
2 changed files with 25 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
/**
* @module "ui/styling/gradient"
*/ /** */
import { LengthPercentUnit } from "./style-properties";
import { Color } from "../../color";
import * as parser from "../../css/parser";
export class LinearGradient {
public angle: number;
public colorStops: ColorStop[];
public static parse(value: parser.LinearGradient): LinearGradient;
public static equals(first: LinearGradient, second: LinearGradient): boolean;
}
export interface ColorStop {
color: Color;
offset?: LengthPercentUnit;
}

View File

@@ -1,12 +1,13 @@
import { LengthPercentUnit } from "./style-properties";
import * as parser from "../../css/parser";
import { Color } from "../../color";
import { ColorStop } from "./gradient";
import * as parser from "../../css/parser";
export class LinearGradient {
public angle: number;
public colorStops: ColorStop[];
static parse(value: parser.LinearGradient): LinearGradient {
public static parse(value: parser.LinearGradient): LinearGradient {
const result = new LinearGradient();
result.angle = value.angle;
result.colorStops = value.colors.map(color => {
@@ -28,7 +29,7 @@ export class LinearGradient {
return result;
}
static equals(first: LinearGradient, second: LinearGradient): boolean {
public static equals(first: LinearGradient, second: LinearGradient): boolean {
if (!first && !second) {
return true;
} else if (!first || !second) {
@@ -57,8 +58,3 @@ export class LinearGradient {
return true;
}
}
export interface ColorStop {
color: Color;
offset?: LengthPercentUnit;
}