Skip to content

Commit 37a82ad

Browse files
committed
feat: created wrapper component
1 parent e008bb5 commit 37a82ad

File tree

2 files changed

+34
-36
lines changed

2 files changed

+34
-36
lines changed

playground/App.vue

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup lang="ts">
2-
// This starter template is using Vue 3 <script setup> SFCs
3-
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
42
import SimpleDropdown from '@/VueSimpleDropdown.vue'
53
import { ref } from 'vue'
64
@@ -11,7 +9,36 @@ const example = ref('vue-simple-dropdown')
119
<div class="container mx-auto px-4">
1210
<div h1 class="text-3xl font-bold pt-4">Playground for {{ example }}</div>
1311
<div class="mt-4">
14-
<SimpleDropdown class="inline" />
12+
<SimpleDropdown class="inline" popper-class="border rounded">
13+
<!-- This will be the popover reference (for the events and position) -->
14+
<button
15+
class="inline-block px-6 py-2.5 bg-blue-600 text-white leading-tight rounded hover:bg-blue-700 focus:bg-blue-700 focus:outline-none focus:ring-0 active:bg-blue-800 transition duration-150 ease-in-out"
16+
>
17+
Click me
18+
</button>
19+
20+
<!-- This will be the content of the popover -->
21+
<template #popper="{ hide }">
22+
<div class="w-44 bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700">
23+
<ul class="py-1 text-sm text-gray-700 dark:text-gray-200">
24+
<li>
25+
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white" @click="hide"
26+
>Dashboard</a
27+
>
28+
</li>
29+
<li>
30+
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Settings</a>
31+
</li>
32+
<li>
33+
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Earnings</a>
34+
</li>
35+
<li>
36+
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Sign out</a>
37+
</li>
38+
</ul>
39+
</div>
40+
</template>
41+
</SimpleDropdown>
1542
</div>
1643
</div>
1744
</template>

src/VueSimpleDropdown.vue

+4-33
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,14 @@
11
<template>
2-
<BaseDropdown :distance="14" placement="bottom-start" :triggers="['click']" auto-hide popper-class="border rounded">
3-
<!-- This will be the popover reference (for the events and position) -->
4-
<button
5-
class="inline-block px-6 py-2.5 bg-blue-600 text-white leading-tight rounded hover:bg-blue-700 focus:bg-blue-700 focus:outline-none focus:ring-0 active:bg-blue-800 transition duration-150 ease-in-out"
6-
>
7-
Click me
8-
</button>
9-
10-
<!-- This will be the content of the popover -->
11-
<template #popper="{ hide }">
12-
<div class="w-44 bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700">
13-
<ul class="py-1 text-sm text-gray-700 dark:text-gray-200">
14-
<li>
15-
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white" @click="hide"
16-
>Dashboard</a
17-
>
18-
</li>
19-
<li>
20-
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Settings</a>
21-
</li>
22-
<li>
23-
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Earnings</a>
24-
</li>
25-
<li>
26-
<a href="#" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Sign out</a>
27-
</li>
28-
</ul>
29-
</div>
2+
<BaseDropdown :distance="14" placement="bottom-start" :triggers="['click']" auto-hide>
3+
<template v-for="(_, slot) in $slots" #[slot]="scope">
4+
<slot :name="slot" v-bind="scope || {}" />
305
</template>
316
</BaseDropdown>
327
</template>
338

349
<script setup lang="ts">
35-
import 'floating-vue/dist/style.css'
36-
3710
import BaseDropdown from './BaseDropdown.vue'
38-
import { ref } from 'vue'
39-
40-
const msg = ref('hello')
11+
import 'floating-vue/dist/style.css'
4112
</script>
4213

4314
<style>

0 commit comments

Comments
 (0)