Skip to content

Commit

Permalink
Dark Mode Implementation
Browse files Browse the repository at this point in the history
To add:
- Remember dark mode state between pages
  • Loading branch information
athuler committed Feb 14, 2024
1 parent e73ef30 commit db4c334
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,18 @@ function gtag(){dataLayer.push(arguments);}
Home
</button></a>

<!-- About the project -->
<button class="btn btn-outline-secondary col-auto float-end ms-auto" data-bs-toggle="modal" data-bs-target="#aboutModal">What's this?</button>
<div class="col-auto float-end ms-auto">
<!-- About the project -->
<button class="btn btn-outline-secondary col-auto" data-bs-toggle="modal" data-bs-target="#aboutModal">What's this?</button>

<!-- Dark Mode Toggle -->
<button id="darkModeSwitch" class="btn btn-outline-secondary col-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-moon-stars-fill" viewBox="0 0 16 16">
<path d="M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278"/>
<path d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.73 1.73 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.73 1.73 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.73 1.73 0 0 0 1.097-1.097zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.16 1.16 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.16 1.16 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732z"/>
</svg>
</button>
</div>
</div>
<h1><?=$show_name;?></h1>

Expand Down Expand Up @@ -357,8 +367,21 @@ function gtag(){dataLayer.push(arguments);}
<!-- Displaying the Homepage -->
<br/>
<div class="row">
<!-- Home Title -->
<h1 class="col-auto">UChicago Ticketing</h1><br/>
<button class="btn btn-outline-secondary col-auto float-end ms-auto" data-bs-toggle="modal" data-bs-target="#aboutModal">What's this?</button>

<div class="col-auto float-end ms-auto">
<!-- About This Project -->
<button class="btn btn-outline-secondary col-auto" data-bs-toggle="modal" data-bs-target="#aboutModal">What's this?</button>

<!-- Dark Mode Toggle -->
<button id="darkModeSwitch" class="btn btn-outline-secondary col-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-moon-stars-fill" viewBox="0 0 16 16">
<path d="M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278"/>
<path d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.73 1.73 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.73 1.73 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.73 1.73 0 0 0 1.097-1.097zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.16 1.16 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.16 1.16 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732z"/>
</svg>
</button>
</div>
</div>

<br/>
Expand Down Expand Up @@ -422,7 +445,19 @@ function gtag(){dataLayer.push(arguments);}

<?php } ?>

<!-- Universal Scripts -->
<script>
document.getElementById('darkModeSwitch').addEventListener('click',()=>{
if (document.documentElement.getAttribute('data-bs-theme') == 'dark') {
document.documentElement.setAttribute('data-bs-theme','light')
}
else {
document.documentElement.setAttribute('data-bs-theme','dark')
}
})
</script>

<!-- Universal Styles -->
<style>
#performanceTemplate {visibility: hidden;}
#headerImg {height:100% !important;}
Expand Down

0 comments on commit db4c334

Please sign in to comment.