mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-17 05:43:51 +02:00
sidebar component
This commit is contained in:
18
src/components/ui/sheet/Sheet.vue
Normal file
18
src/components/ui/sheet/Sheet.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<script setup>
|
||||
import { DialogRoot, useForwardPropsEmits } from 'reka-ui';
|
||||
|
||||
const props = defineProps({
|
||||
open: { type: Boolean, required: false },
|
||||
defaultOpen: { type: Boolean, required: false },
|
||||
modal: { type: Boolean, required: false }
|
||||
});
|
||||
const emits = defineEmits(['update:open']);
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogRoot v-slot="slotProps" data-slot="sheet" v-bind="forwarded">
|
||||
<slot v-bind="slotProps" />
|
||||
</DialogRoot>
|
||||
</template>
|
||||
14
src/components/ui/sheet/SheetClose.vue
Normal file
14
src/components/ui/sheet/SheetClose.vue
Normal file
@@ -0,0 +1,14 @@
|
||||
<script setup>
|
||||
import { DialogClose } from 'reka-ui';
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: null, required: false }
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogClose data-slot="sheet-close" v-bind="props">
|
||||
<slot />
|
||||
</DialogClose>
|
||||
</template>
|
||||
64
src/components/ui/sheet/SheetContent.vue
Normal file
64
src/components/ui/sheet/SheetContent.vue
Normal file
@@ -0,0 +1,64 @@
|
||||
<script setup>
|
||||
import { DialogClose, DialogContent, DialogPortal, useForwardPropsEmits } from 'reka-ui';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { reactiveOmit } from '@vueuse/core';
|
||||
|
||||
import SheetOverlay from './SheetOverlay.vue';
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: null, required: false },
|
||||
side: { type: String, required: false, default: 'right' },
|
||||
forceMount: { type: Boolean, required: false },
|
||||
disableOutsidePointerEvents: { type: Boolean, required: false },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: null, required: false }
|
||||
});
|
||||
const emits = defineEmits([
|
||||
'escapeKeyDown',
|
||||
'pointerDownOutside',
|
||||
'focusOutside',
|
||||
'interactOutside',
|
||||
'openAutoFocus',
|
||||
'closeAutoFocus'
|
||||
]);
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'side');
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<SheetOverlay />
|
||||
<DialogContent
|
||||
data-slot="sheet-content"
|
||||
:class="
|
||||
cn(
|
||||
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
|
||||
side === 'right' &&
|
||||
'data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm',
|
||||
side === 'left' &&
|
||||
'data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm',
|
||||
side === 'top' &&
|
||||
'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b',
|
||||
side === 'bottom' &&
|
||||
'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t',
|
||||
props.class
|
||||
)
|
||||
"
|
||||
v-bind="{ ...$attrs, ...forwarded }">
|
||||
<slot />
|
||||
|
||||
<DialogClose
|
||||
class="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
|
||||
<X class="size-4" />
|
||||
<span class="sr-only">Close</span>
|
||||
</DialogClose>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</template>
|
||||
22
src/components/ui/sheet/SheetDescription.vue
Normal file
22
src/components/ui/sheet/SheetDescription.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<script setup>
|
||||
import { DialogDescription } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { reactiveOmit } from '@vueuse/core';
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false }
|
||||
});
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogDescription
|
||||
data-slot="sheet-description"
|
||||
:class="cn('text-muted-foreground text-sm', props.class)"
|
||||
v-bind="delegatedProps">
|
||||
<slot />
|
||||
</DialogDescription>
|
||||
</template>
|
||||
13
src/components/ui/sheet/SheetFooter.vue
Normal file
13
src/components/ui/sheet/SheetFooter.vue
Normal file
@@ -0,0 +1,13 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: null, required: false }
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="sheet-footer" :class="cn('mt-auto flex flex-col gap-2 p-4', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
13
src/components/ui/sheet/SheetHeader.vue
Normal file
13
src/components/ui/sheet/SheetHeader.vue
Normal file
@@ -0,0 +1,13 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: null, required: false }
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="sheet-header" :class="cn('flex flex-col gap-1.5 p-4', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
28
src/components/ui/sheet/SheetOverlay.vue
Normal file
28
src/components/ui/sheet/SheetOverlay.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<script setup>
|
||||
import { DialogOverlay } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { reactiveOmit } from '@vueuse/core';
|
||||
|
||||
const props = defineProps({
|
||||
forceMount: { type: Boolean, required: false },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false }
|
||||
});
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogOverlay
|
||||
data-slot="sheet-overlay"
|
||||
:class="
|
||||
cn(
|
||||
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80',
|
||||
props.class
|
||||
)
|
||||
"
|
||||
v-bind="delegatedProps">
|
||||
<slot />
|
||||
</DialogOverlay>
|
||||
</template>
|
||||
22
src/components/ui/sheet/SheetTitle.vue
Normal file
22
src/components/ui/sheet/SheetTitle.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<script setup>
|
||||
import { DialogTitle } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { reactiveOmit } from '@vueuse/core';
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false }
|
||||
});
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogTitle
|
||||
data-slot="sheet-title"
|
||||
:class="cn('text-foreground font-semibold', props.class)"
|
||||
v-bind="delegatedProps">
|
||||
<slot />
|
||||
</DialogTitle>
|
||||
</template>
|
||||
14
src/components/ui/sheet/SheetTrigger.vue
Normal file
14
src/components/ui/sheet/SheetTrigger.vue
Normal file
@@ -0,0 +1,14 @@
|
||||
<script setup>
|
||||
import { DialogTrigger } from 'reka-ui';
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: null, required: false }
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogTrigger data-slot="sheet-trigger" v-bind="props">
|
||||
<slot />
|
||||
</DialogTrigger>
|
||||
</template>
|
||||
8
src/components/ui/sheet/index.js
Normal file
8
src/components/ui/sheet/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export { default as Sheet } from './Sheet.vue';
|
||||
export { default as SheetClose } from './SheetClose.vue';
|
||||
export { default as SheetContent } from './SheetContent.vue';
|
||||
export { default as SheetDescription } from './SheetDescription.vue';
|
||||
export { default as SheetFooter } from './SheetFooter.vue';
|
||||
export { default as SheetHeader } from './SheetHeader.vue';
|
||||
export { default as SheetTitle } from './SheetTitle.vue';
|
||||
export { default as SheetTrigger } from './SheetTrigger.vue';
|
||||
108
src/components/ui/sidebar/Sidebar.vue
Normal file
108
src/components/ui/sidebar/Sidebar.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<script setup>
|
||||
import { Sheet, SheetContent } from '@/components/ui/sheet';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import SheetDescription from '@/components/ui/sheet/SheetDescription.vue';
|
||||
import SheetHeader from '@/components/ui/sheet/SheetHeader.vue';
|
||||
import SheetTitle from '@/components/ui/sheet/SheetTitle.vue';
|
||||
|
||||
import { SIDEBAR_WIDTH_MOBILE, useSidebar } from './utils';
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
side: {
|
||||
type: String,
|
||||
default: 'left'
|
||||
},
|
||||
variant: {
|
||||
type: String,
|
||||
default: 'sidebar'
|
||||
},
|
||||
collapsible: {
|
||||
type: String,
|
||||
default: 'offcanvas'
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="collapsible === 'none'"
|
||||
data-slot="sidebar"
|
||||
:class="cn('bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col', 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-slot="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
|
||||
}">
|
||||
<SheetHeader class="sr-only">
|
||||
<SheetTitle>Sidebar</SheetTitle>
|
||||
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
||||
</SheetHeader>
|
||||
<div class="flex h-full w-full flex-col">
|
||||
<slot />
|
||||
</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="group peer text-sidebar-foreground hidden md:block"
|
||||
data-slot="sidebar"
|
||||
: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(
|
||||
'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 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)+(--spacing(4)))]'
|
||||
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)'
|
||||
)
|
||||
" />
|
||||
<div
|
||||
:class="
|
||||
cn(
|
||||
'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 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)+(--spacing(4))+2px)]'
|
||||
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
|
||||
props.class
|
||||
)
|
||||
"
|
||||
v-bind="$attrs">
|
||||
<div
|
||||
data-sidebar="sidebar"
|
||||
class="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
24
src/components/ui/sidebar/SidebarContent.vue
Normal file
24
src/components/ui/sidebar/SidebarContent.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="sidebar-content"
|
||||
data-sidebar="content"
|
||||
:class="
|
||||
cn(
|
||||
'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
16
src/components/ui/sidebar/SidebarFooter.vue
Normal file
16
src/components/ui/sidebar/SidebarFooter.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="sidebar-footer" data-sidebar="footer" :class="cn('flex flex-col gap-2 p-2', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
19
src/components/ui/sidebar/SidebarGroup.vue
Normal file
19
src/components/ui/sidebar/SidebarGroup.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="sidebar-group"
|
||||
data-sidebar="group"
|
||||
:class="cn('relative flex w-full min-w-0 flex-col p-2', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
37
src/components/ui/sidebar/SidebarGroupAction.vue
Normal file
37
src/components/ui/sidebar/SidebarGroupAction.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<script setup>
|
||||
import { Primitive } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
as: {
|
||||
type: [String, Object, Function],
|
||||
default: 'button'
|
||||
},
|
||||
asChild: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
data-slot="sidebar-group-action"
|
||||
data-sidebar="group-action"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:class="
|
||||
cn(
|
||||
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
||||
'after:absolute after:-inset-2 md:after:hidden',
|
||||
'group-data-[collapsible=icon]:hidden',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
16
src/components/ui/sidebar/SidebarGroupContent.vue
Normal file
16
src/components/ui/sidebar/SidebarGroupContent.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="sidebar-group-content" data-sidebar="group-content" :class="cn('w-full text-sm', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
36
src/components/ui/sidebar/SidebarGroupLabel.vue
Normal file
36
src/components/ui/sidebar/SidebarGroupLabel.vue
Normal file
@@ -0,0 +1,36 @@
|
||||
<script setup>
|
||||
import { Primitive } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
as: {
|
||||
type: [String, Object, Function],
|
||||
default: 'div'
|
||||
},
|
||||
asChild: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
data-slot="sidebar-group-label"
|
||||
data-sidebar="group-label"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:class="
|
||||
cn(
|
||||
'text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
||||
'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
16
src/components/ui/sidebar/SidebarHeader.vue
Normal file
16
src/components/ui/sidebar/SidebarHeader.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="sidebar-header" data-sidebar="header" :class="cn('flex flex-col gap-2 p-2', props.class)">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
20
src/components/ui/sidebar/SidebarInput.vue
Normal file
20
src/components/ui/sidebar/SidebarInput.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<script setup>
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Input
|
||||
data-slot="sidebar-input"
|
||||
data-sidebar="input"
|
||||
:class="cn('bg-background h-8 w-full shadow-none', props.class)">
|
||||
<slot />
|
||||
</Input>
|
||||
</template>
|
||||
24
src/components/ui/sidebar/SidebarInset.vue
Normal file
24
src/components/ui/sidebar/SidebarInset.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main
|
||||
data-slot="sidebar-inset"
|
||||
:class="
|
||||
cn(
|
||||
'bg-background relative flex w-full flex-1 flex-col',
|
||||
'md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</main>
|
||||
</template>
|
||||
16
src/components/ui/sidebar/SidebarMenu.vue
Normal file
16
src/components/ui/sidebar/SidebarMenu.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul data-slot="sidebar-menu" data-sidebar="menu" :class="cn('flex w-full min-w-0 flex-col gap-1', props.class)">
|
||||
<slot />
|
||||
</ul>
|
||||
</template>
|
||||
46
src/components/ui/sidebar/SidebarMenuAction.vue
Normal file
46
src/components/ui/sidebar/SidebarMenuAction.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<script setup>
|
||||
import { Primitive } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
as: {
|
||||
type: [String, Object, Function],
|
||||
default: 'button'
|
||||
},
|
||||
asChild: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showOnHover: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
data-slot="sidebar-menu-action"
|
||||
data-sidebar="menu-action"
|
||||
:class="
|
||||
cn(
|
||||
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
||||
'after:absolute after:-inset-2 md:after:hidden',
|
||||
'peer-data-[size=sm]/menu-button:top-1',
|
||||
'peer-data-[size=default]/menu-button:top-1.5',
|
||||
'peer-data-[size=lg]/menu-button:top-2.5',
|
||||
'group-data-[collapsible=icon]:hidden',
|
||||
showOnHover &&
|
||||
'peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0',
|
||||
props.class
|
||||
)
|
||||
"
|
||||
:as="as"
|
||||
:as-child="asChild">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
29
src/components/ui/sidebar/SidebarMenuBadge.vue
Normal file
29
src/components/ui/sidebar/SidebarMenuBadge.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="sidebar-menu-badge"
|
||||
data-sidebar="menu-badge"
|
||||
:class="
|
||||
cn(
|
||||
'text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none',
|
||||
'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
|
||||
'peer-data-[size=sm]/menu-button:top-1',
|
||||
'peer-data-[size=default]/menu-button:top-1.5',
|
||||
'peer-data-[size=lg]/menu-button:top-2.5',
|
||||
'group-data-[collapsible=icon]:hidden',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
67
src/components/ui/sidebar/SidebarMenuButton.vue
Normal file
67
src/components/ui/sidebar/SidebarMenuButton.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<script setup>
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { reactiveOmit } from '@vueuse/core';
|
||||
|
||||
import { useSidebar } from './utils';
|
||||
|
||||
import SidebarMenuButtonChild from './SidebarMenuButtonChild.vue';
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
as: {
|
||||
type: [String, Object, Function],
|
||||
default: 'button'
|
||||
},
|
||||
asChild: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
variant: {
|
||||
type: String,
|
||||
default: 'default'
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'default'
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
tooltip: {
|
||||
type: [String, Object, Function],
|
||||
default: undefined
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const { isMobile, state } = useSidebar();
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'tooltip');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SidebarMenuButtonChild v-if="!tooltip" v-bind="{ ...delegatedProps, ...$attrs }">
|
||||
<slot />
|
||||
</SidebarMenuButtonChild>
|
||||
|
||||
<Tooltip v-else>
|
||||
<TooltipTrigger as-child>
|
||||
<SidebarMenuButtonChild v-bind="{ ...delegatedProps, ...$attrs }">
|
||||
<slot />
|
||||
</SidebarMenuButtonChild>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" align="center" :hidden="state !== 'collapsed' || isMobile">
|
||||
<template v-if="typeof tooltip === 'string'">
|
||||
{{ tooltip }}
|
||||
</template>
|
||||
<component :is="tooltip" v-else />
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</template>
|
||||
47
src/components/ui/sidebar/SidebarMenuButtonChild.vue
Normal file
47
src/components/ui/sidebar/SidebarMenuButtonChild.vue
Normal file
@@ -0,0 +1,47 @@
|
||||
<script setup>
|
||||
import { Primitive } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { sidebarMenuButtonVariants } from '.';
|
||||
|
||||
const props = defineProps({
|
||||
as: {
|
||||
type: [String, Object, Function],
|
||||
default: 'button'
|
||||
},
|
||||
asChild: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
variant: {
|
||||
type: String,
|
||||
default: 'default'
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'default'
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
data-slot="sidebar-menu-button"
|
||||
data-sidebar="menu-button"
|
||||
:data-size="size"
|
||||
:data-active="isActive"
|
||||
:class="cn(sidebarMenuButtonVariants({ variant, size }), props.class)"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
v-bind="$attrs">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
16
src/components/ui/sidebar/SidebarMenuItem.vue
Normal file
16
src/components/ui/sidebar/SidebarMenuItem.vue
Normal file
@@ -0,0 +1,16 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" :class="cn('group/menu-item relative', props.class)">
|
||||
<slot />
|
||||
</li>
|
||||
</template>
|
||||
34
src/components/ui/sidebar/SidebarMenuSkeleton.vue
Normal file
34
src/components/ui/sidebar/SidebarMenuSkeleton.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<script setup>
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
showIcon: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const width = computed(() => {
|
||||
return `${Math.floor(Math.random() * 40) + 50}%`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="sidebar-menu-skeleton"
|
||||
data-sidebar="menu-skeleton"
|
||||
:class="cn('flex h-8 items-center gap-2 rounded-md px-2', props.class)">
|
||||
<Skeleton v-if="showIcon" class="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />
|
||||
|
||||
<Skeleton
|
||||
class="h-4 max-w-(--skeleton-width) flex-1"
|
||||
data-sidebar="menu-skeleton-text"
|
||||
:style="{ '--skeleton-width': width }" />
|
||||
</div>
|
||||
</template>
|
||||
25
src/components/ui/sidebar/SidebarMenuSub.vue
Normal file
25
src/components/ui/sidebar/SidebarMenuSub.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul
|
||||
data-slot="sidebar-menu-sub"
|
||||
data-sidebar="menu-badge"
|
||||
:class="
|
||||
cn(
|
||||
'border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5',
|
||||
'group-data-[collapsible=icon]:hidden',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</ul>
|
||||
</template>
|
||||
49
src/components/ui/sidebar/SidebarMenuSubButton.vue
Normal file
49
src/components/ui/sidebar/SidebarMenuSubButton.vue
Normal file
@@ -0,0 +1,49 @@
|
||||
<script setup>
|
||||
import { Primitive } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
as: {
|
||||
type: [String, Object, Function],
|
||||
default: 'a'
|
||||
},
|
||||
asChild: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'md'
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
data-slot="sidebar-menu-sub-button"
|
||||
data-sidebar="menu-sub-button"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:data-size="size"
|
||||
:data-active="isActive"
|
||||
:class="
|
||||
cn(
|
||||
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
|
||||
'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground',
|
||||
size === 'sm' && 'text-xs',
|
||||
size === 'md' && 'text-sm',
|
||||
'group-data-[collapsible=icon]:hidden',
|
||||
props.class
|
||||
)
|
||||
">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
19
src/components/ui/sidebar/SidebarMenuSubItem.vue
Normal file
19
src/components/ui/sidebar/SidebarMenuSubItem.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<li
|
||||
data-slot="sidebar-menu-sub-item"
|
||||
data-sidebar="menu-sub-item"
|
||||
:class="cn('group/menu-sub-item relative', props.class)">
|
||||
<slot />
|
||||
</li>
|
||||
</template>
|
||||
92
src/components/ui/sidebar/SidebarProvider.vue
Normal file
92
src/components/ui/sidebar/SidebarProvider.vue
Normal file
@@ -0,0 +1,92 @@
|
||||
<script setup>
|
||||
import { defaultDocument, useEventListener, useMediaQuery, useVModel } from '@vueuse/core';
|
||||
import { computed, ref } from 'vue';
|
||||
import { TooltipProvider } from 'reka-ui';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import {
|
||||
SIDEBAR_COOKIE_MAX_AGE,
|
||||
SIDEBAR_COOKIE_NAME,
|
||||
SIDEBAR_KEYBOARD_SHORTCUT,
|
||||
SIDEBAR_WIDTH,
|
||||
SIDEBAR_WIDTH_ICON,
|
||||
provideSidebarContext
|
||||
} from './utils';
|
||||
|
||||
const props = defineProps({
|
||||
defaultOpen: {
|
||||
type: Boolean,
|
||||
default: () => !defaultDocument?.cookie.includes(`${SIDEBAR_COOKIE_NAME}=false`)
|
||||
},
|
||||
open: {
|
||||
type: Boolean,
|
||||
default: undefined
|
||||
},
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const emits = defineEmits(['update:open']);
|
||||
|
||||
const isMobile = useMediaQuery('(max-width: 768px)');
|
||||
const openMobile = ref(false);
|
||||
|
||||
const open = useVModel(props, 'open', emits, {
|
||||
defaultValue: props.defaultOpen ?? false,
|
||||
passive: props.open === undefined
|
||||
});
|
||||
|
||||
function setOpen(value) {
|
||||
open.value = value; // emits('update:open', value)
|
||||
|
||||
// This sets the cookie to keep the sidebar state.
|
||||
document.cookie = `${SIDEBAR_COOKIE_NAME}=${open.value}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
||||
}
|
||||
|
||||
function setOpenMobile(value) {
|
||||
openMobile.value = value;
|
||||
}
|
||||
|
||||
// Helper to toggle the sidebar.
|
||||
function toggleSidebar() {
|
||||
return isMobile.value ? setOpenMobile(!openMobile.value) : setOpen(!open.value);
|
||||
}
|
||||
|
||||
useEventListener('keydown', (event) => {
|
||||
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
||||
event.preventDefault();
|
||||
toggleSidebar();
|
||||
}
|
||||
});
|
||||
|
||||
// We add a state so that we can do data-state="expanded" or "collapsed".
|
||||
// This makes it easier to style the sidebar with Tailwind classes.
|
||||
const state = computed(() => (open.value ? 'expanded' : 'collapsed'));
|
||||
|
||||
provideSidebarContext({
|
||||
state,
|
||||
open,
|
||||
setOpen,
|
||||
isMobile,
|
||||
openMobile,
|
||||
setOpenMobile,
|
||||
toggleSidebar
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipProvider :delay-duration="0">
|
||||
<div
|
||||
data-slot="sidebar-wrapper"
|
||||
:style="{
|
||||
'--sidebar-width': SIDEBAR_WIDTH,
|
||||
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON
|
||||
}"
|
||||
:class="cn('group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full', props.class)"
|
||||
v-bind="$attrs">
|
||||
<slot />
|
||||
</div>
|
||||
</TooltipProvider>
|
||||
</template>
|
||||
37
src/components/ui/sidebar/SidebarRail.vue
Normal file
37
src/components/ui/sidebar/SidebarRail.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<script setup>
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { useSidebar } from './utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const { toggleSidebar } = useSidebar();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
data-sidebar="rail"
|
||||
data-slot="sidebar-rail"
|
||||
aria-label="Toggle Sidebar"
|
||||
:tabindex="-1"
|
||||
title="Toggle Sidebar"
|
||||
:class="
|
||||
cn(
|
||||
'hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex',
|
||||
'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
|
||||
'[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
|
||||
'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
|
||||
'[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
|
||||
'[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
|
||||
props.class
|
||||
)
|
||||
"
|
||||
@click="toggleSidebar">
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
||||
20
src/components/ui/sidebar/SidebarSeparator.vue
Normal file
20
src/components/ui/sidebar/SidebarSeparator.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<script setup>
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Separator
|
||||
data-slot="sidebar-separator"
|
||||
data-sidebar="separator"
|
||||
:class="cn('bg-sidebar-border mx-2 w-auto', props.class)">
|
||||
<slot />
|
||||
</Separator>
|
||||
</template>
|
||||
29
src/components/ui/sidebar/SidebarTrigger.vue
Normal file
29
src/components/ui/sidebar/SidebarTrigger.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<script setup>
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { PanelLeft } from 'lucide-vue-next';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { useSidebar } from './utils';
|
||||
|
||||
const props = defineProps({
|
||||
class: {
|
||||
type: [String, Array, Object],
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
const { toggleSidebar } = useSidebar();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button
|
||||
data-sidebar="trigger"
|
||||
data-slot="sidebar-trigger"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
:class="cn('h-7 w-7', props.class)"
|
||||
@click="toggleSidebar">
|
||||
<PanelLeft />
|
||||
<span class="sr-only">Toggle Sidebar</span>
|
||||
</Button>
|
||||
</template>
|
||||
50
src/components/ui/sidebar/index.js
Normal file
50
src/components/ui/sidebar/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import { cva } from 'class-variance-authority';
|
||||
|
||||
export { default as Sidebar } from './Sidebar.vue';
|
||||
export { default as SidebarContent } from './SidebarContent.vue';
|
||||
export { default as SidebarFooter } from './SidebarFooter.vue';
|
||||
export { default as SidebarGroup } from './SidebarGroup.vue';
|
||||
export { default as SidebarGroupAction } from './SidebarGroupAction.vue';
|
||||
export { default as SidebarGroupContent } from './SidebarGroupContent.vue';
|
||||
export { default as SidebarGroupLabel } from './SidebarGroupLabel.vue';
|
||||
export { default as SidebarHeader } from './SidebarHeader.vue';
|
||||
export { default as SidebarInput } from './SidebarInput.vue';
|
||||
export { default as SidebarInset } from './SidebarInset.vue';
|
||||
export { default as SidebarMenu } from './SidebarMenu.vue';
|
||||
export { default as SidebarMenuAction } from './SidebarMenuAction.vue';
|
||||
export { default as SidebarMenuBadge } from './SidebarMenuBadge.vue';
|
||||
export { default as SidebarMenuButton } from './SidebarMenuButton.vue';
|
||||
export { default as SidebarMenuItem } from './SidebarMenuItem.vue';
|
||||
export { default as SidebarMenuSkeleton } from './SidebarMenuSkeleton.vue';
|
||||
export { default as SidebarMenuSub } from './SidebarMenuSub.vue';
|
||||
export { default as SidebarMenuSubButton } from './SidebarMenuSubButton.vue';
|
||||
export { default as SidebarMenuSubItem } from './SidebarMenuSubItem.vue';
|
||||
export { default as SidebarProvider } from './SidebarProvider.vue';
|
||||
export { default as SidebarRail } from './SidebarRail.vue';
|
||||
export { default as SidebarSeparator } from './SidebarSeparator.vue';
|
||||
export { default as SidebarTrigger } from './SidebarTrigger.vue';
|
||||
|
||||
export { useSidebar } from './utils';
|
||||
|
||||
export const sidebarMenuButtonVariants = cva(
|
||||
'peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
outline:
|
||||
'bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]'
|
||||
},
|
||||
size: {
|
||||
default: 'h-8 text-sm',
|
||||
sm: 'h-7 text-xs',
|
||||
lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!'
|
||||
}
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default'
|
||||
}
|
||||
}
|
||||
);
|
||||
10
src/components/ui/sidebar/utils.js
Normal file
10
src/components/ui/sidebar/utils.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createContext } from 'reka-ui';
|
||||
|
||||
export const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
||||
export const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
||||
export const SIDEBAR_WIDTH = '16rem';
|
||||
export const SIDEBAR_WIDTH_MOBILE = '18rem';
|
||||
export const SIDEBAR_WIDTH_ICON = '3rem';
|
||||
export const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
||||
|
||||
export const [useSidebar, provideSidebarContext] = createContext('Sidebar');
|
||||
Reference in New Issue
Block a user