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.
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
- Solution URL: https://github.com/erelropeta/fem-todo-app-main
- Live Site URL: https://todo-app-erj.netlify.app/
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- Mobile-first workflow
- BEM - CSS methodology
- React - JS library
- Getting preferred color scheme of the user
window
.matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', (e) =>
e.matches ? setDarkTheme(true) : setDarkTheme(false)
);
- Responsive sizing using
clamp()
has a computation
Instead of computing for all sizing (font-size
, margin
, etc.), I utilized Marc Bacon's Clamp() Function Calculator. I used clamp()
from screen width 768px
because it wasn't giving the right size on mobile view (375px).
- Utilizing
useState
instead of usinguseEffect
const getFilteredTodos = (todos, filter) => {
if (filter === 'active') {
return todos.filter((todo) => !todo.isComplete);
} else if (filter === 'completed') {
return todos.filter((todo) => todo.isComplete);
} else {
return todos;
}
};
const visibleTodos = getFilteredTodos(todoList, filterBy);
- React Beautiful DnD - For the smooth drag and drop feature.
- Clamp() Function Calculator - For calculating the responsive sizing of texts, widths, etc.
- You Might Not Need an Effect - Wonderful tutorial in utilizing the power of state instead of unnecessarily using
useEffect
.
- LinkedIn - Erel Ropeta
- Frontend Mentor - @ereljapco