css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <div id="app" :class="[darkBackground ? 'dark-background' : '']">
  <div class="sidebar" v-if="ready">
    <div class="search">
      <div class="search__item">
        <label class="search__item-label">Heading</label>
        <select v-model="headingCategory" class="search__item-select" name="" id="">
      <option :value="item" v-for="item in categories">{{item}}</option>
    </select>
      </div>
      <div class="search__item">
        <label class="search__item-label">Body</label>
        <select v-model="bodyCategory" class="search__item-select" name="" id="">
      <option :value="item" v-for="item in categories">{{item}}</option>
    </select>

      </div>
      <button class="search__item-btn" @click="generate()">
       Generate</button>
    </div>
    <div class="details" v-if="ready">
      <div class="detail">
        <h2 class="detail__title">Heading font</h2>
        <a class="detail__font-family" target="_blank" :href="headingFontUrl" :style=`font-family:${this.headingFont.family}` >{{this.headingFont.family}}</a>
        <p class="detail__subtitle">Import</p>
        <textarea disabled class="detail__code">@import url('https://fonts.googleapis.com/css?family={{this.headingFont.family.replace(/ /g, "+")}}');</textarea>

        <p class="detail__subtitle">Standart</p>
        <textarea disabled class="detail__code"><link href="https://fonts.googleapis.com/css?family={{this.headingFont.family.replace(/ /g, "+")}}" rel="stylesheet"></textarea>
      </div>
      <div class="detail">
        <h2 class="detail__title">Body font</h2>
        <a class="detail__font-family" target="_blank" :style=`font-family:${this.bodyFont.family}` :href="bodyFontUrl">{{this.bodyFont.family}}</a>
        <p class="detail__subtitle">Import</p>
        <textarea disabled class="detail__code">@import url('https://fonts.googleapis.com/css?family={{this.bodyFont.family.replace(/ /g, "+")}}');</textarea>

        <p class="detail__subtitle">Standart</p>
        <textarea disabled class="detail__code"><link href="https://fonts.googleapis.com/css?family={{this.bodyFont.family.replace(/ /g, "+")}}" rel="stylesheet"></textarea>
      </div>
    </div>
  </div>
  <div class="demo" v-if="ready">
    <div class="font-size-settings">
       <p>Heading <button @click="headingFontSize++">+</button> <button @click="headingFontSize--">-</button></p>
      <p>Body <button @click="bodyFontSize++">+</button> <button @click="bodyFontSize--">-</button></p>
       <button class="change-theme" @click="changeBackground()">Toggle Background</button> 
    </div>
    <h2 class="demo__title text" :style=`font-family:${headingFont.family};font-size:${headingFontSize}px`>Flexitarian readymade semiotics knausgaard</h2>
    <div class="demo__content" :style=`font-family:${bodyFont.family};font-size:${bodyFontSize}px`>
      <p class="text">Tbh hoodie man braid mumblecore copper mug. Squid forage truffaut, mustache seitan beard gastropub irony bicycle rights. Dreamcatcher enamel pin bitters shabby chic 3 wolf moon. Salvia flexitarian cronut, single-origin coffee pinterest authentic
        messenger bag meh church-key snackwave thundercats. Shoreditch squid bespoke, roof party echo park vegan authentic chartreuse. Brunch meggings drinking vinegar, pork belly unicorn fingerstache kogi scenester gochujang semiotics. Pitchfork truffaut
        quinoa celiac</p>
      <p class="text">Gochujang wolf tumeric, woke chartreuse gastropub lo-fi dreamcatcher cronut paleo shabby chic. Jean shorts paleo prism deep v disrupt roof party. Plaid kogi hoodie quinoa pickled. Small batch bushwick thundercats raw denim. Cliche quinoa pitchfork,
        typewriter brunch deep v activated charcoal lyft schlitz farm-to-table poke prism yuccie salvia fap. Flexitarian readymade semiotics knausgaard offal gentrify meh, kale chips PBR&B stumptown. Aesthetic leggings kombucha, jean shorts raw denim
        keytar man braid stumptown schlitz lomo yuccie green juice.</p>
      <p class="text">Bicycle rights hot chicken godard semiotics, humblebrag blog irony. Biodiesel chicharrones pitchfork hella, hot chicken butcher brunch craft beer irony single-origin coffee seitan yuccie lyft.</p>
      <p class="text">La croix kombucha small batch tote bag vape, tilde hoodie health goth. Small batch tousled tofu seitan, hexagon single-origin coffee humblebrag organic church-key offal trust fund pop-up. Poutine tbh ennui af, occupy tote bag everyday carry salvia.
        Plaid shabby chic art party you probably haven't heard of them gluten-free jianbing, seitan hoodie food truck skateboard flexitarian microdosing kogi brunch lomo. +1 direct trade kinfolk pinterest put a bird on it.</p>
      <p class="text">Deep v small batch semiotics tousled, chia kinfolk hammock art party. Man braid thundercats leggings gastropub, pok pok ramps hashtag pug mumblecore fanny pack beard literally godard church-key single-origin coffee. Literally pabst man braid pitchfork
        swag, ethical bespoke tofu narwhal street art shoreditch. Irony shoreditch roof party PBR&B umami, ramps affogato bicycle rights ethical brunch vape. Pinterest activated charcoal butcher brunch. Aesthetic flannel keffiyeh direct trade bicycle
        rights quinoa. Photo booth af skateboard locavore squid hella.</p>
    </div>

  </div>
  <div class="error" v-if="!ready">Daily API limit exceeded, please check later.</div>
</div>
            
          
!
            
              .search__item {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  &-select {
    height: 40px;
    max-height: 40px;
    padding: 0 5px;
    background:transparent;
    text-transform: capitalize;
    border: 2px solid #ddd;
    font-family: Montserrat;
    outline: none;
  }
  &-label {
    font-family: Montserrat;
    font-size: 13px;
    margin-bottom: 5px;
  }
  &-btn {
    background: #000;
    outline: none;
    padding: 10px;
    border: none;
    color: #fff;
    font-family: Montserrat;
    font-size: 14px;
    cursor: pointer;
  }
}

.sidebar {
  width: 30%;
  padding: 50px;
  box-sizing: border-box;
}

#app {
  display: flex;
  flex-wrap: wrap;
 
}

.demo {
  width: 70%;
  padding:30px 50px;
  box-sizing: border-box;
  margin: 0 auto;
  line-height: 1.5;
  &__title {
    font-size: 38px;
    display: inline-block;
    margin-bottom: 30px;
  }
  p {
    margin-bottom: 30px;
  }
}

.details {
  background: #eee;
  padding: 20px;
  box-sizing: border-box;
  margin-top: 20px;
}

.detail {
  font-family: Montserrat;
  &:last-child {
    margin-bottom: 0;
  }
  &:last-child {
    margin-bottom: 0;
  }
  &__title {
    font-size: 13px;
    margin-bottom: 5px;
    color: rgba(0, 0, 0, .5);
  }
  &__font-family {
    display: block;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 16px;
    color: #000;
  }
  &__subtitle {
    font-size: 12px;
    margin-bottom: 5px;
  }
  &__code {
    width: 100%;
    resize: none;
    border: none;
    padding: 10px;
    box-sizing: border-box;
    background: #ddd;
    margin-bottom: 15px;
    font-family: Montserrat;
    font-size: 13px;
    min-height: 70px;
  }
}



.font-size-settings{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
  font-family:Montserrat;
  font-size:12px;
  margin-bottom: 15px;
  p{
    margin-left: 20px;
    margin-bottom: 0;
  }
  button{
    margin-left: 4px;
    border:none;
    background:#ddd;
    width:24px;
    height:24px;
    font-size:18px;
   
    font-weight: bold;
    font-family:Montserrat;
    outline:none;
    cursor:pointer;
  }
  .change-theme{
      width:auto;
    font-size:12px;
    margin-left: 15px;
    background:#000;
    color:#fff;
    font-weight: normal;
    }
}

@media screen and (max-width: 768px) {
  #app{
    flex-direction:column;
  }
  .sidebar,.demo{
    width:100%;
  }
}

.dark-background{
  color:#fff;
  background:#000;
  .search__item{
    &-select{
      color:#fff;
      border-color:#333;
      option{
        color:#000;
      }
    }
    &-btn{
      color:#000;
      background:#fff;
    }
  }
  .details{
    background:#333;
  }
  .detail{
    &__title{
      color:rgba(255,255,255,.2);
    }
    &__font-family{
      color:#fff;
    }
    &__code{
      background:#222;
      color:rgba(255,255,255,.4);
    }
  }
  .font-size-settings{
    button{
      background:#333;
      color:#fff;
    }
    .change-theme{
      background:#fff;
      color:#000;
    }
  }
}

.error{
  width:100%;
  height:100%;
   position: fixed;
  left: 0;
  top: 0;
  width:100%;
  height:100%;
  font-size:32px;
  display:flex;
  align-items:center;
  font-family:Montserrat;
  justify-content:center;
}
            
          
!
            
              const app = new Vue({
  el: "#app",
  data() {
    return { 
      fonts: null,
      ready: null,
      categories: [],
      headingCategory: null,
      headingFont: null,
      bodyCategory: null,
      headingStandart: null,
      headingImport: null,
      headingFontUrl: null,
      bodyStandart: null,
      bodyImport: null,
      bodyFont: null,
      bodyFontUrl: null,
      bodyFontSize: 18,
      headingFontSize: 32,
      darkBackground:false
    }; 
  },
  created() {
    this.$http
      .get(
        "https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBjnzN-_nm1saTaG_pXEDx3TFlSAXESdt8"
      )
      .then(
        response => {
          this.ready = true;
          this.fonts = response.body.items;
          this.allCategories();
          this.generate();
        },
        response => {
           this.ready = false;
        }
      );
  },
  methods: {
    allCategories() {
      this.fonts
        .filter(
          (category, index, self) =>
            self.findIndex(t => {
              return t.category === category.category;
            }) === index
        )
        .map(obj => {
          this.categories.push(obj["category"]);
        });
      this.headingCategory = this.categories[0];
      this.bodyCategory = this.categories[1];
    },
    fontFilter(category) {
      let tempFonts = [], font;
      this.fonts
        .filter(item => {
          return item.category == category;
        })
        .map(obj => {
          tempFonts.push(obj);
        });
      font = tempFonts[Math.floor(Math.random() * (tempFonts.length - 1) + 1)];
      return font;
    },
    generate() {
      this.headingFont = this.fontFilter(this.headingCategory);
      this.bodyFont = this.fontFilter(this.bodyCategory);
      const combinedFont = document.head.querySelector("#combined-font");
      const googleUrl = "https://fonts.google.com/specimen/";
      this.headingFontUrl =
        googleUrl + this.headingFont.family.replace(/ /g, "+");
      this.bodyFontUrl = googleUrl + this.bodyFont.family.replace(/ /g, "+");
      if (combinedFont == null) {
        const link = document.createElement("link");
        link.id = "combined-font";
        link.href = `https://fonts.googleapis.com/css?family=${this.headingFont.family.replace(/ /g, "+")}|${this.bodyFont.family.replace(/ /g, "+")}`;
        link.rel = "stylesheet";
        document.head.appendChild(link);
      } else {
        combinedFont.href = `https://fonts.googleapis.com/css?family=${this.headingFont.family.replace(/ /g, "+")}|${this.bodyFont.family.replace(/ /g, "+")}`;
      }
    },
   changeBackground(){
      this.darkBackground ? this.darkBackground = false : this.darkBackground = true;
    }
  },
  watch:{
    bodyFontSize(val){
       val==11 ? this.bodyFontSize = 12 : false
    },
     headingFontSize(val){
      val==11 ? this.headingFontSize = 12 : false
    }
  }
});

            
          
!
999px
🕑 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.
Loading ..................

Console