@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.
- package/dist/collection/common/locale.js +10 -8
- package/dist/collection/common/slot.js +10 -1
- package/dist/collection/components/mds-push-notification/test/mds-push-notification.stories.js +24 -18
- package/dist/collection/dictionary/button.js +5 -1
- package/dist/collection/dictionary/icon.js +1 -1
- package/dist/documentation.json +1 -1
- package/dist/stats.json +3 -4
- package/dist/types/common/slot.d.ts +2 -1
- package/dist/types/components/mds-push-notification/test/mds-push-notification.stories.d.ts +15 -3
- package/dist/types/dictionary/button.d.ts +2 -1
- package/dist/types/dictionary/icon.d.ts +1 -1
- package/dist/types/type/button.d.ts +1 -0
- package/documentation.json +17 -2
- package/package.json +2 -2
- package/src/common/locale.ts +10 -8
- package/src/common/slot.ts +12 -0
- package/src/components/mds-push-notification/test/mds-push-notification.stories.tsx +164 -76
- package/src/dictionary/button.ts +6 -0
- package/src/dictionary/icon.ts +2 -1
- package/src/tailwind/components.css +1 -1
- package/src/type/button.ts +4 -0
- package/src/fixtures/icons.json +0 -470
- package/src/fixtures/iconsauce.json +0 -310
|
@@ -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:
|
|
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:
|
|
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 = (
|
|
46
|
-
return
|
|
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
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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] =
|
|
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(
|
|
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(
|
|
77
|
-
|
|
78
|
-
|
|
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:
|
|
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
|
|
100
|
-
<div class="
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
191
|
+
)
|
|
124
192
|
}
|
|
125
193
|
|
|
126
194
|
const TemplateAddNotifications = () => {
|
|
127
195
|
const [items, setItem] = useState(0)
|
|
128
|
-
return
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
<mds-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
237
|
+
export const AddNotifications = {
|
|
238
|
+
render: TemplateAddNotifications,
|
|
239
|
+
|
|
240
|
+
args: {
|
|
241
|
+
visible: true,
|
|
242
|
+
},
|
|
159
243
|
}
|
|
160
|
-
|
|
161
|
-
AddMultipleNotifications
|
|
162
|
-
|
|
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' })
|
package/src/dictionary/button.ts
CHANGED
|
@@ -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
|
}
|
package/src/dictionary/icon.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import jsonIconsDictionary from '../fixtures/icons.json'
|
|
2
|
-
import jsonMggIconsDictionary from '
|
|
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 = [
|