Skip to content

Commit

Permalink
feat: add zindex prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed Apr 28, 2024
1 parent 3e84131 commit 0cedb63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Popover options:
- `showContent` show the content slot, default is `false`
- `calcX` optional - provide your own logic to calculate the X translation
- `calcY` optional - provide your own logic to calculate the Y translation
- `zIndex` optional - z-index for the content element, default is empty


## Examples

Expand Down Expand Up @@ -57,21 +59,14 @@ Popover options:
Once you've created a project and installed dependencies with `yarn`, start a development server:

```bash
npm run dev
pnpm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

pnpm run dev -- --open
```

```

````
## Building

```bash
npm run package
pnpm run package
```
````
11 changes: 9 additions & 2 deletions src/lib/Popdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import { portal } from 'svelte-portal';
import { type Writable, writable } from 'svelte/store';
const isBrowser = 'document' in global && 'querySelector' in document;
const isBrowser = 'document' in globalThis && 'querySelector' in document;
export let contentClass = '';
export let position = 'outer-bottom inner-left';
export let target: string | HTMLElement = isBrowser ? (document.scrollingElement as HTMLElement) : 'body';
export let showContent = false;
export let calcLeft: null | CalcPosition = null;
export let calcTop: null | CalcPosition = null;
export let zIndex = null;
let trigger: Writable<HTMLElement> = writable();
let windowSize: Writable<number[]> = writable();
Expand Down Expand Up @@ -53,7 +54,13 @@
</div>

{#if target && showContent}
<div class="content {contentClass}" bind:this={$content} style:transform={$contentTransformStyle} use:portal={target}>
<div
class="content {contentClass}"
bind:this={$content}
style:transform={$contentTransformStyle}
style:zIndex
use:portal={target}
>
<slot name="content" />
</div>
{/if}
Expand Down

0 comments on commit 0cedb63

Please sign in to comment.