Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flora.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ library flora-web
FloraWeb.Common.Pagination
FloraWeb.Common.Tracing
FloraWeb.Common.Utils
FloraWeb.Components.SkipLink
FloraWeb.Components.AdvisoryListItem
FloraWeb.Components.Alert
FloraWeb.Components.Button
Expand All @@ -338,6 +337,7 @@ library flora-web
FloraWeb.Components.PackageListItem
FloraWeb.Components.PaginationNav
FloraWeb.Components.Pill
FloraWeb.Components.SkipLink
FloraWeb.Components.SlimSearchBar
FloraWeb.Components.Utils
FloraWeb.Components.VersionListHeader
Expand Down
22 changes: 0 additions & 22 deletions src/web/FloraWeb/Components/Header.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ header = do
html_
( [ lang_ "en"
, class_ "no-js"
, xData_
"{ updateTheme() { \
\ const customTheme = document.documentElement.getAttribute('data-theme'); \
\ const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches; \
\ const applyTheme = (theme) => { \
\ document.documentElement.setAttribute('data-theme', theme); \
\ console.log(\"theme switch\"); \
\ (async () => { await cookieStore.set('theme', theme) })(); \
\ }; \
\ switch (customTheme) { \
\ case 'light': \
\ applyTheme('dark'); \
\ break; \
\ case 'dark': \
\ applyTheme('light'); \
\ break; \
\ default: \
\ isSystemDark ? applyTheme('light') : applyTheme('dark'); \
\ break; \
\ } \
\ } \
\}"
]
<> theme'
)
Expand Down
53 changes: 39 additions & 14 deletions src/web/FloraWeb/Components/Navbar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,45 @@ import FloraWeb.Pages.Templates.Types
navbar :: FloraHTML
navbar = do
ActiveElements{aboutNav, packagesNav} <- asks activeElements
nav_ [class_ "top-navbar"] $ do
div_ [class_ "navbar-content"] $ do
navbarDropdown aboutNav packagesNav
div_ [class_ "navbar-left"] $ do
brand
navbarSearch
div_ [class_ "navbar-right"] $ do
navBarLink "navbar-menu-button" "/" "Search on Flora" False
navBarLink' "/about" "About" aboutNav
a_ [href_ "/documentation", class_ "navbar-link", target_ "_blank"] (text "Documentation")
navBarLink' "/categories" "Categories" packagesNav
navBarLink' "/packages" "Packages" packagesNav
userMenu
themeToggle
nav_
[ class_ "top-navbar"
, xData_
"{ updateTheme() { \
\ const customTheme = document.documentElement.getAttribute('data-theme'); \
\ const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches; \
\ const applyTheme = (theme) => { \
\ document.documentElement.setAttribute('data-theme', theme); \
\ console.log(\"theme switch\"); \
\ (async () => { await cookieStore.set('theme', theme) })(); \
\ }; \
\ switch (customTheme) { \
\ case 'light': \
\ applyTheme('dark'); \
\ break; \
\ case 'dark': \
\ applyTheme('light'); \
\ break; \
\ default: \
\ isSystemDark ? applyTheme('light') : applyTheme('dark'); \
\ break; \
\ } \
\ } \
\}"
]
$ do
div_ [class_ "navbar-content"] $ do
navbarDropdown aboutNav packagesNav
div_ [class_ "navbar-left"] $ do
brand
navbarSearch
div_ [class_ "navbar-right"] $ do
navBarLink "navbar-menu-button" "/" "Search on Flora" False
navBarLink' "/about" "About" aboutNav
a_ [href_ "/documentation", class_ "navbar-link", target_ "_blank"] (text "Documentation")
navBarLink' "/categories" "Categories" packagesNav
navBarLink' "/packages" "Packages" packagesNav
userMenu
themeToggle

brand :: FloraHTML
brand = do
Expand Down