Context
css-analyzer/values already exports classification helpers like colorFunctions, colorKeywords, and namedColors. There is no equivalent helper for identifying CSS gradient functions.
Consumers currently write inline regex checks like:
/^(repeating-)?(linear|conic|radial)-gradient$/.test(name)
This duplicates knowledge of which function names are gradients and will need updating if new gradient types are standardized (e.g. conic-gradient was added relatively recently).
Proposed API
/** Returns true if `name` is a CSS gradient function name. */
function isGradientFunction(name: string): boolean
Example
import { isGradientFunction } from '@projectwallace/css-analyzer/values'
isGradientFunction('linear-gradient') // true
isGradientFunction('repeating-radial-gradient') // true
isGradientFunction('conic-gradient') // true
isGradientFunction('rgb') // false
isGradientFunction('url') // false
Gradient functions to cover
- linear-gradient
- radial-gradient
- conic-gradient
- repeating-linear-gradient
- repeating-radial-gradient
- repeating-conic-gradient
Motivation
Centralises the list of gradient function names alongside other value-classification constants in this package. Prevents consumers from maintaining inline regexes that may diverge from the actual CSS specification over time.
Context
css-analyzer/valuesalready exports classification helpers likecolorFunctions,colorKeywords, andnamedColors. There is no equivalent helper for identifying CSS gradient functions.Consumers currently write inline regex checks like:
This duplicates knowledge of which function names are gradients and will need updating if new gradient types are standardized (e.g. conic-gradient was added relatively recently).
Proposed API
Example
Gradient functions to cover
Motivation
Centralises the list of gradient function names alongside other value-classification constants in this package. Prevents consumers from maintaining inline regexes that may diverge from the actual CSS specification over time.