mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
docs(notification): add examples "Prevent default close behavior" (#1380)
Follow-up to #1379
This commit is contained in:
parent
924b6d352e
commit
04f18ae5e9
2 changed files with 31 additions and 1 deletions
|
@ -11,6 +11,21 @@ source: Notification/InlineNotification.svelte
|
||||||
|
|
||||||
<InlineNotification title="Error:" subtitle="An internal server error occurred." />
|
<InlineNotification title="Error:" subtitle="An internal server error occurred." />
|
||||||
|
|
||||||
|
### Prevent default close behavior
|
||||||
|
|
||||||
|
`InlineNotification` is a controlled component. Prevent the default close behavior using the `e.preventDefault()` method in the dispatched `on:close` event.
|
||||||
|
|
||||||
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
|
<div class="body-short-01">
|
||||||
|
Svelte version 3.48.0 or greater is required.
|
||||||
|
</div>
|
||||||
|
</InlineNotification>
|
||||||
|
|
||||||
|
<InlineNotification title="Error" subtitle="An internal server error occurred." on:close={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
// custom close logic (e.g., transitions)
|
||||||
|
}} />
|
||||||
|
|
||||||
### Slottable title, subtitle
|
### Slottable title, subtitle
|
||||||
|
|
||||||
<InlineNotification>
|
<InlineNotification>
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: Notification/ToastNotification.svelte
|
||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ToastNotification } from "carbon-components-svelte";
|
import { ToastNotification, InlineNotification } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -11,6 +11,21 @@ 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()}" />
|
||||||
|
|
||||||
|
### Prevent default close behavior
|
||||||
|
|
||||||
|
`ToastNotification` is a controlled component. Prevent the default close behavior using the `e.preventDefault()` method in the dispatched `on:close` event.
|
||||||
|
|
||||||
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
|
<div class="body-short-01">
|
||||||
|
Svelte version 3.48.0 or greater is required.
|
||||||
|
</div>
|
||||||
|
</InlineNotification>
|
||||||
|
|
||||||
|
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" on:close={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
// custom close logic (e.g., transitions)
|
||||||
|
}} />
|
||||||
|
|
||||||
### Slottable title, subtitle, caption
|
### Slottable title, subtitle, caption
|
||||||
|
|
||||||
<ToastNotification>
|
<ToastNotification>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue