( this: MacroContext | void, angle: string, ...tokens: [SpectrumColor, number][] )
| 321 | } |
| 322 | |
| 323 | export function linearGradient( |
| 324 | this: MacroContext | void, |
| 325 | angle: string, |
| 326 | ...tokens: [SpectrumColor, number][] |
| 327 | ): [LinearGradient] { |
| 328 | // Generate @property rules for each gradient stop color. This allows the gradient to be animated. |
| 329 | let propertyDefinitions: string[] = []; |
| 330 | for (let i = 0; i < tokens.length; i++) { |
| 331 | propertyDefinitions.push(`@property --g${i} { |
| 332 | syntax: '<color>'; |
| 333 | initial-value: #0000; |
| 334 | inherits: false; |
| 335 | }`); |
| 336 | } |
| 337 | |
| 338 | if (this && typeof this.addAsset === 'function') { |
| 339 | this.addAsset({ |
| 340 | type: 'css', |
| 341 | content: propertyDefinitions.join('\n\n') |
| 342 | }); |
| 343 | } |
| 344 | |
| 345 | return [ |
| 346 | { |
| 347 | type: 'linear-gradient', |
| 348 | angle, |
| 349 | stops: tokens |
| 350 | } |
| 351 | ]; |
| 352 | } |
| 353 | |
| 354 | // Spacing uses rems, padding does not. |
| 355 | function generateSpacing<K extends number[]>( |
no test coverage detected