Rich-Harris / svelte-knobby

MIT License
201 stars 16 forks source link

Plugin architecture #4

Closed Rich-Harris closed 3 years ago

Rich-Harris commented 3 years ago

It would be nice to be able to add user-defined components. For example leva has this bezier curve editor:

image

This should work (though haven't tested it yet)...

const values = knobby({
  curve: {
    component: BezierCurveEditor,
    value: [0.25, 0.1, 0.25, 1]
  }
});

...but in cases where you're dealing with familiar data types throughout your app it might be nice to do this sort of thing instead:

import { knobby, interpret } from 'svelte-knobby';

interpret(value => {
  if (Array.isArray(value) && value.length === 4 && value.every(x => typeof x === 'number') {
    return {
      component: BezierCurveEditor,
      value
    };
  }
});

const values = knobby({
  curve: [0.25, 0.1, 0.25, 1]
});

Perhaps that's overthinking things though.

We also need a way for components to occupy the full width of the panel and have arbitrary height. now possible

Rich-Harris commented 3 years ago

This already works, it just needs to be documented