@weni/unnnic-system 2.0.25 → 2.0.26

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 2.0.26 (2024-06-20)
9
+
10
+ ### Added
11
+
12
+ - Migrated ModalNext to Vue 3.
13
+
8
14
  ## 2.0.25 (2024-06-20)
9
15
 
10
16
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,435 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ 'unnnic-modal',
5
+ `type-${type}`,
6
+ {
7
+ 'show-close-button': showCloseButton,
8
+ 'show-actions-area':
9
+ validate || actionPrimaryLabel || actionSecondaryLabel,
10
+ },
11
+ ]"
12
+ @click.self="closeByDarkBackground"
13
+ >
14
+ <div class="container">
15
+ <template v-if="type === 'default'">
16
+ <div
17
+ v-if="showCloseButton"
18
+ class="header"
19
+ >
20
+ <UnnnicIcon
21
+ icon="close-1"
22
+ size="sm"
23
+ clickable
24
+ @click="$emit('close')"
25
+ />
26
+ </div>
27
+
28
+ <div class="content">
29
+ <slot></slot>
30
+ </div>
31
+ </template>
32
+
33
+ <div
34
+ v-else-if="type === 'video'"
35
+ class="content"
36
+ >
37
+ <div class="aspect-ratio-box">
38
+ <iframe
39
+ class="aspect-ratio-box-inside"
40
+ type="text/html"
41
+ :src="url"
42
+ frameborder="0"
43
+ allowfullscreen
44
+ />
45
+ </div>
46
+ </div>
47
+
48
+ <template v-else-if="type === 'alert'">
49
+ <div
50
+ v-if="showCloseButton"
51
+ class="header"
52
+ >
53
+ <UnnnicIcon
54
+ icon="close-1"
55
+ size="sm"
56
+ clickable
57
+ @click="$emit('close')"
58
+ />
59
+ </div>
60
+
61
+ <div :class="['content', { 'with-validation': validate }]">
62
+ <div
63
+ v-if="icon"
64
+ class="icon"
65
+ >
66
+ <UnnnicIcon
67
+ :icon="icon"
68
+ :scheme="scheme"
69
+ size="xl"
70
+ ></UnnnicIcon>
71
+ </div>
72
+
73
+ <div
74
+ v-if="$slots.title || title"
75
+ class="title"
76
+ >
77
+ <slot
78
+ v-if="$slots.title"
79
+ name="title"
80
+ ></slot>
81
+
82
+ <template v-else>{{ title }}</template>
83
+ </div>
84
+
85
+ <div
86
+ v-if="$slots.description || description"
87
+ class="description"
88
+ >
89
+ <slot
90
+ v-if="$slots.description"
91
+ name="description"
92
+ ></slot>
93
+
94
+ <template v-else>{{ description }}</template>
95
+ </div>
96
+
97
+ <div
98
+ v-if="validate"
99
+ class="confirm-text"
100
+ >
101
+ <UnnnicInput
102
+ v-model="confirmText"
103
+ :placeholder="validatePlaceholder"
104
+ >
105
+ <template #label>
106
+ <span v-html="validateLabel" />
107
+ </template>
108
+ </UnnnicInput>
109
+ </div>
110
+
111
+ <div
112
+ v-if="validate || actionPrimaryLabel || actionSecondaryLabel"
113
+ class="actions"
114
+ :style="{ marginTop: validate ? '0' : undefined }"
115
+ >
116
+ <UnnnicButton
117
+ v-if="validate || actionSecondaryLabel"
118
+ type="tertiary"
119
+ :disabled="actionPrimaryLoading"
120
+ @click="
121
+ $attrs['click-action-secondary']
122
+ ? $emit('click-action-secondary', { close: justClose })
123
+ : $emit('close')
124
+ "
125
+ >
126
+ {{ actionSecondaryLabel }}
127
+ </UnnnicButton>
128
+
129
+ <UnnnicButton
130
+ v-if="validate || actionPrimaryLabel"
131
+ :type="actionPrimaryButtonType"
132
+ :class="
133
+ actionPrimaryButtonType === 'primary'
134
+ ? ['button', buttonType]
135
+ : undefined
136
+ "
137
+ :disabled="disabled || actionPrimaryLoading"
138
+ :loading="actionPrimaryLoading"
139
+ @click="
140
+ $attrs['click-action-primary']
141
+ ? $emit('click-action-primary', { close: justClose })
142
+ : null
143
+ "
144
+ >
145
+ {{ actionPrimaryLabel }}
146
+ </UnnnicButton>
147
+ </div>
148
+ </div>
149
+ </template>
150
+ </div>
151
+ </div>
152
+ </template>
153
+
154
+ <script>
155
+ import UnnnicIcon from '../Icon.vue';
156
+ import UnnnicInput from '../Input/Input.vue';
157
+ import UnnnicButton from '../Button/Button.vue';
158
+
159
+ export default {
160
+ components: {
161
+ UnnnicIcon,
162
+ UnnnicInput,
163
+ UnnnicButton,
164
+ },
165
+
166
+ props: {
167
+ type: {
168
+ type: String,
169
+ default: 'default',
170
+ },
171
+
172
+ url: String,
173
+ icon: String,
174
+ scheme: String,
175
+ title: String,
176
+ description: String,
177
+ validate: String,
178
+ validatePlaceholder: String,
179
+ validateLabel: String,
180
+
181
+ actionPrimaryLabel: String,
182
+ actionPrimaryLoading: Boolean,
183
+ actionPrimaryButtonType: {
184
+ type: String,
185
+ default: 'primary',
186
+ },
187
+
188
+ actionSecondaryLabel: String,
189
+
190
+ showCloseButton: Boolean,
191
+ },
192
+
193
+ emits: ['close', 'click-action-primary', 'click-action-secondary'],
194
+
195
+ data() {
196
+ return {
197
+ confirmText: '',
198
+ };
199
+ },
200
+
201
+ computed: {
202
+ isPersistent() {
203
+ return this.data?.persistent;
204
+ },
205
+
206
+ buttonType() {
207
+ if (this.disabled) {
208
+ return '';
209
+ }
210
+
211
+ if (this.scheme === 'feedback-red') {
212
+ return 'danger';
213
+ }
214
+
215
+ if (this.scheme === 'feedback-yellow') {
216
+ return 'alert';
217
+ }
218
+
219
+ return '';
220
+ },
221
+
222
+ disabled() {
223
+ if (this.validate) {
224
+ return this.confirmText !== this.validate;
225
+ }
226
+ // return (
227
+ // _.get(this.data, 'validate.text') &&
228
+ // this.confirmText !== this.data.validate.text
229
+ // );
230
+
231
+ return false;
232
+ },
233
+ },
234
+
235
+ methods: {
236
+ closeByDarkBackground() {
237
+ this.$emit('close');
238
+ },
239
+ close() {
240
+ this.justClose();
241
+
242
+ if (this.data?.onClose) {
243
+ this.data.onClose();
244
+ }
245
+ },
246
+
247
+ justClose() {
248
+ // this.closeModal(this.id);
249
+ },
250
+ },
251
+ };
252
+ </script>
253
+
254
+ <style lang="scss" scoped>
255
+ @import '../../assets/scss/unnnic.scss';
256
+
257
+ .unnnic-modal {
258
+ z-index: 5;
259
+ position: fixed;
260
+ top: 0;
261
+ right: 0;
262
+ bottom: 0;
263
+ left: 0;
264
+ background-color: rgba(0, 0, 0, $unnnic-opacity-level-overlay);
265
+ display: flex;
266
+ align-items: center;
267
+ padding: 0 12.88%;
268
+ box-sizing: border-box;
269
+
270
+ .container {
271
+ flex: 1;
272
+ max-height: 90vh;
273
+ box-sizing: border-box;
274
+ display: flex;
275
+ flex-direction: column;
276
+
277
+ border-radius: $unnnic-border-radius-sm;
278
+ background-color: $unnnic-color-background-carpet;
279
+ box-shadow: $unnnic-shadow-level-separated;
280
+ padding-top: $unnnic-spacing-stack-giant;
281
+
282
+ padding: $unnnic-spacing-stack-giant $unnnic-inline-md;
283
+
284
+ .content {
285
+ $scroll-size: $unnnic-inline-nano;
286
+
287
+ flex: 1;
288
+ overflow: overlay;
289
+
290
+ padding-right: calc(#{$unnnic-inline-xs} + #{$scroll-size});
291
+ width: 100%;
292
+
293
+ &::-webkit-scrollbar {
294
+ width: $scroll-size;
295
+ }
296
+
297
+ &::-webkit-scrollbar-thumb {
298
+ background: $unnnic-color-neutral-cleanest;
299
+ border-radius: $unnnic-border-radius-pill;
300
+ }
301
+
302
+ &::-webkit-scrollbar-track {
303
+ background: $unnnic-color-neutral-soft;
304
+ border-radius: $unnnic-border-radius-pill;
305
+ }
306
+ }
307
+ }
308
+
309
+ &.type-video {
310
+ .container {
311
+ max-width: 60 * $unnnic-font-size;
312
+ margin: 0 auto;
313
+ padding: 0 $unnnic-inline-md;
314
+ // padding-top: $unnnic-spacing-stack-giant;
315
+ padding-bottom: $unnnic-spacing-stack-lg;
316
+ }
317
+
318
+ .content {
319
+ .aspect-ratio-box {
320
+ height: 0;
321
+ overflow: hidden;
322
+ padding-top: calc(9 / 16 * 100%);
323
+ position: relative;
324
+ }
325
+
326
+ .aspect-ratio-box-inside {
327
+ position: absolute;
328
+ top: 0;
329
+ left: 0;
330
+ width: 100%;
331
+ height: 100%;
332
+ }
333
+ }
334
+ }
335
+
336
+ &.type-default .container {
337
+ max-width: 31.125 * $unnnic-font-size;
338
+ margin: 0 auto;
339
+ padding: 0 $unnnic-inline-md;
340
+ padding-top: $unnnic-spacing-stack-sm;
341
+ padding-bottom: $unnnic-spacing-stack-giant;
342
+ }
343
+
344
+ .icon {
345
+ text-align: center;
346
+ margin-bottom: $unnnic-spacing-stack-sm;
347
+ }
348
+
349
+ &.type-confirm,
350
+ &.type-alert {
351
+ .title {
352
+ text-align: center;
353
+ font-family: $unnnic-font-family-secondary;
354
+ color: $unnnic-color-neutral-darkest;
355
+ font-weight: $unnnic-font-weight-black;
356
+ font-size: $unnnic-font-size-title-sm;
357
+ line-height: ($unnnic-font-size-title-sm + $unnnic-line-height-medium);
358
+ padding-bottom: $unnnic-spacing-stack-md;
359
+ }
360
+
361
+ .description {
362
+ text-align: center;
363
+
364
+ font-family: $unnnic-font-family-secondary;
365
+ color: $unnnic-color-neutral-cloudy;
366
+ font-weight: $unnnic-font-weight-regular;
367
+ font-size: $unnnic-font-size-body-lg;
368
+ line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
369
+ }
370
+ }
371
+
372
+ &.show-close-button .container {
373
+ padding-top: $unnnic-spacing-stack-sm;
374
+
375
+ .header {
376
+ display: flex;
377
+ justify-content: flex-end;
378
+ margin-bottom: $unnnic-spacing-stack-xs;
379
+ }
380
+ }
381
+
382
+ &.show-actions-area .container {
383
+ padding-bottom: $unnnic-spacing-stack-lg;
384
+ }
385
+
386
+ &.confirm .container {
387
+ max-width: 31.125 * $unnnic-font-size;
388
+ margin: 0 auto;
389
+ padding: 0 $unnnic-spacing-stack-lg;
390
+ padding-top: $unnnic-spacing-stack-giant;
391
+ padding-bottom: $unnnic-inline-md;
392
+
393
+ .description {
394
+ margin-bottom: $unnnic-spacing-stack-giant;
395
+ }
396
+ }
397
+
398
+ &.type-alert .container {
399
+ max-width: 31.125 * $unnnic-font-size;
400
+ margin: 0 auto;
401
+
402
+ .header {
403
+ margin-bottom: $unnnic-spacing-stack-xs;
404
+ text-align: right;
405
+ }
406
+
407
+ .content.with-validation .description {
408
+ margin-bottom: $unnnic-spacing-stack-lg;
409
+ }
410
+
411
+ .confirm-text {
412
+ margin-bottom: $unnnic-spacing-stack-lg;
413
+ }
414
+
415
+ .actions {
416
+ display: grid;
417
+ column-gap: $unnnic-inline-lg;
418
+ grid-auto-flow: column;
419
+ margin-top: $unnnic-spacing-stack-giant;
420
+
421
+ .button {
422
+ &.danger:not([disabled]) {
423
+ background-color: $unnnic-color-feedback-red;
424
+ color: $unnnic-color-neutral-snow;
425
+ }
426
+
427
+ &.alert:not([disabled]) {
428
+ background-color: $unnnic-color-feedback-yellow;
429
+ color: $unnnic-color-neutral-snow;
430
+ }
431
+ }
432
+ }
433
+ }
434
+ }
435
+ </style>
@@ -0,0 +1,189 @@
1
+ import unnnicModalNext from '../components/ModalNext/ModalNext.vue';
2
+ import icons from '../utils/icons';
3
+
4
+ const iconsOptions = Object.keys(icons);
5
+
6
+ const schemesOptions = [
7
+ 'feedback-red',
8
+ 'feedback-green',
9
+ 'feedback-yellow',
10
+ 'feedback-blue',
11
+ 'feedback-grey',
12
+ 'aux-blue',
13
+ 'aux-purple',
14
+ 'aux-orange',
15
+ 'aux-lemon',
16
+ 'aux-pink',
17
+ 'brand-weni',
18
+ 'brand-weni-soft',
19
+ 'neutral-clean',
20
+ 'neutral-cleanest',
21
+ 'neutral-dark',
22
+ 'neutral-soft',
23
+ 'neutral-darkest',
24
+ ];
25
+
26
+ export default {
27
+ title: 'Example/ModalNext',
28
+ component: unnnicModalNext,
29
+ argTypes: {
30
+ type: {
31
+ control: { type: 'select', options: ['default', 'video', 'alert'] },
32
+ },
33
+ icon: { control: { type: 'select', options: iconsOptions } },
34
+ scheme: { control: { type: 'select', options: schemesOptions } },
35
+ text: { control: { type: 'text' } },
36
+ description: { control: { type: 'text' } },
37
+ actionPrimaryButtonType: {
38
+ control: { type: 'select', options: ['primary', 'secondary'] },
39
+ },
40
+ },
41
+ render: (args) => ({
42
+ setup() {
43
+ return { args };
44
+ },
45
+ data() {
46
+ return {
47
+ open: false,
48
+ };
49
+ },
50
+ components: { unnnicModalNext },
51
+ template: `
52
+ <div>
53
+ <button @click="open = true">Open</button>
54
+ <unnnic-modal-next v-show="open" v-bind="args" @close="open = false">
55
+
56
+ This is the info content<br>
57
+ This is the info content<br>
58
+ This is the info content<br>
59
+ This is the info content<br>
60
+ This is the info content<br>
61
+ This is the info content<br>
62
+ This is the info content<br>
63
+ This is the info content<br>
64
+ This is the info content<br>
65
+ This is the info content<br>
66
+ This is the info content<br>
67
+ This is the info content<br>
68
+ This is the info content<br>
69
+ This is the info content<br>
70
+ This is the info content<br>
71
+ This is the info content<br>
72
+ This is the info content<br>
73
+ This is the info content<br>
74
+ This is the info content<br>
75
+ This is the info content<br>
76
+ This is the info content<br>
77
+ </unnnic-modal-next>
78
+ </div>
79
+ `,
80
+ }),
81
+ };
82
+
83
+ export const Video = {
84
+ render: (args) => ({
85
+ setup() {
86
+ return { args };
87
+ },
88
+ data() {
89
+ return {
90
+ open: false,
91
+ };
92
+ },
93
+ components: { unnnicModalNext },
94
+ template: `
95
+ <div>
96
+ <button @click="open = true">Open</button>
97
+ <unnnic-modal-next v-show="open" v-bind="args" @close="open = false" />
98
+ </div>
99
+ `,
100
+ }),
101
+ args: {
102
+ type: 'video',
103
+ url: 'https://www.youtube.com/embed/J9QJBPrmoHs',
104
+ confirmButtonType: undefined,
105
+ },
106
+ };
107
+
108
+ export const Default = {
109
+ args: {
110
+ type: undefined,
111
+ confirmButtonType: undefined,
112
+ },
113
+ };
114
+
115
+ export const Alert = {
116
+ args: {
117
+ type: 'alert',
118
+ icon: 'add-1',
119
+ scheme: 'feedback-green',
120
+ title: 'Title',
121
+ description: 'Description',
122
+ confirmButtonType: undefined,
123
+ },
124
+ };
125
+
126
+ export const AlertWithSlots = {
127
+ render: (args) => ({
128
+ setup() {
129
+ return { args };
130
+ },
131
+ data() {
132
+ return {
133
+ open: false,
134
+ };
135
+ },
136
+ components: { unnnicModalNext },
137
+ template: `
138
+ <div>
139
+ <button @click="open = true">Open</button>
140
+ <unnnic-modal-next v-show="open" v-bind="args" @close="open = false">
141
+ <template #title>
142
+ Title Slot
143
+ </template>
144
+
145
+ <template #description>
146
+ Description Slot
147
+ </template>
148
+ </unnnic-modal-next>
149
+ </div>
150
+ `,
151
+ }),
152
+ args: {
153
+ type: 'alert',
154
+ icon: 'add-1',
155
+ scheme: 'feedback-green',
156
+ confirmButtonType: undefined,
157
+ },
158
+ };
159
+
160
+ export const AlertWithValidate = {
161
+ args: {
162
+ type: 'alert',
163
+ icon: 'add-1',
164
+ scheme: 'feedback-red',
165
+ title: 'Title',
166
+ description: 'Description',
167
+ confirmButtonType: undefined,
168
+ validate: 'Hello World!',
169
+ validatePlaceholder: 'Validate Placeholder',
170
+ validateLabel: 'Validate <b>Hello World!</b>',
171
+ actionPrimaryLabel: 'Confirm',
172
+ actionSecondaryLabel: 'Cancel',
173
+ },
174
+ };
175
+
176
+ export const AlertWithActionButtons = {
177
+ args: {
178
+ type: 'alert',
179
+ icon: 'add-1',
180
+ scheme: 'feedback-red',
181
+ title: 'Title',
182
+ description: 'Description',
183
+ confirmButtonType: undefined,
184
+ actionPrimaryLabel: 'Confirm',
185
+ actionSecondaryLabel: 'Cancel',
186
+ actionPrimaryButtonType: undefined,
187
+ showCloseButton: true,
188
+ },
189
+ };