Open mreinstein opened 5 years ago
kiwi.js is really cool! One thing I've found painful is having to construct all of the constraints in javascript. I've developed a simplistic parser and wrapper interface to make this easier. Here's what I've currently got:
import constraints from './lib/constraints.js' // the wrapper for kiwi.js const layout = constraints({ editableVariables: [ { name: 'mine', strength: 'strong' // optional parameter } ], constraints: ` windowWidth <= (windowHeight - modalHeight) / 25 windowHeight == 45 / 6 modalHeight == mine * 10 windowWidth >= 0 required windowHeight >= 0 required ` }) layout.suggestValue('mine', 102) layout.updateVariables() console.log(layout.getValues()) // { mine: 102, windowWidth: 0, windowHeight: 7.5, modalHeight: 1020 }
Would something like this be a welcome addition to kiwi? Open for suggestions on changing the API etc.
thanks for a great module!!
current working implementation of this https://github.com/mreinstein/constraint-solver
updated implementation, replaced my janky parser with one based on pegjs. (adapted the grammar from cassowary.js)
https://github.com/mreinstein/constraint-solver
kiwi.js is really cool! One thing I've found painful is having to construct all of the constraints in javascript. I've developed a simplistic parser and wrapper interface to make this easier. Here's what I've currently got:
Would something like this be a welcome addition to kiwi? Open for suggestions on changing the API etc.
thanks for a great module!!