通知コンポーネントを使用すると、プッシュ(またはローカル)システム通知のように見える必要なメッセージを表示できます。
以下のコンポーネントが含まれています。
通知
名前 | タイプ | デフォルト | 説明 |
---|---|---|---|
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' | マテリアルテーマの通知右テキストの色 |
component | 文字列 | 'div' | コンポーネントのHTML要素 |
opened | 真偽値 | 未定義 | 通知を開閉し、初期状態を設定できます。 |
subtitle | 文字列 | 通知の「サブタイトル」領域の内容 | |
text | 文字列 | 通知の「テキスト」領域の内容 | |
title | 文字列 | 通知の「タイトル」領域の内容 | |
titleRightText | 文字列 | 通知の「タイトル右テキスト」領域の内容 | |
translucent | 真偽値 | true | iOSテーマで通知の背景を半透明にします(`backdrop-filter: blur`を使用)。 |
名前 | タイプ | 説明 |
---|---|---|
close | function(e) | 閉じる要素をクリックしたときのハンドラ |
名前 | 説明 |
---|---|
button | 通知ボタンの内容 |
icon | 通知アイコンのHTMLレイアウトまたは画像 |
subtitle | 通知の「サブタイトル」領域の内容 |
text | 通知の「テキスト」領域の内容 |
title | 通知の「タイトル」領域の内容 |
titlerighttext | 通知の「タイトル右テキスト」領域の内容 |
<template><k-page><k-navbar title="Notification" /><k-notification:opened="opened.notificationFull"title="Konsta UI"title-right-text="now"subtitle="This is a subtitle"text="This is a simple notification message"><template #icon><demo-icon /></template></k-notification><k-notification:opened="opened.notificationWithButton"title="Konsta UI"subtitle="Notification with close button"text="Click (x) button to close me"@click="() => (opened.notificationWithButton = false)"><template #icon><demo-icon /></template><template #button /></k-notification><k-notification:opened="opened.notificationCloseOnClick"title="Konsta UI"title-right-text="now"subtitle="Notification with close on click"text="Click me to close"@click="() => (opened.notificationCloseOnClick = false)"><template #icon><demo-icon /></template></k-notification><k-notification:opened="opened.notificationCallbackOnClose"title="Konsta UI"title-right-text="now"subtitle="Notification with close on click"text="Click me to close"@click="() => {opened.notificationCallbackOnClose = false;alertOpened = true;}"><template #icon><demo-icon /></template></k-notification><k-dialog:opened="alertOpened"@backdropclick="() => (alertOpened = false)"><template #title>Konsta UI</template>Notification closed<template #buttons><k-dialog-button @click="() => (alertOpened = false)">Ok</k-dialog-button></template></k-dialog><k-block strong-ios outline-ios 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><k-button @click="() => openNotification('notificationFull')">Full layout notification</k-button></p><p><k-button @click="() => openNotification('notificationWithButton')">With Close Button</k-button></p><p><k-button @click="() => openNotification('notificationCloseOnClick')">Click to Close</k-button></p><p><k-button@click="() => openNotification('notificationCallbackOnClose')">Callback on Close</k-button></p></k-block></k-page></template><script>import { ref, watch } from 'vue';import {kPage,kNavbar,kNavbarBackLink,kBlock,kNotification,kButton,kDialog,kDialogButton,useTheme,} from 'konsta/vue';import DemoIcon from '../components/DemoIcon.vue';export default {components: {kPage,kNavbar,kNavbarBackLink,kBlock,kNotification,kButton,kDialog,kDialogButton,DemoIcon,},setup() {const opened = ref({notificationFull: false,notificationWithButton: false,notificationCloseOnClick: false,notificationCallbackOnClose: false,});const alertOpened = ref(false);const theme = useTheme();const openNotification = (setter) => {opened.value = {notificationFull: false,notificationWithButton: false,notificationCloseOnClick: false,notificationCallbackOnClose: false,};opened.value[setter] = true;};const autoCloseNotificationFull = () => {if (opened.value.notificationFull) {setTimeout(() => {opened.value.notificationFull = false;}, 3000);}};watch(() => opened.value.notificationFull, autoCloseNotificationFull);return {opened,alertOpened,openNotification,theme,};},};</script>