Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

a proposal for improved ergonomics #14

@mreinstein

Description

@mreinstein

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!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions