feat: Changes to utils for new measurement icons
This commit is contained in:
parent
5e48846884
commit
bb64eebd7c
4 changed files with 20 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@freesewing/utils",
|
||||
"version": "2.16.1-rc.0",
|
||||
"version": "2.16.1-rc.1",
|
||||
"description": "A collection of utilities shared across freesewing projects",
|
||||
"author": "Joost De Cock <joost@joost.at> (https://github.com/joostdecock)",
|
||||
"homepage": "https://freesewing.org/",
|
||||
|
|
|
@ -23,11 +23,11 @@ const createConfig = (util, module) => {
|
|||
peerDepsExternal(),
|
||||
resolve({ modulesOnly: true }),
|
||||
json(),
|
||||
terser({
|
||||
output: {
|
||||
preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
||||
}
|
||||
})
|
||||
//terser({
|
||||
// output: {
|
||||
// preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
||||
// }
|
||||
//})
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ const config = []
|
|||
for (let util of utils) {
|
||||
config.push(createConfig(util, false))
|
||||
// Webpack doesn't handle .mjs very well
|
||||
//config.push(createConfig(util, true));
|
||||
config.push(createConfig(util, true));
|
||||
}
|
||||
export default config
|
||||
|
|
|
@ -8,10 +8,14 @@ const measurementDiffers = (
|
|||
neckCircumference,
|
||||
measurementName,
|
||||
measurementValue,
|
||||
breasts = false
|
||||
) =>
|
||||
Math.abs(
|
||||
Math.round((measurementValue - neckstimate(neckCircumference, measurementName, breasts)) / 20)
|
||||
)
|
||||
breasts = false,
|
||||
absolute = true
|
||||
) => {
|
||||
let result = Math.round((measurementValue - neckstimate(neckCircumference, measurementName, breasts)) / 20)
|
||||
|
||||
return absolute
|
||||
? Math.abs(Math.round((measurementValue - neckstimate(neckCircumference, measurementName, breasts)) / 20))
|
||||
: (measurementValue - neckstimate(neckCircumference, measurementName, breasts, true)) / 20
|
||||
}
|
||||
|
||||
export default measurementDiffers
|
||||
|
|
|
@ -3,7 +3,7 @@ import withoutBreasts from './without-breasts'
|
|||
import ratio from './ratio'
|
||||
|
||||
// This estimates a measurement based on the neck
|
||||
const neckstimate = (neck = false, measurement = false, breasts = false) => {
|
||||
const neckstimate = (neck = false, measurement = false, breasts = false, noRound=false) => {
|
||||
let data = breasts ? withBreasts : withoutBreasts
|
||||
|
||||
// Shoulder slope is in degrees now. Always return de default.
|
||||
|
@ -37,7 +37,9 @@ const neckstimate = (neck = false, measurement = false, breasts = false) => {
|
|||
// This is what should happen
|
||||
let delta = (neck / data.neck) * data[measurement] - data[measurement]
|
||||
|
||||
return Math.round(data[measurement] + delta * ratio[measurement])
|
||||
return noRound
|
||||
? data[measurement] + delta * ratio[measurement]
|
||||
: Math.round(data[measurement] + delta * ratio[measurement])
|
||||
}
|
||||
|
||||
export default neckstimate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue