mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat(ui-shell): add HeaderGlobalAction component
This commit is contained in:
parent
9b6284a139
commit
7b3c111b5f
7 changed files with 110 additions and 1 deletions
33
src/UIShell/HeaderGlobalAction.svelte
Normal file
33
src/UIShell/HeaderGlobalAction.svelte
Normal file
|
@ -0,0 +1,33 @@
|
|||
<script>
|
||||
/**
|
||||
* Set to `true` to use the active variant
|
||||
* @type {boolean} [isActive=false]
|
||||
*/
|
||||
export let isActive = false;
|
||||
|
||||
/**
|
||||
* Specify the icon to render
|
||||
* @type {typeof import("carbon-icons-svelte/lib/Add16").default} [icon]
|
||||
*/
|
||||
export let icon = undefined;
|
||||
|
||||
/**
|
||||
* Obtain a reference to the HTML button element
|
||||
* @type {null | HTMLButtonElement} [ref=null]
|
||||
*/
|
||||
export let ref = null;
|
||||
</script>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
ref="{ref}"
|
||||
class:bx--header__action="{true}"
|
||||
class:bx--header__action--active="{isActive}"
|
||||
{...$$restProps}
|
||||
on:click>
|
||||
<slot>
|
||||
{#if icon}
|
||||
<svelte:component this="{icon}" />
|
||||
{/if}
|
||||
</slot>
|
||||
</button>
|
|
@ -27,6 +27,7 @@
|
|||
import HeaderPanelLinks from "./GlobalHeader/HeaderPanelLinks.svelte";
|
||||
import Content from "./Content.svelte";
|
||||
import SkipToContent from "./SkipToContent.svelte";
|
||||
import HeaderGlobalAction from "./HeaderGlobalAction.svelte";
|
||||
|
||||
let isSideNavOpen = undefined;
|
||||
|
||||
|
@ -188,6 +189,15 @@
|
|||
<HeaderActionLink type="Account" icon="{iAccount}" />
|
||||
</HeaderUtilities>
|
||||
</Header>
|
||||
{:else if story === 'header-global-action'}
|
||||
<Header {...$$props}>
|
||||
<HeaderUtilities>
|
||||
<HeaderGlobalAction isActive>
|
||||
<AppSwitcher20 />
|
||||
</HeaderGlobalAction>
|
||||
<HeaderGlobalAction icon="{AppSwitcher20}" />
|
||||
</HeaderUtilities>
|
||||
</Header>
|
||||
{:else if story === 'header-with-switcher'}
|
||||
<Header {...$$props}>
|
||||
<HeaderUtilities>
|
||||
|
|
|
@ -43,6 +43,16 @@ export const HeaderWithUtilities = () => ({
|
|||
},
|
||||
});
|
||||
|
||||
export const HeaderGlobalAction = () => ({
|
||||
Component,
|
||||
props: {
|
||||
story: "header-global-action",
|
||||
href: text("The link href (href)", "#"),
|
||||
company: text("Company name", "IBM"),
|
||||
platformName: text("Platform name", "Platform Name"),
|
||||
},
|
||||
});
|
||||
|
||||
export const HeaderWithSwitcher = () => ({
|
||||
Component,
|
||||
props: {
|
||||
|
|
|
@ -16,3 +16,4 @@ export { default as SideNavMenu } from "./SideNav/SideNavMenu.svelte";
|
|||
export { default as SideNavMenuItem } from "./SideNav/SideNavMenuItem.svelte";
|
||||
export { default as Content } from "./Content.svelte";
|
||||
export { default as SkipToContent } from "./SkipToContent.svelte";
|
||||
export { default as HeaderGlobalAction } from "./HeaderGlobalAction.svelte";
|
||||
|
|
|
@ -124,5 +124,6 @@ export {
|
|||
SideNavMenuItem,
|
||||
Content,
|
||||
SkipToContent,
|
||||
HeaderGlobalAction,
|
||||
} from "./UIShell";
|
||||
export { UnorderedList } from "./UnorderedList";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue