Skip to content

Commit 24f906b

Browse files
committed
Interactive switch
1 parent c125a2f commit 24f906b

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

index.html

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,33 @@
4242
</head>
4343
<body>
4444
<script>
45-
let shown = false;
46-
function toggle() {
45+
let menuShown = false;
46+
function toggleMenu() {
4747
const el = document.getElementById("menu");
4848
const body = document.body;
49-
if (shown) {
49+
if (menuShown) {
5050
el.style.transform = "translate(100%, 0)";
5151
body.style.overflow = "auto";
52-
shown = false;
52+
menuShown = false;
5353
} else {
5454
el.style.transform = "translate(0, 0)";
5555
body.style.overflow = "hidden";
56-
shown = true;
56+
menuShown = true;
57+
}
58+
}
59+
60+
let switchOn = true;
61+
function toggleSwitch() {
62+
const el = document.getElementById("switch");
63+
const sq = document.getElementById("switch-sq");
64+
if (switchOn) {
65+
el.style.backgroundColor = "#FF9A9A";
66+
sq.style.marginLeft = "0px";
67+
switchOn = false;
68+
} else {
69+
el.style.backgroundColor = "#74DAAD";
70+
sq.style.marginLeft = "calc(100% - 16px)";
71+
switchOn = true;
5772
}
5873
}
5974
</script>
@@ -64,7 +79,7 @@
6479
class="xl:hidden flex flex-row grow items-center justify-between px-5 py-5"
6580
>
6681
<img src="/softpoint/assets/images/logo.svg" alt="Logo" />
67-
<button onclick="toggle()" aria-label="Open Menu">
82+
<button onclick="toggleMenu()" aria-label="Open Menu">
6883
<img
6984
src="/softpoint/assets/images/burger.svg"
7085
alt="Menu icon"
@@ -94,7 +109,7 @@
94109
<div
95110
class="fixed top-0 right-0 left-0 bottom-0 z-3 bg-white/50 backdrop-blur-xl flex flex-col items-center justify-center gap-8 transition"
96111
id="menu"
97-
onclick="toggle()"
112+
onclick="toggleMenu()"
98113
style="transform: translate(100%, 0)"
99114
>
100115
<a class="text-xl" href="#features">Features</a>
@@ -574,9 +589,16 @@ <h2 class="mt-6 font-semibold text-xl">Clean Code</h2>
574589
<div class="flex flex-row gap-4 mt-9">
575590
<p class="text-xl">Monthly</p>
576591
<div
577-
class="rounded-md bg-[#74DAAD] w-15 h-7 flex flex-row justify-end p-[6px]"
592+
class="rounded-md w-15 h-7 p-[6px] transition"
593+
style="background-color: #74daad"
594+
id="switch"
595+
onclick="toggleSwitch()"
578596
>
579-
<div class="rounded-sm w-4 h-4 bg-white"></div>
597+
<div
598+
class="rounded-sm w-4 h-4 bg-white transition-all"
599+
id="switch-sq"
600+
style="margin-left: calc(100% - 16px)"
601+
></div>
580602
</div>
581603
<p class="text-xl">Quarterly</p>
582604
</div>

0 commit comments

Comments
 (0)