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

Function maskStopUtility

packages/tailwindcss/src/utilities.ts:3242–3341  ·  view source on GitHub ↗
(classRoot: string, desc: MaskStopDescription)

Source from the content-addressed store, hash-verified

3240 }
3241
3242 function maskStopUtility(classRoot: string, desc: MaskStopDescription) {
3243 utilities.functional(classRoot, (candidate) => {
3244 if (!candidate.value) return
3245
3246 // Arbitrary values
3247 if (candidate.value.kind === 'arbitrary') {
3248 let value: string | null = candidate.value.value
3249 let type =
3250 candidate.value.dataType ?? inferDataType(value, ['length', 'percentage', 'color'])
3251
3252 switch (type) {
3253 case 'color': {
3254 value = asColor(value, candidate.modifier, theme)
3255 if (value === null) return
3256
3257 return desc.color(value)
3258 }
3259 case 'percentage': {
3260 if (candidate.modifier) return
3261 if (!isPositiveInteger(value.slice(0, -1))) return
3262
3263 return desc.position(value)
3264 }
3265 default: {
3266 if (candidate.modifier) return
3267
3268 return desc.position(value)
3269 }
3270 }
3271 }
3272
3273 // Known values: Color Stops
3274 {
3275 let value = resolveThemeColor(candidate, theme, ['--background-color', '--color'])
3276 if (value) {
3277 return desc.color(value)
3278 }
3279 }
3280
3281 // Known values: Positions
3282 {
3283 if (candidate.modifier) return
3284
3285 let type = inferDataType(candidate.value.value, ['number', 'percentage'])
3286 if (!type) return
3287
3288 switch (type) {
3289 case 'number': {
3290 let multiplier = theme.resolve(null, ['--spacing'])
3291 if (!multiplier) return
3292 if (!isValidSpacingMultiplier(candidate.value.value)) return
3293
3294 return desc.position(`--spacing(${candidate.value.value})`)
3295 }
3296
3297 case 'percentage': {
3298 if (!isPositiveInteger(candidate.value.value.slice(0, -1))) return
3299 return desc.position(candidate.value.value)

Callers 2

maskEdgeUtilityFunction · 0.85
createUtilitiesFunction · 0.85

Calls 9

inferDataTypeFunction · 0.90
isPositiveIntegerFunction · 0.90
isValidSpacingMultiplierFunction · 0.90
asColorFunction · 0.85
resolveThemeColorFunction · 0.85
suggestFunction · 0.85
resolveMethod · 0.80
functionalMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected