```
These are defined in the tablet JS file.
Components have the following structure:
```
Vue.component('component-name), { // component names are lower case since they are HTML tags
props: ['prop1', 'prop2'], // props are a powerful way to pass data into components and change the way a tag looks/works.
methods: {
function1(){} // methods are functions you can give your component to call in event handlers and expressions.
},
lifeCycleHooks: function() {}, // there are several such as mounted, unmounted...they are ways you can run a function at certain times during the creation, operation, and destruction of a component
data: function(){ // data is a function that returns an object that your component can reference. It returns an object so each unique
return { // component has their own unique data data, and not shared unless you have a certain reason for that. Your component can reference this as this.dataMember, or dataMember
dataMember: "string" // inside of an expression in your template
}
},
computed: function(){ // computed is a way that you can manipulate/format data/props coming in and still retain reactivity.
return {
computedMember: function(){
return formattedData;
}
}
},
template: // this is a string containing the template in HTML format you would like to use. We use a VSCode plugin is used to give HTML syntax coloring in template strings that are activated by /*html*/ before the template string.
/*html*/`
templates must have only one root element but can contain anything you want. This is the heart of your UI.
{{ dataMember }} // this is a JavaScript expression that evaluates to HTML.
`
}
```
### Vue bindings
In order to distinguish from normal HTML attributes, Vue uses special bindings that allow you to have access to certain Vue functionality and work reactively with data changes.
For example, if you want to dynamically change an img tag's source, you would change ```
``` to ```
```. Url, in this case, may be a prop that is passed down, or a member of the data object. Since this is used often, its shorthand is . :src="url".
Other handy Vue attributes are v-if which you feed it an expression so it knows whether to render an element or not, v-on is how events are handled like clicking on an element with v-on:click. The shorthand for this would be @click="functionToRun".
One of the best Vue features we use is v-for. It iterates through an array or object and creates html for each item. For example, we have an array of danceObjects and need to create a component for each. We first create a root element and give it an attribute of v-for="dance in dances". Then we on put one tag in that div and give it props that customize how each one looks based on the element that is in the array. Updating our data member will automatically refresh this list. So cool!
Vue has great [documentation](https://vuejs.org/v2/guide/). Look at the code and reference the Vue docs if there is anything you are curious about. Vue is also a great way to organize chunks of similar
HTML sections by creating custom elements.
# Conclusion
The dance app was a lot of fun to work on and was a constant source of amusement as well as irritation during all-hands meetings at the virtual office :)
Some of the takeaways are:
- Using appUi to simplify the tablet making process
- Applying animations to your Avatar
- Working with Controller Actions
- How the Tablet and Interface communicate together
- Making more complex and interactive apps with the tablet using a framework like Vue.JS
Some ideas for remixing:
- Make up new dances to use
- Find a way to sync up playlists with people around you so you are dancing together
- Go beyond dances and try using other kinds of animations
Let us know if you make something new!