Skip to content

Commit

Permalink
Merge pull request #89 from XavierJ96/feat/add-button
Browse files Browse the repository at this point in the history
Feat/add button
  • Loading branch information
XavierJ96 authored Jul 2, 2024
2 parents 9327e77 + d8bdb3d commit 98d09c1
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 4 deletions.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
<title>TaskForge</title>
</head>
<body>
<div id="root" class="container min-h-[500px]"></div>
<div
id="root"
class="container min-h-[600px] max-h-[600px] overflow-x-hidden overflow-y-scroll"
></div>
<script type="module" src="/src/main.jsx"></script>
<script
src="/src/utils/font-awesome.js"
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "TaskForge",
"version": "1.1.043",
"version": "1.1.045",
"action": { "default_popup": "index.html" },
"permissions": ["storage"],
"icons": {
Expand Down
102 changes: 102 additions & 0 deletions src/components/AddTasks.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, { useState } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { collection, addDoc } from "@firebase/firestore";
import { db } from "../utils/firebase_config";

function AddTasks() {
const [taskText, setTaskText] = useState("");
const [taskDate, setTaskDate] = useState("");
const [selectedDate, setSelectedDate] = useState('today');

const handleTextChange = (event) => {
setTaskText(event.target.value);
};

const tasksCollection = collection(db, "forgedTasks");

const handleDateChange = (event) => {
setSelectedDate(event.target.value);
setTaskDate(event.target.value);
};

const handleSubmit = async (event) => {
event.preventDefault();

if (!taskText.trim()) {
alert("Task text cannot be empty");
return;
}

const task = {
text: taskText,
date: taskDate,
};

let dateAdded;

if (taskDate === "yesterday") {
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
dateAdded = yesterday.toISOString();
} else {
dateAdded = new Date().toISOString();
}

chrome.runtime.sendMessage(
{ action: "checkSignInStatus" },
async (response) => {
const user = response.user;

try {
await addDoc(tasksCollection, {
cardTitle: task.text,
cardType: "project",
author: { name: user.email, id: user.uid },
dateAdded: dateAdded,
});

setTaskText("");
setTaskDate("");
setSelectedDate('today');
} catch (error) {
throw new Error("Error adding document: ", error);
}
}
);
};

return (
<form
onSubmit={handleSubmit}
className="absolute bottom-0 w-full bg-[#161616] min-h-[50px] p-3 flex items-center space-x-3"
>
<div className="relative w-full">
<FontAwesomeIcon
icon={faPlus}
onClick={handleSubmit}
className="absolute left-3 top-[50%] -translate-y-[50%] text-white cursor-pointer"
/>
<input
type="text"
required
className="pl-8 border w-full bg-[#161616] text-white border-gray-300 px-3 py-2 mr-2 rounded-lg"
value={taskText}
placeholder="Add Tasks"
onChange={handleTextChange}
/>
</div>
<select
required
className="border w-[150px] bg-[#161616] text-white border-gray-300 px-2 py-2 text-[11px] rounded-lg appearance-none custom-select-arrow"
onChange={handleDateChange}
value={selectedDate}
>
<option value="today">Today</option>
<option value="yesterday">Yesterday</option>
</select>
</form>
);
}

export default AddTasks;
4 changes: 3 additions & 1 deletion src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TaskCard from "../components/TaskComponent";
import ToggleSection from "../components/ToggleSection";
import TaskList from "../components/TaskList";
import * as taskUtils from "../utils/taskUtils";
import AddTasks from "../components/AddTasks";

function Home({ userEmail }) {
const [taskData, setTaskData] = useState([]);
Expand Down Expand Up @@ -142,7 +143,7 @@ function Home({ userEmail }) {
taskData={taskData}
setTaskData={setTaskData}
/>
<div className="task-board space-y-3">
<div className="task-board space-y-3 pb-16">
<Stats
projectTasksCount={projectTasksCount}
reviewTasksCount={reviewTasksCount}
Expand Down Expand Up @@ -172,6 +173,7 @@ function Home({ userEmail }) {
view={view}
/>
</div>
<AddTasks />
</div>
);
}
Expand Down
14 changes: 14 additions & 0 deletions src/styles/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@
transition: background-color 0.3s, transform 0.3s;
}

.custom-select-arrow {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: #161616;
background-image: url("data:image/svg+xml,%3csvg fill='white' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M8.354 11.646l4-4a.5.5 0 0 0-.708-.708L8 10.293 4.354 6.646a.5.5 0 0 0-.708.708l4 4a.5.5 0 0 0 .708 0z'/%3e%3c/svg%3e");
background-repeat: no-repeat;
background-position-x: calc(100% - 0.5rem);
background-position-y: center;
padding-right: 1.5rem;
background-size: 0.75rem;
cursor: pointer;
}

#delete-btn:focus {
outline: none;
}
Expand Down
5 changes: 4 additions & 1 deletion src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
@tailwind components;
@tailwind utilities;

.container{
.container {
max-width: 1280px;
min-width: 400px;
margin: 0 auto;
background-color: #161616;
}

input[type="date"]::-webkit-calendar-picker-indicator {
filter: invert(1);
}

0 comments on commit 98d09c1

Please sign in to comment.