mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 04:13:02 +00:00
breaking(ui-shell): remove GlobalHeader, SideNav folders (#1223)
* breaking(ui-shell): remove GlobalHeader/SideNav folders * Run "yarn build:docs"
This commit is contained in:
parent
d34f571150
commit
62735d6275
34 changed files with 56 additions and 56 deletions
|
@ -1,66 +0,0 @@
|
|||
<script>
|
||||
/**
|
||||
* Specify the `href` attribute
|
||||
* @type {string}
|
||||
*/
|
||||
export let href = undefined;
|
||||
|
||||
/**
|
||||
* Specify the text
|
||||
* @type {string}
|
||||
*/
|
||||
export let text = undefined;
|
||||
|
||||
/** Set to `true` to select the item */
|
||||
export let isSelected = false;
|
||||
|
||||
/** Obtain a reference to the HTML anchor element */
|
||||
export let ref = null;
|
||||
|
||||
import { getContext, onMount } from "svelte";
|
||||
|
||||
const id = "ccs-" + Math.random().toString(36);
|
||||
const ctx = getContext("HeaderNavMenu");
|
||||
|
||||
let selectedItemIds = [];
|
||||
|
||||
const unsubSelectedItems = ctx?.selectedItems.subscribe((_selectedItems) => {
|
||||
selectedItemIds = Object.keys(_selectedItems);
|
||||
});
|
||||
|
||||
$: ctx?.updateSelectedItems({ id, isSelected });
|
||||
|
||||
onMount(() => {
|
||||
return () => {
|
||||
if (unsubSelectedItems) unsubSelectedItems();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<li role="none">
|
||||
<a
|
||||
bind:this="{ref}"
|
||||
role="menuitem"
|
||||
tabindex="0"
|
||||
href="{href}"
|
||||
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
|
||||
class:bx--header__menu-item="{true}"
|
||||
aria-current="{isSelected ? 'page' : undefined}"
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
on:keyup
|
||||
on:keydown
|
||||
on:focus
|
||||
on:blur
|
||||
on:blur="{() => {
|
||||
if (selectedItemIds.indexOf(id) === selectedItemIds.length - 1) {
|
||||
ctx?.closeMenu();
|
||||
}
|
||||
}}"
|
||||
>
|
||||
<span class:bx--text-truncate--end="{true}">{text}</span>
|
||||
</a>
|
||||
</li>
|
Loading…
Add table
Add a link
Reference in a new issue