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="container" id="view-root">
  <h1 v-show="!fullscreen">Time</h1>
  <h2 v-show="!fullscreen">A Timeline Creator</h2>
  <div class="menu-list">
    <template v-if="!fullscreen">
        <a class="menu-item" href="#" @click.prevent="saveData">save</a>
        <a class="menu-item" href="#" @click.prevent="loadData">load</a>
        <a class="menu-item" href="#" @click.prevent="clearData">new</a>
    </template>
        <a class="menu-item" href="#" @click.prevent="handleFullscreen" v-show="!fullscreen">fullscreen</a>  
        <a class="menu-item" href="#" @click.prevent="handleCloseFullscreen" v-show="fullscreen">minimize</a>
  </div>
  <template v-if="!fullscreen">
  <input-form @submit="pushTimeline"></input-form>
  </template>
  <timeline-list :timelines="timelines">
  </timeline-list>  
</div>

<template id="timeline-item-template">
    <li class="timeline-item">
      <div class="circle" :class="{'bounceIn animated': animated}"></div>
      <div class="time">{{time}}</div>
      <div class="name">{{name}}</div>
      <div class="description">{{description}}</div>
    </li>  
</template>

<template id="timeline-list-template">
  <ul class="timeline-list">
    <div class="h-line"></div>

    <template v-for="node in timelines">
      <timeline-item @click.prevent="setActive"
                     :name="node.name" 
                     :time="node.time" 
                     :description="node.description">
      </timeline-item>
    </template>
    <!-- active on form -->
    <timeline-item v-if="active.name !== ''" :name="active.name" :time="active.time" :description="active.description"></timeline-item>
  </ul>
</template>

<template id="input-form-template">
  <form action="" class="timeline-form">
    <p style="text-align: center; margin-top: 1em;">Create Node</p>
    <label for="time">Time</label>
    <input type="date" id="time" v-model.trim="time">  
    <label for="name">Name</label>
    <input type="text" id="name" v-model.trim="name">
    <label for="description">Description</label>
    <textarea v-model.trim="description" @keyup.enter="handleSubmit"></textarea>
    <br>
    <input type="submit" value="create" @click.prevent="handleSubmit">
<!--     <div class="circle-create"></div> -->
  </form>
  </template>
              
            
!

CSS

              
                body {
  background: linear-gradient(180deg, #e3d9ca 62%, #95a792);
  color: #403f48;
  font-family: 'Rubik', sans-serif;
  font-size: 1em;
  line-height: 1.618;
}
a {
  color: #2b3595;
}
.container {
  display: flex;
  flex-flow: column wrap;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 100vh;
  width: 100%;
}
.menu-list {
  position: fixed;
  display: flex;
  justify-content: center;
  top: 0;
  width: 100%;
  background: linear-gradient(0deg, #4f323b, #6e5773);
  border-bottom: 2px solid white;
}
.menu-item {
  color: #e9e2d0;
  height: 100%;
  padding: 1em;
  text-shadow: 0 3px 3px rgba(0, 0, 0, .62);
  &:hover {
    text-decoration: none;
    color: #ea9085;
    background: #4f323b;
    text-shadow: 0 3px 3px rgba(0, 0, 0, .16);
  }
}

.timeline-form {
  display: flex;
  width: 38%;
  margin: 2em auto;
  flex-direction: column;
  justify-content: center;
}
.circle-create {
    display: inline-block;
    width: 3em;
    height: 3em;
    background: green;
    border-radius: 50%;
    margin: 3em auto;
    border: 3px dotted white;
    animation: infiniteRotation 3.82s infinite linear;
}
@keyframes infiniteRotation {
  to {
    transform: rotateZ(360deg);
  }
}

/* timeline */
.timeline-list {
  position: relative;
  display: block;
  margin: 1em 0;
  padding: 0;
  // width: 100%;
  display: flex;
  flex-flow: row unwrap;
  justify-content: center;
}
.timeline-item {
  list-style-type: none;
  display: flex;
  flex-flow: column wrap;
  justify-content: flex-start;
  align-items: center;
  margin-right: 2em;
  position: relative;
  > .time {
  }
  > .circle {
    display: block;
    position: relative;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #eee;
    z-index: 100;
    top: -1em;
  }
  > .name {
    
  }
  > .description {
    display: none;
  }

  &:before {
    
      
  }
}

.h-line {
  display: block;
  position: absolute;
  top: 5%;
  height: 3px;
  width: 100%;
  background-color: #eee;
  z-index: -100;
}


/** form **/
input, textarea {
  border: none;
  background-color: transparent; // rgba(255, 255, 255, .16);
  border-bottom: 2px solid white;
  
  font-size: 1.618em;
  line-height: 1.2em;  
  font-family: "Rubik", sans-serif;
  &:focus {
    outline: none;
  }
}
label {
  margin-top: 1em;
  text-align: center;
}
input[type="submit"] {
  --btn-main-color: #95a792;
  --btn-2nd-color: #596c68;
  --btn-color: #ffffff;
  border: none;
  background: linear-gradient(0deg, var(--btn-2nd-color), var(--btn-main-color) 62%);
  border: 1px solid var(--btn-2nd-color);
  border-radius: 1em;
  color: var(--btn-color);
  line-height: 1.618em;
  box-shadow: 0 .1618em 0px rgba(0, 0, 0, .16);
  transition: all .3s ease;
  text-shadow: 0 4px 0px rgba(0, 0, 0, .38);
  &:hover {
    background: linear-gradient(0deg, var(--btn-2nd-color), var(--btn-main-color) 83%);
    transform: translate(0, 1px);
    cursor: pointer;
    box-shadow: 0 .0618em 0px rgba(0, 0, 0, .38);
    text-shadow: 0 1px 0px rgba(0, 0, 0, .62);
  }
  &:focus {
    outline: none;
  }
  &:active {
    box-shadow: none;
    text-shadow: none;
    transition: none;
  }
}

@media (max-width: 860px) {
  .timeline-form {
    width: 62%;
  }
}
@media (min-width: 480px) and (max-width: 640px) {
  .timeline-form {
    width: 83%;
  }
}
              
            
!

JS

              
                /* Get the documentElement (<html>) to display the page in fullscreen */
var elem = document.documentElement;

/* View in fullscreen */
function openFullscreen() {
  if (elem.requestFullscreen) {
    elem.requestFullscreen();
  } else if (elem.mozRequestFullScreen) { /* Firefox */
    elem.mozRequestFullScreen();
  } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
    elem.webkitRequestFullscreen();
  } else if (elem.msRequestFullscreen) { /* IE/Edge */
    elem.msRequestFullscreen();
  }
}

/* Close fullscreen */
function closeFullscreen() {
  if (document.exitFullscreen) {
    document.exitFullscreen();
  } else if (document.mozCancelFullScreen) { /* Firefox */
    document.mozCancelFullScreen();
  } else if (document.webkitExitFullscreen) { /* Chrome, Safari and Opera */
    document.webkitExitFullscreen();
  } else if (document.msExitFullscreen) { /* IE/Edge */
    document.msExitFullscreen();
  }
}

const timelineItem = {
  template: "#timeline-item-template",
  props: ["name", "time", "description"],
  data() {
     return {
       animated: false
     }
  },
  created() {
    this.animated = true;
    setTimeout(function () {
      this.animated = false;
    }.bind(this), 1000);
  },
  methods: {
    setActive() {
      this.$store.commit('SET_ACTIVE', {
        name: this.name,
        time: this.time,
        description: this.description
      });
    }
  }
};

const timelineList = {
  template: "#timeline-list-template",
  props: ["timelines"],
  components: {
    "timeline-item": timelineItem
  },
  computed: {
    active() {
      return this.$store.state.active;
    }
  }
};

const inputForm = {
  template: "#input-form-template",
  computed: {
    name: {
      get () {
        return this.$store.state.active.name;
      },
      set(value) {
        this.$store.commit('UPDATE_NAME', value);
      }
    },
    time: {
      get () {
        return this.$store.state.active.time;        
      },
      set (value) {
        this.$store.commit('UPDATE_TIME', value);
      }      
    },
    description: {
      get () {
        return this.$store.state.active.description;
      },
      set (value) {
        this.$store.commit('UPDATE_DESCRIPTION', value);
      }
    }
  },
  methods: {
    handleSubmit(e) {
      e.preventDefault();
      this.$emit("submit");
      this.resetForm();
    },
    resetForm() {
      this.$store.commit('RESET_FORM');
    }
  }
};

const store = new Vuex.Store({
  state: {
    active: {
      name: '',
      time: '',
      description: ''
    }
  },
  mutations: {
    RESET_FORM(state) {
      for (let key in state.active) {
        state.active[key] = '';
      }
    },
    UPDATE_NAME(state, value) {
      state.active.name = value;
    },
    UPDATE_TIME(state, value) {
      state.active.time = value;      
    },
    UPDATE_DESCRIPTION(state, value) {
      state.active.description = value;
    },
    SET_ACTIVE(state, objVal) {
      ({ 
        name: state.active.name,
        time: state.active.time,
        description: state.active.description
      } = objVal);
    }
  }
  
});

const viewRoot = new Vue({
  el: "#view-root",
  data: {
    timelines: [],
    fullscreen: false
  },
  store,
  computed: {
    active() {
      return this.$store.state.active;
    }
  },
  components: {
    "input-form": inputForm,
    "timeline-list": timelineList
  },  
  created() {
    if (localStorage['timelines']) {     
      this.loadData();
    }
  },
  methods: {
    pushTimeline() {
      let timeline = Object.create(null);
      timeline.name = this.active.name;
      timeline.time = this.active.time;
      timeline.description = this.active.description;
      if (!timeline.name) {
        return;
      }
      this.timelines.push(timeline);
      if (!this.timelines[timeline.time]) {
        this.timelines[timeline.time] = Object.create(null);        
      }
      this.timelines[timeline.time] = this.active;
      console.log(this.timelines);
    },
    handleFullscreen() {
      openFullscreen();
      this.toggleScreen();
    },
    handleCloseFullscreen() {
      closeFullscreen();
      this.toggleScreen();
    },
    toggleScreen() {
      this.fullscreen = !this.fullscreen;
    },
    loadData() {
      let objTimelines = localStorage.getItem('timelines');
      objTimelines = JSON.parse(objTimelines);
      this.timelines = toArr(objTimelines, 'time');
    },
    saveData() {
      let newObjTimelines = toObj(this.timelines, 'time');
      newObjTimelines = JSON.stringify(newObjTimelines);
      localStorage.setItem('timelines', newObjTimelines);
    },
    clearData() {
      this.timelines = [];
      localStorage.removeItem('timelines');
    }
    
  }
});

/**
 * converting array to object / hash map
 */
function toObj(arr, key) {
  let res = Object.create(null);
  for (let i = 0, y = arr.length; i < y; i++) {
    res[arr[i][key]] = arr[i];
  }
  return res;
}

/**
 * converting obj to array and sort asc by key
 */
function toArr(obj, sortBy) {
  let newArr = [];
  for (let key in obj) {
    newArr.push(obj[key]);
  }
  return newArr.sort();
}
              
            
!
999px

Console