JSFiddle - React, Tailwind, and code Playground

by Alexandru Gatea

HTML

<ol>

  <li>Click the blue button to expand it </li>
  <li>Click it again to close</li>
  <li> &lt;- Drag the console's left window to change size from landscape to portrait</li>
  <li>Notice how the sidebar changes pozition</li>

</ol>

<p>Screen Width: <span class="sw"></span> <br>Screen Height: <span class="sh"></span><br>
  Sidebar Width: <span class="sbw"></span><br> SidebarHeight: <span class="sbh"></span>
</p>

<div class="search">

  <div class="search-content">
    <div class="search-field">
      <div class="close"></div>
    </div>
    <div class="tabs">
      <div class="tabs-nav">
        <div class="div"></div>
        <div class="div"></div>
        <div class="div"></div>
        <div class="div"></div>
      </div>
      <div class="tabs-content">

        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>
        <div class="sq"></div>

      </div>
    </div>

  </div>
</div>

SCSS

body {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.search {
  width: 50px;
  height: 50px;
  background: #0b79dc;
  position: absolute;
  top: calc(100% - 80px);
  left: 30px;
  border-radius: 4px;
  box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.25s ease-in-out;
  overflow: hidden;
  
  .search-content {
    top: 1000px;
    opacity: 0;
  }
  
  .search-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 30px;
    
    .search-field {
      width: 100%;
      height: 50px;
      margin-bottom: 30px;
      background: rgba(255, 255, 255, 0.2);
      padding: 10px;
      display: flex;
      justify-content: flex-end;
      
      .close {
        width: 30px;
        height: 30px;
        background: rgba(255, 255, 255, 0.2);
      }
    }
    .tabs {
      height: 100%;
      display: flex;
    }
    
    .tabs-nav {
      width: 100px;
      height: auto;
      background: rgba(255, 255, 255, 0.2);
      display: flex;
      flex-direction: column;
      padding: 20px;
      justify-content: space-between;
      
      .div {
         height: 23%;
         background: #ffffff;
         opacity: 0.2;
      }
    }
    .tabs-content {
      flex-grow: 1;
      margin-left: 30px;
      height: 100%;
      background: rgba(255, 255, 255, 0.2);
      
      padding: 30px;
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      grid-gap: 20px;
      grid-auto-flow: row;
      align-items: start;
      .sq {
        height: 100%;
        background: rgba(255, 255, 255, 0.2);
      }
    }
  }

  &.open {
    .search-content {
       top: 0px;
      opacity: 1;
    }

    @media screen and (orientation: landscape) {
      left: 0;
      width: 75vh;
      height:...

JavaScript

jQuery(document).ready(function($) {

  getSizes();

  $(window).on('resize', function() {
    getSizes();
  })


  function getSizes() {

    $('.sw').text($(window).width() + "px");
    $('.sh').text($(window).height() + "px");
    $('.sbw').text($(".search").width() + "px");
    $('.sbh').text($(".search").height() + "px");

  }


  $('.search').on('click', function() {
    $(this).toggleClass('open');

    setTimeout(function() {
      getSizes();
    }, 400)

  });


});