0.5.1
Eslint
Added create-react-app's eslint config with minor changes for it to work correctly with this project. Now you will see errors about unused variables and other useful things.
Simplified Input
Before, there was RepeatInput
and InspectorInput
. Now, there's just Input
which can be rendered in the inspector, or inside of a repeat:
import { Inspector, Repeat, Input } from 'gutenblock-controls';
export default () => (
<Inspector>
<Input name="title" placeholder="Title" />
<Repeat title="Projects" addNew="Add Project" attribute="projects">
<Input name="title" />
</Repeat>
</Inspector>
);
Add MediaSelect
component
import { Inspector, MediaSelect } from 'gutenblock-controls';
export default () => (
<Inspector>
<MediaSelect name="backgroundURL" />
</Inspector>
);
This will prompt the user to select or upload photos and store the resulting image inside the attributes.
Add Async select component
Load in items from an api and store the value on attributes
import { Inspector, Select } from 'gutenblock-controls';
export default () => (
<Inspector>
<Select name="id" loadOptions={async search => {
let response = await fetch(`/wp-json/wp/v2/posts?search=${search}`);
let json = await response.json();
return {
options: json.map(item => ({ label: item.title.rendered, value: item.id })),
};
} />
</Inspector>
);