JSFiddle - React, Tailwind, and code Playground

Image gallery

by Hugo Carneiro

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<div class="titles">
  <p>My images</p>
  <p>Select an image from your library below.</p>
</div>

<div class="gallery-tool clearfix">
  <!-- BACK BUTTON ONLY SHOWS WHEN THE USER NAVIGATES INSIDE A FOLDER -->
  <div class="back-btn">
    Up to Folder Name
  </div>

  <div class="breadcrumbs-select">
    <label for="breadcrumbs" class="select-proxy-display">
      <span class="icon fa fa-chevron-down"></span>
      <span class="select-value-proxy">Some Folder</span>
      <select id="breadcrumbs" class="hidden-select form-control">
        <option value="" selected="selected">Some Folder</option>
        <option value="">Parent Folder</option>
        <option value="">Parent Parent Folder</option>
        <option value="">Organisation/App Folder</option>
      </select>
    </label>
    <div class="helper">Jump to:</div>
  </div>
</div>

<div class="folder-selection">
  <span>Select an image below</span>
</div>

<div class="image-library">
  <div class="col-xs-4 item-holder folder" data-id="405">
    <div class="image-holder">
      <div class="image-overlay">
        <i class="fa fa-folder" aria-hidden="true"></i>
      </div>
      <div class="image-info">
        <p>
          <strong>Folder One</strong>
        </p>
        <p>
          Double click to open the folder
        </p>
      </div>
    </div>
    <div class="image-title">
      <p>
        <strong>Folder One</strong>
      </p>
    </div>
  </div>

  <div class="col-xs-4 item-holder image" data-id="405">
    <div class="image-holder" style="background-image: url('https://fliplet-staging.s3-eu-west-1.amazonaws.com/apps/110/1471540587943-file-Screen%20Shot%202016-08-18%20at%2018.15.55.png');">
      <div class="image-info">
        <p>
          <strong>Screen Shot 2016-08-18 at...

CSS

/* NO NEED TO COPY THIS BIT - MORE BELOW */

.titles {
  font-size: 1em;
  border-bottom: 1px solid #E3E9EB;
  margin-bottom: 3rem;
  padding-bottom: 1.5em;
}

.titles p {
  font-weight: bold;
  margin: 0;
}

.titles p + p {
  font-weight: normal;
  font-size: 0.8em;
  margin: 0.8em 0 0;
}

.image-library {
  display: flex;
  justify-content: flex-start;
  flex-flow: wrap;
}

.image-library .col-xs-4 {
  padding-left: 10px;
  padding-right: 10px;
  margin-bottom: 10px;
}

.image-holder {
  position: relative;
  width: 100%;
  padding-top: 59%;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;
  border: 1px solid #d9ddde;
  background-color: #FFFFFF;
}

.image-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(255, 255, 255, 0.6);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-flow: row wrap;
  overflow: hidden;
  opacity: 0;
}

.image-holder:hover .image-overlay {
  opacity: 1;
}

.image-info {
  position: absolute;
  left: -1px;
  right: -1px;
  top: 100%;
  background-color: #FFF;
  border: 1px solid #d9ddde;
  padding: 9px 10px 10px 10px;
  margin-top: 0px;
  opacity: 0;
  visibility: hidden;
  -webkit-transition: all 0.225s ease-in-out;
  transition: all 0.25s ease-in-out;
  z-index: 10;
  word-break: break-word;
}

.btn-primary {
  color: #FFF;
  background-color: #00abd2;
  border-bottom: 2px solid #0087a6;
}

.image-overlay .btn {
  opacity: 0;
  line-height: 28px;
  font-size: 0.8em;
  border-radius: 4px;
}

.image-overlay .btn:nth-child(1) {
  order: 1;
}

.image-holder:hover .image-overlay .btn {
  opacity: 1;
}

.image-overlay::after,
.image-overlay::before {
  content: '';
  width: 100%;
  order: 1;
}

.image-info,
.image-title {
  font-size: 12px;
}

.image-title {
  padding: 9px 11px;
  word-break: break-word;
}

.image-title p {
  margin: 0;
}

.image-holder:hover > .image-info {
  opacity: 1;
 ...

JavaScript

// Single Click
$(".image").on('click', function() {
	
	// Removes any selected folder
	$('.image').not(this).each(function(){
    $(this).removeClass('selected');
  });
	
  // Selects clicked folder or deselects clicked folder
	$(this).toggleClass('selected');
  var itemType;
  if ( $(this).hasClass('image') ) {
  	itemType = 'image'
  	changeSelection(itemType);
  } else if (  $(this).hasClass('folder')) {
  	itemType = 'folder'
  	changeSelection(itemType);
  }
  
  // removes the button if no folder is selected
  if ( $('.image.selected').length == 0 ) {
  	removeSelection();
  }
});

// Double Click
$(".folder").dblclick(function() {
  console.log('double clicked');
});

// Change select box
$('#breadcrumbs').on('change', function() {
  var selectedValue = $(this).val();
  var selectedText = $(this).find("option:selected").text();
  $(this).parents('.select-proxy-display').find('.select-value-proxy').html(selectedText);
});

function changeSelection(itemType) {
	$('.folder-selection span').addClass('active').html('You have <strong>selected one</strong> ' + itemType);
}

function removeSelection() {
	$('.folder-selection span').removeClass('active').html('Select an image below');
}