fix: (somehow) make absolute work again
This commit is contained in:
1 parent
d19a90658b
commit
2bc4d19ae0
8 files changed
+148
-106
No files matched your search
@@ -28,10 +28,10 @@
|
||||
|
||||
<nav
|
||||
class="sticky bg-slate-50/70 dark:bg-zinc-950/70 backdrop-blur-3xl top-0
|
||||
z-50 mt-2"
|
||||
z-50"
|
||||
>
|
||||
<div
|
||||
class="flex z-20 flex-row gap-4 items-center w-full h-16 max-w-5xl mx-auto px-6"
|
||||
class="flex z-20 flex-row gap-4 items-center w-full h-16 max-w-5xl mx-auto px-6 my-1"
|
||||
>
|
||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||
<a href="/" class="flex flex-row items-center gap-2">
|
||||
@@ -56,8 +56,13 @@
|
||||
<Icon src={GlobeAlt} width={16} />
|
||||
<span class="hidden sm:inline ml-1">Communities</span>
|
||||
</Link>
|
||||
<Menu>
|
||||
<Button color={Color.accent} slot="button" label="Create">
|
||||
<Menu let:toggleOpen>
|
||||
<Button
|
||||
color={Color.accent}
|
||||
slot="button"
|
||||
label="Create"
|
||||
on:click={toggleOpen}
|
||||
>
|
||||
<Icon src={Plus} width={16} />
|
||||
<span class="hidden sm:inline">Create</span>
|
||||
</Button>
|
||||
@@ -68,12 +73,13 @@
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
</div>
|
||||
<Menu>
|
||||
<Menu let:toggleOpen>
|
||||
<button
|
||||
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
||||
dark:bg-zinc-800 relative"
|
||||
aria-label="Profile"
|
||||
slot="button"
|
||||
on:click={toggleOpen}
|
||||
>
|
||||
{#if $user}
|
||||
<img
|
||||
|
||||
@@ -15,32 +15,25 @@
|
||||
|
||||
let element: any
|
||||
|
||||
export let preventDefault = false
|
||||
export const toggleOpen = () => (open = !open)
|
||||
</script>
|
||||
|
||||
<svelte:body
|
||||
on:click={(event) => {
|
||||
if (open) {
|
||||
let path = event.composedPath()
|
||||
|
||||
if (!path.includes(element)) {
|
||||
open = false
|
||||
}
|
||||
on:click={(e) => {
|
||||
if (!element.contains(e.target)) {
|
||||
open = false
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="overflow-visible z-30 {absolute
|
||||
? 'absolute'
|
||||
: 'relative'} cursor-auto {clazz}"
|
||||
on:click={(e) => {
|
||||
if (preventDefault) e.preventDefault()
|
||||
|
||||
open = !open
|
||||
}}
|
||||
bind:this={element}
|
||||
>
|
||||
<slot name="button" />
|
||||
<slot name="button" {toggleOpen} />
|
||||
{#if open}
|
||||
<div
|
||||
transition:scale|local={{
|
||||
@@ -48,7 +41,7 @@
|
||||
start: 0.95,
|
||||
easing: expoOut,
|
||||
}}
|
||||
class="absolute max-h-64 overflow-auto {rtl
|
||||
class="absolute max-h-64 z-30 overflow-auto {rtl
|
||||
? 'origin-top-right right-0'
|
||||
: 'origin-top-left left-0'}
|
||||
{top ? 'bottom-[100%] origin-bottom-left' : 'top-[100%]'}
|
||||
@@ -57,8 +50,8 @@
|
||||
: 'bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800'}"
|
||||
>
|
||||
{#if open}
|
||||
<slot />
|
||||
<slot {toggleOpen} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
@@ -9,19 +9,21 @@
|
||||
const click = createEventDispatcher()
|
||||
</script>
|
||||
|
||||
{#if link}
|
||||
<a
|
||||
{href}
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
on:click={(e) => click('click', e)}
|
||||
type="button"
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
{/if}
|
||||
<li>
|
||||
{#if link}
|
||||
<a
|
||||
{href}
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
on:click={(e) => click('click', e)}
|
||||
type="button"
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {color}"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
{/if}
|
||||
</li>
|
||||
Reference in new issue
Block a user