-
Notifications
You must be signed in to change notification settings - Fork 39
dark mode added to the component #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| body{ | ||
| font-family: "Roboto", "Helvetica", "Arial", sans-serif; | ||
| } | ||
|
|
||
| #light-theme{ | ||
| --font-color: black; | ||
| --body-bg-color: white; | ||
| --hover-color: gray; | ||
| } | ||
|
|
||
| #dark-theme{ | ||
| --font-color: lightgray; | ||
| --body-bg-color: #0F3460; | ||
| --hover-color: #ff4081; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| .todo-container{ | ||
| background-color: var(--body-bg-color); | ||
| color: var(--font-color) | ||
| } | ||
|
|
||
| .theme-switch{ | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import React, { useState } from "react"; | ||
| import { Reorder } from "framer-motion"; | ||
| import { Container } from "@material-ui/core"; | ||
| import { Container, Switch } from "@material-ui/core"; | ||
|
|
||
| import "./Todo.css"; | ||
| import { Item, TodoCompletedList } from "./common"; | ||
| import { Form } from "./common/Todo/Form"; | ||
| import { TodoItem } from "./common/types"; | ||
|
|
||
|
|
||
| export interface TodoAppProps { | ||
| defaultItems?: TodoItem[]; | ||
| onChange: (items: TodoItem[]) => void; | ||
|
|
@@ -49,8 +49,14 @@ function TodoApp(props: TodoAppProps) { | |
| setItems([...updatedItems, ...completedItems]); | ||
| }; | ||
|
|
||
| const [theme, setTheme] = useState("light-theme"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As people will use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not so sure how to create a prop that can be later used as optional feature. As I am very new in react, I only know Javascript, I don't have idea about Typescript. But I will let you know if I am able to make a prop for the feature. |
||
| const toggleTheme = ()=>{ | ||
| setTheme(prevTheme=>(prevTheme === "light-theme"? "dark-theme" : "light-theme")); | ||
| } | ||
|
|
||
| return ( | ||
| <Container> | ||
| <div id={theme} > | ||
| <Container className="todo-container"> | ||
| <Form addItem={addItem} /> | ||
| <Reorder.Group | ||
| axis="y" | ||
|
|
@@ -74,7 +80,12 @@ function TodoApp(props: TodoAppProps) { | |
| setItemsCallback={setItemsCallback} | ||
| completedItems={completedItems} | ||
| /> | ||
| <div className="theme-switch"> | ||
| <Switch color="secondary" onChange={toggleTheme}/> | ||
| {theme === "light-theme"? <p>Light Mode</p>: <p>Dark Mode</p>} | ||
| </div> | ||
| </Container> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10614,6 +10614,11 @@ react-textarea-autosize@^8.3.0: | |
| use-composed-ref "^1.0.0" | ||
| use-latest "^1.0.0" | ||
|
|
||
| react-todo-component@^2.0.3: | ||
| version "2.0.3" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||
| resolved "https://registry.yarnpkg.com/react-todo-component/-/react-todo-component-2.0.3.tgz#762878d0ffb86b87bad84b0f6925b1a57c8598b0" | ||
| integrity sha512-Z/ES1MYRXg3oaS33wEF0I0gvsyv35v2HemeJaZq5KfBBqvZWqjeFNuijKZLsWX/jzuLRCtGNemNVs4lBkLqjHg== | ||
|
|
||
| react-transition-group@^4.4.0: | ||
| version "4.4.5" | ||
| resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.5.tgz#e53d4e3f3344da8521489fbef8f2581d42becdd1" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
react-todo-componentdependency