MCPcopy
hub / github.com/tailwindlabs/tailwindcss / handleScale

Function handleScale

packages/tailwindcss/src/utilities.ts:1443–1468  ·  packages/tailwindcss/src/utilities.ts::handleScale
({ negative }: { negative: boolean })

Source from the content-addressed store, hash-verified

1441 */
1442 staticUtility(class="st">'scale-none', [[class="st">'scale', class="st">'none']])
1443 function handleScale({ negative }: { negative: boolean }) {
1444 return (candidate: Extract<Candidate, { kind: class="st">'functional' }>) => {
1445 if (!candidate.value || candidate.modifier) return
1446
1447 let value
1448 if (candidate.value.kind === class="st">'arbitrary') {
1449 value = candidate.value.value
1450 value = negative ? `calc(${value} * -1)` : value
1451 return [decl(class="st">'scale', value)]
1452 } else {
1453 value = theme.resolve(candidate.value.value, [class="st">'--scale'])
1454 if (!value && isPositiveInteger(candidate.value.value)) {
1455 value = `${candidate.value.value}%`
1456 }
1457 if (!value) return
1458 }
1459 value = negative ? `calc(${value} * -1)` : value
1460 return [
1461 scaleProperties(),
1462 decl(class="st">'--tw-scale-x', value),
1463 decl(class="st">'--tw-scale-y', value),
1464 decl(class="st">'--tw-scale-z', value),
1465 decl(class="st">'scale', `var(--tw-scale-x) var(--tw-scale-y)`),
1466 ]
1467 }
1468 }
1469 utilities.functional(class="st">'-scale', handleScale({ negative: true }))
1470 utilities.functional(class="st">'scale', handleScale({ negative: false }))
1471

Callers 1

createUtilitiesFunction · 0.85

Calls 4

declFunction · 0.90
isPositiveIntegerFunction · 0.90
scalePropertiesFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected