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

Function handleScale

packages/tailwindcss/src/utilities.ts:1443–1468  ·  view source on GitHub ↗
({ negative }: { negative: boolean })

Source from the content-addressed store, hash-verified

1441 */
1442 staticUtility('scale-none', [['scale', 'none']])
1443 function handleScale({ negative }: { negative: boolean }) {
1444 return (candidate: Extract<Candidate, { kind: 'functional' }>) => {
1445 if (!candidate.value || candidate.modifier) return
1446
1447 let value
1448 if (candidate.value.kind === 'arbitrary') {
1449 value = candidate.value.value
1450 value = negative ? `calc(${value} * -1)` : value
1451 return [decl('scale', value)]
1452 } else {
1453 value = theme.resolve(candidate.value.value, ['--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('--tw-scale-x', value),
1463 decl('--tw-scale-y', value),
1464 decl('--tw-scale-z', value),
1465 decl('scale', `var(--tw-scale-x) var(--tw-scale-y)`),
1466 ]
1467 }
1468 }
1469 utilities.functional('-scale', handleScale({ negative: true }))
1470 utilities.functional('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