@maggioli-design-system/mds-push-notification 5.2.0 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,21 +12,22 @@ export default {
12
12
  },
13
13
  }
14
14
  interface Notification {
15
- message: string,
16
-
17
- datetime?: string,
18
- preview?: NotificationItemPreviewType,
19
- icon?: string,
20
- initial?: string
21
- src?: string,
22
- subject?: string,
15
+ message: string;
16
+
17
+ datetime?: string;
18
+ preview?: NotificationItemPreviewType;
19
+ icon?: string;
20
+ initial?: string;
21
+ src?: string;
22
+ subject?: string;
23
23
  }
24
24
  const exampleNotifications: Notification[] = [
25
25
  {
26
26
  preview: 'avatar',
27
27
  src: '/avatar-05-200x200.jpeg',
28
28
  subject: 'Sarah Ho',
29
- message: 'Sto preparando il documento che mi hai richiesto, dovrei finire in giornata, fammi sapere se hai altri aggiornamenti al riguardo così non mi perdo pezzi per la strada.',
29
+ message:
30
+ 'Sto preparando il documento che mi hai richiesto, dovrei finire in giornata, fammi sapere se hai altri aggiornamenti al riguardo così non mi perdo pezzi per la strada.',
30
31
  },
31
32
  {
32
33
  preview: 'avatar',
@@ -38,45 +39,75 @@ const exampleNotifications: Notification[] = [
38
39
  preview: 'avatar',
39
40
  src: '/avatar-06-200x200.jpeg',
40
41
  subject: 'JamPushNotificationElementes Millennial',
41
- message: 'Domani ci sei alla riunione che ha organizzato Gigetto? Ho saputo che ci sarà anche Puppo.',
42
+ message:
43
+ 'Domani ci sei alla riunione che ha organizzato Gigetto? Ho saputo che ci sarà anche Puppo.',
42
44
  },
43
45
  ]
44
46
 
45
- const PushNotificationElement = ( { index }) => {
46
- return <mds-push-notification-item icon="mi/baseline/attachment" subject={`Notification ${index + 1}`} message="Sto preparando il documento che mi hai richiesto, dovrei finire in giornata, fammi sapere se hai altri aggiornamenti al riguardo così non mi perdo pezzi per la strada."></mds-push-notification-item>
47
+ const PushNotificationElement = ({ index }) => {
48
+ return (
49
+ <mds-push-notification-item
50
+ icon="mi/baseline/attachment"
51
+ subject={`Notification ${index + 1}`}
52
+ message="Sto preparando il documento che mi hai richiesto, dovrei finire in giornata, fammi sapere se hai altri aggiornamenti al riguardo così non mi perdo pezzi per la strada."
53
+ ></mds-push-notification-item>
54
+ )
47
55
  }
48
56
 
49
57
  type GetNotificationsProps = {
50
- notifications: Notification[]
51
- }
58
+ notifications: Notification[];
59
+ };
52
60
  const GetNotifications = ({ notifications }: GetNotificationsProps) => {
53
61
  // console.log('getNotifications', notifications)
54
62
  if (notifications.length > 0) {
55
- return <Fragment>
56
- {notifications.map((n, i) => {
57
- return <mds-push-notification-item key={i} preview={n.preview} src={n.src} subject={n.subject} message={n.message}>
58
- <mds-button slot="actions" variant="primary" tone="weak" size="sm">Rispondi</mds-button>
59
- </mds-push-notification-item>
60
- })}
61
- </Fragment>
63
+ return (
64
+ <Fragment>
65
+ {notifications.map((n, i) => {
66
+ return (
67
+ <mds-push-notification-item
68
+ key={i}
69
+ preview={n.preview}
70
+ src={n.src}
71
+ subject={n.subject}
72
+ message={n.message}
73
+ >
74
+ <mds-button
75
+ slot="actions"
76
+ variant="primary"
77
+ tone="weak"
78
+ size="sm"
79
+ >
80
+ Rispondi
81
+ </mds-button>
82
+ </mds-push-notification-item>
83
+ )
84
+ })}
85
+ </Fragment>
86
+ )
62
87
  }
63
88
  }
64
89
 
65
90
  const Template = args => {
66
- const [notifications, setNotifications] = useState<Notification[]>(exampleNotifications)
91
+ const [notifications, setNotifications] =
92
+ useState<Notification[]>(exampleNotifications)
67
93
  const [visible, setVisible] = useState(args.visible || false)
68
94
 
69
95
  useEffect(() => {
70
- const pushNotificationsElement = document.querySelector('.mds-push-notification')
96
+ const pushNotificationsElement = document.querySelector(
97
+ '.mds-push-notification',
98
+ )
71
99
  if (pushNotificationsElement === null) {
72
100
  // eslint-disable-next-line no-alert
73
101
  alert('Push notifications element not found')
74
102
  return
75
103
  }
76
- pushNotificationsElement.addEventListener('mdsPushNotificationChange', (e: CustomEvent) => {
77
- console.info('mdsPushNotificationChange', e.detail)
78
- setVisible(e.detail)
79
- })
104
+ pushNotificationsElement.addEventListener(
105
+ 'mdsPushNotificationChange',
106
+ (e: CustomEvent) => {
107
+ console.info('mdsPushNotificationChange', e.detail)
108
+ setVisible(e.detail)
109
+ },
110
+ )
80
111
 
81
112
  pushNotificationsElement.addEventListener('mdsPushNotificationShow', () => {
82
113
  console.info('mdsPushNotificationShow')
@@ -91,48 +122,89 @@ const Template = args => {
91
122
 
92
123
  function pushN () {
93
124
  const n: Notification = {
94
- message: 'Sto preparando il documento che mi hai richiesto, dovrei finire in giornata, fammi sapere se hai altri aggiornamenti al riguardo così non mi perdo pezzi per la strada.',
125
+ message:
126
+ 'Sto preparando il documento che mi hai richiesto, dovrei finire in giornata, fammi sapere se hai altri aggiornamenti al riguardo così non mi perdo pezzi per la strada.',
95
127
  }
96
128
  setNotifications([...notifications, n])
97
129
  // console.log(notifications)
98
130
  }
99
- return <div class="-m-600">
100
- <div class="fixed top-600 left-600 flex gap-100">
101
- { visible
102
- ? <mds-button class="shadow-outline-50 shadow-tone-neutral" onClick={() => setVisible(false) } icon="mdi/eye-off-outline" variant="error">Hide notifications</mds-button>
103
- : <mds-button class="shadow-outline-50 shadow-tone-neutral" onClick={() => setVisible(true) } icon="mi/baseline/remove-red-eye" variant="primary">Show notifications</mds-button>
104
- }
105
- <mds-button class="shadow-outline-50 shadow-tone-neutral" variant="success" onClick={pushN}>Carica altre...</mds-button>
106
- </div>
107
- <mds-push-notification class="mds-push-notification" visible={visible === false ? undefined : true} behavior={args.behavior}>
108
- {/* <mds-button slot="top" variant="dark" onClick={deleteNotifications}>Cancella notifiche</mds-button> */}
109
- <GetNotifications notifications={notifications}/>
110
- </mds-push-notification>
111
- <div class="p-1200 flex justify-center">
112
- <div class="grid gap-600 grid-cols-3 mobile:grid-cols-1 max-w-screen-desktop">
113
- { Array(18).fill(null).map((_item, index) => {
114
- return (
115
- <div class="grid gap-25" key={index}>
116
- <mds-text typography='h5' tag="h2">This is a section title</mds-text>
117
- <mds-text>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus iure, ratione beatae quam optio cumque rerum modi consectetur odit eligendi omnis veniam fuga non ipsam voluptatum a ut neque illum.</mds-text>
118
- </div>
119
- )
120
- })}
131
+ return (
132
+ <div class="-m-600">
133
+ <div class="fixed top-600 left-600 flex gap-100">
134
+ {visible ? (
135
+ <mds-button
136
+ class="shadow-outline-50 shadow-tone-neutral"
137
+ onClick={() => setVisible(false)}
138
+ icon="mdi/eye-off-outline"
139
+ variant="error"
140
+ >
141
+ Hide notifications
142
+ </mds-button>
143
+ ) : (
144
+ <mds-button
145
+ class="shadow-outline-50 shadow-tone-neutral"
146
+ onClick={() => setVisible(true)}
147
+ icon="mi/baseline/remove-red-eye"
148
+ variant="primary"
149
+ >
150
+ Show notifications
151
+ </mds-button>
152
+ )}
153
+ <mds-button
154
+ class="shadow-outline-50 shadow-tone-neutral"
155
+ variant="success"
156
+ onClick={pushN}
157
+ >
158
+ Carica altre...
159
+ </mds-button>
160
+ </div>
161
+ <mds-push-notification
162
+ class="mds-push-notification"
163
+ visible={visible === false ? undefined : true}
164
+ behavior={args.behavior}
165
+ >
166
+ {/* <mds-button slot="top" variant="dark" onClick={deleteNotifications}>Cancella notifiche</mds-button> */}
167
+ <GetNotifications notifications={notifications} />
168
+ </mds-push-notification>
169
+ <div class="p-1200 flex justify-center">
170
+ <div class="grid gap-600 grid-cols-3 max-mobile:grid-cols-1 max-w-screen-desktop">
171
+ {Array(18)
172
+ .fill(null)
173
+ .map((_item, index) => {
174
+ return (
175
+ <div class="grid gap-25" key={index}>
176
+ <mds-text typography="h5" tag="h2">
177
+ This is a section title
178
+ </mds-text>
179
+ <mds-text>
180
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit.
181
+ Accusamus iure, ratione beatae quam optio cumque rerum modi
182
+ consectetur odit eligendi omnis veniam fuga non ipsam
183
+ voluptatum a ut neque illum.
184
+ </mds-text>
185
+ </div>
186
+ )
187
+ })}
188
+ </div>
121
189
  </div>
122
190
  </div>
123
- </div>
191
+ )
124
192
  }
125
193
 
126
194
  const TemplateAddNotifications = () => {
127
195
  const [items, setItem] = useState(0)
128
- return <div>
129
- <mds-button onClick={() => setItem(items + 1) }>Add notifications</mds-button>
130
- <mds-push-notification>
131
- { Array.from(Array(items).keys()).map((_item, index) =>
132
- <PushNotificationElement index={index}/>,
133
- ) }
134
- </mds-push-notification>
135
- </div>
196
+ return (
197
+ <div>
198
+ <mds-button onClick={() => setItem(items + 1)}>
199
+ Add notifications
200
+ </mds-button>
201
+ <mds-push-notification>
202
+ {Array.from(Array(items).keys()).map((_item, index) => (
203
+ <PushNotificationElement index={index} />
204
+ ))}
205
+ </mds-push-notification>
206
+ </div>
207
+ )
136
208
  }
137
209
 
138
210
  const TemplateAddMultipleNotifications = args => {
@@ -140,26 +212,42 @@ const TemplateAddMultipleNotifications = args => {
140
212
  const addItems = () => {
141
213
  setItem(items + 3)
142
214
  }
143
- return <div>
144
- <mds-button onClick={addItems.bind(this)}>Carica notifiche...</mds-button>
145
- <mds-push-notification {...args}>
146
- <mds-button slot="top" variant="dark" onClick={addItems.bind(this)}>Carica notifiche...</mds-button>
147
- { Array.from(Array(items).keys()).map((_item, index) =>
148
- <PushNotificationElement index={index}/>,
149
- ) }
150
- <mds-button slot="bottom" variant="dark">Cancella notifiche</mds-button>
151
- </mds-push-notification>
152
- </div>
215
+ return (
216
+ <div>
217
+ <mds-button onClick={addItems.bind(this)}>Carica notifiche...</mds-button>
218
+ <mds-push-notification {...args}>
219
+ <mds-button slot="top" variant="dark" onClick={addItems.bind(this)}>
220
+ Carica notifiche...
221
+ </mds-button>
222
+ {Array.from(Array(items).keys()).map((_item, index) => (
223
+ <PushNotificationElement index={index} />
224
+ ))}
225
+ <mds-button slot="bottom" variant="dark">
226
+ Cancella notifiche
227
+ </mds-button>
228
+ </mds-push-notification>
229
+ </div>
230
+ )
231
+ }
232
+
233
+ export const Default = {
234
+ render: Template,
153
235
  }
154
236
 
155
- export const Default = Template.bind({})
156
- export const AddNotifications = TemplateAddNotifications.bind({})
157
- AddNotifications.args = {
158
- visible: true,
237
+ export const AddNotifications = {
238
+ render: TemplateAddNotifications,
239
+
240
+ args: {
241
+ visible: true,
242
+ },
159
243
  }
160
- export const AddMultipleNotifications = TemplateAddMultipleNotifications.bind({})
161
- AddMultipleNotifications.args = {
162
- visible: true,
244
+
245
+ export const AddMultipleNotifications = {
246
+ render: TemplateAddMultipleNotifications,
247
+
248
+ args: {
249
+ visible: true,
250
+ },
163
251
  }
164
252
 
165
253
  export const ManualNotification = Template.bind({}, { behavior: 'manual' })
@@ -48,6 +48,11 @@ const buttonSizeDictionary = [
48
48
  'xl',
49
49
  ]
50
50
 
51
+ const tabSizeDictionary = [
52
+ 'sm',
53
+ 'md',
54
+ ]
55
+
51
56
  const buttonIconPositionDictionary = [
52
57
  'left',
53
58
  'right',
@@ -68,4 +73,5 @@ export {
68
73
  buttonToneVariantDictionary,
69
74
  buttonTypeDictionary,
70
75
  buttonVariantDictionary,
76
+ tabSizeDictionary,
71
77
  }
@@ -1,5 +1,6 @@
1
1
  import jsonIconsDictionary from '../fixtures/icons.json'
2
- import jsonMggIconsDictionary from '../fixtures/iconsauce.json'
2
+ import jsonMggIconsDictionary from '@maggioli-design-system/svg-icons/dist/iconsauce.json'
3
+
3
4
  const iconsDictionary = jsonIconsDictionary
4
5
  const mggIconsDictionary = jsonMggIconsDictionary
5
6
  const svgIconsDictionary = [
@@ -21,7 +21,7 @@
21
21
  pointer-events: none;
22
22
  position: absolute;
23
23
  transition-behavior: allow-discrete;
24
- transition-property: display opacity;
24
+ transition-property: display, opacity;
25
25
  }
26
26
 
27
27
  .contrast-area-50 {
@@ -14,6 +14,10 @@ export type ButtonSizeType =
14
14
  | 'lg'
15
15
  | 'xl'
16
16
 
17
+ export type TabSizeType =
18
+ | 'sm'
19
+ | 'md'
20
+
17
21
  export type ButtonIconPositionType =
18
22
  | 'left'
19
23
  | 'right'