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

Function getBorderWidth

packages/extension/mcp/tools/code/styles/normalize.ts:285–314  ·  view source on GitHub ↗
(style: StyleMap)

Source from the content-addressed store, hash-verified

283}
284
285function getBorderWidth(style: StyleMap): string | null {
286 const sideWidths = BORDER_SIDES.map((side) => {
287 const width = style[`border-${side}-width`]
288 if (width) return normalizeStyleValue(width)
289 const border = style[`border-${side}`]
290 if (!border) return null
291 const parsed = parseBorderShorthand(normalizeStyleValue(border))
292 return parsed.width ? normalizeStyleValue(parsed.width) : null
293 })
294
295 if (sideWidths.every((width): width is string => typeof width === 'string' && width.length > 0)) {
296 const [first, ...rest] = sideWidths
297 if (rest.every((width) => width === first)) {
298 return first
299 }
300 }
301
302 const borderWidth = style['border-width']
303 if (borderWidth) {
304 const [t, r, b, l] = parseBoxValues(normalizeStyleValue(borderWidth))
305 if (t === r && r === b && b === l) return t
306 }
307
308 if (style.border) {
309 const parsed = parseBorderShorthand(normalizeStyleValue(style.border))
310 if (parsed.width) return normalizeStyleValue(parsed.width)
311 }
312
313 return null
314}
315
316function hasOverflowClipping(style: StyleMap): boolean {
317 const overflowValues = [style.overflow, style['overflow-x'], style['overflow-y']]

Callers 1

Calls 3

normalizeStyleValueFunction · 0.90
parseBorderShorthandFunction · 0.70
parseBoxValuesFunction · 0.70

Tested by

no test coverage detected