JSFiddle - React, Tailwind, and code Playground

Tweak to chat UI

by Hugo Carneiro

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<main>
  <aside><div></div>
  Click me when you're in mobile</aside>
  <section>Hey!</section>
</main>

CSS

html, body {
  height: 100%;
  margin: 0;
}

main {
  position: relative;
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

aside {
  background: green;
  width: 200px;
  transition: margin 0.3s;
  position: relative;
}

aside div {
  background: rgba(0,0,0,0.5);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.3s;
}

section {
  flex: 1;
  background: yellow;
  transition: left 0.3s;
}

@media (max-width:400px) {
  aside {  
    width: 100%;
  }
  
  .open aside {
    margin-left: -50px;
  }
  
  .open aside div {
    opacity: 1;
  }
  
  section {
    position: absolute;
    top: 0;
    left: 100%;
    width: 100%;
    height: 100%;
  }
  .open section {
    left: 0;
  }
}

JavaScript

$('aside').click(function () {
	$(this).parent().addClass('open')
})

$('section').click(function () {
	$(this).parent().removeClass('open')
})