-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
78 lines (77 loc) · 2.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const febHolidays = [
"Dear Baby,",
"First of all, I love you❤️",
"You're my everything",
"You are my soulmate",
"And of course...",
"My future wife🤭",
"I will always be there for you",
"No matter how far we are🥰",
"You're the prettiest, cutest, funniest,",
"sweetest girl alive.",
"In one word, you're just perfect.😍",
"I'm the happiest man alive🥰",
"I'm so grateful I met you❤️",
"I'll always do my best to keep you happy🥺",
"You are the most special person in my life🥰",
"I don't want to lose you",
"And trust me I dont want anyone else",
"There's no one better than you❤️",
"You're the best best baby!!",
"Or should I say, mo gro coco d'amour que j'adore a la folie XD",
"Wow!! Time flies, we've already been together for 7 year",
"There's some hardships,",
"but we overcame most of them",
"and it made me realised how important you are in my life❤️",
"This for you,",
"To l'amour",
"ek mo l'amour",
"fr 2 liv pomme d'amour🤣❤️",
"But anyways, Happy 7 years my sweet little girlfriend(wife🤭)",
"You're the love of my life,",
"I Love You So much❤️"
];
const ulEl = document.querySelector("ul");
const d = new Date();
let daynumber = d.getMonth() == 1 ? d.getDate() - 1 : 0;
let activeIndex = daynumber;
const rotate = -360 / febHolidays.length;
init();
function init() {
febHolidays.forEach((holiday, idx) => {
const liEl = document.createElement("li");
liEl.style.setProperty("--day_idx", idx);
liEl.innerHTML = `<time datetime="2022-02-${idx + 1}">${
idx + 1
}</time><span>${holiday}</span>`;
ulEl.append(liEl);
});
ulEl.style.setProperty("--rotateDegrees", rotate);
adjustDay(0);
}
function adjustDay(nr) {
daynumber += nr;
ulEl.style.setProperty("--currentDay", daynumber);
const activeEl = document.querySelector("li.active");
if (activeEl) activeEl.classList.remove("active");
activeIndex = (activeIndex + nr + febHolidays.length) % febHolidays.length;
const newActiveEl = document.querySelector(
`li:nth-child(${activeIndex + 1})`
);
document.body.style.backgroundColor = window.getComputedStyle(
newActiveEl
).backgroundColor;
newActiveEl.classList.add("active");
}
window.addEventListener("keydown", (e) => {
switch (e.key) {
case "ArrowUp":
adjustDay(-1);
break;
case "ArrowDown":
adjustDay(1);
break;
default:
return;
}
});