Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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

              
                <div class="main-container">
  <div class="wrapper">
    <h2 class="page-title">
      Spotify Search
      <small>Lookup your favorite tracks, artists and albums</small>
    </h2>
    <input id="search-value" name="search-input" type="text" class="searchbox" placeholder="Search here..." />
  </div><!-- /.wrapper -->
  
  
  <div id="rendered-content"></div>
</div>


              
            
!

CSS

              
                /* pre defined styles */
body {
  background: #DCE35B;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to left, #DCE35B, #45B649);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to left, #DCE35B, #45B649);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  font-family: 'Raleway', sans-serif;
  position: relative;
}

.main-container {
  width: 100%;
}

.wrapper {
  background: #ecebe8;
  border: 1px solid #000;
  margin: 20px auto;
  padding: 10px;
  width: 80%;
}

input {
  background: transparent;
  border-top: 0;
  border-left: 0;
  border-bottom: 2px solid #66FF33;
  display: block;
  margin: 5px auto;
  outline: transparent;
  padding: 10px;
  text-align: center;
  width: 200px;
  transition: .2s ease;
}

input:focus {
  font-size: 20px;
  font-weight: bold;
  transition: .2s ease;
}

/* Typography */
.page-title {
  font-weight: bold;
  text-align: center;
}

small {
  color: #84bd00;
  display: block;
}

/* Dynamic Content */
#rendered-content {
  width: 100%;
  position: absolute;
}

.result {
  float: left;
  width: 20em;
}


/* Create  your own styles here --> See the JS code for class names
*********************************************************************/
.artist-card {
  -webkit-transform: translateY(-50%) translateX(-50%);
  transform: translateY(-50%) translateX(-50%);
  padding: 20px;
  width: 80%;
  display: inline-block;
  margin: 20px;
  background-color: #FFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  cursor: pointer;
}

.artist-card .artist-card__header {
  background-size: cover;
}

.artist-card:hover {
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}

.artist-card:hover .artist-card__header {
  height: 40px;
}

.artist-card:hover .artist-card__header .artist-card__icon {
  -webkit-transform: translateX(-50%) translateY(-50%) scale(3);
  transform: translateX(-50%) translateY(-50%) scale(3);
}

.artist-card:hover .artist-card__body {
  height: 300px;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li {
  -webkit-transform: translateX(0);
  transform: translateX(0);
  -webkit-transition-timing-function: cubic-bezier(0, 1.5, 1, 1);
  transition-timing-function: cubic-bezier(0, 1.5, 1, 1);
  -webkit-transition-duration: 0.5s;
  transition-duration: 0.5s;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li:nth-child(1) {
  -webkit-transition-delay: 0.25s;
  transition-delay: 0.25s;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li:nth-child(2) {
  -webkit-transition-delay: 0.5s;
  transition-delay: 0.5s;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li:nth-child(3) {
  -webkit-transition-delay: 0.75s;
  transition-delay: 0.75s;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li:nth-child(4) {
  -webkit-transition-delay: 1s;
  transition-delay: 1s;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li:nth-child(5) {
  -webkit-transition-delay: 1.25s;
  transition-delay: 1.25s;
}

.artist-card:hover .artist-card__body .artist-card__knowledge li:nth-child(6) {
  -webkit-transition-delay: 1.5s;
  transition-delay: 1.5s;
}

.artist-card .artist-card__header {
  position: relative;
  background-color: #eb6c3f;
  height: 170px;
  margin: -20px -20px 20px -20px;
  -webkit-transition: height 0.5s;
  transition: height 0.5s;
  overflow: hidden;
}

.artist-card .artist-card__header .artist-card__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translateY(-50%) translateX(-50%);
  transform: translateY(-50%) translateX(-50%);
  display: block;
  -webkit-transition: -webkit-transform 0.5s;
  transition: -webkit-transform 0.5s;
  transition: transform 0.5s;
  transition: transform 0.5s, -webkit-transform 0.5s;
}

.artist-card .artist-card__body {
  height: 40px;
  -webkit-transition: height 0.5s;
  transition: height 0.5s;
  overflow: hidden;
}

.artist-card .artist-card__body .artist-card__title {
  font-size: 1.4em;
  font-weight: 600;
  text-transform: uppercase;
}

.artist-card .artist-card__body .artist-card__details {
  color: #9E9E9E;
  font-style: italic;
}

.artist-card .artist-card__body .artist-card__knowledge {
  margin-top: 10px;
  color: #424242;
}

.artist-card .artist-card__body .artist-card__knowledge li {
  margin-top: 5px;
  -webkit-transition-duration: 0;
  transition-duration: 0;
  -webkit-transition-delay: 0.5s;
  transition-delay: 0.5s;
  -webkit-transform: translateX(-100%);
  transform: translateX(-100%);
}

h2 {
  margin: 0;
}

@media screen and (min-width: 541px) {
  #rendered-content {
    top: 350px;
    left: 250px;
  }
    
}

@media screen and (max-width: 540px) {
  #rendered-content {
    top: 350px;
    left: 200px;
  }
    
}

@media screen and (max-width: 375px) {
  #rendered-content {
    top: 350px;
    left: 110px;
    width: 50%;
  }
  
  .artist-card {
    width: 50%;
  }
    
}
              
            
!

JS

              
                // code up a get request from Spotify API
// see API sandboxhere -> https://developer.spotify.com/web-api/console/get-search-item/?q=tania%2A&type=artist#complete 

/* Take a look at the code, you will see below where you can modify it
***********************************************************************/

const url       = "https://api.spotify.com/v1/search?q="; // api base url
const searchBox = document.getElementById("search-value");
const content   = document.getElementById("rendered-content");

searchBox.addEventListener('keyup', function() {
  const searchTerm = searchBox.value; // the value from the searchbox
  content.innerHTML = ""; // reset the dynamic data on each new API call

  
  // fetch the url, with the searchterm, specify artist / song / album as well as the limit
  fetch(url + searchTerm + "*&type=artist")
    .then(response => response.json()) // turn API data into JSON
    .then((data) => {
      // use dot notation to look into the json data
      let results = data.artists.items;
       results.forEach(artist => content.innerHTML +=      
                       
                       
        /* Don't change any code ABOVE this line!
        *****************************************************
        
         * Create something beautiful with the following HTML, 
         * feel free to change the HTML tags if you need to.
         */
        `<div class='result'>
           <div class="artist-card">
              <header class="artist-card__header" style="background-image: url('${artist.images[0].url}')">
                  
              </header>
              <section class="artist-card__body">
                <h2 class="artist-title"> ${artist.name} </h2>
                    <span class="artist-card__details">Details</span>
                    <ul class="artist-card__knowledge">
                      <li class="artist-followers">${artist.followers.total} Followers</li>
                      <li class="artist-popularity">Popularity: ${artist.popularity}</li>
                      <li class="artist-genres">Genres: ${artist.genres}</li>
                      <li>
                          <a class="artist-link" target="_blank" href=" ${artist.external_urls.spotify} ">Link</a>
                      </li>
                    </ul>
              </section>
            </div>
         </div>
      `)
       /* Don't change any code BELOW this line! 
        *******************************************************/
    
    
    })
    .catch(err => console.log('Fetch Error :-S', err)); // catch an error (see console if error occurs) 
});
              
            
!
999px

Console