mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23: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
|
@ -4388,8 +4388,11 @@ export type CarbonTheme = "white" | "g10" | "g80" | "g90" | "g100";
|
|||
### Slots
|
||||
|
||||
| Slot name | Default | Props | Fallback |
|
||||
| :-------- | :------ | :---- | :------- |
|
||||
| :-------- | :------ | :---- | :---------------------- |
|
||||
| -- | Yes | -- | -- |
|
||||
| caption | No | -- | <code>{caption}</code> |
|
||||
| subtitle | No | -- | <code>{subtitle}</code> |
|
||||
| title | No | -- | <code>{title}</code> |
|
||||
|
||||
### Events
|
||||
|
||||
|
|
|
@ -12279,7 +12279,27 @@
|
|||
"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": [
|
||||
{
|
||||
"type": "dispatched",
|
||||
|
|
|
@ -11,6 +11,14 @@ source: Notification/ToastNotification.svelte
|
|||
|
||||
<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
|
||||
|
||||
<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 NotificationButton from "./NotificationButton.svelte";
|
||||
import NotificationIcon from "./NotificationIcon.svelte";
|
||||
import NotificationTextDetails from "./NotificationTextDetails.svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
|
@ -79,13 +78,18 @@
|
|||
on:mouseleave
|
||||
>
|
||||
<NotificationIcon kind="{kind}" />
|
||||
<NotificationTextDetails
|
||||
title="{title}"
|
||||
subtitle="{subtitle}"
|
||||
caption="{caption}"
|
||||
>
|
||||
<div class:bx--toast-notification__details="{true}">
|
||||
<h3 class:bx--toast-notification__title="{true}">
|
||||
<slot name="title">{title}</slot>
|
||||
</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 />
|
||||
</NotificationTextDetails>
|
||||
</div>
|
||||
{#if !hideCloseButton}
|
||||
<NotificationButton
|
||||
iconDescription="{iconDescription}"
|
||||
|
|
|
@ -73,5 +73,5 @@ export default class ToastNotification extends SvelteComponentTyped<
|
|||
mouseenter: WindowEventMap["mouseenter"];
|
||||
mouseleave: WindowEventMap["mouseleave"];
|
||||
},
|
||||
{ default: {} }
|
||||
{ default: {}; caption: {}; subtitle: {}; title: {} }
|
||||
> {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue