mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-31 18:17:29 +01:00
* feat: add shadcn * feat: add themes * feat: make sidebar use shadcn * feat: sort bg * feat: lint fixes * feat: make daisyui toggleable, add tooltips to sidebar, add work in progress docs page * fix: theme switching for shadcn * Fix minor profile.vue issue * feat: update docs, enlarge SidebarMenuButton and refine profile layout * feat: add testing page * feat: update css and remove comments from template * fix: create dropdown not opening due to tooltip interference also lint * fix: correct CSS selector for homebox in main.css to ensure proper theming functionality * feat: make theme switching actually kinda work for shadcn * fix: sidebar colours * fix: remove unused router import, made sidebar indicate active page and sort tailwind config linting * style: update styles * chore: remove unused duplicate code * style: refine theme management, CSS variables, get styles closer to original * feat: implement suggested changes * feat: better button size --------- Co-authored-by: Matt Kilgore <tankerkiller125@users.noreply.github.com>
91 lines
3.0 KiB
Vue
91 lines
3.0 KiB
Vue
<script setup lang="ts">
|
|
import { SIDEBAR_WIDTH_MOBILE, useSidebar } from "./utils";
|
|
import type { SidebarProps } from ".";
|
|
import { Sheet, SheetContent } from "@/components/ui/sheet";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
defineOptions({
|
|
inheritAttrs: false,
|
|
});
|
|
|
|
const props = withDefaults(defineProps<SidebarProps>(), {
|
|
side: "left",
|
|
variant: "sidebar",
|
|
collapsible: "offcanvas",
|
|
});
|
|
|
|
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
v-if="collapsible === 'none'"
|
|
:class="cn('flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground', props.class)"
|
|
v-bind="$attrs"
|
|
>
|
|
<slot />
|
|
</div>
|
|
|
|
<Sheet v-else-if="isMobile" :open="openMobile" v-bind="$attrs" @update:open="setOpenMobile">
|
|
<SheetContent
|
|
data-sidebar="sidebar"
|
|
data-mobile="true"
|
|
:side="side"
|
|
class="bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden"
|
|
:style="{
|
|
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
}"
|
|
>
|
|
<div class="flex size-full flex-col">
|
|
<slot />
|
|
</div>
|
|
</SheetContent>
|
|
</Sheet>
|
|
|
|
<div
|
|
v-else
|
|
class="group peer hidden md:block"
|
|
:data-state="state"
|
|
:data-collapsible="state === 'collapsed' ? collapsible : ''"
|
|
:data-variant="variant"
|
|
:data-side="side"
|
|
>
|
|
<!-- This is what handles the sidebar gap on desktop -->
|
|
<div
|
|
:class="
|
|
cn(
|
|
'duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear',
|
|
'group-data-[collapsible=offcanvas]:w-0',
|
|
'group-data-[side=right]:rotate-180',
|
|
variant === 'floating' || variant === 'inset'
|
|
? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]'
|
|
: 'group-data-[collapsible=icon]:w-[--sidebar-width-icon]'
|
|
)
|
|
"
|
|
/>
|
|
<div
|
|
:class="
|
|
cn(
|
|
'duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex',
|
|
side === 'left'
|
|
? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
|
|
: 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
|
|
// Adjust the padding for floating and inset variants.
|
|
variant === 'floating' || variant === 'inset'
|
|
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'
|
|
: 'group-data-[collapsible=icon]:w-[--sidebar-width-icon]',
|
|
props.class
|
|
)
|
|
"
|
|
v-bind="$attrs"
|
|
>
|
|
<div
|
|
data-sidebar="sidebar"
|
|
class="text-sidebar-foreground bg-sidebar group-data-[variant=floating]:border-sidebar-border flex size-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow"
|
|
>
|
|
<slot />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|