MCPcopy Create free account
hub / github.com/adobe/react-spectrum / linearGradient

Function linearGradient

packages/@react-spectrum/s2/style/spectrum-theme.ts:323–352  ·  view source on GitHub ↗
(
  this: MacroContext | void,
  angle: string,
  ...tokens: [SpectrumColor, number][]
)

Source from the content-addressed store, hash-verified

321}
322
323export 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.
355function generateSpacing<K extends number[]>(

Callers 1

Button.tsxFile · 0.90

Calls 2

pushMethod · 0.80
addAssetMethod · 0.65

Tested by

no test coverage detected