Optional Lab - Enable Makeswift for a Third-Party Component
Optional Lab - Enable Makeswift for a Third-Party Component
Optional Lab - Enable Makeswift for a Third-Party Component
In this first exercise in creating Makeswift-enabled components, you’ll take a pre-existing, open-source React component and simply “wrap” an implementation of it for use in the visual editor.
Double check that the right site API key is present in your .env.local file.
Make sure your local dev server is running in your custom Makeswift project by using the following command in the root directory:
Sign into the Makeswift editor and make sure the appropriate site is chosen and that the Host URL matches the localhost domain your server is running on.
Remember!
These exercises will proceed from the project you previously set up from the lab repository, which already contains boilerplate code these steps rely on. Revisit the initial setup lab in this course if necessary to get your project set up.
If it’s helpful to compare your own code as you go, you can clone or download the completed version of this lab as a reference.
Image Compare Slider Component Lab Snapshot
You’ll be implementing a component called React Compare Slider, which is available for installation via npm.
This component presents an interactive slider interface for comparing two pieces of content.
.gif)
Our goal is to create a simple implementation of this comparison slider with two images, enabling this as a Makeswift component that can supply those images with editor controls.
The project boilerplate already includes the ImageCompareSlider component with placeholder text. Your first step is simply to register the component so it can be used in the Makeswift builder.
Remember that all file paths given here are relative to the core directory in the root of the Catalyst project.
You have no prop controls defined at this time, but this registration will make it available to the Makeswift runtime. The only other step that’s necessary is to make sure this registration is imported when a page renders.

Now you’ll bring the real ReactCompareSlider component into your own, albeit still with placeholder content.

For a fully functional Makeswift component, you need the ability to control the images presented using the editor.
Note the use of Image.Format.URL for the format. You won’t need to know the dimensions of the images, so this simple format will give you just the image URL as a string in the prop.

To make your new component maximally flexible in the editor, it would be best for its sizing, spacing, and border properties to be editable, which you can do with a Style control.
The component doesn’t involve any text, so you’re specifying a list of supported properties excluding the text formatting controls.

The React Compare Slider component includes a number of props to vary the interactive experience, such as props for changing the interaction method to hover instead of drag or for applying a top-to-bottom slider instead of side-to-side.
See the full list of props on the npm info page.
Try selecting a few of these props to support in your own component, then implement appropriate Makeswift controls for them and pass the values through in your own component code.