Skip to content

Commit

Permalink
fix(header): fix desktop rendering after resize
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaraa committed May 2, 2024
1 parent dd7c6a8 commit 72caf83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 14 additions & 1 deletion components/ui/header/header.templ
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,23 @@ templ desktopHeader() {

templ Header(isMobile bool) {
<header class={ "bg-accent", "p-[20px]", "md:p-[10px]" }>
// mobiles are usually shitty at rendering, so this prevents mobiles from rendering two blocks and choosing one using CSS.
if isMobile {
@mobileHeader()
} else {
@desktopHeader()
<div style="display: contents" class={ "hidden", "md:block" }>
@desktopHeader()
</div>
<!--
for when opened on a desktop and the client's width is really small,
and a similar thing isn't being done for mobile, since mobile clients can't change width w/o reloading
-->
<div style="display: contents" class={ "md:hidden" }>
@mobileHeader()
</div>
}
</header>
// script is being used here, so it doesn't render twice on desktops and break shit.
<script src="/static/js/search.js" lang="javascript">
</script>
}
4 changes: 1 addition & 3 deletions components/ui/search/search.templ
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@ templ Search() {
id="search-suggestions-container"
></div>
</div>
//
<script src="/static/js/search.js" lang="javascript">
</script>
// script is in ui/header/header.templ
}

0 comments on commit 72caf83

Please sign in to comment.