Appearance
Coded component
Use coded components to import assets from Veeva Vault.
This tutorial shows how to develop a dynamic arrow that expands and collapses when you click it.
You can import your coded component from Veeva Vault to e-Detailers and emails with wiz-coded-component.
Development
To develop a coded component:
Initialize a component with the
wiz init componentcommand.shwiz init componentAs a result, you get a component with a predefined directory structure.
sh. └─ └─.ewizard/ ├ └─ settings.json # The eWizard.js project settings and plugins configuration ├─ demo/ # The demo e-Detailer project ├─ dist/ ├ └─ build.js # The component builder ├─ .gitignore # By default, /node_modules is ignored ├─ .npmignore # By default, /demo and /node_modules are ignored ├─ index.vue # Add your component code here ├─ package.json # npm manifest └─ settings.json # The component configurationRemove the
demodirectory from the initialized component to use the component in an actual template.Install the necessary dependencies for the component with the wiz install command. You can install components, blocks, and other dependencies.
Install the
component-typesmodule.shwiz install @ewizardjs/component-typesThe
component-typesmodule is required for eWizard.js to recognize the component types.Install the
wiz-imagecomponent.shwiz install @edetailer/wiz-image
After the installation, eWizard.js adds the dependencies to the
package.jsonfile of the component.json// ./package.json { "dependencies": { "@ewizardjs/component-types": "^3.1.0", "@edetailer/wiz-image": "^2.0.0", } }Declare the component types in the
ewizard.config.jsfile.js// ./ewizard.config.js import { PropType, FileType } from "component-types";Configure the component properties for eWizard Editor in the
propsobject of theewizard.config.jsfile. For example, thecomponentName,hideOnSlides,showSecondaryLogo,logoPrimary, andlogoSecondaryproperties:js// ./ewizard.config.js export default { props: { componentName: { label: { eng: "Arrow btn", deu: "Arrow btn", rus: "Arrow btn", ukr: "Arrow btn", esp: "Arrow btn", fra: "Arrow btn", }, actualType: PropType.String, }, hideOnSlides: { label: { eng: "Hide on slides", deu: "Hide on slides", rus: "Hide on slides", ukr: "Hide on slides", esp: "Hide on slides", fra: "Hide on slides", }, actualType: PropType.Slides, }, showSecondaryLogo: { label: { eng: "Show secondary logo", deu: "Show secondary logo", rus: "Show secondary logo", ukr: "Show secondary logo", esp: "Show secondary logo", fra: "Show secondary logo", }, actualType: PropType.Slides, }, logoPrimary: { label: { eng: "Arrow primary", deu: "Arrow primary", rus: "Arrow primary", ukr: "Arrow primary", esp: "Arrow primary", fra: "Arrow primary", }, actualType: PropType.File, subtype: FileType.Image, sealed: true, }, logoSecondary: { label: { eng: "Arrow secondary", deu: "Arrow secondary", rus: "Arrow secondary", ukr: "Arrow secondary", esp: "Arrow secondary", fra: "Arrow secondary", }, actualType: PropType.File, subtype: FileType.Image, sealed: true, }, }, };The
ewizard.config.jsfile shows the following properties:The
componentNameproperty is the name of the component in eWizard Editor.The
hideOnSlidesproperty hides the arrow logo in the collapsed state, andshowSecondaryLogoshows the logo in an open state.The
logoPrimaryandlogoSecondaryproperties represent the expanded and collapsed state of the arrow. When properties aresealed, they're not displayed in eWizard Editor. For more information, see Hide properties.
Each property has a defined type in the
actualTypefield. For more information, see Property types.Import the assets in the
<script>tag of theindex.vuefile of the component. You can import images, styles, and eWizard.js components. For example,wiz-image:html<script> import wizImage from 'wiz-image'; import logoPrimary from './media/images/openMenu.png'; import logoSecondary from './media/images/openMenuWhite.png'; export default { name: 'wiz-by-arrow-open-menu', components: { wizImage } }; </script>Add the component markup in the
<template>tag of theindex.vuefile. You can use HTML attributes and eWizard components. For example, an HTML table with a row and a column:html<!-- ./index.vue --> <template> <div v-show="isVisible" class="wiz-by-arrow-open-menu"> <wiz-image v-if="showPrimaryLogo" class="arrow-image" :src="logoPrimary"></wiz-image> <wiz-image v-else class="arrow-image" :src="logoSecondary"></wiz-image> </div> </template>The component uses the
v-show,v-if, andv-elseVue directives to show the different arrow logos for the collapsed and expanded arrow state.Define the component properties, in the
propsobject of theindex.vuefile.html<!-- ./index.vue --> <script> export default { name: 'wiz-by-arrow-open-menu', props: { componentName: { type: String, default: "Arrow Btn" }, hideOnSlides: { default: () => [] }, showSecondaryLogo: { default: () => [] }, logoPrimary: { type: String, default: logoPrimary }, logoSecondary: { type: String, default: logoSecondary } } }; </script>Add the function that shows different arrow logos when it's collapsed or expanded in the
index.vuefile.html<script> export default { name: 'wiz-by-arrow-open-menu' computed: { isVisible() { return !this.hideOnSlides.some(item => item.slide === this.currentSlide); }, showPrimaryLogo() { return !this.showSecondaryLogo.some(item => item.slide === this.currentSlide); }, currentSlide() { return this.$navigator.getCurrentSlide().slide; } } }; </script>The function uses the
getCurrentSlidemethod of the navigation plugin.Add some component styles in the
<style>tag of theindex.vuefile.html<!-- ./index.vue --> <style scoped> .wiz-by-arrow-open-menu .arrow-image{ display: block; width: 26px; height: 17px; } </style>
Adding to a template
To use your custom component in a template:
Add the developed component directory to the
./common/componentsdirectory of your template.Add the component tag to the Vue file with the layout.
For an e-Detailer slide:
./slides/default/index.vue. Here,defaultis the slide ID.For an e-Detailer master template, email, and landing page:
./App.vueFor a page in a multipage site:
./pages/default/index.vue. Here,defaultis the page ID.
For example, add the
wiz-by-arrow-open-menucomponent to theApp.vuefile of an e-Detailer master template:html<!-- App.vue --> <template> <wiz-root :class="{'refs-styles': isDefaultSlides}"> <wiz-viewer> <wiz-container id="arrowOpenContainer" @click.native="openMenu()" class="btn-wrapper not-menu pa"> <wiz-by-arrow-open-menu :show-secondary-logo="[{'slide': 'blankSlide11'}]" id="arrowOpen" class="img-for-btn arrow" data-element-type="Headline"></wiz-by-arrow-open-menu> </wiz-container> </wiz-viewer> </wiz-root> </template>The
data-element-typeattribute is used for the component classification when publishing your template to Veeva Vault.data-element-typeis required for the component to work in the modular approach.By default,
data-element-typehas a specific set of values based on the component. Check the values in the ELEMENT TYPE field in eWizard Editor. To add or change values, please contact eWizard Support.Register the component locally in the Vue layout file. For example, the
App.vuefile:html<!-- App.vue --> <script> import wizByArrowOpenMenu from './common/components/wiz-by-arrow-open-menu/index.vue'; export default { name: 'wiz-app', components: { wizByArrowOpenMenu, }, }; </script>You can't register custom components globally with preinstalled eWizard components in the same template. Register custom components locally to use them with preinstalled components.
Uploading to Veeva Vault
Upload your component to Veeva Vault, so you can import it to eWizard Editor.
Before uploading the component, make sure to archive the component with the wiz-component-build command.
To use the component in Veeva Vault, upload it as a user, and connect it to a module as an admin.
To upload the component:
Create a new document. There are two ways to create a new document:
Click + Create → Upload while on the Library tab.
Click ▼ → Upload.
- Upload an archive with your component.
- Choose the document type Component > Interactive when uploading the component archive.
Fill in all the required fields and save changes.
After uploading the component as a user, switch to the admin mode and create a new module.
In the content module menu, select the Content Module Document Assets and click + Create.
- Select Data in the Content Asset Module Type field.
Fill in the required fields in the Create Data pop-up.
Asset is the name of the uploaded component in Veeva Vault.
Channel is the eWizard item type you plan to use the component for. Select e-Detailer or Email.
Image Element Type is the element type for image classification. For example, when you select the Icon element type for eWizard images, only assets of the matching element type can be uploaded from Veeva Vault.
Read more