JSFiddle - React, Tailwind, and code Playground

by Darren Galway

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.8/vue.min.js"></script>
<div id="app">
  <div class="container">
    <main-content></main-content>
    <nav-bar></nav-bar>
  </div>
</div>

SCSS

.slide-enter-active {
  animation: enter 300ms ease;
}

.slide-leave-active {
  animation: enter 300ms ease reverse;
}

@keyframes enter {
  0% {
    max-height: 0;
  }

  100% {
    max-height: 600px;
  }
}

body {
  font-family: sans-serif;
}

.container {
  max-width: 375px;
  margin: 1rem auto;
  overflow: hidden;
}

button {
  border: 0;
  background: transparent;
  border-radius: 0;
}

.nav {
  display: flex;
}

.nav-item {
  flex: 1;
  padding: 1rem;
  background: #000;
  color: #eee;
  text-align: center;
  font-size: 1.5rem;
  
  &.bg-yellow {
    background: yellow;
    color: #000;
  }
  
  &:not(:last-of-type) {
    border-right: 1px solid #eee;
  }
}

.content {
  background: #eee;
  height: 500px;
  padding: 2rem;
}

JavaScript

window.Event = new Vue()

Vue.component('nav-bar', {
  template: `
    <div class="nav">
      <button class="nav-item"><i class="zmdi zmdi-tag"></i></button>
      <button class="nav-item"><i class="zmdi zmdi-check-square"></i></button>
      <button class="nav-item"><i class="zmdi zmdi-alert-triangle"></i></button>
      <button class="nav-item bg-yellow" @click="toggleContent">
      	<i class="zmdi" :class="[ isActive ? 'zmdi-close' : 'zmdi-menu']"></i>
      </button>
    </div>
  `,
  data() {
  	return {
    	isActive: false
    }
  },
  methods: {
  	toggleContent() {
    	Event.$emit('toggleContent')
      this.isActive = !this.isActive
    }
  }
})

Vue.component('main-content', {
	template: `
  <transition name="slide">
  	<div class="content" v-if="active">
      <h2>Some slider</h2>
      <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    </div>
  </transition>
  `,
  data() {
  	return {
      active: false,
    }
  },
  created() {
  	Event.$on('toggleContent', () => {
      this.active = !this.active
    })
  }
})

new Vue({
 el: '#app'
})