<p> <a href="https://npmjs.com/package/css-gradient-parser"><img src="https://img.shields.io/npm/v/css-gradient-parser.svg" alt="npm version"></a> <a href="https://npmjs.com/package/css-gradient-parser"><img src="https://img.shields.io/npm/dm/css-gradient-parser.svg" alt="npm downloads"></a> </p>

css-gradient-parser

This lib intends to give a parser for satori so that we can handle more gradient features

API

parseLinearGradient

interface LinearOrientation {
  type: 'directional' | 'angular'
  value: string
}

interface LinearResult {
  orientation: LinearOrientation
  repeating: boolean
  stops: ColorStop[]
}

parseRadialGradient

type ValueType = 'keyword' | 'length'

interface RadialResult {
  shape: 'circle' | 'ellipse'
  repeating: boolean
  size: {
    type: ValueType
    value: string
  }[]
  position: {
    x: { type: ValueType, value: string }
    y: { type: ValueType, value: string }
  }
  stops: ColorStop[]
}

parseConicGradient

type RectColorSpace = 'srgb' | 'srgb-linear' | 'lab' | 'oklab' | 'xyz' | 'xyz-d50' | 'xyz-d65'
type PolarColorSpace = 'hsl' | 'hwb' | 'lch' | 'oklch'
type HueInterpolationMethod = `${'shorter' | 'longer' | 'increasing' | 'decreasing'} hue`

interface ConicGradient {
  angle: string
  repeating: boolean
  position: string
  color?: Color
  stops: ColorStop[]
}

type Color = {
  space: RectColorSpace | PolarColorSpace
  method?: HueInterpolationMethod
}

LICENSE

MIT

css-gradient-parser - Installation

To install css-gradient-parser via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install css-gradient-parser --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install css-gradient-parser

Learn more about the config option.

PNPM

pnpm install css-gradient-parser --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install css-gradient-parser --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

css-gradient-parser - Download

Download Tarball (v0.0.18)

Integrity sha512-iYfdExM/e/EYs16q5cTY8JTIzLkJASgQPueaX/xqh+dZzV3SQgxlDUpvCSMcas6aeudPRbrtChWMiNOa1gtb0g==
SHASUM 35b37b8160f6d5d54d0e90260dc342aba20d12fd
Tarball https://js.registry.sudovanilla.org/css-gradient-parser/-/css-gradient-parser-0.0.18.tgz