mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
first commit on the UIShell
This commit is contained in:
parent
ce469df6db
commit
93b912240f
13 changed files with 492 additions and 0 deletions
|
@ -0,0 +1,51 @@
|
|||
<script>
|
||||
export let rightPanel = undefined;
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
import { cx } from '../../../lib';
|
||||
import ActionSearch from './ActionSearch.svelte';
|
||||
import ActionComponent from './ActionComponent.svelte';
|
||||
import ActionLink from './ActionLink.svelte';
|
||||
|
||||
// let switcherAtLast = [];
|
||||
// let renderSwitcher = false;
|
||||
|
||||
$: switcherAtLast = rightPanel.map((item, index, array) => {
|
||||
if (item.action === 'switcher') {
|
||||
if (index !== rightPanel.length) {
|
||||
const newItem = array[index];
|
||||
return newItem;
|
||||
}
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
$: renderSwitcher = switcherAtLast ? true : false;
|
||||
|
||||
onMount(()=>{
|
||||
console.log(switcherAtLast);
|
||||
console.log(renderSwitcher);
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class={cx('--header__global')}>
|
||||
{#each rightPanel as action, index}
|
||||
{#if action.action === 'search'}
|
||||
<ActionSearch {...action} />
|
||||
{:else if action.action === 'switcher'}
|
||||
{#if index === rightPanel.length}
|
||||
<ActionLink {...action} />
|
||||
{/if}
|
||||
{:else if action.type === 'search'}
|
||||
<ActionSearch {...action} />
|
||||
{:else if action.type === 'component'}
|
||||
<ActionComponent {...action} />
|
||||
{:else if action.type === 'link'}
|
||||
<ActionLink {...action} />
|
||||
{/if}
|
||||
{/each}
|
||||
{#if renderSwitcher}
|
||||
<ActionLink {...switcherAtLast} />
|
||||
{/if}
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue