tabs: separate controls for header and content padding
This commit is contained in:
@@ -23,12 +23,22 @@
|
|||||||
activeIndex?: number;
|
activeIndex?: number;
|
||||||
/** Callback fired when the active tab changes */
|
/** Callback fired when the active tab changes */
|
||||||
onchange?: (event: { index: number; tab: TabPage }) => void;
|
onchange?: (event: { index: number; tab: TabPage }) => void;
|
||||||
/** Applies layout padding to the tab header & content areas (default: false) */
|
/** Applies layout padding to the tab header (default: false) */
|
||||||
padded?: boolean;
|
padHeader?: boolean;
|
||||||
|
/** Applies layout padding to the content areas (default: false) */
|
||||||
|
padContent?: boolean;
|
||||||
|
/** Additional classes applied to the outer container */
|
||||||
class?: ClassValue | null;
|
class?: ClassValue | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { pages, activeIndex = 0, onchange, padded = false, class: classValue }: Props = $props();
|
let {
|
||||||
|
pages,
|
||||||
|
activeIndex = 0,
|
||||||
|
onchange,
|
||||||
|
padHeader = false,
|
||||||
|
padContent = false,
|
||||||
|
class: classValue
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
let primaryContainerEl: HTMLDivElement;
|
let primaryContainerEl: HTMLDivElement;
|
||||||
let tabContainerEl: HTMLDivElement;
|
let tabContainerEl: HTMLDivElement;
|
||||||
@@ -99,7 +109,7 @@
|
|||||||
bind:this={tabContainerEl}
|
bind:this={tabContainerEl}
|
||||||
class={[
|
class={[
|
||||||
'border-sui-text/15 relative mb-4 flex items-center gap-5 border-b-2',
|
'border-sui-text/15 relative mb-4 flex items-center gap-5 border-b-2',
|
||||||
padded && 'px-layout'
|
padHeader && 'px-layout'
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{#each pages as page, i (page.title)}
|
{#each pages as page, i (page.title)}
|
||||||
@@ -134,7 +144,7 @@
|
|||||||
|
|
||||||
{#key activeIndex}
|
{#key activeIndex}
|
||||||
<div
|
<div
|
||||||
class={[padded && 'px-layout']}
|
class={[padContent && 'px-layout']}
|
||||||
in:flyX={{ direction: activeIndex > prevIndex ? 1 : -1, duration: 180, delay: 181 }}
|
in:flyX={{ direction: activeIndex > prevIndex ? 1 : -1, duration: 180, delay: 181 }}
|
||||||
out:flyX={{ direction: activeIndex > prevIndex ? -1 : 1, duration: 180 }}
|
out:flyX={{ direction: activeIndex > prevIndex ? -1 : 1, duration: 180 }}
|
||||||
onoutrostart={lockHeight}
|
onoutrostart={lockHeight}
|
||||||
|
|||||||
Reference in New Issue
Block a user