JSFiddle - React, Tailwind, and code Playground

by bejnar

HTML

<article class="blocky-testimonial blocky-testimonial--center blocky-testimonial--defaults">
  <div class="blocky-testimonial_quote">
    Centered speech bubble
  </div>
  <div class="blocky-testimonial_arrow">
  </div>
  <div class="blocky-testimonial_image blocky-testimonial_image--round"
    style="background-image: url(https://placeimg.com/600/600/people)"
  ></div>
  <p class="blocky-testimonial_name">
    Jenny Jenson
  </p>
  <p class="blocky-testimonial_byline">
    The Example Co.
  </p>
  <div class="blocky-testimonial_stars">
    <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><path d="M9 11.3l3.71 2.7-1.42-4.36L15 7h-4.55L9 2.5 7.55 7H3l3.71 2.64L5.29 14z"/><path fill="none" d="M0 0h18v18H0z"/></svg>
    <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><path d="M9 11.3l3.71 2.7-1.42-4.36L15 7h-4.55L9 2.5 7.55 7H3l3.71 2.64L5.29 14z"/><path fill="none" d="M0 0h18v18H0z"/></svg>
    <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><path d="M9 11.3l3.71 2.7-1.42-4.36L15 7h-4.55L9 2.5 7.55 7H3l3.71 2.64L5.29 14z"/><path fill="none" d="M0 0h18v18H0z"/></svg>
  </div>
</article>

<article class="blocky-testimonial blocky-testimonial--left blocky-testimonial--defaults">
  <div class="blocky-testimonial_quote">
    Left aligned speech bubble Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  </div>
  <div class="blocky-testimonial_arrow">
  </div>
  <div class="blocky-testimonial_image blocky-testimonial_image--round"
    style="background-image:...

SCSS

$avatar-width: 100px;

.blocky-testimonial {
  // max-width: 600px; // if enabled
  width: 100%;
  display: grid;
  padding-bottom: 10px;
  
  .blocky-testimonial_quote {
    background-color: #eee;
    padding: 20px;
    position: relative; // ! important for arrow positioning
  }

  .blocky-testimonial_arrow {
    height: 0;
    width: 0;
    border-top: 15px solid #eee;
    border-bottom: 15px solid transparent;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
  }

  .blocky-testimonial_image {
    height: $avatar-width;
    width: $avatar-width;
    background-size: cover;
    background-position: center;

    &--round {
      border-radius: $avatar-width;
    }
  }

  .blocky-testimonial_name {
    font-weight: bold;
    margin: 5px;
  }

  .blocky-testimonial_byline {
    margin: 0 5px 5px 5px;
  }

}

// OPTIONS

// Centering
.blocky-testimonial {
  &--center {
    justify-items: center;
  }
  
  &--left {
    justify-items: start;
    .blocky-testimonial_arrow {
      margin-left: $avatar-width / 3;
    }
  }
  &--right {
    justify-items: end;
    .blocky-testimonial_arrow {
      margin-right: $avatar-width / 3;
    }
  }
}

// Typography
.blocky-testimonial--defaults {
  font-family: arial;
  line-height: 1.2;
}

// Styles
.blocky-testimonial--card {
  
  grid-template-columns: $avatar-width 1fr 1fr;
  grid-template-rows: auto;
  grid-template-areas: 
    "quote quote quote"
    "image name name"
    "image byline byline";
  
  .blocky-testimonial_quote {
    grid-area: quote;
  }
  
  .blocky-testimonial_image {
    grid-area: image;
  }
  
  .blocky-testimonial_name {
    grid-area: name;
    align-self: end;
  }

  .blocky-testimonial_byline {
    grid-area: byline;
    align-self: start;
  }
  
}