111 lines
4.6 KiB
HTML
111 lines
4.6 KiB
HTML
<header id="site-header" class="mb3 bb bw1 b--theme-dark">
|
|
<div class="user-options flex justify-center justify-end-ns">
|
|
{{ if .User }}
|
|
{{ if .User.IsStaff }}
|
|
<a class="admin-panel pa2" href="{{ .Header.AdminUrl }}"><span class="icon-settings"> Admin</span></a>
|
|
{{ end }}
|
|
<div>
|
|
<a class="dib pv2 pl2" href="{{ .Header.UserProfileUrl }}">{{ .User.Username }}</a>
|
|
<a class="dib pv2 pr2" href="{{ .Header.UserSettingsUrl }}">(settings)</a>
|
|
</div>
|
|
<a class="logout pa2" href="{{ .Header.LogoutActionUrl }}"><span class="icon-logout"></span> Log Out</a>
|
|
{{ else }}
|
|
<a class="register pa2" id="register-link" href="{{ .Header.RegisterUrl }}">Register</a>
|
|
<a class="login pa2" id="login-link" href="{{ .LoginPageUrl }}">Log in</a>
|
|
<div id="login-popup">
|
|
<form action="{{ .Header.LoginActionUrl }}" method="post" class="ma0">
|
|
<input type="text" name="username" class="w-100" value="" placeholder="Username" />
|
|
<input type="password" name="password" class="w-100 mt1" value="" placeholder="Password" />
|
|
<a class="db" style="padding: 0.5rem 0;" href="{{ .Header.ForgotPasswordUrl }}">Forgot your password?</a>
|
|
<input type="hidden" name="redirect" value="{{ $.CurrentUrl }}">
|
|
<div class="pt2">
|
|
<input type="submit" value="Log In" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
<div class="menu-bar flex flex-column flex-row-l justify-between {{ if .IsProjectPage }}project{{ end }}">
|
|
<div class="flex flex-column flex-row-ns">
|
|
<a href="{{ .Header.HMNHomepageUrl }}" class="hmn-logo bg-theme-dark">
|
|
Handmade
|
|
</a>
|
|
<div class="items flex items-center justify-center justify-start-ns ml2-ns ml3-l">
|
|
<div class="root-item">
|
|
<a href="{{ .Header.ProjectIndexUrl }}">Projects</a>
|
|
</div>
|
|
<div class="root-item">
|
|
<a>Media <div class="dib svgicon ml1">{{ svg "chevron-down-thick" }}</div></a>
|
|
<div class="submenu b--theme-dark">
|
|
<a href="{{ .Header.PodcastUrl }}">Podcast</a>
|
|
<a href="https://handmadedev.show/" target="_blank">Handmade Dev Show</a>
|
|
</div>
|
|
</div>
|
|
<div class="root-item">
|
|
<a href="{{ .Header.ForumsUrl }}">Forums</a>
|
|
</div>
|
|
<div class="root-item">
|
|
<a>Resources <div class="dib svgicon ml1">{{ svg "chevron-down-thick" }}</div></a>
|
|
<div class="submenu b--theme-dark">
|
|
<a href="{{ .Header.LibraryUrl }}">Library</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<script type="text/javascript">
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
const header = document.querySelector('#site-header');
|
|
|
|
// set up dropdown stuff for mobile / touch
|
|
{
|
|
const rootItems = header.querySelectorAll('.root-item');
|
|
|
|
function clearDropdowns() {
|
|
for (const item of rootItems) {
|
|
item.classList.remove('clicked');
|
|
}
|
|
}
|
|
|
|
function clickDropdown(el) {
|
|
if (el.classList.contains('clicked')) {
|
|
clearDropdowns();
|
|
} else {
|
|
clearDropdowns();
|
|
el.classList.add('clicked');
|
|
}
|
|
}
|
|
|
|
for (const item of rootItems) {
|
|
if (item.querySelector('.submenu')) {
|
|
item.addEventListener('click', e => {
|
|
clickDropdown(item);
|
|
e.stopPropagation();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// set up login form
|
|
{
|
|
const loginPopup = document.getElementById("login-popup");
|
|
const loginLink = document.getElementById("login-link");
|
|
|
|
if (loginPopup !== null) {
|
|
loginLink.removeAttribute("href");
|
|
|
|
loginLink.onclick = () => {
|
|
loginPopup.classList.toggle("open");
|
|
}
|
|
}
|
|
|
|
for (const time of document.querySelectorAll('time')) {
|
|
const d = new Date(Date.parse(time.dateTime));
|
|
time.title = d.toLocaleString();
|
|
}
|
|
}
|
|
});
|
|
</script>
|