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