Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refined scrolling behavior of the main layout #526

Merged
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
4 changes: 2 additions & 2 deletions components/custom/Nav/icon/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<!-- TODO: Just a placeholder lol nobody would want a skull to be their icon -->
<NuxtLink class="flex items-center" to="/">
<Icon name="mdi:skull-crossbones" />
<h1 class="font-black">
<div class="font-black">
Enspire
</h1>
</div>
</NuxtLink>
</template>

Expand Down
4 changes: 2 additions & 2 deletions components/custom/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button } from '@/components/ui/button'

<template>
<div :class="cn('h-full', $attrs.class ?? '')">
<div class="space-y-3 py-4 backdrop-blur-3xl border-r-2 h-full mt-14">
<div class="space-y-3 py-4 backdrop-blur-3xl border-r-2 h-full">
<div class="px-3 py-2">
<div class="space-y-1 mt-2">
<NuxtLink to="/">
Expand Down Expand Up @@ -62,7 +62,7 @@ import { Button } from '@/components/ui/button'
<NuxtLink to="/about">
<Button :variant="$route.name === 'about' ? 'secondary' : 'ghost'" class="w-full justify-start">
<Icon class="mr-2 h-4 w-4" name="material-symbols:info-outline" />
关于我们
关于 Enspire
</Button>
</NuxtLink>
</div>
Expand Down
63 changes: 40 additions & 23 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,49 @@ watch(
</script>

<template>
<!--
Current main layout structure
column flex [overflow-hidden, 100vh]:
navbar [fixed height]
row flex [occupies the rest of the screen]:
sidebar [100% height, overflow-scroll]
main content [100% height, overflow-scroll, additional whitespace in the bottom (that fills the space clipped by the main container)]
-->
<div class="h-screen">
<div class="border-b px-4 fixed top-0 w-full backdrop-blur-3xl z-40">
<div class="flex h-14 items-center">
<Toggle class="lg:hidden" data-state="off" @click="toggleSidebar">
<Icon name="ph:list" size="1.3em" />
</Toggle>
<CustomNavIcon class="ml-4" />

<div class="ml-auto flex items-center space-x-4">
<CustomNavUser />
<div class="top-0 flex flex-col h-full overflow-hidden">
<!-- Navbar -->
<div class="border-b px-4 w-full backdrop-blur-3xl">
<div class="flex h-14 items-center">
<Toggle class="lg:hidden" data-state="off" @click="toggleSidebar">
<Icon name="ph:list" size="1.3em" />
</Toggle>
<CustomNavIcon class="ml-4" />

<div class="ml-auto flex items-center space-x-4">
<CustomNavUser />
</div>
</div>
</div>
</div>
<div
class="fixed top-0 left-0 z-20 h-full transition-all duration-500 w-screen"
:class="{ 'transform -translate-x-full': !isSidebarOpen, 'transform translate-x-0': isSidebarOpen }"
>
<Sidebar class="mt-14" />
</div>
<div class="relative h-full">
<div class="border-t h-full">
<div class="bg-background">
<div class="flex flex-row">
<Sidebar class="sticky top-0 hidden lg:block h-screen w-1/6" />
<div class="h-full px-4 py-6 lg:px-8 w-full mt-14">
<slot />

<!-- Sidebar -->
<div
class="fixed top-0 left-0 z-20 h-full transition-all duration-500 w-screen"
:class="{ 'transform -translate-x-full': !isSidebarOpen, 'transform translate-x-0': isSidebarOpen }"
>
<Sidebar class="mt-14" />
</div>

<!-- Main area -->
<div class="grow grow-1 max-h-full">
<div class="border-t h-full">
<div class="bg-background h-full">
<div class="flex flex-row h-full">
<!-- Sidebar -->
<Sidebar class="top-0 hidden lg:inline-block h-full w-1/6" />
<!-- Main content -->
<div class="h-full px-4 lg:px-8 w-full pt-8 pb-24 overflow-y-scroll">
<slot />
</div>
</div>
</div>
</div>
Expand Down
Loading