mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46:36 +00:00
feat(ui-shell): make SideNavMenuItem text slottable
This commit is contained in:
parent
de348f0a8c
commit
bee8b521ca
6 changed files with 26 additions and 8 deletions
|
@ -3086,7 +3086,9 @@ None.
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
None.
|
| Slot name | Default | Props | Fallback |
|
||||||
|
| :-------- | :------ | :---- | :------------------ |
|
||||||
|
| -- | Yes | -- | <code>{text}</code> |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
|
|
@ -7979,7 +7979,14 @@
|
||||||
"reactive": true
|
"reactive": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"slots": [],
|
"slots": [
|
||||||
|
{
|
||||||
|
"name": "__default__",
|
||||||
|
"default": true,
|
||||||
|
"fallback": "{text}",
|
||||||
|
"slot_props": "{}"
|
||||||
|
}
|
||||||
|
],
|
||||||
"events": [{ "type": "forwarded", "name": "click", "element": "a" }],
|
"events": [{ "type": "forwarded", "name": "click", "element": "a" }],
|
||||||
"typedefs": [],
|
"typedefs": [],
|
||||||
"rest_props": { "type": "Element", "name": "a" }
|
"rest_props": { "type": "Element", "name": "a" }
|
||||||
|
|
|
@ -13,11 +13,14 @@
|
||||||
SideNavItems,
|
SideNavItems,
|
||||||
SideNavMenu,
|
SideNavMenu,
|
||||||
SideNavMenuItem,
|
SideNavMenuItem,
|
||||||
|
Tag,
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
import LogoGithub20 from "carbon-icons-svelte/lib/LogoGithub20";
|
import LogoGithub20 from "carbon-icons-svelte/lib/LogoGithub20";
|
||||||
import Theme from "../components/Theme.svelte";
|
import Theme from "../components/Theme.svelte";
|
||||||
import Footer from "../components/Footer.svelte";
|
import Footer from "../components/Footer.svelte";
|
||||||
|
|
||||||
|
const deprecated = ["ToggleSmall", "Icon"];
|
||||||
|
|
||||||
let isOpen = false;
|
let isOpen = false;
|
||||||
let isSideNavOpen = true;
|
let isSideNavOpen = true;
|
||||||
let innerWidth = 2048;
|
let innerWidth = 2048;
|
||||||
|
@ -98,16 +101,22 @@
|
||||||
text="{child.title}"
|
text="{child.title}"
|
||||||
href="{$url(child.path)}"
|
href="{$url(child.path)}"
|
||||||
isSelected="{$isActive($url(child.path))}"
|
isSelected="{$isActive($url(child.path))}"
|
||||||
/>
|
>
|
||||||
|
{child.title}
|
||||||
|
{#if deprecated.includes(child.title)}
|
||||||
|
<Tag size="sm" type="red">Deprecated</Tag>
|
||||||
|
{/if}
|
||||||
|
</SideNavMenuItem>
|
||||||
{/each}
|
{/each}
|
||||||
</SideNavMenu>
|
</SideNavMenu>
|
||||||
<SideNavMenu expanded="{$isActive($url('/recipes'))}" text="Recipes">
|
<SideNavMenu expanded="{$isActive($url('/recipes'))}" text="Recipes">
|
||||||
{#each recipes.children as child, i (child.path)}
|
{#each recipes.children as child, i (child.path)}
|
||||||
<SideNavMenuItem
|
<SideNavMenuItem
|
||||||
text="{child.title}"
|
|
||||||
href="{$url(child.path)}"
|
href="{$url(child.path)}"
|
||||||
isSelected="{$isActive($url(child.path))}"
|
isSelected="{$isActive($url(child.path))}"
|
||||||
/>
|
>
|
||||||
|
{child.title}
|
||||||
|
</SideNavMenuItem>
|
||||||
{/each}
|
{/each}
|
||||||
</SideNavMenu>
|
</SideNavMenu>
|
||||||
</SideNavItems>
|
</SideNavItems>
|
||||||
|
|
|
@ -7,7 +7,7 @@ components: ["ToggleSmall", "ToggleSmallSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<InlineNotification svx-ignore title="Deprecation warning:" kind="warning" hideCloseButton>
|
<InlineNotification svx-ignore title="Deprecation warning" kind="warning" hideCloseButton>
|
||||||
<div>
|
<div>
|
||||||
This component will be removed in the next major release. Use the <Link href="/components/Toggle#small-size">Toggle small variant</Link> instead.
|
This component will be removed in the next major release. Use the <Link href="/components/Toggle#small-size">Toggle small variant</Link> instead.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -30,6 +30,6 @@
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
>
|
>
|
||||||
<span class:bx--side-nav__link-text="{true}">{text}</span>
|
<span class:bx--side-nav__link-text="{true}"><slot>{text}</slot></span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
2
types/UIShell/SideNav/SideNavMenuItem.d.ts
vendored
2
types/UIShell/SideNav/SideNavMenuItem.d.ts
vendored
|
@ -28,5 +28,5 @@ export interface SideNavMenuItemProps
|
||||||
export default class SideNavMenuItem extends SvelteComponentTyped<
|
export default class SideNavMenuItem extends SvelteComponentTyped<
|
||||||
SideNavMenuItemProps,
|
SideNavMenuItemProps,
|
||||||
{ click: WindowEventMap["click"] },
|
{ click: WindowEventMap["click"] },
|
||||||
{}
|
{ default: {} }
|
||||||
> {}
|
> {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue