fluid-tailwind
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -111,7 +111,10 @@ "use strict"; | ||
name = "FluidError"; | ||
static fromCode(code, ...args) { | ||
const fn = codes[code]; | ||
const message = fn(...args); | ||
return new this(code, message); | ||
} | ||
}; | ||
function error(code, ...args) { | ||
const fn = codes[code]; | ||
const message = fn(...args); | ||
throw new FluidError(code, message); | ||
throw FluidError.fromCode(code, ...args); | ||
} | ||
@@ -258,4 +261,9 @@ | ||
} | ||
const comment = (code, ...args) => `/* ${code ? "not " : ""}fluid${type ? " type" : ""} from ${start.cssText} at ${startBP.cssText} to ${end.cssText} at ${endBP.cssText}${atContainer ? " (container)" : ""}${// @ts-expect-error | ||
code ? ": " + codes[code](...args) : ""} */`; | ||
const comment = (code, ...args) => { | ||
const expr = `/* ${code ? "not " : ""}fluid${type ? " type" : ""} from ${start.cssText} at ${startBP.cssText} to ${end.cssText} at ${endBP.cssText}${atContainer ? " (container)" : ""}${// @ts-expect-error | ||
code ? ": " + codes[code](...args) : ""} */`; | ||
if (code) | ||
return [expr, FluidError.fromCode(code, ...args)]; | ||
return [expr]; | ||
}; | ||
if (startBP.number === 0) { | ||
@@ -293,3 +301,5 @@ startBP.unit = endBP.unit; | ||
} | ||
return `clamp(${min},${toPrecision(intercept, p)}${unit} + ${toPrecision(slope * 100, p)}${atContainer ? "cqw" : "vw"},${max})${comment()}`; | ||
return [ | ||
`clamp(${min},${toPrecision(intercept, p)}${unit} + ${toPrecision(slope * 100, p)}${atContainer ? "cqw" : "vw"},${max})${comment()}` | ||
]; | ||
}; | ||
@@ -322,3 +332,3 @@ var rewrite = (container, context, [startBP, endBP], atContainer) => { | ||
final: true | ||
}); | ||
})[0]; | ||
} | ||
@@ -547,3 +557,3 @@ ); | ||
try { | ||
const clamp2 = generate(start, end, context); | ||
const [clamp2] = generate(start, end, context); | ||
return origFn(clamp2, { modifier: null }); | ||
@@ -574,3 +584,3 @@ } catch (e) { | ||
try { | ||
const clamp2 = generate(start, end, context, { negate: true }); | ||
const [clamp2] = generate(start, end, context, { negate: true }); | ||
return origFn(clamp2, { modifier: null }); | ||
@@ -653,5 +663,8 @@ } catch (e) { | ||
try { | ||
rules["font-size"] = generate(from.fontSize, to.fontSize, context, { | ||
const [clamp2, err] = generate(from.fontSize, to.fontSize, context, { | ||
type: true | ||
}); | ||
rules["font-size"] = clamp2; | ||
if (err) | ||
return rules; | ||
} catch (e) { | ||
@@ -664,3 +677,3 @@ handle(e, "~text: Font size"); | ||
try { | ||
rules["line-height"] = generate(from.lineHeight, to.lineHeight, context); | ||
rules["line-height"] = generate(from.lineHeight, to.lineHeight, context)[0]; | ||
} catch (e) { | ||
@@ -674,3 +687,7 @@ handle(e, "~text: Line height"); | ||
try { | ||
rules["letter-spacing"] = generate(from.letterSpacing, to.letterSpacing, context); | ||
rules["letter-spacing"] = generate( | ||
from.letterSpacing, | ||
to.letterSpacing, | ||
context | ||
)[0]; | ||
} catch (e) { | ||
@@ -677,0 +694,0 @@ handle(e, "~text: Letter spacing"); |
@@ -27,3 +27,4 @@ import { Length } from './css'; | ||
constructor(code: keyof typeof codes, message: string); | ||
static fromCode<C extends keyof typeof codes>(code: C, ...args: Parameters<(typeof codes)[C]>): FluidError; | ||
} | ||
export declare function error<C extends keyof typeof codes>(code: C, ...args: Parameters<(typeof codes)[C]>): never; |
import { Container } from 'postcss'; | ||
import { Length, type RawValue } from './css'; | ||
import { FluidError } from './errors'; | ||
import type { Context } from './context'; | ||
@@ -11,3 +12,3 @@ export declare const generate: (_start: RawValue | Length, _end: RawValue | Length, context: Context, { startBP: _startBP, endBP: _endBP, atContainer, type, final, negate }?: { | ||
negate?: boolean | undefined; | ||
}) => string; | ||
}) => [expr: string] | [expr: string, err: FluidError]; | ||
export declare const rewrite: (container: Container, context: Context, [startBP, endBP]: [Length | RawValue, Length | RawValue], atContainer?: string | true) => void; |
{ | ||
"name": "fluid-tailwind", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"author": "Maxwell Barvian", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64100
1787
0