This repo shows how to duplicate an existing Flex Component so it can be customized with your own desired functionality.
TLDR: Here's a diff of the following process
- Navigate to Miva Admin > User Interface > Flex Components
- Check the desired component (ex. mmx-featured-product)
- Click the "Download Component" button
- Extract the downloaded component (ex.
mmx-featured-product.tar.bz2
) Example - Rename the component's folder with its own unique name Example
- In
flex.json
, change thecode
,name
,version
, &resourcegroup_code
to unique values Example - In
flex.json
, changemanaged
fromtrue
tofalse
Example - Optionally, change the
src/images/preview.svg
Example - Remove the JavaScript or provide a unique alternative
- If updating with a unique alternative:
- Change the
flex.json > scripts
filepath
andresource_code
to a unique value Example - Change the JavaScript file's class & tag name Example
- Change
init.mvt
to load your resource Example - Change
instance.mvt
to use your web-component Example - Remove/update the
flex.json > scripts > attributes
for theintegrity
attribute Example
- Change the
- If removing:
- Remove the corresponding
flex.json > scripts > attributes
item - Remove the corresponding
src/js/*.js
file
- Remove the corresponding
- If updating with a unique alternative:
- Remove the CSS or provide a unique alternative
- If updating with a unique alternative:
- Change the
flex.json > styles
filepath
andresource_code
to a unique value Example - Change
init.mvt
to load your resource Example - Update the JS file's
styleResourceCodes
to use your CSS Example - Remove/update the flex.json > styles > attributes for the
integrity
attribute Example - Optionally, update any of the CSS contents for your customizations Example
- Optionally, update the component's CSS class namespace. For example:
- The JavaScript file's
render()
function would be updated from<div ... class="mmx-featured-product ...">
to<div ... class="dup-featured-product ...">
- and all the
.mmx-featured-product
selectors in the CSS file would become.dup-featured-product
- The JavaScript file's
- Change the
- If removing:
- Remove the corresponding
flex.json > styles > attributes
item - Remove the corresponding
src/css/*.css
file
- Remove the corresponding
- If updating with a unique alternative:
- Optionally, change any other files of the component to add your custom functionality (ex. init.mvt, instance.mvt, flex.json properties, other CSS & JS files, etc.)
- Review and confirm/update the
flex.json > depends
&flex.json > conflicts
values
- tar your directory Example
$ cd dup-featured-product && tar -cvjSf ../dup-featured-product.tar.bz2 *
- Navigate to Miva Admin > User Interface > Flex Components
- Click the "Upload Component" button
- Upload your
dup-featured-product.tar.bz2
file
- Navigate to Miva Admin > User Interface > Content Management
- Create/edit a page
- Click the "Add Component" button
- Select your custom component
$ mmt checkout ...
your remote- Edit the properties, scripts, styles, and templates of your component:
css/dup-featured-product.css
js/dup-featured-product.js
properties/flex/dup-featured-product.json
templates/flex-initialization-template-dup-featured-product.mvt
templates/flex-instance-template-dup-featured-product.mvt
$ mmt push --notes "updated foo"
to push your changes up- Preview your changes and repeat mmt pushes until you are finished
- Navigate to Miva Admin > User Interface > Flex Components
- Check the desired component (ex. dup-featured-product)
- Click the "Download Component" button
- Take the downloaded
dup-featured-product.tar.bz2
and import it into a client store
- Start with a basic component (ex. mmx-example)
- mmt checkout an existing component as a reference
- Copy over the flex.json settings, properties, scripts, styles, and templates to your component
- Tar and distribute the component