mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
feat(uishell): add panel
This commit is contained in:
parent
d323b2d500
commit
e3a3b620f5
1 changed files with 17 additions and 6 deletions
|
@ -1,11 +1,21 @@
|
||||||
<script>
|
<script>
|
||||||
export let type = undefined;
|
export let type = undefined;
|
||||||
export let icon = undefined;
|
export let icon = undefined;
|
||||||
export let content = undefined;
|
|
||||||
export let componentIsActive = undefined;
|
export let componentIsActive = undefined;
|
||||||
|
|
||||||
|
let elRigthPanel = undefined;
|
||||||
|
|
||||||
import { cx } from '../../../lib';
|
import { cx } from '../../../lib';
|
||||||
import Icon from '../../Icon/Icon.svelte';
|
import Icon from '../../Icon/Icon.svelte';
|
||||||
import { slide } from 'svelte/transition';
|
import { slide } from 'svelte/transition';
|
||||||
|
|
||||||
|
function mouseUp({ target }) {
|
||||||
|
if (target && elRigthPanel) {
|
||||||
|
if (!elRigthPanel.contains(target)) {
|
||||||
|
componentIsActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -14,25 +24,26 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<svelte:window on:mouseup={mouseUp} />
|
||||||
|
|
||||||
<div id="right-panel-action-component">
|
<div id="right-panel-action-component">
|
||||||
<button
|
<button
|
||||||
aria-label={type}
|
aria-label={type}
|
||||||
class={cx('--header__action', componentIsActive && '--header__action--active')}
|
class={cx('--header__action', componentIsActive && '--header__action--active')}
|
||||||
type="button"
|
type="button"
|
||||||
on:keydown={({ key }) => {
|
on:click={() => {
|
||||||
if (key === 'Enter') {
|
componentIsActive = true;
|
||||||
componentIsActive = !componentIsActive;
|
|
||||||
}
|
|
||||||
}}>
|
}}>
|
||||||
<Icon {...icon} />
|
<Icon {...icon} />
|
||||||
</button>
|
</button>
|
||||||
{#if componentIsActive}
|
{#if componentIsActive}
|
||||||
<div
|
<div
|
||||||
|
bind:this={elRigthPanel}
|
||||||
id="right-panel-action-component-form"
|
id="right-panel-action-component-form"
|
||||||
class={cx('--header-panel', '--header-panel--expanded')}
|
class={cx('--header-panel', '--header-panel--expanded')}
|
||||||
transition:slide={{ duration: 200 }}>
|
transition:slide={{ duration: 200 }}>
|
||||||
<div class="component-form">
|
<div class="component-form">
|
||||||
<svelte:component this={content} />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue