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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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="app">
        <h1>Vue To-Do List</h1>
        <div class="app">
            <section class="new-task" id="new-task">
                <input type="checkbox" name="check-all" id="check-all" :checked="areAllChecked" @click="checkAll">
                <input type="text" name="new-input" id="new-input" placeholder="What do you need to do?" autofocus v-model="newTask" @keyup.enter="addTask">
            </section>
            <ul class="list" v-if="loaded">
                <li  v-for="task in activeList" :key="task.id">
                    <input type="checkbox" v-model="task.checked" :id="'check-'+task.id" class="check">
                    <input type="checkbox" v-model="task.starred" :id="'star-'+task.id" class="star">
                    <label :for="'task-'+task.id" :class="{checked: task.checked, starred: task.starred}">{{ task.text }}</label>
                    <button class="delete" @click="removeTask(task)"><i class="fa fa-times" aria-hidden="true"></i></button>
                </li>
            </ul>
            <ul class="foot-buttons">
                <li>
                    <button @click="removeChecked">Clear Completed</button>
                </li>
                <li>
                    <button @click="activeList = taskList" :class="{active: queryList(taskList)}">All tasks</button>
                </li>
                <li>
                    <button @click="activeList = starredList" :class="{active: queryList(starredList)}">Important</button>
                </li>
                <li>
                    <button @click="activeList = uncheckedList" :class="{active: queryList(uncheckedList)}">Active</button>
                </li>
                <li>
                    <button @click="activeList = checkedList" :class="{active: queryList(checkedList)}">Completed</button>
                </li>
            </ul>
        </div>
        <p class="counter" v-if="loaded">{{ checkCount }} / {{ taskCount }} Tasks Completed</p>
    </div>
              
            
!

CSS

              
                *,*::before,*::after {
    box-sizing: border-box;
}

html {
    font-size: 20px;
    font-family: "Montserrat", sans-serif;
}

body {
    display: flex;
    color: #333;
    margin: 0;
    padding: 0;
    height: 100vh;
    background-image: linear-gradient(to bottom right, #e86, #86e);
    background-attachment: fixed;
}

[v-cloak] {
  display: none;
}

.container {
    margin: auto;
    padding: 1rem; 
    width: 100%;
    max-width: 640px;
}

.app {
    background: #f8f8f8;
    border-radius: 4px;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #fff;
    font-weight: 300;
    font-size: 2rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

p {
    color: #fff;
    font-weight: 300;
    text-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.new-task {
    padding: .75rem;
    background: #eee;
    border-radius: 4px 4px 0 0;
}

input[type=text] {
    font-size: 1rem;
    font-family: inherit;
    line-height: 2;
    padding: 0 0.5em;
    background: #fff;
    border: 1px solid #ddd;
    width: calc(100% - 2rem);
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list li {
    padding: .75em;
    position: relative;
    border-bottom: 1px solid #ddd;
}

.list li i {
    font-size: 1.2rem;
}

.list li button {
    opacity: 0;
    color: #888;
    cursor: pointer;
    background: none;
    padding: 0;
    border: none;
    outline: none;
    visibility: hidden;
    transition: 300ms ease;

    position: absolute;
    right: 1rem;
}

.list li:hover button {
    opacity: 1;
    visibility: visible;
}

li input[type=text] {
    display: none;
}

li label {
    position: relative;
    transition: 450ms ease;
}

li label::after {
    content: "";
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: #aaa;
    top: calc(60% - 1px);
    left: 0;
    transform: scaleX(0);
    transform-origin: 0 0;
    transition: 450ms ease;
}

.starred {
    color: #d12;
}

.checked {
    color: #aaa;
}

.checked::after {
    transform: scaleX(1);
}

.foot-buttons {
    list-style: none;
    margin: 0;
    padding: .5rem;
    text-align: center;
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

.foot-buttons button {
    cursor: pointer;
    background: transparent;
    color: #888;
    border: none;
    display: inline-block;
    padding: .5em;
    font-size: .7rem;
    border-radius: 3px;
    outline: none;
    transition: 150ms ease;
}

.foot-buttons button.active {
    color: #333;
    background: #eee;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.counter {
    text-align: center;
}

.star {
  
}
              
            
!

JS

              
                //Create a new Vue instance
var app = new Vue({

    //Bind Vue instance to #app element
    el: "#app",

    //Register data for instance
    data: {
        newTask: "",
        //A counter is used to ensure strikeout animations aren't repeated unnecessarily
        counter: 7,
        //Example values
        taskList: [
            {
                text: "Buy christmas presents",
                checked: false,
                starred: true,
                id: 1
            },
            {
                text: "Send invoice",
                checked: false,
                starred: true,
                id: 2
            },
            {
                text: "Do homework",
                checked: true,
                starred: false,
                id: 3
            },
            {
                text: "Go shopping",
                checked: false,
                starred: false,
                id: 4
            },
            {
                text: "Make To-do List",
                checked: true,
                starred: true,
                id: 5
            }
        ],
        activeList: [],
        loaded: false
    },

    //Derived data
    computed: {
        taskCount: function () {
            return this.taskList.length;
        },
        checkCount: function () {
            return this.checkedList.length
        },
        areAllChecked: function() {
            //Check if every checked property returns true and if there is at least one to-do item
            return this.taskList.every(function(task) {
                return task.checked;
            }) && this.taskList.length > 0;
        },
        checkedList: function () {
            return this.taskList.filter(function (self) {
                return self.checked;
            })
        },
        uncheckedList: function () {
            return this.taskList.filter(function (self) {
                return !self.checked;
            })
        },
        starredList: function () {
            return this.taskList.filter(function (self) {
                return self.starred;
            })
        }
        
    },

    //This is where we will hold the methods we want to use in our application
    methods: {
        queryList: function (list) {
            return this.activeList === list;
        },
        addTask: function () {
            //Remove whitespace from start and end
            var task = this.newTask.trim();

            if (task) {
                //Add new a task to the start of the task list
                this.taskList.push({
                    text: task,
                    checked: false,
                    id: this.counter
                });
                this.counter++;
            }

            this.newTask = "";
        },
        removeTask: function (task) {
            var index = this.taskList.indexOf(task); 
            this.taskList.splice(index, 1);
        },

        removeChecked: function () {
            this.taskList = this.taskList.filter(function (self) {
                return self.checked === false;
            })
            this.activeList = this.taskList;
        },

        checkAll: function(task) {
            //targetValue is set to the opposite of areAllSelected
            var targetValue = this.areAllChecked ? false : true;
            //we use a for loop to set the checked state of all items to the target value
            for (var i = 0; i < this.taskList.length; i++) {
                this.taskList[i].checked = targetValue;
            }
        },

        clearList: function() {
            //Setting taskList to an empty array clears the whole list
            this.taskList = [];
        }
    }
});

app.activeList = app.taskList;
app.loaded = true;
              
            
!
999px

Console