Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): include field in widgets #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maarten2424
Copy link
Contributor

@maarten2424 maarten2424 commented Jun 12, 2024

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}
      />
  );
}

Copy link

vercel bot commented Jun 12, 2024

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

A member of the Team first needs to authorize it.

@r00dY
Copy link
Contributor

r00dY commented Jul 9, 2024

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: #53

@maarten2424
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants