Skip to content

Commit

Permalink
Add a slot to p-divider for a centered item with space around.
Browse files Browse the repository at this point in the history
  • Loading branch information
collincchoy committed Dec 7, 2023
1 parent f164311 commit 6cb4235
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion demo/sections/components/Divider.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<template>
<ComponentPage title="Divider" :demos="[{ title: 'Divider' }]">
<ComponentPage title="Divider" :demos="[{ title: 'Divider' }, { title: 'With Slot' }]">
<template #divider>
<span>above</span>
<p-divider />
<span>below</span>
</template>

<template #with-slot>
<p-divider><span class="text-xl text-subdued">§</span></p-divider>
</template>
</ComponentPage>
</template>

Expand Down
18 changes: 17 additions & 1 deletion src/components/Divider/PDivider.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<template>
<hr class="p-divider">
<div class="flex items-center gap-x-2">
<hr class="p-divider">

<template v-if="$slots.default">
<div class="p-divider__text">
<slot />
</div>
<hr class="p-divider">
</template>
</div>
</template>

<style>
Expand All @@ -10,4 +19,11 @@
w-full
my-3
}
.p-divider__text { @apply
px-2
flex-shrink-0
flex
items-center
}
</style>

0 comments on commit 6cb4235

Please sign in to comment.