File tree 2 files changed +63
-0
lines changed
2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Composable for showing notification messages to the user
3
+ *
4
+ * @returns {Object } The notify function
5
+ */
6
+ export function useNotify ( ) {
7
+ /**
8
+ * Display a notification message
9
+ *
10
+ * @param {String } message - The message to display
11
+ * @param {String } level - The notification level ('success', 'warning', or empty for neutral)
12
+ */
13
+ function notify ( message , level = '' ) {
14
+ pkp . eventBus . $emit ( 'notify' , message , level ) ;
15
+ }
16
+
17
+ return { notify} ;
18
+ }
Original file line number Diff line number Diff line change
1
+ import {Meta } from ' @storybook/blocks' ;
2
+
3
+ <Meta title = " Composables/useNotify" />
4
+
5
+ # useNotify
6
+
7
+ ## notify
8
+
9
+ A simple composable for displaying notification messages to the user.
10
+
11
+ ``` html
12
+ <template >
13
+ <div >
14
+ <PkpButton @click =" showSuccessNotification" >Success Notification</PkpButton >
15
+ <PkpButton @click =" showWarningNotification" >Warning Notification</PkpButton >
16
+ <PkpButton @click =" showNeutralNotification" >Neutral Notification</PkpButton >
17
+ </div >
18
+ </template >
19
+
20
+ <script setup >
21
+ import {useNotify } from ' @/composables/useNotify' ;
22
+
23
+ const {notify } = useNotify ();
24
+
25
+ function showSuccessNotification () {
26
+ notify (' Your changes have been saved.' , ' success' );
27
+ }
28
+
29
+ function showWarningNotification () {
30
+ notify (' Please review your submission before continuing.' , ' warning' );
31
+ }
32
+
33
+ function showNeutralNotification () {
34
+ notify (' This is a neutral informational message.' );
35
+ }
36
+ </script >
37
+ ```
38
+
39
+ ### Parameters
40
+
41
+ - ` message ` (String, required) - The text message to display in the notification
42
+ - ` level ` (String, optional) - The notification style to use
43
+ - ` 'success' ` - Green success notification
44
+ - ` 'warning' ` - Yellow warning notification
45
+ - ` '' ` (empty string or omitted) - Blue neutral notification (default)
You can’t perform that action at this time.
0 commit comments