通知コンポーネントを使用すると、プッシュ(またはローカル)システム通知のように見える必要なメッセージを表示できます。
次のコンポーネントが含まれています
通知
名前 | 型 | デフォルト | 説明 |
---|---|---|---|
colors | オブジェクト | Tailwind CSS カラークラスを持つオブジェクト | |
colors.bgIos | 文字列 | 'bg-white dark:bg-[#1e1e1e]' | iOS テーマの通知の背景色 |
colors.bgMaterial | 文字列 | 'bg-md-light-surface-5 dark:bg-md-dark-surface-5' | マテリアルテーマの通知の背景色 |
colors.deleteIconIos | 文字列 | 'fill-stone-400 active:fill-stone-200 dark:fill-stone-500 dark:active:fill-stone-700' | iOS テーマの通知削除アイコンの色 |
colors.deleteIconMd | 文字列 | 'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant' | マテリアルテーマの通知削除アイコンの色 |
colors.subtitleIos | 文字列 | 'text-black dark:text-white' | iOS テーマの通知サブタイトル色 |
colors.textMaterial | 文字列 | 'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant' | マテリアルテーマの通知テキスト色 |
colors.titleIos | 文字列 | 'text-black dark:text-white' | iOS テーマの通知タイトル色 |
colors.titleRightIos | 文字列 | 'text-opacity-45 text-black dark:text-white dark:text-opacity-45' | iOS テーマの通知右テキスト色 |
colors.titleRightMd | 文字列 | 'text-md-light-on-surface-variant before:bg-md-light-on-surface-variant dark:text-md-dark-on-surface-variant before:dark:bg-md-dark-on-surface-variant' | マテリアルテーマの通知右テキスト色 |
opened | ブール値 | 未定義 | 通知の開閉と初期状態の設定を許可します |
subtitle | 文字列 | 通知の「サブタイトル」領域の内容 | |
text | 文字列 | 通知の「テキスト」領域の内容 | |
title | 文字列 | 通知の「タイトル」領域の内容 | |
titleRightText | 文字列 | 通知の「右タイトルテキスト」領域の内容 | |
translucent | ブール値 | true | iOS テーマで通知の背景を半透明にします( |
onClose | 関数(e) | 閉じる要素のクリックハンドラー |
名前 | 説明 |
---|---|
button | 通知ボタンの内容 |
icon | 通知アイコンの HTML レイアウトまたは画像 |
subtitle | 通知の「サブタイトル」領域の内容 |
text | 通知の「テキスト」領域の内容 |
title | 通知の「タイトル」領域の内容 |
titlerighttext | 通知の「右タイトルテキスト」領域の内容 |
<script>import {Page,Navbar,NavbarBackLink,Block,Notification,Button,Dialog,DialogButton,} from 'konsta/svelte';import DemoIcon from '../components/DemoIcon.svelte';let notificationFull = false;let notificationWithButton = false;let notificationCloseOnClick = false;let notificationCallbackOnClose = false;let alertOpened = false;const openNotification = (setter) => {notificationFull = false;notificationWithButton = false;notificationCloseOnClick = false;notificationCallbackOnClose = false;setter();if (notificationFull) {setTimeout(() => {notificationFull = false;}, 3000);}};</script><Page><Navbar title="Notification" /><Notificationopened={notificationFull}title="Konsta UI"titleRightText="now"subtitle="This is a subtitle"text="This is a simple notification message"><DemoIcon slot="icon" /></Notification><Notificationopened={notificationWithButton}title="Konsta UI"subtitle="Notification with close button"text="Click (x) button to close me"buttononClose={() => (notificationWithButton = false)}><DemoIcon slot="icon" /></Notification><Notificationopened={notificationCloseOnClick}title="Konsta UI"titleRightText="now"subtitle="Notification with close on click"text="Click me to close"onClick={() => (notificationCloseOnClick = false)}><DemoIcon slot="icon" /></Notification><Notificationopened={notificationCallbackOnClose}title="Konsta UI"titleRightText="now"subtitle="Notification with close on click"text="Click me to close"onClick={() => {notificationCallbackOnClose = false;alertOpened = true;}}><DemoIcon slot="icon" /></Notification><Dialog opened={alertOpened} onBackdropClick={() => (alertOpened = false)}><svelte:fragment slot="title">Konsta UI</svelte:fragment>Notification closed<svelte:fragment slot="buttons"><DialogButton onClick={() => (alertOpened = false)}>Ок</DialogButton></svelte:fragment></Dialog><Block strongIos outlineIos class="space-y-4"><p>Konsta UI comes with simple Notifications component that allows you toshow some useful messages to user and request basic actions.</p><p><Button onClick={() => openNotification(() => (notificationFull = true))}>Full layout notification</Button></p><p><ButtononClick={() => openNotification(() => (notificationWithButton = true))}>With Close Button</Button></p><p><ButtononClick={() =>openNotification(() => (notificationCloseOnClick = true))}>Click to Close</Button></p><p><ButtononClick={() =>openNotification(() => (notificationCallbackOnClose = true))}>Callback on Close</Button></p></Block></Page>