Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zIndex rewrite for popover-related components #3210

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-horses-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skeletonlabs/skeleton-svelte': patch
---

feat: renamed `positionerZIndex` to `zIndex` and used CSS values instead of Tailwind classes for **Popover**, **Modal**, **Tooltip** and **Combobox**
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
inputGroupClasses = '',
// Positioner
positionerBase = '',
positionerZIndex = '',
zIndex = 'auto',
positionerClasses = '',
// Content
contentBase = 'card p-2',
Expand Down Expand Up @@ -127,10 +127,14 @@
</label>
<!-- Menu -->
{#if api.open}
<div {...api.getPositionerProps()} transition:fade={{ duration: 100 }} class="{positionerBase} {positionerZIndex} {positionerClasses}">
<div {...api.getPositionerProps()} transition:fade={{ duration: 100 }} class="{positionerBase} {positionerClasses}">
{#if options.length > 0}
<!-- Content (list) -->
<nav {...api.getContentProps()} class="{contentBase} {contentBackground} {contentSpaceY} {contentClasses}">
<nav
{...api.getContentProps()}
class="{contentBase} {contentBackground} {contentSpaceY} {contentClasses}"
style="z-index: {zIndex}"
>
{#each options as item}
{@const isChecked = api.getItemProps({ item })['data-state'] === 'checked'}
{@const displayClass = isChecked ? optionActive : optionHover}
Expand Down
4 changes: 2 additions & 2 deletions packages/skeleton-svelte/src/lib/components/Combobox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export interface ComboboxProps extends Omit<combobox.Context, 'id' | 'collection
// Positioner ---
/** Set base classes for the positioner. */
positionerBase?: string;
/** Set z-index classes for the positioner. */
positionerZIndex?: string;
/** Set z-index for the positioner. */
zIndex?: string;
/** Provide arbitrary classes for the positioner. */
positionerClasses?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
positionerJustify = 'justify-center',
positionerAlign = 'items-center',
positionerPadding = 'p-4',
positionerZIndex = '',
zIndex = 'auto',
positionerClasses = '',
// Content
contentBase = '',
Expand Down Expand Up @@ -87,12 +87,12 @@
<div
use:portal
{...api.getPositionerProps()}
class="{positionerBase} {positionerDisplay} {positionerJustify} {positionerAlign} {positionerPadding} {positionerZIndex} {positionerClasses}"
class="{positionerBase} {positionerDisplay} {positionerJustify} {positionerAlign} {positionerPadding} {positionerClasses}"
in:fly={transitionsPositionerIn}
out:fly={transitionsPositionerOut}
>
<!-- Content -->
<div {...api.getContentProps()} class="{contentBase} {contentBackground} {contentClasses}">
<div {...api.getContentProps()} class="{contentBase} {contentBackground} {contentClasses}" style="z-index: {zIndex};">
{@render content?.()}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/skeleton-svelte/src/lib/components/Modal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export interface ModalProps extends Omit<dialog.Context, 'id' | 'open'> {
positionerAlign?: string;
/** Set padding classes for the positioner. */
positionerPadding?: string;
/** Set z-index classes for the positioner. */
positionerZIndex?: string;
/** Set z-index for the positioner. */
zIndex?: string;
/** Provide arbitrary classes for the positioner. */
positionerClasses?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
triggerClasses = '',
// Positioner
positionerBase = '',
positionerZIndex = '',
zIndex = 'auto',
positionerClasses = '',
// Content
contentBase = '',
Expand Down Expand Up @@ -67,14 +67,10 @@
{@render trigger?.()}
</button>
<!-- Portal -->
<div
use:portal={{ disabled: !api.portalled }}
{...api.getPositionerProps()}
class="{positionerBase} {positionerZIndex} {positionerClasses}"
>
<div use:portal={{ disabled: !api.portalled }} {...api.getPositionerProps()} class="{positionerBase} {positionerClasses}">
<!-- Popover -->
{#if api.open}
<div {...api.getContentProps()} transition:fade={{ duration: 100 }}>
<div {...api.getContentProps()} transition:fade={{ duration: 100 }} style="z-index: {zIndex};">
<!-- Arrow -->
{#if arrow}
<div {...api.getArrowProps()}>
Expand Down
4 changes: 2 additions & 2 deletions packages/skeleton-svelte/src/lib/components/Popover/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export interface PopoverProps extends Omit<popover.Context, 'id' | 'open'> {
// Positioner ---
/** Set base classes for the positioner. */
positionerBase?: string;
/** Set z-index classes for the positioner. */
positionerZIndex?: string;
/** Set z-index for the positioner. */
zIndex?: string;
/** Provide arbitrary classes for the positioner. */
positionerClasses?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
triggerClasses = '',
// Positioner
positionerBase = '',
positionerZIndex = '',
zIndex = 'auto',
positionerClasses = '',
// Content
contentBase = '',
Expand Down Expand Up @@ -69,15 +69,15 @@
</button>
<!-- Tooltip Content -->
{#if api.open}
<div {...api.getPositionerProps()} transition:fade={{ duration: 100 }} class="{positionerBase} {positionerZIndex} {positionerClasses}">
<div {...api.getPositionerProps()} transition:fade={{ duration: 100 }} class="{positionerBase} {positionerClasses}">
<!-- Arrow -->
{#if arrow}
<div {...api.getArrowProps()}>
<div {...api.getArrowTipProps()} class="{arrowBase} {arrowBackground} {arrowClasses}"></div>
</div>
{/if}
<!-- Snippet Content -->
<div {...api.getContentProps()} class="{contentBase} {contentBackground} {contentClasses}">
<div {...api.getContentProps()} class="{contentBase} {contentBackground} {contentClasses}" style="z-index: {zIndex};">
{@render content?.()}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/skeleton-svelte/src/lib/components/Tooltip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export interface TooltipProps extends Omit<tooltip.Context, 'id' | 'open'> {
// Positioner ---
/** Set base classes for the positioner. */
positionerBase?: string;
/** Set z-index classes for the positioner. */
positionerZIndex?: string;
/** Set z-index for the positioner. */
zIndex?: string;
/** Provide arbitrary classes for the positioner. */
positionerClasses?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Generate modals or dialogs that require a user's immediate attention. [View API
Skeleton does not take an opinionated stance regarding z-index stacking. This means elements may be occluded beneath other elements with a higher index. Adjust this using the `zIndex` component property.

```svelte
<Popover ... zIndex={10}>
<Popover ... zIndex="{10}">
<!-- ... -->
</Popover>
```
Expand Down