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

Function getBorderWidth

packages/extension/utils/css.ts:458–489  ·  view source on GitHub ↗
(style: Record<string, string>)

Source from the content-addressed store, hash-verified

456}
457
458function getBorderWidth(style: Record<string, string>): string | null {
459 if (style.border) {
460 const parsed = parseBorderShorthand(normalizeStyleValue(style.border))
461 if (parsed.width) {
462 return normalizeStyleValue(parsed.width)
463 }
464 }
465
466 if (style['border-width']) {
467 return normalizeStyleValue(style['border-width'])
468 }
469
470 const sideWidths = BORDER_SIDES.map((side) => {
471 const width = style[`border-${side}-width`]
472 if (width) return normalizeStyleValue(width)
473
474 const border = style[`border-${side}`]
475 if (!border) return null
476
477 const parsed = parseBorderShorthand(normalizeStyleValue(border))
478 return parsed.width ? normalizeStyleValue(parsed.width) : null
479 })
480
481 if (sideWidths.every((width): width is string => typeof width === 'string' && width.length > 0)) {
482 const [first, ...rest] = sideWidths
483 if (rest.every((width) => width === first)) {
484 return first
485 }
486 }
487
488 return null
489}
490
491function isZeroBorderWidth(value: string): boolean {
492 return ZERO_BORDER_WIDTH_RE.test(normalizeStyleValue(value).toLowerCase())

Callers 1

resolveGradientBorderFunction · 0.70

Calls 2

normalizeStyleValueFunction · 0.85
parseBorderShorthandFunction · 0.70

Tested by

no test coverage detected