Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

               <!DOCTYPE html>
<html lang="en">
    <title>Coding for publishers</title>
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Permanent+Marker" rel="stylesheet">
      <img id="cover"/>
      <h2  id="title">[words will go here]</h2>

          <li id="isbn">ISBN: </li>
          <li id="pub-date">Pub date: </li>
          <li id="page-count">Page count</li>
          <li id="rating">Google rating: </li>
          <li id="authors">[contributors will go here]</li>

        <h3 id="error"></h3>
        <h1>About the book</h1>
        <div id="blurb">[blurb will go here]</div>
        <div id="google-link">Link: </div>
        <div id="reader-link">Start reading: </div>

      <input type="button" id="create-ai-button" value="Create AI">
      <p>Created using the Google Books API, by publishers who code, at the London Book Fair 2019</p>

              * {
  box-sizing: border-box;

body {
  font-family: 'Montserrat';
  /* font-family: 'Permanent Marker'; */
  line-height: 1.4;
  color: dark-grey;
  display: flex;
  min-height: 100vh;
  flex-direction: column;

header {
  border-bottom: 10px solid DarkViolet;
  padding: 30px;
  text-align: center;
  font-size: 35px;
  display: flex;
  flex-wrap: wrap;
  background: #F5F2EF;

#cover {
  border: 2px solid black;
  height: 250px;

img {
  width: auto;
  height: auto;

#authors {
  font-size: 15px;

h2 {
  flex: 1;
  display: inline-flex;
  padding-left: 90px;
  text-align: left;

section {  
  display: flex;
  flex-wrap: wrap;
  flex: 1;

nav {
  height: 300px;
  padding: 20px;
  flex: 25%;

nav ul {
  list-style-type: none;
  padding: 0;

article {
  padding: 20px;
  height: 300px;
  flex: 70%;

footer {
  display: flex;
  flex-wrap: wrap;
  background-color: #24211E;
  padding: 10px;
  text-align: center;
  color: white;
  font-size: 12px;

#create-ai-button {
  float: left;
  padding: 10px;
  border-radius: 3px;
  background-color: #F5F2EF;
  font-weight: bold;
  font-size: 18px;

p {
  padding-left: 20px;

#error {
  font-size: 40px;
  color: red; 

@media screen and (max-width: 700px) {
  section {
    flex-direction: column;

              document.getElementById("create-ai-button").addEventListener("click", () => {
    .then(response => response.json())
    .then(result => {
      const bookData           = result.items[0].volumeInfo
      const accessData 				 = result.items[0].accessInfo
      const coverUrl           = document.getElementById("cover")
      const titleElement       = document.getElementById("title")
      const authorsElement     = document.getElementById("authors")
      const blurbElement       = document.getElementById("blurb")
      const pubDateElement     = document.getElementById("pub-date")
      const pageCountElement   = document.getElementById("page-count")
      const ratingElement      = document.getElementById("rating")
      const isbnElement        = document.getElementById("isbn")
      const googleLinkElement  = document.getElementById("google-link")
			const readerLinkElement  = document.getElementById("reader-link")

      coverUrl.src             = bookData.imageLinks.thumbnail
      titleElement.innerHTML   = bookData.title
      blurbElement.innerHTML   = bookData.description
      authorsElement.innerHTML = bookData.authors
      pubDateElement.insertAdjacentHTML("beforeEnd", bookData.publishedDate)
      isbnElement.insertAdjacentHTML("beforeEnd", bookData.industryIdentifiers[1].identifier)
      ratingElement.insertAdjacentHTML("beforeEnd", bookData.averageRating)
      pageCountElement.textContent = bookData.pageCount + ' pages'
      googleLinkElement.innerHTML =
        `<a href="${result.items[0].selfLink}",  target = "_blank">View source</a>`
      readerLinkElement.innerHTML =
        `<a href="${accessData.webReaderLink}", target = "_blank">Start reading ${accessData.accessViewStatus}→</a>`

    .catch(error => {
      document.getElementById("error").innerHTML = error.message

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.