Skip to content

Commit

Permalink
Fix divider when bottom is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ernstmul committed Jan 16, 2025
1 parent ee61f74 commit e2c54c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions v2/pink-sb/src/lib/bottom-sheet/Default.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export let isOpen = false;
export let useSlots = false;
export let sheetContainerRef: undefined | HTMLDivElement;
export let showDivider = true;
let isDisappearing: null | boolean = null;
function setIfDisappearing(isOpenState: boolean) {
Expand Down Expand Up @@ -35,7 +36,7 @@
<div class="content">
<slot name="top" />
</div>
<Divider />
{#if showDivider}<Divider />{/if}
<div class="content">
<slot name="bottom" />
</div>
Expand Down Expand Up @@ -127,7 +128,7 @@
animation: slideOut 0.2s ease-in-out forwards;
}
.content {
.content:has(:nth-child(2)) {
padding: var(--gap-xxs, 4px);
}
</style>
9 changes: 7 additions & 2 deletions v2/pink-sb/src/lib/bottom-sheet/SheetMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export let isOpen = false;
let sheetContainerRef: HTMLDivElement;
let activeMenu = menu;
let showDivider = true;
function navigateSubMenu(subMenu: SheetMenu) {
if (sheetContainerRef) {
Expand All @@ -20,9 +21,11 @@
} else {
activeMenu = subMenu;
}
showDivider = activeMenu.bottom !== undefined;
}
function restoreMenu(isOpenState: boolean) {
showDivider = activeMenu.bottom !== undefined;
if (!isOpenState) {
setTimeout(() => {
activeMenu = menu;
Expand All @@ -33,7 +36,9 @@
$: restoreMenu(isOpen);
</script>

<BottomSheet.Default bind:isOpen useSlots={true} bind:sheetContainerRef>
<BottomSheet.Default bind:isOpen useSlots={true} bind:sheetContainerRef bind:showDivider>
<div slot="top"><SheetMenuBlock menu={activeMenu.top} {navigateSubMenu} /></div>
<div slot="bottom"><SheetMenuBlock menu={activeMenu.bottom} {navigateSubMenu} /></div>
<div slot="bottom">
{#if activeMenu.bottom}<SheetMenuBlock menu={activeMenu.bottom} {navigateSubMenu} />{/if}
</div>
</BottomSheet.Default>

0 comments on commit e2c54c3

Please sign in to comment.