Skip to content

Commit

Permalink
Fixed Bugs
Browse files Browse the repository at this point in the history
Also changed max pto behavior.
  • Loading branch information
Emmennater committed Nov 16, 2023
1 parent 947c7aa commit 21cace0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ function updateDayElem(i) {
else
dayElem.classList.remove("starting-day");

// Hit max
if (timeOffRatio == 1) {
dayElem.classList.add("hit-max");
} else {
dayElem.classList.remove("hit-max");
}

}

function updatePTOElems() {
Expand Down
20 changes: 12 additions & 8 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ class Month {
let hitMax = startingPTO >= maxPTO;
for (const day of this.days) {
cumulativePTO += day.getLocalTimeOff();
day.setTimeOff(cumulativePTO);

// Max PTO date
if (!hitMax && cumulativePTO >= maxPTO) {
hitMax = true;
Settings.setMaxDate(day);

// Max PTO
if (cumulativePTO >= maxPTO) {
cumulativePTO = maxPTO;
if (!hitMax) {
hitMax = true;
Settings.setMaxDate(day);
}
}

day.setTimeOff(cumulativePTO);
}
}

Expand Down Expand Up @@ -215,8 +219,8 @@ class Day {
}

getLocalTimeOff() {
let time = this.isStartingDay() ? Settings.start : 0;
time += this.data.time;
if (this.isStartingDay()) return Settings.start;
let time = this.data.time;
if (this.data.add) time += Settings.getSetting("add");
if (this.data.sub) time -= Settings.getSetting("sub");
return time;
Expand Down
8 changes: 8 additions & 0 deletions style/calandar.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
transition: box-shadow 0.1s;
}

.day.hit-max {
background: linear-gradient(
to top,
rgba(255, 0, 0, 0.308) calc(var(--pto-ratio) * 100%),
#ffffff12 calc(var(--pto-ratio) * 100%)
);
}

.day.starting-day {
box-shadow: inset 0px 0px 20px #88ffb680;
}
Expand Down

0 comments on commit 21cace0

Please sign in to comment.