Skip to content
Open
Show file tree
Hide file tree
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
58 changes: 32 additions & 26 deletions src/AddToBucket.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { createSignal } from "solid-js";

export function AddToBucket(props) {
const [newItem, setNewItem] = createSignal('');
const [newItem, setNewItem] = createSignal("");

return (
<form>
<input
type="text"
placeholder="Make a wish"
value={newItem()}
onChange={(e) => {
setNewItem(e.target.value);
}}
/>
<button
type="submit"
onClick={(e) => {
e.preventDefault();
props.setItems((items) => {
return [...items, { text: newItem(), complete: false }].reverse();
});
setNewItem('');
}}
>
Add
</button>
</form>
);
}
return (
<form>
<input
type="text"
placeholder="Make a wish"
value={newItem()}
onChange={(e) => {
setNewItem(e.target.value);
}}
/>
<button
type="submit"
onClick={(e) => {
e.preventDefault();
if (newItem()!=='') {
props.setItems((items) => {
return [
...items,
{ text: newItem(), complete: false },
].reverse();
});
setNewItem("");
} else {
alert(`You can't submit empty value`);
}
}}>
Add
</button>
</form>
);
}
64 changes: 39 additions & 25 deletions src/BucketListItem.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
export function BucketListItem(props) {
return (
<li
class="list-item"
style={{
"text-decoration": props.item.complete ? "line-through" : undefined,
}}
>
<label>
<input
type="checkbox"
checked={props.item.complete}
onChange={() => {
props.setItems((items) => {
const newItems = items.map((item) =>
props.item === item
? { ...item, complete: !item.complete }
: item
);
return newItems;
const { item, setItems } = props;

const handleDelete = () => {
setItems((prevItems) => {
return prevItems.filter((prevItem) => {
return prevItem.text !== item.text;
});
}}
/>
{props.item.text}
</label>
</li>
);
});
};

return (
<li
class="list-item"
style={{
"text-decoration": props.item.complete
? "line-through"
: undefined,
}}>
<label>
<input
type="checkbox"
checked={props.item.complete}
onChange={() => {
props.setItems((items) => {
const newItems = items.map((item) =>
props.item === item
? { ...item, complete: !item.complete }
: item
);
return newItems;
});
}}
/>
{props.item.text}
</label>
<button onClick={handleDelete} style={{ "margin-left": "10px" }}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue doesn't require the delete wish functionality. Delete wish is a separate issue and in open source project management we follow one issue vs one pull request.

Please remove the code for delete issue and only fix the issue asked for.

Delete
</button>
</li>
);
}