Skip to content

Commit

Permalink
Adjust daynight cicle colors
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniopelusi committed Jan 17, 2025
1 parent edee2f2 commit 48151a7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
36 changes: 23 additions & 13 deletions assets/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,26 @@ function getBackgroundColors() {
const minutes = now.getMinutes();

const colors = {
night: "#001f3d",
dawn: "#ff6f47",
morning: "#87ceeb",
noon: "#00bfff",
sunset: "#f27a3a",
evening: "#3d4f5c",
earlyMorning: "#41405d", // 03:00 - 06:00
dawn: "#f3ae5d", // 06:00 - 09:00
morning: "#74c3e1", // 09:00 - 12:00
noon: "#57b0d9", // 12:00 - 15:00
afternoon: "#6d9cc3", // 15:00 - 18:00
evening: "#e48959", // 18:00 - 21:00
night: "#314867", // 21:00 - 00:00
midnight: "#1c304b", // 00:00 - 03:00
};

let startColor, endColor, factor;

if (hours >= 0 && hours < 6) {
startColor = colors.night;
if (hours >= 0 && hours < 3) {
startColor = colors.midnight;
endColor = colors.earlyMorning;
factor = (hours + minutes / 60) / 3;
} else if (hours >= 3 && hours < 6) {
startColor = colors.earlyMorning;
endColor = colors.dawn;
factor = (hours + minutes / 60) / 6;
factor = (hours + minutes / 60 - 3) / 3;
} else if (hours >= 6 && hours < 9) {
startColor = colors.dawn;
endColor = colors.morning;
Expand All @@ -65,16 +71,20 @@ function getBackgroundColors() {
factor = (hours + minutes / 60 - 9) / 3;
} else if (hours >= 12 && hours < 15) {
startColor = colors.noon;
endColor = colors.sunset;
endColor = colors.afternoon;
factor = (hours + minutes / 60 - 12) / 3;
} else if (hours >= 15 && hours < 18) {
startColor = colors.sunset;
startColor = colors.afternoon;
endColor = colors.evening;
factor = (hours + minutes / 60 - 15) / 3;
} else {
} else if (hours >= 18 && hours < 21) {
startColor = colors.evening;
endColor = colors.night;
factor = (hours + minutes / 60 - 18) / 6;
factor = (hours + minutes / 60 - 18) / 3;
} else {
startColor = colors.night;
endColor = colors.midnight;
factor = (hours + minutes / 60 - 21) / 3;
}

return { startColor, endColor, factor };
Expand Down
2 changes: 1 addition & 1 deletion chrome_manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "ToolsTab",
"version": "1.2",
"version": "1.3",
"description": "Minimal and responsive browser startpage with useful tools.",
"chrome_url_overrides": {
"newtab": "index.html",
Expand Down
2 changes: 1 addition & 1 deletion firefox_manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "ToolsTab",
"version": "1.2",
"version": "1.3",
"description": "Minimal and responsive browser startpage with useful tools.",
"chrome_url_overrides": {
"newtab": "index.html"
Expand Down

0 comments on commit 48151a7

Please sign in to comment.