Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
i had added a toggle button for light and dark theme
  • Loading branch information
Giftzzz authored Oct 18, 2024
1 parent 80477f9 commit a213b82
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MediHub</title>
<style>
/* Light Theme */
:root {
--bg-color: #ffffff;
--text-color: #000000;
--button-bg: #f0f0f0;
--button-text: #000000;
}

/* Dark Theme */
[data-theme="dark"] {
--bg-color: #1c1c1c;
--text-color: #ffffff;
--button-bg: #444444;
--button-text: #ffffff;
}

/* General Styles */
body {
background-color: var(--bg-color);
color: var(--text-color);
Expand Down Expand Up @@ -61,7 +56,6 @@ <h1>Welcome to MediHub</h1>
</div>

<script>
// Function to toggle between light and dark themes
const themeToggleButton = document.getElementById('theme-toggle');
const currentTheme = localStorage.getItem('theme') || 'light';

Expand All @@ -71,7 +65,7 @@ <h1>Welcome to MediHub</h1>
themeToggleButton.addEventListener('click', function () {
const newTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme); // Save theme preference
localStorage.setItem('theme', newTheme);
themeToggleButton.textContent = newTheme === 'dark' ? 'Switch to Light Theme' : 'Switch to Dark Theme';
});
</script>
Expand Down

0 comments on commit a213b82

Please sign in to comment.