Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--
- This script defines a Vue.js application for creating a to-do list with notes.
- Users can input new tasks and corresponding notes, view the list of tasks with notes, and delete tasks as needed.
- The application is styled using CSS to provide a visually appealing and user-friendly interface.
- The Vue.js framework is utilized for data binding and DOM manipulation, enabling dynamic updates to the task list without page reloads.
- -->
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>TO-DO LIST WITH NOTES</title>
- <!-- Importing Vue.js library -->
- <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
- <style>
- /* Styling for the entire document */
- body {
- font-family: Arial, sans-serif;
- margin: 0;
- padding: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- /* Background gradient */
- background: linear-gradient(-45deg, #000, #000, #191970, #4B0082, #191970, #000, #000);
- }
- /* Styling for the main application container */
- #app {
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
- position: absolute;
- top: 10%;
- left: 10%;
- right: 10%;
- border: 4px solid #000;
- word-wrap: break-word;
- display: flex;
- flex-direction: column;
- }
- /* Styling for headers */
- h1,
- strong,
- span {
- text-align: left;
- margin-bottom: 20px;
- font-weight: bold;
- }
- /* Styling for input fields */
- input[type="text"],
- textarea {
- width: calc(100% - 40px);
- padding: 8px;
- border-radius: 4px;
- border: 1px solid #ccc;
- margin-bottom: 10px;
- resize: vertical;
- }
- /* Styling for the to-do list */
- ul {
- list-style-type: none;
- padding: 0;
- flex-grow: 1;
- overflow-y: auto;
- }
- li {
- display: flex;
- flex-direction: column;
- padding: 8px;
- border-bottom: 1px solid #ccc;
- }
- .task {
- margin-bottom: 5px;
- flex-grow: 1;
- }
- /* Styling for buttons */
- button {
- background-color: #ff6347;
- color: #fff;
- border: none;
- border-radius: 4px;
- padding: 4px 8px;
- cursor: pointer;
- }
- button:hover {
- background-color: #ff473d;
- }
- /* Styling for the submit button */
- .submit-btn {
- align-self: flex-end;
- }
- </style>
- </head>
- <body>
- <!-- Main application container -->
- <div id="app">
- <!-- Header -->
- <h1><strong>TO-DO LIST</strong></h1>
- <!-- Input field for adding a new task -->
- <input type="text" v-model="newTodo.task" placeholder="ADD A NEW TASK & PRESS [ENTER]..." @keyup.enter="focusNotesInput" ref="taskInput">
- <!-- Text area for adding notes -->
- <textarea v-model="newTodo.note" placeholder="ADD NOTES & SELECT [SUBMIT]..." ref="notesInput"></textarea>
- <!-- Displaying the list of to-do items -->
- <ul>
- <li v-for="(todo, index) in todos" :key="index">
- <!-- Displaying the task and a delete button -->
- <div style="display: flex; align-items: center;"> <strong class="task">{{ todo.task }}</strong>
- <button style="margin-left: 10px;" @click="removeTodo(index)">X</button>
- </div>
- <!-- Displaying notes for the task --><strong>Notes:</strong>
- <br>{{ todo.note }} </li>
- </ul>
- <!-- Submit button -->
- <button class="submit-btn" @click="addTodo">[SUBMIT]</button>
- </div>
- <!-- Vue.js script -->
- <script>
- // Vue.js instance
- var app = new Vue({
- el: '#app', // Mounting point
- data: {
- // Data for managing to-do items
- newTodo: {
- task: '',
- note: ''
- }, // New to-do item
- todos: [] // List of to-do items
- },
- methods: {
- // Method to add a new to-do item
- addTodo: function() {
- if(this.newTodo.task !== '') {
- this.todos.push({
- task: this.newTodo.task,
- note: this.newTodo.note
- }); // Add new item to the list
- this.newTodo.task = ''; // Clear task input
- this.newTodo.note = ''; // Clear note input
- this.$refs.taskInput.focus(); // Focus on task input
- }
- },
- // Method to remove a to-do item
- removeTodo: function(index) {
- this.todos.splice(index, 1); // Remove item from the list
- },
- // Method to focus on notes input
- focusNotesInput: function() {
- this.$refs.notesInput.focus(); // Focus on notes input
- }
- }
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement