Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <img class='logo' src='http://matthew-morton.com/amazon-logo.png' width='200px' height='auto' />
<br><br>
<p>
  Thanks for your interest in Amazon. The Advertising Design Technology team is a lean group of designer-developers who appreciate intuitive, streamlined user experiences; beautiful visual design; elegant interaction animations; and simple, easy-to-read code. We stay on top of technology trends while keeping in mind limitations that may prevent us from deploying to our many devices and platforms. Millions of Amazon customers around the world interact with the experiences we build.
</p>
<h2>Exercise 2: Product Carousel</h2>
<p>
  To complete this exercise, first create a free CodePen account (if you don’t already have one) and fork this pen. Then design and develop a simple product carousel with the JSON file and sprite sheet below. The widget should support product images, product titles, reviews, star ratings, prime eligibility, price and anything else you'd like to add. Things we’re looking for include:
  <ul>
    <li>Simple, intuitive user experience</li>
    <li>Fun, interactive user interface</li>
    <li>Beautiful, polished visual design</li>
    <li>Elegant, easy-to-read code</li>
  </ul>
To put it another way, <em>wow us with something you’re proud to show off</em>.
</p>
<p>
  Spend as much time as needed; however, the expectation is that the exercise should only require a few hours to complete. Please do not use any external libraries as we'd like to see what you can create from scratch. You can assume the carousel widget will be viewed only in modern browsers. Once completed, enter your name in the space provided and include links to your online portfolio and any recent work you’d like to share.<br>
  JSON: <a href="https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/exercise2/echo_products.json">echo_products.json</a><br>
  Sprite sheet: <a href="https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/exercise2/sprite.png">sprite.png</a>
</p>
<hr>
<div class='widget'>
  <div id="carousel-title">Today's Deals</div>
    <div id="carousel-wrapper">
      <div id="carousel-widget">
        <div id="carousel-container"></div>
      </div>
      <div id="left-arrow" class="carousel-arrow left-arrow"></div>
      <div id="right-arrow" class="carousel-arrow right-arrow"></div>
      <div id="loading-veil">
          <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
      </div>
    </div>
</div>
<h3>Matthew Morton</h3>
<p class='links'>
 
</p>
<hr>
<h2>Thank You!</h2>
<p>
  Thank you for your participation. For more information, please visit <a href='https://www.amazon.jobs/en/teams/axt' target='_blank'>amazon.jobs/en/teams/axt</a>.
</p>
              
            
!

CSS

              
                @font-face {
    font-family: 'Amazon Ember';
    src: url(https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/fonts/amazonember.woff2) format("woff2"),url(https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/fonts/amazonember.woff) format("woff")
}
html,
body {
  position: relative;
  margin: 0px auto;
	background-color: #333333;
  color: #FFFFFF;
  -webkit-font-smoothing: antialiased;
  font-smoothing: antialiased;
  font-family: "Amazon Ember";
}

body {
  max-width: 1000px;
  font-size: 16px;
  line-height: 1.5;
}

a,
a:visited {
  color: #99CCFF;
  text-decoration: none;
}

a:hover {
  color: #ff9900;
}

.logo {
  display: block;
  margin: 0px auto;
  margin-top: 30px;
}

h2, h3 {
  font-weight: 500;
  letter-spacing: 1px;
  text-align: center;
}

em {
  font-weight: 500;
  font-size: 1.25em;
  animation: glow 1s ease-in-out alternate infinite;
}

hr {
  border-top-color: rgba(0,0,0,0.5);
  border-bottom-color: rgba(255,255,255,0.1);
  border-left: none;
  border-right: none;
}

.widget {
  position: relative;
  margin: 0px auto;
  margin-top: 20px;
  margin-bottom: 0px;
  width: 100%;
  height: 342px;
  box-shadow: inset 0px 0px 0px 1px rgba(0,0,0,0.15), inset 0px 1px 2px rgba(0,0,0,0.25), 0px 1px 0px rgba(255,255,255,0.1);
  border-radius: 5px;
  background-color: #2A292A;
}

.links {
  text-align: center;
}

@keyframes glow {
  from {
    color: #FFFFFF;
  } to {
    color: #FFAA00;
  }
}

/* EXAMPLE 
------------------*/
@import 'variables';
@import 'mixins';
@import 'adlp';

html,body{
  background-color: #333;
  -webkit-font-smoothing: antialiased;
  -moz-font-smoothing: antialiased;
  -ms-font-smoothing: antialiased;
  font-smoothing: antialiased;
}

@font-face {
    font-family: 'Amazon Ember';
    src: url(https://m.media-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-amazonember_rg-cc7ebaa05a2cd3b02c0929ac0475a44ab30b7efa._V2_.woff2) format("woff2"),url(https://m.media-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-amazonember_rg-8a9db402d8966ae93717c348b9ab0bd08703a7a7._V2_.woff) format("woff")
}
#carousel-title{
  width: 98%;
  margin: 1%;
  margin-bottom: 0px;
  font-size: 24px;
}
h2{
  color: #FFF;
  display: inline-block;
}
a{
  font-size: 18px;
  color:#48a3c6;
}
#carousel-wrapper{
  position: absolute;
  width: 98%;
  height: 280px;
  margin: 1%;
  border-radius: 4px;
  overflow: hidden;
}
#carousel-widget{
  position: relative;
  height: 280px;
  background-color: #FFF;
  font-family: "Amazon Ember";
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  -webkit-box-shadow: 0px 0px 6px 0px rgba(0,0,0,1);
  -moz-box-shadow: 0px 0px 6px 0px rgba(0,0,0,1);
  box-shadow: 0px 0px 6px 0px rgba(0,0,0,1);
  margin: 0 40px;
}
#carousel-container{
  position: absolute;
  width: max-content;
  height:280px;
}
.carousel-arrow{
  position: absolute;
  top: 0;
  width:40px;
  height: 280px;
  background-color: #FFF;

  -webkit-box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.15);
  -moz-box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.15);
  box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.15);
  font-size: 4rem;
  line-height: 16rem;
  user-select:none;
  color: #ccc;
  text-align:center;
  background-image: url("https://ksomedia.s3.amazonaws.com/lcdtest/mortm/ADT-Coding-Exercise/carousel-arrows.png");
  background-size: cover;
}
.left-arrow{
  left: 0;
  border-right:1px solid #CCC;
  background-position: 0 0;
}
.left-arrow:hover{
  background-position: -40px 0;
  cursor: pointer;
}
.right-arrow{
  right: 0;
  border-left:1px solid #CCC;
  background-position: 200px 0;
}
.right-arrow:hover{
  background-position: 240px 0;
  cursor: pointer;
}
.off{
  display: none;
}
#carousel-widget::-webkit-scrollbar {
  -webkit-appearance: none;
}
#carousel-widget::-webkit-scrollbar:horizontal {
  height: 12px;
}
#carousel-widget::-webkit-scrollbar-thumb {
  border-radius: 8px;
  border: 1px solid #FFF; /* should match background, can't be transparent */
  background-color: #58C8FA;
  background-color: #ccc;
  padding: 4px;
}
#carousel-widget::-webkit-scrollbar-track { 
  background-color: #F2F2F2; 
  border-radius: 4px;
} 
/* PRODUCT STYLES
-----------------------------*/
ul.products{
  margin: 0;
  padding: 0;
}
.product_cell{
  width: 240px;
  height: 280px;
  display: inline-block;
  padding: 0px 20px;
  transition-property: all;
  transition-duration: 0.25s;
}
.product_cell:hover{
  background-color: rgba(113, 113, 113, 0.08);
  cursor: pointer;
} 
.product_image{
  margin: auto;
  text-align: center;
  mix-blend-mode: multiply;
  user-select:none;
}
.asin_image{
  margin-top: 20px;
  max-height: 140px;
  min-height: 140px;
  max-width: 140px;
  object-fit:contain;
  vertical-align: middle;
}
.product_details{
  position: relative;
  top:20px;
}
.product_title{
  font-size: 16px;
  color: #000;
  margin-bottom: 6px;
}
.product_price{ 
  font-size: 16px;
  color: #000;
  display: inline-block;
}
.product_price::first-letter{ 
    font-size: 12px;
    vertical-align: text-top;
}
.rating_count{
  position: relative;
  bottom: 2px;
  color: #0066c0;
  font-size: 13px;
}
.stars{
  font-size: 16px;
  width: 80px;
  height: 18px;
  word-wrap: normal;
  overflow: hidden;
  color: #FF9900;
  letter-spacing: 1px;
  pointer-events: none;
  float: left;
  margin-right: 6px;
  background-image: url("https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/exercise2/sprite.png");
  background-size: 400px 900px;
  background-repeat: no-repeat;
}
.star_count_5{
  background-position: -5px -368px;
}
.star_count_4{
  background-position: -21px -368px;
}
.star_count_3{
  background-position: -36px -368px;
}
.prime{
  position: relative;
  top: 5px;
  left: 6px;
  width: 100px;
  height: 20px;
  display: inline-block;
  background-size: 400px 900px;
  background-repeat: no-repeat;
}
.prime_true{
  background-image: url("https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/exercise2/sprite.png");
  background-position: -5px -490px;
}
/* PRODUCT ANIMATIONS
---------------------------*/
.product_image{
  cursor: pointer;
  image-rendering: auto;
  
  -webkit-transform: translate3d(0,0,0);
  -moz-transform: translate3d(0,0,0);
  -ms-transform: translate3d(0,0,0);
  transform: translate3d(0,0,0);
  
  -webkit-transition-property: transform;
  -webkit-transition-duration: 0.15s;
  -webkit-transition-timing-function: ease-in-out;
  
  -moz-transition-property: transform;
  -moz-transition-duration: 0.15s;
  -moz-transition-timing-function: ease-in-out;
  
  -ms-transition-property: transform;
  -ms-transition-duration: 0.15s;
  -ms-transition-timing-function: ease-in-out;
  
  transition-property: transform;
  transition-duration: 0.15s;
  transition-timing-function: ease-in-out;
  
  -webkit-animation: bounce 0.3s 1 ease-in-out;
  -webkit-animation-delay: 0.05s;
  
  -moz-animation: bounce 0.3s 1 ease-in-out;
  -moz-animation-delay: 0.05s;
  
  -ms-animation: bounce 0.3s 1 ease-in-out;
  -ms-animation-delay: 0.05s;
  
  animation: bounce 0.3s 1 ease-in-out;
  animation-delay: 0.05s;
}

.product_cell:hover > .product_image {
  -webkit-transform: scale3d(1.05,1.05,1);
  -moz-transform: scale3d(1.05,1.05,1);
  -ms-transform: scale3d(1.05,1.05,1);
  transform: scale3d(1.05,1.05,1);
  image-rendering: auto;
}
/* LOADING - USE ECHO BRANDING
---------------------------*/
#loading-veil{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: auto;
  background-color: rgba(255,255,255,1);
  z-index: 1;
  border-radius: 4px;
  opacity: 1;
  pointer-events:all;
  transition-property: all;
  transition-duration: 0.5s;
}
.fade-out {
 opacity: 0 !important;
 pointer-events:none !important;
}
.lds-ring {
  position: absolute;
  width: 64px;
  height: 64px;
  top: 50%;
  left:50%;
  margin-left: -32px;
  margin-top: -52px;
}
.lds-ring div {
  box-sizing: border-box;
  display: block;
  position: absolute;
  width: 51px;
  height: 51px;
  margin: 6px;
  border: 3px solid #58C8FA;
  border-radius: 50%;
  animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  border-color: #58C8FA transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
  animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
  animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
  animation-delay: -0.15s;
}
@keyframes lds-ring {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
/* ERROR RESPONSE
---------------------------*/
#error-message{
  position: absolute;
  text-align: center;
  width: 100%;
  top: 58%;
  font-family: "Amazon Ember";
  font-size: 16px;
  color: #000;
}

              
            
!

JS

              
                const $carouselWidget = document.getElementById("carousel-widget");
const $carousel = document.getElementById("carousel-container");
const $loader = document.getElementById("loading-veil");
const $rightArrow = document.getElementById("right-arrow");
const $leftArrow = document.getElementById("left-arrow");
const productsJSON = 'https://d3jlxzdxc80cmp.cloudfront.net/adt/hiring/exercise2/echo_products.json'

const init = () => {

  fetch(productsJSON)
  .then(function(response) {
    return response.json();
  })
  .catch(error => $loader.innerHTML += "<div id='error-message'>Sorry, something went wrong.</div>")
  .then(function(response) {
    buildCarousel(response);
  });
};

const buildCarousel = (response) => {

  const products = response.asins;

  let displayProducts = "";
  let i;

  displayProducts += "<ul class='products'>";
  
  products.forEach( (product) => {
    
    displayProducts += `

    <li class='product_cell' data-link='${product.detailPageUrl}'>
      <div class='product_image'> <img class='asin_image' src='${product.imageHires}'/> </div>
        
      <div class='product_details'>  

        <div class='product_title'>${product.title.substring(0, 20)}...</div>
        <div class='asin_details'>
          <div class='stars star_count_${product.rating}'  id='stars'></div>
          <div class='rating_count'>${product.ratingCount}</div>
          <div class='product_price'>${product.price}</div>
          <div class='prime prime_${product.isPrimeEligible}'></div>
        </div>

      </div>

    </li>`;

  });

  displayProducts += "</ul>";

  $carousel.innerHTML = displayProducts;

  const product_links = document.querySelectorAll(".product_cell");
  let j;
  for (j = 0; j < product_links.length; j++) {
    product_links[j].addEventListener('click', function() {
      let linkOut = this.getAttribute('data-link');
      window.open("http://amazon.com" + linkOut ); 
    });
  }
  //REMOVE LOADER TO DISPLAY RESULTS
  setTimeout(() => { $loader.classList.add("fade-out"); }, 250);

}
// LEFT AND RIGHT ARROWS
$leftArrow.addEventListener('click', () => {
  $carouselWidget.scrollBy({ top: 0, left: -1 * $carouselWidget.offsetWidth, behavior: 'smooth' });
});
$rightArrow.addEventListener('click', () => {
  $carouselWidget.scrollBy({ top: 0, left: $carouselWidget.offsetWidth, behavior: 'smooth' });
});

init();
              
            
!
999px

Console