1
1
/**
2
2
* External dependencies
3
3
*/
4
- import type gradientParser from 'gradient-parser' ;
4
+ import type { ColorStop , GradientNode } from 'gradient-parser' ;
5
5
6
- export function serializeGradientColor ( {
7
- type,
8
- value,
9
- } : gradientParser . ColorStop ) {
6
+ export function serializeGradientColor ( { type, value } : ColorStop ) {
10
7
if ( type === 'literal' ) {
11
8
return value ;
12
9
}
@@ -16,9 +13,7 @@ export function serializeGradientColor( {
16
13
return `${ type } (${ value . join ( ',' ) } )` ;
17
14
}
18
15
19
- export function serializeGradientPosition (
20
- position : gradientParser . ColorStop [ 'length' ]
21
- ) {
16
+ export function serializeGradientPosition ( position : ColorStop [ 'length' ] ) {
22
17
if ( ! position ) {
23
18
return '' ;
24
19
}
@@ -30,15 +25,15 @@ export function serializeGradientColorStop( {
30
25
type,
31
26
value,
32
27
length,
33
- } : gradientParser . ColorStop ) {
28
+ } : ColorStop ) {
34
29
return `${ serializeGradientColor ( {
35
30
type,
36
31
value,
37
- } as gradientParser . ColorStop ) } ${ serializeGradientPosition ( length ) } `;
32
+ } as ColorStop ) } ${ serializeGradientPosition ( length ) } `;
38
33
}
39
34
40
35
export function serializeGradientOrientation (
41
- orientation : gradientParser . GradientNode [ 'orientation' ]
36
+ orientation : GradientNode [ 'orientation' ]
42
37
) {
43
38
if (
44
39
Array . isArray ( orientation ) ||
@@ -54,13 +49,11 @@ export function serializeGradient( {
54
49
type,
55
50
orientation,
56
51
colorStops,
57
- } : gradientParser . GradientNode ) {
52
+ } : GradientNode ) {
58
53
const serializedOrientation = serializeGradientOrientation ( orientation ) ;
59
54
const serializedColorStops = colorStops
60
55
. sort ( ( colorStop1 , colorStop2 ) => {
61
- const getNumericStopValue = (
62
- colorStop : gradientParser . ColorStop
63
- ) => {
56
+ const getNumericStopValue = ( colorStop : ColorStop ) => {
64
57
return colorStop ?. length ?. value === undefined
65
58
? 0
66
59
: parseInt ( colorStop . length . value ) ;
0 commit comments