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>
|
<script lang="ts" module>
|
||||||
export type TabPage = {
|
export type TabPage = {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -14,12 +19,16 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
pages: TabPage[];
|
pages: TabPage[];
|
||||||
|
/** Currently active tab index (default: 0) */
|
||||||
activeIndex?: number;
|
activeIndex?: number;
|
||||||
|
/** 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) */
|
||||||
|
padded?: boolean;
|
||||||
class?: ClassValue | null;
|
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 primaryContainerEl: HTMLDivElement;
|
||||||
let tabContainerEl: HTMLDivElement;
|
let tabContainerEl: HTMLDivElement;
|
||||||
@@ -88,7 +97,10 @@
|
|||||||
<div bind:this={primaryContainerEl} class={[classValue]}>
|
<div bind:this={primaryContainerEl} class={[classValue]}>
|
||||||
<div
|
<div
|
||||||
bind:this={tabContainerEl}
|
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)}
|
{#each pages as page, i (page.title)}
|
||||||
{@const active = activeIndex === i}
|
{@const active = activeIndex === i}
|
||||||
@@ -122,7 +134,7 @@
|
|||||||
|
|
||||||
{#key activeIndex}
|
{#key activeIndex}
|
||||||
<div
|
<div
|
||||||
class={[]}
|
class={[padded && '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}
|
||||||
|
|||||||
@@ -429,6 +429,7 @@
|
|||||||
<p class="title">Tabs</p>
|
<p class="title">Tabs</p>
|
||||||
|
|
||||||
<Tabs
|
<Tabs
|
||||||
|
padded={true}
|
||||||
pages={[
|
pages={[
|
||||||
{
|
{
|
||||||
title: 'Dashboard',
|
title: 'Dashboard',
|
||||||
|
|||||||
Reference in New Issue
Block a user