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

32 user testing goals section #36

Merged
merged 5 commits into from
Oct 15, 2024
Merged
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
Binary file added images/draggableBulletUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/leafBulletPoint.png
Binary file not shown.
11 changes: 8 additions & 3 deletions popupWindow/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ h4 {
/* Input and Button Styling */
input[type="text"], input[type="text"]:hover {
border: none;
color: #F28705;
}

button {
Expand Down Expand Up @@ -188,12 +189,15 @@ ul div {
}

li {
cursor: grab;
cursor: move;
display: flex;
justify-content:space-between;
flex-direction: row;
gap: 5px;
align-items: center;
/* background-color: rgba(242, 160, 7, 0.5); */
/* box-sizing: border-box; */
border-radius: 10px;
}

.notDrag {
Expand All @@ -205,16 +209,17 @@ span {
color:#F28705;
width: 75vw;
word-wrap:break-word;
cursor: text;
}

#bulletPoint {
width: 25px;
height: 25px;
background-image: url('/images/leafBulletPoint.png');
background-image: url('/images/draggableBulletUI.png');
background-size: contain;
background-repeat: no-repeat;
border-bottom: none !important;
margin-right: 15px;
/* margin-right: 15px; */
}

/* for countdown timer */
Expand Down
40 changes: 29 additions & 11 deletions popupWindow/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function addTaskToDOM(section, task) {
const taskSpan = document.createElement('span');
taskSpan.id = task.id;
taskSpan.textContent = task.content;
taskSpan.contentEditable = true;
taskSpan.addEventListener('dragstart', (e) => {
e.preventDefault(); // make text not draggable (bug fix)
});
Expand All @@ -234,23 +235,32 @@ function addTaskToDOM(section, task) {
const prettyBulletPoint = document.createElement('div');
prettyBulletPoint.id = 'bulletPoint';

listItem.appendChild(document.createElement('div'))
listItem.appendChild(prettyBulletPoint);
listItem.appendChild(taskSpan);
listItem.appendChild(deleteButton);
listItem.appendChild(document.createElement('div'))
taskList.parentNode.insertBefore(listItem, taskList.nextSibling);
}

function editTask(section, taskSpan) {
const taskList = getTasksFromStorage();
const task = taskList[section].find(t => t.id === taskSpan.id);
if (task !== undefined){
if (!taskSpan.isContentEditable) {
taskSpan.contentEditable = true;
taskSpan.focus();
} else {
task.content = taskSpan.textContent;
saveTasksToStorage(taskList);
}
taskSpan.focus();
// Add blur event to save when done editing
taskSpan.addEventListener('blur', () => {
if (taskSpan.textContent === "") {
deleteTask(section, taskSpan.id);
} else {
task.content = taskSpan.textContent;
taskList[section] = taskList[section].map(t =>
t.id === task.id ? task : t
);
saveTasksToStorage(taskList);
}
});

}
}

Expand All @@ -262,9 +272,12 @@ function deleteTask(section, taskId) {

function getTasksFromStorage() {
const tasks = localStorage.getItem('tasks');
if (!tasks || tasks === 'undefined') {
if (!tasks || tasks === 'undefined' || tasks === "{\"NotDone\":[],\"Doing\":[],\"Done\":[]}") {
return {
'NotDone': [],
'NotDone': [{
id: "task0",
content: "Your first task! Drag/drop, edit, or delete this."
}],
'Doing': [],
'Done': []
};
Expand Down Expand Up @@ -318,7 +331,12 @@ function makeTaskDraggable(sortableList) {
}
afterElement.style.borderBottom = '5px solid #8C5C4A';
// Insert after the hovered element by using insertBefore and nextSibling
sortableList.insertBefore(draggedItem, afterElement.nextSibling);
try {
sortableList.insertBefore(draggedItem, afterElement.nextSibling);
} catch (error) {
// functionality still works, because it throws the error when it's in a temporarily invliad state (when the user is still hovering)
}

}
});

Expand All @@ -328,7 +346,7 @@ function makeTaskDraggable(sortableList) {
),];
return draggableElements.reduce((closest, child) => {
const box = child.getBoundingClientRect();
const offset = y - box.top - box.height / 2;
const offset = y - box.top - box.height;
if (offset < 0 && offset > closest.offset) {
return { offset: offset, element: child };
} else {
Expand Down