-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-2254 Initialize test IndexView context & implement theme switcher
- Loading branch information
Showing
9 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
reposilite-backend/src/main/kotlin/com/reposilite/ui/views/IndexView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.reposilite.ui.views | ||
|
||
class IndexView( | ||
val title: String, | ||
val description: String, | ||
val logo: String, | ||
val website: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 23 additions & 1 deletion
24
reposilite-backend/src/main/resources/ui/component/Header.jte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
@param String title | ||
|
||
<header class="border-b-1 border-gray-50 h-16 flex items-center w-full"> | ||
<p class="px-2">${title}</p> | ||
<div class="mx-auto container-xl flex justify-between w-full"> | ||
<nav> | ||
${title} | ||
</nav> | ||
<nav> | ||
<button id="theme-switcher" class="flex bg-gray-900 rounded px-4 py-1"> | ||
Switch | ||
<span class="sun-icon color-white"> | ||
@template.lib.icons.SunIcon() | ||
</span> | ||
<span class="moon-icon color-black"> | ||
@template.lib.icons.MoonIcon() | ||
</span> | ||
</button> | ||
</nav> | ||
</div> | ||
<script> | ||
document.getElementById("theme-switcher").addEventListener("click", () => { | ||
document.documentElement.classList.toggle("dark") | ||
document.documentElement.classList.toggle("light") | ||
localStorage.setItem("color-theme", document.documentElement.classList.contains("dark") ? "dark" : "light") | ||
}) | ||
</script> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
<!--suppress JSUnresolvedReference --> | ||
<script> | ||
tailwind.config = { | ||
darkMode: 'selector' | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@raw | ||
<script> | ||
const themeKey = 'color-theme' | ||
let darkThemeEnabled = localStorage.getItem(themeKey) === 'dark' | ||
if (!darkThemeEnabled && !(themeKey in localStorage)) { | ||
darkThemeEnabled = window.matchMedia('(prefers-color-scheme: dark)').matches | ||
} | ||
if (darkThemeEnabled) { | ||
document.documentElement.classList.add('dark') | ||
document.documentElement.classList.remove('light') | ||
} else { | ||
document.documentElement.classList.remove('dark') | ||
document.documentElement.classList.add('light') | ||
} | ||
</script> | ||
@endraw |
15 changes: 15 additions & 0 deletions
15
reposilite-backend/src/main/resources/ui/lib/icons/MoonIcon.jte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- Source: https://heroicons.dev/ --> | ||
<svg | ||
class="w-6 h-6" | ||
fill="none" | ||
stroke="currentColor" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" | ||
/> | ||
</svg> |
15 changes: 15 additions & 0 deletions
15
reposilite-backend/src/main/resources/ui/lib/icons/SunIcon.jte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- Source: https://heroicons.dev/ --> | ||
<svg | ||
class="w-6 h-6" | ||
fill="none" | ||
stroke="currentColor" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" | ||
/> | ||
</svg> |