Skip to content

Commit 7e8f129

Browse files
committed
chore: wrap direction content
1 parent e30f17d commit 7e8f129

File tree

2 files changed

+77
-34
lines changed

2 files changed

+77
-34
lines changed
+33-34
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
11
<script setup lang="ts">
2-
import { DrawerContent, DrawerOverlay, DrawerPortal, DrawerRoot, DrawerTrigger } from 'vaul-vue'
2+
import { type DrawerDirection, DrawerOverlay, DrawerPortal, DrawerRoot, DrawerTrigger } from 'vaul-vue'
3+
import { ref } from 'vue'
4+
import DrawerContentWrapper from './DrawerContent.vue'
5+
6+
const direction = ref<DrawerDirection>('bottom')
37
</script>
48

59
<template>
6-
<DrawerRoot should-scale-background direction="left">
10+
<DrawerRoot should-scale-background :direction="direction">
711
<DrawerTrigger
812
class="rounded-full bg-white px-4 py-2.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
913
>
1014
Open Drawer
1115
</DrawerTrigger>
1216
<DrawerPortal>
1317
<DrawerOverlay class="fixed bg-black/40 inset-0" />
14-
<DrawerContent
15-
class="bg-gray-100 flex flex-col rounded-t-[10px] h-full mt-24 max-h-[96%] fixed bottom-0 left-0 right-0"
16-
>
17-
<div class="p-4 bg-white rounded-t-[10px] flex-1">
18-
<div class="mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-gray-300 mb-8" />
19-
<div class="max-w-md mx-auto">
20-
<h2 id="radix-:R3emdaH1:" class="font-medium mb-4">
21-
Drawer for Vue.
22-
</h2>
23-
<p class="text-gray-600 mb-2">
24-
This component can be used as a Dialog replacement on mobile and tablet devices.
25-
</p>
26-
<p class="text-gray-600 mb-2">
27-
It comes unstyled, has gesture-driven animations, and is made by
28-
<a href="https://emilkowal.ski/" class="underline" target="_blank">Emil Kowalski</a>.
29-
</p>
30-
<p class="text-gray-600 mb-8">
31-
It uses
32-
<a
33-
href="https://www.radix-ui.com/docs/primitives/components/dialog"
34-
class="underline"
35-
target="_blank"
36-
>Radix's Dialog primitive</a>
37-
under the hood and is inspired by
38-
<a
39-
href="https://twitter.com/devongovett/status/1674470185783402496"
40-
class="underline"
41-
target="_blank"
42-
>this tweet.</a>
43-
</p>
44-
</div>
18+
<DrawerContentWrapper :direction="direction">
19+
<div class="max-w-md mx-auto">
20+
<h2 id="radix-:R3emdaH1:" class="font-medium mb-4">
21+
Drawer for Vue.
22+
</h2>
23+
<p class="text-gray-600 mb-2">
24+
This component can be used as a Dialog replacement on mobile and tablet devices.
25+
</p>
26+
<p class="text-gray-600 mb-2">
27+
It comes unstyled, has gesture-driven animations, and is made by
28+
<a href="https://emilkowal.ski/" class="underline" target="_blank">Emil Kowalski</a>.
29+
</p>
30+
<p class="text-gray-600 mb-8">
31+
It uses
32+
<a
33+
href="https://www.radix-ui.com/docs/primitives/components/dialog"
34+
class="underline"
35+
target="_blank"
36+
>Radix's Dialog primitive</a>
37+
under the hood and is inspired by
38+
<a
39+
href="https://twitter.com/devongovett/status/1674470185783402496"
40+
class="underline"
41+
target="_blank"
42+
>this tweet.</a>
43+
</p>
4544
</div>
46-
</DrawerContent>
45+
</DrawerContentWrapper>
4746
</DrawerPortal>
4847
</DrawerRoot>
4948
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<script setup lang="ts">
2+
import { DrawerContent, type DrawerDirection } from 'vaul-vue'
3+
4+
const props = withDefaults(defineProps<{
5+
direction: DrawerDirection
6+
}>(), {
7+
direction: 'bottom',
8+
})
9+
</script>
10+
11+
<template>
12+
<DrawerContent
13+
data-testid="content"
14+
class="bg-zinc-100 flex fixed p-6"
15+
:class="{
16+
'rounded-t-[10px] flex-col h-[50%] bottom-0 left-0 right-0': direction === 'bottom',
17+
'rounded-b-[10px] flex-col h-[50%] top-0 left-0 right-0': direction === 'top',
18+
'rounded-r-[10px] flex-row w-[50%] left-0 top-0 bottom-0': direction === 'left',
19+
'rounded-l-[10px] flex-row w-[50%] right-0 top-0 bottom-0': direction === 'right',
20+
}"
21+
>
22+
<div
23+
class="w-full h-full flex rounded-full gap-8"
24+
:class="{
25+
'flex-col': direction === 'bottom',
26+
'flex-col-reverse': direction === 'top',
27+
'flex-row-reverse': direction === 'left',
28+
'flex-row ': direction === 'right',
29+
}"
30+
>
31+
<div
32+
class="rounded-full bg-zinc-300"
33+
:class="{
34+
'mx-auto w-12 h-1.5': direction === 'top' || direction === 'bottom',
35+
'my-auto h-12 w-1.5': direction === 'left' || direction === 'right',
36+
}"
37+
/>
38+
39+
<div class="grid place-content-center w-full h-full">
40+
<slot />
41+
</div>
42+
</div>
43+
</DrawerContent>
44+
</template>

0 commit comments

Comments
 (0)