tabs: supported padded mode with spacing-layout
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
<!--
|
||||
Documents the purpose, API, and usage details of the selected component.
|
||||
Include key props, expected behavior, and any important notes for consumers.
|
||||
-->
|
||||
|
||||
<script lang="ts" module>
|
||||
export type TabPage = {
|
||||
title: string;
|
||||
@@ -14,12 +19,16 @@
|
||||
|
||||
interface Props {
|
||||
pages: TabPage[];
|
||||
/** Currently active tab index (default: 0) */
|
||||
activeIndex?: number;
|
||||
/** Callback fired when the active tab changes */
|
||||
onchange?: (event: { index: number; tab: TabPage }) => void;
|
||||
/** Applies layout padding to the tab header & content areas (default: false) */
|
||||
padded?: boolean;
|
||||
class?: ClassValue | null;
|
||||
}
|
||||
|
||||
let { pages, activeIndex = 0, onchange, class: classValue }: Props = $props();
|
||||
let { pages, activeIndex = 0, onchange, padded = false, class: classValue }: Props = $props();
|
||||
|
||||
let primaryContainerEl: HTMLDivElement;
|
||||
let tabContainerEl: HTMLDivElement;
|
||||
@@ -88,7 +97,10 @@
|
||||
<div bind:this={primaryContainerEl} class={[classValue]}>
|
||||
<div
|
||||
bind:this={tabContainerEl}
|
||||
class={['border-sui-text/15 relative mb-4 flex items-center gap-5 border-b-2']}
|
||||
class={[
|
||||
'border-sui-text/15 relative mb-4 flex items-center gap-5 border-b-2',
|
||||
padded && 'px-layout'
|
||||
]}
|
||||
>
|
||||
{#each pages as page, i (page.title)}
|
||||
{@const active = activeIndex === i}
|
||||
@@ -122,7 +134,7 @@
|
||||
|
||||
{#key activeIndex}
|
||||
<div
|
||||
class={[]}
|
||||
class={[padded && 'px-layout']}
|
||||
in:flyX={{ direction: activeIndex > prevIndex ? 1 : -1, duration: 180, delay: 181 }}
|
||||
out:flyX={{ direction: activeIndex > prevIndex ? -1 : 1, duration: 180 }}
|
||||
onoutrostart={lockHeight}
|
||||
|
||||
@@ -429,6 +429,7 @@
|
||||
<p class="title">Tabs</p>
|
||||
|
||||
<Tabs
|
||||
padded={true}
|
||||
pages={[
|
||||
{
|
||||
title: 'Dashboard',
|
||||
|
||||
Reference in New Issue
Block a user