easyblockshq / easyblocks

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

feat(editor): include field in widgets #58

Open maarten2424 opened 4 weeks ago

maarten2424 commented 4 weeks 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 4 weeks 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 1 day 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