mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33:02 +00:00
feat(toast-notification): make title/subtitle/caption slottable
This commit is contained in:
parent
e59e1a9348
commit
e225c545ab
5 changed files with 47 additions and 12 deletions
|
@ -4387,9 +4387,12 @@ export type CarbonTheme = "white" | "g10" | "g80" | "g90" | "g100";
|
||||||
|
|
||||||
### Slots
|
### Slots
|
||||||
|
|
||||||
| Slot name | Default | Props | Fallback |
|
| Slot name | Default | Props | Fallback |
|
||||||
| :-------- | :------ | :---- | :------- |
|
| :-------- | :------ | :---- | :---------------------- |
|
||||||
| -- | Yes | -- | -- |
|
| -- | Yes | -- | -- |
|
||||||
|
| caption | No | -- | <code>{caption}</code> |
|
||||||
|
| subtitle | No | -- | <code>{subtitle}</code> |
|
||||||
|
| title | No | -- | <code>{title}</code> |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
|
|
@ -12279,7 +12279,27 @@
|
||||||
"reactive": false
|
"reactive": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }],
|
"slots": [
|
||||||
|
{ "name": "__default__", "default": true, "slot_props": "{}" },
|
||||||
|
{
|
||||||
|
"name": "caption",
|
||||||
|
"default": false,
|
||||||
|
"fallback": "{caption}",
|
||||||
|
"slot_props": "{}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "subtitle",
|
||||||
|
"default": false,
|
||||||
|
"fallback": "{subtitle}",
|
||||||
|
"slot_props": "{}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "title",
|
||||||
|
"default": false,
|
||||||
|
"fallback": "{title}",
|
||||||
|
"slot_props": "{}"
|
||||||
|
}
|
||||||
|
],
|
||||||
"events": [
|
"events": [
|
||||||
{
|
{
|
||||||
"type": "dispatched",
|
"type": "dispatched",
|
||||||
|
|
|
@ -11,6 +11,14 @@ source: Notification/ToastNotification.svelte
|
||||||
|
|
||||||
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||||
|
|
||||||
|
### Slottable title, subtitle, caption
|
||||||
|
|
||||||
|
<ToastNotification>
|
||||||
|
<strong slot="title">Error: </strong>
|
||||||
|
<strong slot="subtitle">An internal server error occurred.</strong>
|
||||||
|
<strong slot="caption">{new Date().toLocaleString()}</strong>
|
||||||
|
</ToastNotification>
|
||||||
|
|
||||||
### Hidden close button
|
### Hidden close button
|
||||||
|
|
||||||
<ToastNotification hideCloseButton kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
<ToastNotification hideCloseButton kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
import { createEventDispatcher, onMount } from "svelte";
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
import NotificationButton from "./NotificationButton.svelte";
|
import NotificationButton from "./NotificationButton.svelte";
|
||||||
import NotificationIcon from "./NotificationIcon.svelte";
|
import NotificationIcon from "./NotificationIcon.svelte";
|
||||||
import NotificationTextDetails from "./NotificationTextDetails.svelte";
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
@ -79,13 +78,18 @@
|
||||||
on:mouseleave
|
on:mouseleave
|
||||||
>
|
>
|
||||||
<NotificationIcon kind="{kind}" />
|
<NotificationIcon kind="{kind}" />
|
||||||
<NotificationTextDetails
|
<div class:bx--toast-notification__details="{true}">
|
||||||
title="{title}"
|
<h3 class:bx--toast-notification__title="{true}">
|
||||||
subtitle="{subtitle}"
|
<slot name="title">{title}</slot>
|
||||||
caption="{caption}"
|
</h3>
|
||||||
>
|
<div class:bx--toast-notification__subtitle="{true}">
|
||||||
|
<slot name="subtitle">{subtitle}</slot>
|
||||||
|
</div>
|
||||||
|
<div class:bx--toast-notification__caption="{true}">
|
||||||
|
<slot name="caption">{caption}</slot>
|
||||||
|
</div>
|
||||||
<slot />
|
<slot />
|
||||||
</NotificationTextDetails>
|
</div>
|
||||||
{#if !hideCloseButton}
|
{#if !hideCloseButton}
|
||||||
<NotificationButton
|
<NotificationButton
|
||||||
iconDescription="{iconDescription}"
|
iconDescription="{iconDescription}"
|
||||||
|
|
|
@ -73,5 +73,5 @@ export default class ToastNotification extends SvelteComponentTyped<
|
||||||
mouseenter: WindowEventMap["mouseenter"];
|
mouseenter: WindowEventMap["mouseenter"];
|
||||||
mouseleave: WindowEventMap["mouseleave"];
|
mouseleave: WindowEventMap["mouseleave"];
|
||||||
},
|
},
|
||||||
{ default: {} }
|
{ default: {}; caption: {}; subtitle: {}; title: {} }
|
||||||
> {}
|
> {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue