Skip to content

Commit

Permalink
feat: add ColorStop type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie1210 committed Oct 14, 2023
1 parent dd8edec commit 2416daa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/conic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolveStops, split } from "./utils"
import { ColorStop } from './type'

type RectColorSpace = 'srgb' | 'srgb-linear' | 'lab' | 'oklab' | 'xyz' | 'xyz-d50' | 'xyz-d65'
type PolarColorSpace = 'hsl' | 'hwb' | 'lch' | 'oklch'
Expand All @@ -9,11 +10,7 @@ interface ConicGradient {
repeating: boolean
position: string
color?: Color
stops: Array<{
color: string
offset: string
hint?: string
}>
stops: ColorStop[]
}

type Color = {
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './linear'
export * from './radial'
export * from './conic'
export * from './conic'
export * from './type'
7 changes: 2 additions & 5 deletions src/linear.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { split, resolveStops } from "./utils"
import { ColorStop } from './type'

interface LinearOrientation {
type: 'directional' | 'angular'
Expand All @@ -8,11 +9,7 @@ interface LinearOrientation {
export interface LinearResult {
orientation: LinearOrientation
repeating: boolean
stops: Array<{
color: string
offset: string
hint?: string
}>
stops: ColorStop[]
}

export function parseLinearGradient(input: string): LinearResult {
Expand Down
7 changes: 2 additions & 5 deletions src/radial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolveStops, split } from './utils'
import { ColorStop } from './type'

export type RgExtentKeyword = 'closest-corner' | 'closest-side' | 'farthest-corner' | 'farthest-side'

Expand All @@ -7,11 +8,7 @@ export interface RadialResult {
repeating: boolean
size: string
position: string
stops: Array<{
color: string
offset: string
hint?: string
}>
stops: ColorStop[]
}

export function parseRadialGradient(input: string): RadialResult {
Expand Down
5 changes: 5 additions & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ColorStop {
color: string
offset: string
hint?: string
}

0 comments on commit 2416daa

Please sign in to comment.