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.

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

            
                <ul id="todo_widget">
    <li class="header">
      <img src='https://vuejs.org/images/logo.png' class='logo'/>
      <h2 class="title">My to do list</h2></li>
    <li class="add_reset_section new_item">
      <input ref="newItem" placeholder="Add a new task..." />
    </li>
    <li class="button add"><button v-on:click="_handleAddItem">Add</button></li>
    <li class="button reset"><button v-on:click="_handleResetList">Reset</button></li>
    <li class="todo_item" v-for="(item, index) in list" :key="index">
      <input
        v-if="
          doneList.filter(function(val) {
            return val === index;
          }).length === 0 ||
            doneList.filter(function(val) {
              return val === index;
            }).length === undefined
        "
        class="checkbox"
        type="checkbox"
        :id="index"
        ref='cb'
        v-on:click="_handleCheckBoxClick"
      />
      <input
        v-else
        class="checkbox"
        type="checkbox"
        :checked="true"
        :id="index"
        ref='cb'
        v-on:click="_handleCheckBoxClick"
      />

      <strike>{{ item }}</strike>
    </li>

    <li class="footer">
      <button class="remove" v-on:click="_handleRemoveDoneItems">Remove</button>
    </li>
  </ul>
            
          
!

CSS

            
              #todo_widget {
  font-family: sans-serif;
  text-align: center;
  font-size: 1.5em;
}

ul#todo_widget {
  padding: 0;
  margin: 0;
  list-style: none;
  height: 200px;

  -ms-box-orient: horizontal;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-flex;
  display: flex;

  -webkit-justify-content: space-around;
  justify-content: space-around;
  -webkit-flex-flow: row wrap;
  flex-flow: row wrap;
  -webkit-align-items: stretch;
  align-items: stretch;
}

.header,
.footer,
.todo_item {
  flex: 1 100%;
}
.button {
  flex: 1;
}
.new_item {
  flex: 9;
}

#todo_widget li {
  /*background: tomato;*/
  padding: 10px;
  width: 500px;
  // border: 3px solid rgba(0, 0, 0, 0.2);

  /*color: white;*/
  font-weight: bold;
  font-size: 0.8em;
  text-align: right;
}

#todo_widget li.header,#todo_widget li.footer {
  text-align: center;
}

button {
  color: #fff;
  text-transform: uppercase;
  background: #ed3330;
  padding: 0.5vw;
  border-radius: 5px;
  display: inline-block;
  border: none;
  height: 100%;
}
button.remove {
  background-color: green;
  padding: 0.1em;
  height: ;
}

#todo_widget li.new_item input {
  width: 100%;
  height: 100%;
}
#todo_widget li.todo_item {
  font-size: 1.1em;
  line-height: 1.2em;
  display: flex;
  align-items: center;
}

#todo_widget .checkbox {
    height: 1em;
    width: 1em;
    color: green;
    margin-right: 0.2em; 
  }
 
 strike {
  text-decoration: none;
}

input:checked + strike {
  text-decoration: line-through;
  opacity: 0.5;
}

.logo {height:3em;width:auto}


            
          
!

JS

            
              var app = new Vue({
  el: '#todo_widget',
  name: "ToDoApp",
  data() {
    return {
      list: ["Get up in the morning", "Brush my teeth"],
      doneList: []
    };
  },
  computed: {
    // Computed stuff goes here
  },
  methods: {
     init() {
       this.resetList=[...this.list];
       this.resetDoneList=[...this.doneList];
     },
    _handleAddItem() {
      var newItem = this.$refs.newItem;
      if (newItem.value === "") return;
      this.list.push(newItem.value);
      console.log(this.$refs.newItem.value);
      newItem.value = ""
    },
    _handleCheckBoxClick(e) {
      console.log(e.target.checked);
      let checkIfInDoneList = this.doneList.filter(function(val) {
        return val === parseInt(e.target.id);
      });

      if (checkIfInDoneList === undefined || checkIfInDoneList.length === 0) {
        // add to list
        this.doneList.push(parseInt(e.target.id));
        e.target.checked = true;
      } else {
        //delete from list
        let i = this.doneList.indexOf(parseInt(e.target.id));
        this.doneList.splice(i, 1);
        e.target.value = false;
      }
      console.log("donelist afterremove-->");
      console.log(this.doneList);
    },
    _handleRemoveDoneItems(e) {
      this.doneList.sort((a, b) => a - b);
      console.log(this.doneList);
      for (var i = this.doneList.length - 1; i >= 0; i--)
        this.list.splice(this.doneList[i], 1);

      console.log(this.list);
      this.doneList = [];
    },
     _handleResetList() {
      //  let newItem =this.refs.newItem.value;
      console.log("\n ***Reset Button Pressed... **");
    

      
      this.donelist=[...this.resetDoneList];
      this.list=[...this.resetList];
        console.log(
        "Reset handler will reset list to default values..." +
          JSON.stringify(this.donelist)
      );
        
       // To Do : reset done check boxes 
       // this.doneList.forEach(function(value,index) {
       //   this.refs.cb[index]=true;
       // });


    }

  },
  mounted(){
    this.init()
  }
});
            
          
!
999px

Console