chore: add new sidebar template

This commit is contained in:
Xin 2024-04-04 21:57:17 +00:00
parent f40c7fd5d4
commit 462cc5b68d
3 changed files with 44 additions and 3 deletions

View File

@ -1,5 +1,5 @@
@media (max-width: 767px) {
.sidebar-container {
.hextra-sidebar-container {
@apply hx-fixed hx-pt-[calc(var(--navbar-height))] hx-top-0 hx-w-full hx-bottom-0 hx-z-[15] hx-overscroll-contain hx-bg-white dark:hx-bg-dark;
transition: transform 0.8s cubic-bezier(0.52, 0.16, 0.04, 1);
will-change: transform, opacity;
@ -8,7 +8,7 @@
}
}
.sidebar-container {
.hextra-sidebar-container {
li > div {
@apply hx-h-0;
}

View File

@ -3,7 +3,7 @@
document.addEventListener('DOMContentLoaded', function () {
const menu = document.querySelector('.hamburger-menu');
const overlay = document.querySelector('.mobile-menu-overlay');
const sidebarContainer = document.querySelector('.sidebar-container');
const sidebarContainer = document.querySelector('.hextra-sidebar-container');
// Initialize the overlay
const overlayClasses = ['hx-fixed', 'hx-inset-0', 'hx-z-10', 'hx-bg-black/80', 'dark:hx-bg-black/60'];

View File

@ -0,0 +1,41 @@
{{- $context := .context -}}
{{- $disableSidebar := .disableSidebar | default false -}}
{{- $displayPlaceholder := .displayPlaceholder | default false -}}
{{- $sidebarClass := cond $disableSidebar (cond $displayPlaceholder "md:hidden xl:block" "md:hidden") "md:sticky" -}}
{{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}}
{{- $pageURL := $context.RelPermalink -}}
{{ $data := partialCached "components/sidebar/read-data" $context $context.FirstSection }}
<aside class="hextra-sidebar-container flex flex-col print:hidden md:top-16 md:shrink-0 md:w-64 md:self-start max-md:[transform:translate3d(0,-100%,0)] {{ $sidebarClass }}">
{{/* Search bar on small screen */}}
{{- partialCached "sidebar/mobile-search" . -}}
<div class="hextra-scrollbar overflow-y-auto overflow-x-hidden p-4 grow md:h-[calc(100vh-var(--navbar-height)-var(--menu-height))]">
<ul class="flex flex-col gap-1 md:hidden"></ul>
</div>
{{/* Sidebar on large screen */}}
<ul class="flex flex-col gap-1 max-md:hx-hidden"></ul>
</aside>
{{ with $data }}
{{ warnf "The data file for the sidebar is still unstable. Please use caution when upgrading." }}
<pre>
{{ . | jsonify (dict "indent" " ") }}
</pre
>
{{ else }}
{{ end }}
{{- define "partials/sidebar/mobile-search" -}}
<div class="px-4 pt-4 md:hx-hidden">
{{- partialCached "search.html" . -}}
</div>
{{- end -}}