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 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.

HTML

              
                <div id="app">
  <travel-log />
</div>
              
            
!

CSS

              
                // constanta
$text-color: black

html, body
  height: 100%
  
body
  background: #f5f5f5
  display: flex
  justify-content: center
  align-items: center
  font-family: Helvetica Neue
  font-size: 10px
  color: $text-color
  
.travel-log
  display: flex
  flex-direction: column
  &__content
    display: flex
    flex-direction: row
  &__selected
    display: flex
    align-items: center
    justify-content: center
    width: 15rem
    padding: 1rem
    border: 1px solid $text-color
    border-radius: .5rem
    margin-right: 1rem
    &--none
      font-style: italic
      font-size: 1.2rem
  &__cities
    display: flex
    flex-direction: column
    justify-content: center
    &--single
      display: flex
      align-items: center
      justify-content: space-between
      &:not(:first-of-type)
        margin-top: .5rem
      h2
        margin-right: 1rem
        font-size: 1.5rem
        cursor: pointer
        &.selected
          color: #47c97e
      &-visit
        width: 1rem
        height: 1rem
        border: 2px solid #4189f3
        border-radius: 50%
        cursor: pointer
        &.visited
          background: #4189f3
  &__alert
    display: flex
    align-items: center
    justify-content: center
    height: 2rem
    margin-bottom: .5rem
    background: #4189f3
    transition: opacity .5s ease-in
    span
      color: white
      font-size: .8rem
          
.city
  display: flex
  flex-direction: column
  justify-content: center
  align-items: center
  &__icon
    width: 8rem
    height: 9rem
    margin-bottom: 1rem
  &__info
    &--bit
      &:not(:first-of-type)
        margin-top: .5rem
      span
        font-size: 1rem
        &:first-of-type
          font-weight: bold
          margin-right: .2rem
        
    
  
              
            
!

JS

              
                const cities = [
  {
    id: '1',
    name: 'France',
    language: 'French',
    currency: 'Euro (€)',
    population: '66,991,000',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/paris.png'
  },
  {
    id: '2',
    name: 'Russia',
    language: 'Russian',
    currency: 'Russian Ruble (₽)',
    population: '144,463,451',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/moscow.png'
  },
  {
    id: '3',
    name: 'England',
    language: 'English',
    currency: 'Pound (£)',
    population: '54,786,300',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/london.png'
  },
  {
    id: '4',
    name: 'Argentina',
    language: 'Spanish',
    currency: 'Peso ($)',
    population: '43,417,000',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/buenos_aires.png'
  },
  {
    id: '5',
    name: 'Turkey',
    language: 'Turkish',
    currency: 'Turkish Lira (₺)',
    population: '79,814,87',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/istanbul.png'
  },
  {
    id: '6',
    name: 'New York',
    language: 'English',
    currency: 'US Dollar ($)',
    population: '8,175,133',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/new_york.png'
  },
  {
    id: '7',
    name: 'Brazil',
    language: 'Portuguese',
    currency: 'Real (R$)',
    population: '207,350,000',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/rio.png'
  },
  {
    id: '8',
    name: 'Seattle',
    language: 'English',
    currency: 'US Dollar ($)',
    population: '704,352',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/seattle.png'
  },
  {
    id: '9',
    name: 'Washington DC',
    language: 'English',
    currency: 'US Dollar ($)',
    population: '681,170',
    icon: 'https://raw.githubusercontent.com/jakepeyser/vue-mobx/master/icons/washington.png'
  }
]

Vue.component('travel-log', {
  template: `
  <div class="travel-log">
    <div class="travel-log__alert" :style="{ opacity: alert ? 1 : 0 }">
      <span>Travel log updated!</span>
    </div>
    <div class="travel-log__content">
      <div class="travel-log__selected">
        <div class="city" v-if="selectedCity">
          <img class="city__icon" :src="selectedCity.icon" />
          <ul class="city__info">
            <div class="city__info--bit"><span>Name:</span><span>{{selectedCity.name}}</span></div>
            <div class="city__info--bit"><span>Language:</span><span>{{selectedCity.language}}</span></div>
            <div class="city__info--bit"><span>Currency:</span><span>{{selectedCity.currency}}</span></div>
            <div class="city__info--bit"><span>Population:</span><span>{{selectedCity.population}}</span></div>
          </ul>
        </div>
        <span v-else class="travel-log__selected--none">Please select a city</span>
      </div>
      <ul class="travel-log__cities">
        <div class="travel-log__cities--single" v-for="city in sortedCities" key="city.id">
          <h2 :class="{ selected: city.id === selectedCityId }" @click="selectCity(city.id)">{{city.name}}</h2>
          <div :class="{ 'travel-log__cities--single-visit': true, visited: visited[city.id] }" @click="toggleCity(city.id)" />
        </div>
      </ul>
    </div>
  </div>
`,
 
  data: function() {
    return {
      cities: cities,
      selectedCityId: null,
      visited: {},
      alert: false,
      clearAlert: null
    }
  },

  computed: {
    selectedCity() {
      return this.cities.find(city => city.id === this.selectedCityId);
    },
    sortedCities() {
      return this.cities.sort((a, b) => a.name > b.name ? 1 : -1);
    }
  },
  
  watch: {
    visited() {
      if (this.clearAlert) {
        clearTimeout(this.clearAlert);
      }

      this.clearAlert = setTimeout(() => {
        this.alert = false;
      }, 3000);
      this.alert = true;
    }
  },
  
  methods: {
    
    selectCity(cityId) {
      this.selectedCityId = cityId;
    },
    
    toggleCity(cityId) {
      if (this.visited[cityId]) {
        const { [cityId]: city, ...rest } = this.visited;
        this.visited = rest;
      } else {
        this.visited = { ...this.visited, [cityId]: true };
      }
    }
  }
});

new Vue({
  el: '#app'
});

              
            
!
999px

Console