Skip to content
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

Bug/checkbox complete disable #20

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 51 additions & 30 deletions src/components/Todo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IconButton,
useMediaQuery,
Checkbox,
Grid
} from "@material-ui/core";
import { Draggable } from "react-beautiful-dnd";
import DeleteTwoToneIcon from "@material-ui/icons/DeleteTwoTone";
Expand All @@ -32,14 +33,23 @@ const Todo = ({
if (todo.completed) checkedStyle.textDecoration = "line-through";
else checkedStyle.textDecoration = "none";
// todo.completed ? (checkedStyle.textDecoration = "line-through") : null;
const cardStyles = {
marginTop: matches ? 20 : 35,
background: "lightgray",
};
const iconStyles = {
float: "right",
paddingTop: "10px",
};
const styles = {
card: {
marginTop: matches ? 20 : 35,
background: "lightgray",
},
icon: {
float: "right",
paddingTop: "10px",
},
text: {
wordBreak: "break-word",
display: "-webkit-box",
WebkitLineClamp: 2,
WebkitBoxOrient: "vertical",
overflow: "hidden"
}
}
const deleteTodo = (e) => {
if (e.shiftKey || isDeleteConfirmation) {
delTodo(todo.id);
Expand All @@ -57,7 +67,7 @@ const Todo = ({
{...p.draggableProps}
{...p.dragHandleProps}
style={{
...cardStyles,
...styles.card,
userSelect: "none",
...p.draggableProps.style,
}}
Expand All @@ -69,27 +79,38 @@ const Todo = ({
style={checkedStyle}
className="todo-text"
>
<Checkbox
color="primary"
style={{ marginRight: 5 }}
onClick={() => markComplete(todo.id)}
centerRipple={false}
/>
{todo.title}
<IconButton
style={iconStyles}
onClick={deleteTodo}
centerRipple={false}
>
<DeleteTwoToneIcon color="error" />
</IconButton>
<IconButton
style={iconStyles}
onClick={() => setEditOpen(true)}
centerRipple={false}
>
<EditTwoToneIcon color="primary" />
</IconButton>
<Grid container justify="center" alignItems="center">
<Grid item xs={2} sm={1}>
<Checkbox
checked={todo.completed}
color="primary"
style={{ marginRight: 5 }}
onClick={() => markComplete(todo.id)}
centerRipple={false}
/>
</Grid>
<Grid item xs={6} sm={10}>
<div style={styles.text}>
{todo.title}
</div>
</Grid>
<Grid item xs={4} sm={1}>
<IconButton
style={styles.icon}
onClick={deleteTodo}
centerRipple={false}
>
<DeleteTwoToneIcon color="error" />
</IconButton>
<IconButton
style={styles.icon}
onClick={() => setEditOpen(true)}
centerRipple={false}
>
<EditTwoToneIcon color="primary" />
</IconButton>
</Grid>
</Grid>
</Typography>
</CardContent>
</Card>
Expand Down