mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
feat(header-action): make panel transition configurable
This commit is contained in:
parent
7d6a0940b6
commit
ba36ee6068
3 changed files with 19 additions and 4 deletions
|
@ -1,4 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
|
/**
|
||||||
|
* @typedef {{ delay?: number; duration?: number; easing?: (t: number) => number; }} HeaderActionSlideTransition
|
||||||
|
*/
|
||||||
|
|
||||||
/** Set to `true` to open the panel */
|
/** Set to `true` to open the panel */
|
||||||
export let isOpen = false;
|
export let isOpen = false;
|
||||||
|
|
||||||
|
@ -10,7 +14,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the text
|
* Specify the text
|
||||||
* Alternatively, use the named slot "text" (e.g. <div slot="text">...</div>)
|
* Alternatively, use the named slot "text" (e.g., <div slot="text">...</div>)
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
export let text = undefined;
|
export let text = undefined;
|
||||||
|
@ -18,6 +22,13 @@
|
||||||
/** Obtain a reference to the button HTML element */
|
/** Obtain a reference to the button HTML element */
|
||||||
export let ref = null;
|
export let ref = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customize the panel transition (i.e., `transition:slide`)
|
||||||
|
* Set to `false` to disable the transition
|
||||||
|
* @type {false | HeaderActionSlideTransition}
|
||||||
|
*/
|
||||||
|
export let transition = { duration: 200 };
|
||||||
|
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
import { slide } from "svelte/transition";
|
import { slide } from "svelte/transition";
|
||||||
import Close20 from "carbon-icons-svelte/lib/Close20";
|
import Close20 from "carbon-icons-svelte/lib/Close20";
|
||||||
|
@ -78,7 +89,7 @@
|
||||||
bind:this="{refPanel}"
|
bind:this="{refPanel}"
|
||||||
class:bx--header-panel="{true}"
|
class:bx--header-panel="{true}"
|
||||||
class:bx--header-panel--expanded="{true}"
|
class:bx--header-panel--expanded="{true}"
|
||||||
transition:slide="{{ duration: 200 }}"
|
transition:slide="{{ ...transition, duration: transition === false ? 0 : transition.duration }}"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<SkipToContent />
|
<SkipToContent />
|
||||||
</div>
|
</div>
|
||||||
<HeaderUtilities>
|
<HeaderUtilities>
|
||||||
<HeaderAction bind:isOpen>
|
<HeaderAction bind:isOpen transition="{false}">
|
||||||
<HeaderPanelLinks>
|
<HeaderPanelLinks>
|
||||||
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
||||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
Column,
|
Column,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import SettingsAdjust20 from "carbon-icons-svelte/lib/SettingsAdjust20";
|
import SettingsAdjust20 from "carbon-icons-svelte/lib/SettingsAdjust20";
|
||||||
|
import { quintOut } from "svelte/easing";
|
||||||
|
|
||||||
let isSideNavOpen = false;
|
let isSideNavOpen = false;
|
||||||
let isOpen = false;
|
let isOpen = false;
|
||||||
|
@ -32,7 +33,10 @@
|
||||||
<HeaderUtilities>
|
<HeaderUtilities>
|
||||||
<HeaderActionSearch />
|
<HeaderActionSearch />
|
||||||
<HeaderGlobalAction aria-label="Settings" icon="{SettingsAdjust20}" />
|
<HeaderGlobalAction aria-label="Settings" icon="{SettingsAdjust20}" />
|
||||||
<HeaderAction bind:isOpen>
|
<HeaderAction
|
||||||
|
bind:isOpen
|
||||||
|
transition="{{ duration: 400, easing: quintOut }}"
|
||||||
|
>
|
||||||
<HeaderPanelLinks>
|
<HeaderPanelLinks>
|
||||||
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
<HeaderPanelDivider>Switcher subject 1</HeaderPanelDivider>
|
||||||
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
<HeaderPanelLink>Switcher item 1</HeaderPanelLink>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue