MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / extractLeadingGradient

Function extractLeadingGradient

packages/extension/utils/css.ts:413–456  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

411}
412
413function extractLeadingGradient(value: string): string | null {
414 const input = value.trim()
415 if (!input) return null
416
417 const lower = input.toLowerCase()
418 if (!GRADIENT_FUNCTION_PREFIXES.some((prefix) => lower.startsWith(prefix))) {
419 return null
420 }
421
422 let depth = 0
423 let quote: '"' | "'" | null = null
424
425 for (let i = 0; i < input.length; i++) {
426 const ch = input[i]
427
428 if (quote) {
429 if (ch === '\\') {
430 i++
431 continue
432 }
433 if (ch === quote) quote = null
434 continue
435 }
436
437 if (ch === '"' || ch === "'") {
438 quote = ch
439 continue
440 }
441
442 if (ch === '(') {
443 depth++
444 continue
445 }
446
447 if (ch === ')') {
448 depth = Math.max(0, depth - 1)
449 if (depth === 0) {
450 return input.slice(0, i + 1).trim()
451 }
452 }
453 }
454
455 return null
456}
457
458function getBorderWidth(style: Record<string, string>): string | null {
459 if (style.border) {

Callers 1

resolveGradientBorderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected