summaryrefslogtreecommitdiff
path: root/tailwindcss/02-vite/src/main.js
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-07-05 22:16:56 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-07-05 22:16:56 +0530
commit5d38404d54732193b822d80485371d5b74ae4e4b (patch)
tree18719394c15c90e58e76deecdc519239266978c9 /tailwindcss/02-vite/src/main.js
parent5287a9a10507c998540ac51442ff451a280dc05c (diff)
Theme colors changed, font size change links added
Diffstat (limited to 'tailwindcss/02-vite/src/main.js')
-rw-r--r--tailwindcss/02-vite/src/main.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/tailwindcss/02-vite/src/main.js b/tailwindcss/02-vite/src/main.js
index 9a69e49..c39e9ff 100644
--- a/tailwindcss/02-vite/src/main.js
+++ b/tailwindcss/02-vite/src/main.js
@@ -1,3 +1,5 @@
+/* Toggle button (or link) to change the theme */
+
const toggleButton = document.querySelector('#theme-toggle');
toggleButton.addEventListener('click', () => {
@@ -8,3 +10,26 @@ toggleButton.addEventListener('click', () => {
const isDark = document.documentElement.classList.contains('dark');
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
+
+
+/* Font size increase or decrease */
+
+let currentSize = 1; // 1 rem is the baseline
+
+function increaseFontSize() {
+ if (currentSize < 1.5) { // Cap at 150%
+ currentSize += 0.1;
+ applyFontSize();
+ }
+}
+
+function decreaseFontSize() {
+ if (currentSize > 0.8) { // Set a minimum limit
+ currentSize -= 0.1;
+ applyFontSize();
+ }
+}
+
+function applyFontSize() {
+ document.documentElement.style.fontSize = currentSize * 100 + "%";
+}