easyblockshq / easyblocks

The open-source visual builder framework.
https://easyblocks.io
GNU Affero General Public License v3.0
344 stars 55 forks source link

feat(editor): include field in widgets #58

Open maarten2424 opened 5 months ago

maarten2424 commented 5 months ago

Description

To create fully custom widgets, include all the field parameters as a property. This enables the developer to read all the field information in a widget, so they can create fully custom widgets.

Example widget:

export default function NumberWidget({ value, onChange, field, params }) {
  return (
      <SliderInput
        label={field.label}
        type="slider"
        unit={params.unit}
        min={params.min}
        max={params.max}
        step={params.increment}
        size="small"
        onChange={(e, value) => {
          onChange(value);
        }}
        value={value}
        hint={field.description}
      />
  );
}
vercel[bot] commented 5 months ago

@maarten2424 is attempting to deploy a commit to the Shopstory Team on Vercel.

A member of the Team first needs to authorize it.

r00dY commented 4 months ago

Hey, could you please show me the SliderInput widget?

The widget doesn't have access to a label and description by design. The widget is just "a control", but the label, description and other control-wrapping stuff (responsible for responsive field, "Mixed" field when multi-selection etc) are unified across the system.

I'm asking about this because I’m trying to see whether it’s the right approach. Maybe we should open the field widget to be customised? There was a discussion started here: https://github.com/easyblockshq/easyblocks/pull/53

maarten2424 commented 4 months ago

I think all of these information should be available in widgets, why withhold that information on a widgets. A widget should have full customizability. So would be a good idea to open up! Example; For this slider input you'd also need params.increment, params.unit, etc. etc.

Screenshot 2024-07-18 at 12 51 11