(classRoot: string, desc: MaskStopDescription)
| 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) |
no test coverage detected