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

通知 Vue コンポーネント

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

通知コンポーネント

以下のコンポーネントが含まれています。

  • 通知

通知プロパティ

名前タイプデフォルト説明
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`を使用)。

通知イベント

名前タイプ説明
closefunction(e)

閉じる要素をクリックしたときのハンドラ

通知スロット

名前説明
button

通知ボタンの内容

icon

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

subtitle

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

text

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

title

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

titlerighttext

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

Notification.vue
<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 to
show 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>
コードのライセンス MIT.
2022 © Konsta UI by nolimits4web.