Skip to content

rnsnceman/Todo-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Todo app solution

This is a solution to the Todo app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the app depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Add new todos to the list
  • Mark todos as complete
  • Delete todos from the list
  • Filter by all/active/complete todos
  • Clear all completed todos
  • Toggle light and dark mode
  • Bonus: Drag and drop to reorder items on the list

Screenshot

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow

What I learned

This is the drag and drop code below:

listItem.draggable = true;

        listItem.addEventListener('dragstart', e => {
            draggedItem = e.target;
        });

        listItem.addEventListener('dragover', e => {
            e.preventDefault();
        });

        listItem.addEventListener('dragenter', e => {
            e.target.classList.add('drag-over');
        });

        listItem.addEventListener('dragleave', e => {
            e.target.classList.remove('drag-over');
        });

        listItem.addEventListener('drop', e => {
            e.target.classList.remove('drag-over');
            if (draggedItem !== null) {
                const items = Array.from(itemsList.getElementsByClassName('list-item'));
                const currentIndex = items.indexOf(e.target);
                const draggedIndex = items.indexOf(draggedItem);
                if (currentIndex > draggedIndex) {
                    itemsList.insertBefore(draggedItem, e.target.nextSibling);
                } else {
                    itemsList.insertBefore(draggedItem, e.target);
                }
                draggedItem = null;
            }
        });

Continued development

I need to learn how to do implement more advanced interactive features such as the drag and drop.

Useful resources

  • W3Schools - This site helps me whenever I need a reminder of how to use certain code
  • ChatGPT - This helped me with the code for the dragg & drop feature

Author

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published