mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-17 11:11:25 +00:00
feat(breadcrumb)!: integrate Breadcrumb
with v11 (#1956)
This commit is contained in:
parent
08036e105c
commit
1600308614
10 changed files with 94 additions and 154 deletions
|
@ -1,10 +1,13 @@
|
|||
<script>
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @slot {{props?: { ["aria-current"]?: string; class: "bx--link"; }}}
|
||||
* @slot {{props?: Pick<AriaAttributes, "aria-current"> & { class: "bx--link"; }}}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the `href` to use an anchor link
|
||||
* Set the `href` to use an anchor link.
|
||||
* The `Link` component is used if `href` is set.
|
||||
* @type {string}
|
||||
*/
|
||||
export let href = undefined;
|
||||
|
@ -17,28 +20,32 @@
|
|||
import { setContext } from "svelte";
|
||||
|
||||
setContext("BreadcrumbItem", {});
|
||||
|
||||
$: ariaCurrent = $$props["aria-current"];
|
||||
$: current = isCurrentPage && ariaCurrent !== "page";
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||
<li
|
||||
class:bx--breadcrumb-item="{true}"
|
||||
class:bx--breadcrumb-item--current="{isCurrentPage &&
|
||||
$$restProps['aria-current'] !== 'page'}"
|
||||
class:bx--breadcrumb-item--current="{current}"
|
||||
{...$$restProps}
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
aria-current={undefined}
|
||||
>
|
||||
{#if href}
|
||||
<Link href="{href}" aria-current="{$$restProps['aria-current']}">
|
||||
<Link
|
||||
href="{href}"
|
||||
aria-current="{ariaCurrent}"
|
||||
on:click
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
on:mouseleave
|
||||
>
|
||||
<slot />
|
||||
</Link>
|
||||
{:else}
|
||||
<slot
|
||||
props="{{
|
||||
'aria-current': $$restProps['aria-current'],
|
||||
'aria-current': ariaCurrent,
|
||||
class: 'bx--link',
|
||||
}}"
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue