JSFiddle - React, Tailwind, and code Playground

by lxjwlt

HTML

<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<div id="app"></div>

CSS

button:focus {
  outline: 1px solid blue;
}

.btn-wrap {
  overflow: hidden;
  border: 1px dotted #ddd;
  padding: 10px;
}

JavaScript

new Vue({
	el: '#app',
  render (createElement) {
  	return createElement('div', { class: 'btn-wrap' }, [
    	!this.inFirst ? createElement('button', {
      	on: {
        	click: this.prev
        }
      }, 'prev') : null,
      createElement('button', {
        style: {
          'float': 'right'
        },
        on: {
          click: this.noop
        }
      }, 'cancel'),
      this.inEnd ? createElement('button', {
      	style: {
          'float': 'right'
        },
      	on: {
        	click: this.noop
        }
      }, 'submit') : null,
      !this.inEnd ? createElement('button', {
      	style: {
          'float': 'right'
        },
      	on: {
        	click: this.next
        }
      }, 'next') : null
    ])
  },
  data: {
  	index: 0,
    total: 1
  },
  computed: {
  	inFirst () { return this.index === 0; },
    inEnd () { return this.index === this.total; }
  },
  methods: {
  	prev () {
    	this.index -= 1;
    },
    next () {
    	this.index += 1;
    },
    noop () {}
  }
})