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
Empty list Light theme Complete todo
- Solution URL: My solution
- Live Site URL: Live site URL here
- React - JS library
- Redux.js - React framework
- Styled Components - For styles
I learned how to create global styles and how to use the theme context to toggle the theme-mode using styled-components. I also improve my redux knowledge.
import styled, { createGlobalStyle } from 'styled-components';
export const GlobalStyles = createGlobalStyle` {
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
}
const App = ({ children }) => {
const currentTheme = () => {
const localTheme = localStorage.getItem('TODO_THEME');
return localTheme || 'dark';
};
const [theme, toggleTheme] = useTheme(currentTheme);
const themeMode = theme === 'dark' ? darkTheme : lightTheme;
<ThemeProvider theme={themeMode}>{children}</ThemeProvider>;
};
- react-beautiful-dnd - This helped me for implement the drag and drop functionality and understand how to use it. I'd recommend it to anyone still learning this concept.