mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
feat(uishell): global header utilities
This commit is contained in:
parent
f43f684b5c
commit
53e873bd94
8 changed files with 387 additions and 0 deletions
39
src/components/UIShell/UIShellNav/UtilityComponent.svelte
Normal file
39
src/components/UIShell/UIShellNav/UtilityComponent.svelte
Normal file
|
@ -0,0 +1,39 @@
|
|||
<script>
|
||||
export let type = undefined;
|
||||
export let icon = undefined;
|
||||
export let content = undefined;
|
||||
export let componentIsActive = undefined;
|
||||
import { cx } from '../../../lib';
|
||||
import Icon from '../../Icon/Icon.svelte';
|
||||
import { slide } from 'svelte/transition';
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.component-form {
|
||||
margin: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="right-panel-action-component">
|
||||
<button
|
||||
aria-label={type}
|
||||
class={cx('--header__action', componentIsActive && '--header__action--active')}
|
||||
type="button"
|
||||
on:keydown={({ key }) => {
|
||||
if (key === 'Enter') {
|
||||
componentIsActive = !componentIsActive;
|
||||
}
|
||||
}}>
|
||||
<Icon {...icon} />
|
||||
</button>
|
||||
{#if componentIsActive}
|
||||
<div
|
||||
id="right-panel-action-component-form"
|
||||
class={cx('--header-panel', '--header-panel--expanded')}
|
||||
transition:slide={{ duration: 200 }}>
|
||||
<div class="component-form">
|
||||
<svelte:component this={content} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue