🔥 新プロジェクトのご紹介 t0ggles - 究極のプロジェクト管理ツール! 🔥

通知 Svelte コンポーネント

通知コンポーネントを使用すると、プッシュ(またはローカル)システム通知のように見える必要なメッセージを表示できます。

通知コンポーネント

次のコンポーネントが含まれています

  • 通知

通知プロパティ

名前デフォルト説明
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 テーマで通知の背景を半透明にします(backdrop-filter: blurを使用)

onClose関数(e)

閉じる要素のクリックハンドラー

通知スロット

名前説明
button

通知ボタンの内容

icon

通知アイコンの HTML レイアウトまたは画像

subtitle

通知の「サブタイトル」領域の内容

text

通知の「テキスト」領域の内容

title

通知の「タイトル」領域の内容

titlerighttext

通知の「右タイトルテキスト」領域の内容

Notification.svelte
<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" />
<Notification
opened={notificationFull}
title="Konsta UI"
titleRightText="now"
subtitle="This is a subtitle"
text="This is a simple notification message"
>
<DemoIcon slot="icon" />
</Notification>
<Notification
opened={notificationWithButton}
title="Konsta UI"
subtitle="Notification with close button"
text="Click (x) button to close me"
button
onClose={() => (notificationWithButton = false)}
>
<DemoIcon slot="icon" />
</Notification>
<Notification
opened={notificationCloseOnClick}
title="Konsta UI"
titleRightText="now"
subtitle="Notification with close on click"
text="Click me to close"
onClick={() => (notificationCloseOnClick = false)}
>
<DemoIcon slot="icon" />
</Notification>
<Notification
opened={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 to
show some useful messages to user and request basic actions.
</p>
<p>
<Button onClick={() => openNotification(() => (notificationFull = true))}>
Full layout notification
</Button>
</p>
<p>
<Button
onClick={() => openNotification(() => (notificationWithButton = true))}
>
With Close Button
</Button>
</p>
<p>
<Button
onClick={() =>
openNotification(() => (notificationCloseOnClick = true))}
>
Click to Close
</Button>
</p>
<p>
<Button
onClick={() =>
openNotification(() => (notificationCallbackOnClose = true))}
>
Callback on Close
</Button>
</p>
</Block>
</Page>
ライセンス MIT.
2022 © Konsta UI by nolimits4web.