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

added styles using tailwindCss, delete not working #35

Merged
merged 11 commits into from
Mar 31, 2024
Binary file added public/img/Home-cover2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/HomeCover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/homeCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/api/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ export async function deleteItem(listPath, itemId) {
const docRef = doc(db, listPath, 'items', itemId);
await deleteDoc(docRef);
}
// delete collection path
// export async function deleteCollectionPath(db, listName, collectionId) {
// const docRef = doc(db, listName, collectionId)
// try {
// await deleteDoc(docRef);
// console.log(docRef)
// } catch (err) {
// console.error(err);
// }
// }

export async function comparePurchaseUrgency(dataset) {
dataset.sort((a, b) => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/SingleList.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
.SingleList-label {
margin-left: 0.2em;
}
.selected {
background-color: #000000;
color: #e69500;
}
24 changes: 20 additions & 4 deletions src/components/SingleList.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import './SingleList.css';
import { MdOutlineDeleteForever } from 'react-icons/md';

export function SingleList({ name, path, setListPath }) {
export function SingleList({
name,
path,
setListPath,
deleteCollectionPath,
selected,
}) {
function handleClick() {
setListPath(path);
}
// function handleDelete() {
// deleteCollectionPath(path);
// }

return (
<li className="SingleList">
<button onClick={handleClick}>{name}</button>
</li>
<div
className={`flex items-center justify-between ${selected ? 'selected' : ''}`}
>
<li className="SingleList">
<button onClick={handleClick}>{name}</button>
</li>
<hr />
<MdOutlineDeleteForever className="text-red-700" />
</div>
);
}
23 changes: 23 additions & 0 deletions src/views/Home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.home {
background: rgba(255, 255, 255, 0.24);
border-radius: 16px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(4.7px);
-webkit-backdrop-filter: blur(4.7px);
border: 1px solid rgba(255, 255, 255, 0.3);
@apply rounded-2xl shadow-2xl px-4 md:px-24 text-black mt-8;
}
#list {
@apply mt-8 flex flex-col justify-center items-center;
}
.input {
@apply border border-blue-700 text-black bg-white p-3 rounded-xl;
width: 70%;
}
.btn {
background-color: #113767;
@apply text-white p-3 rounded-xl shadow-md mb-8;
}
:hover .btn {
background-color: #38598b;
}
27 changes: 18 additions & 9 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom';

export function Home({ data, setListPath, userId, userEmail }) {
const [name, setName] = useState('');
const [selectedList, setSelectedList] = useState(null); // State to track the selected list
Copy link
Collaborator

Choose a reason for hiding this comment

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

You do not need this additional state here. We already have the listPath in the App, you can pass it as props and use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay... thank you

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

const navigate = useNavigate();

const handleSubmit = async (event) => {
Expand All @@ -31,34 +32,42 @@ export function Home({ data, setListPath, userId, userEmail }) {
const handleChange = (e) => {
setName(e.target.value);
};
// to create a highlighted list
const handleListClick = (path) => {
setListPath(path);
setSelectedList(path); // Update selected list
};

return (
<div className="Home">
<p>
Hello from the home (<code>/</code>) page!
</p>

<div className="home">
<form id="list" onSubmit={handleSubmit}>
<label htmlFor="listName">Name of shopping list: </label>
<label htmlFor="listName" className="pt-8 font-bold">
Kindly generate a shopping Collection
</label>
<br />
<input
type="text"
id="listName"
value={name}
onChange={handleChange}
className="input"
placeholder="Type Here..."
required
/>
<br />
<button type="submit">Create list</button>
<div className="btn">
<button type="submit">Register Collection List </button>
</div>
</form>

<ul>
{data?.map((item) => (
<SingleList
key={item.path}
name={item.name}
path={item.path}
setListPath={setListPath}
// setListPath={setListPath}
setListPath={handleListClick}
selected={selectedList === item.path} // Pass whether the list is selected
/>
))}
</ul>
Expand Down
4 changes: 4 additions & 0 deletions src/views/Layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
display: flex;
flex-direction: column;
height: 100dvh;
background-image: url('/img/Home-cover2.jpg') !important;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

.Layout > * {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function Layout() {
<>
<div className="Layout">
<header className="Layout-header">
<h1>Smart shopping list</h1>
<h1>Welcome to a Smart shopping list</h1>
{!user ? (
<div>
<SignInButton />
Expand Down
Loading