@mozaic-ds/vue 0.36.1 → 0.37.1-beta.0

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.
@@ -1,465 +1,261 @@
1
1
  <template>
2
- <div class="mc-kpi">
3
- <div v-if="size === 's'" class="mc-kpi-small">
4
- <div
5
- :class="'mc-kpi-small__value-' + [classForTheme]"
6
- class="mc-kpi-small__value"
7
- >
8
- {{ value }}
9
- </div>
10
- <div v-if="showIcon && icon" class="mc-kpi-small__icon">
11
- <m-icon :name="icon" />
12
- </div>
13
- </div>
14
- <div v-else-if="size === 'm'" class="mc-kpi-medium">
15
- <div class="mc-kpi-medium__data">
16
- <div class="mc-kpi-medium__label">
17
- {{ label }}
18
- </div>
19
- </div>
20
- <div
21
- class="mc-kpi-medium__container"
22
- :class="'mc-kpi-medium__container-' + classForTheme"
23
- >
24
- <div
25
- class="mc-kpi-medium__value"
26
- :class="[
27
- 'mc-kpi-medium__value-' + classForTheme,
28
- classExpectedValueWithoutIcon,
29
- ]"
30
- >
31
- {{ value }}
32
- </div>
33
- <div v-if="showIcon && icon" class="mc-kpi-medium__icon">
34
- <div>
35
- <m-icon :name="icon" />
36
- </div>
37
- </div>
38
- </div>
39
- </div>
40
- <div v-else class="mc-kpi-large" :class="'mc-kpi-large-' + classForTheme">
41
- <div
42
- class="mc-kpi-large__data"
43
- :class="[classDetailsBarActive, 'mc-kpi-large__data-' + classForTheme]"
44
- >
45
- <div class="mc-kpi-large__container">
46
- <div
47
- class="mc-kpi-large__label"
48
- :class="'mc-kpi-large__label-' + classForTheme"
49
- >
50
- {{ label }}
51
- </div>
52
- <div
53
- class="mc-kpi-large__value"
54
- :class="'mc-kpi-large__value-' + classForTheme"
55
- >
56
- {{ value }}
57
- </div>
58
- </div>
59
- </div>
60
- <div v-if="showDetailsBar" class="mc-kpi-large__details">
61
- <div
62
- v-if="showExpectedValue"
63
- class="mc-kpi-large__expected"
64
- :class="classExpectedValueWithoutIcon"
65
- >
66
- {{ expected }}
67
- </div>
68
- <div
69
- v-if="showIcon && icon"
70
- class="mc-kpi-large__icon"
71
- :class="classIconWithoutExpectedValue"
72
- >
73
- <m-icon :name="icon" />
74
- </div>
2
+ <div class="mc-kpi" :class="classObject">
3
+ <span v-if="label" class="mc-kpi__label">{{ label }}</span>
4
+ <div class="mc-kpi__content">
5
+ <div class="mc-kpi__value">{{ value }}</div>
6
+ <div v-if="icon || detail" class="mc-kpi__details">
7
+ <span v-if="detail" class="mc-kpi__text">
8
+ {{ detail }}
9
+ </span>
10
+ <MIcon v-if="icon" :name="icon" class="mc-kpi__icon" color="black" />
75
11
  </div>
76
12
  </div>
77
13
  </div>
78
14
  </template>
79
15
 
80
16
  <script>
81
- import {
82
- responsiveModifierValidators,
83
- } from '../../utils/mozaicClasses';
84
17
  import MIcon from '../icon/MIcon.vue';
85
18
  export default {
86
19
  name: 'MKpi',
87
-
88
20
  components: {
89
21
  MIcon,
90
22
  },
91
-
92
23
  props: {
93
- label: {
94
- type: String,
95
- default: 'Label',
96
- },
97
24
  value: {
98
- type: String,
99
- default: '99.99%'
100
- },
101
- theme: {
102
- type: String,
103
- default: 'info',
104
- },
105
- expected: {
106
- type: String,
107
- default: '> 10% expected'
108
- },
109
- size: {
110
- type: String,
111
- default: 'l',
112
- validator: (value) =>
113
- responsiveModifierValidators(value, ['s', 'm', 'l',]),
25
+ type: String,
26
+ required: true,
114
27
  },
115
28
  icon: {
116
- type: String,
117
- default: 'ArrowArrowTopRight16',
29
+ type: String,
30
+ required: true,
118
31
  },
119
- showDetailsBar: {
120
- type: Boolean,
121
- default: true,
32
+ label: {
33
+ type: String,
34
+ default: undefined,
122
35
  },
123
- showExpectedValue: {
124
- type: Boolean,
125
- default: true,
36
+ type: {
37
+ type: String,
38
+ default: 'information',
39
+ validator: (value) =>
40
+ ['information', 'warning', 'danger', 'success', 'neutral'].includes(
41
+ value
42
+ ),
126
43
  },
127
- showIcon: {
128
- type: Boolean,
129
- default: true,
44
+ detail: {
45
+ type: String,
46
+ default: undefined,
130
47
  },
131
48
  },
132
-
133
49
  computed: {
134
- classDetailsBarActive() {
135
- return !this.showDetailsBar ? 'mc-kpi__without-details-bar' : '';
136
- },
137
- classExpectedValueWithoutIcon() {
138
- return !this.showIcon ? 'mc-kpi__without-icon' : '';
139
- },
140
- classIconWithoutExpectedValue() {
141
- return !this.showExpectedValue ? 'mc-kpi__without-expected-value' : '';
50
+ getSize() {
51
+ let size = 'small';
52
+
53
+ if (this.label && !this.detail) {
54
+ size = 'medium';
55
+ } else if (this.detail) {
56
+ size = 'large';
57
+ }
58
+
59
+ return size;
142
60
  },
143
- classForTheme() {
144
- return this.theme;
61
+ classObject() {
62
+ return {
63
+ [`mc-kpi--${this.getSize}`]: this.getSize,
64
+ [`mc-kpi--${this.type}`]: this.type,
65
+ };
145
66
  },
146
67
  },
147
-
148
68
  };
149
69
  </script>
150
70
 
151
- <style lang="scss">
71
+ <style lang="scss" scoped>
152
72
  @import 'settings-tools/all-settings';
153
73
 
154
- .mc-kpi {
74
+ $kpi-type: (
75
+ 'information': (
76
+ 'background': #daeff7,
77
+ 'border': #007bb4,
78
+ 'text': #005c91,
79
+ ),
80
+ 'warning': (
81
+ 'background': #fdf1e8,
82
+ 'border': #c65200,
83
+ 'text': #8c3500,
84
+ ),
85
+ 'danger': (
86
+ 'background': #fdeaea,
87
+ 'border': #c61112,
88
+ 'text': #8c0003,
89
+ ),
90
+ 'success': (
91
+ 'background': #ebf5de,
92
+ 'border': #188803,
93
+ 'text': #006902,
94
+ ),
95
+ 'neutral': (
96
+ 'background': #e6e6e6,
97
+ 'border': #666666,
98
+ 'text': #4d4d4d,
99
+ ),
100
+ );
101
+
102
+ $color-kpi-background: var(
103
+ --color-kpi-background,
104
+ map-deep-get($kpi-type, 'information', 'background')
105
+ );
106
+ $color-kpi-border: var(
107
+ --color-kpi-border,
108
+ map-deep-get($kpi-type, 'information', 'border')
109
+ );
110
+ $color-kpi-text: var(
111
+ --color-kpi-text,
112
+ map-deep-get($kpi-type, 'information', 'text')
113
+ );
114
+
115
+ @mixin set-kpi-container() {
116
+ background-color: $color-kpi-background;
117
+ border: 1px solid $color-kpi-border;
118
+ border-radius: 4px;
119
+ overflow: hidden;
120
+ }
155
121
 
156
- &__expected-without-icon {
157
- width: 100% !important;
158
- text-align: center;
159
- border-radius: 4px 4px 4px 4px !important;
160
- margin: 0;
122
+ .mc-kpi {
123
+ $parent: get-parent-selector(&);
124
+
125
+ color: $color-kpi-text;
126
+ display: inline-block;
127
+
128
+ // label
129
+ &__label {
130
+ @include set-font-scale('04', 'm');
131
+
132
+ display: block;
133
+ }
134
+
135
+ // content
136
+ &__content {
137
+ display: flex;
138
+ }
139
+
140
+ // value
141
+ &__value {
142
+ @include set-font-scale('04', 'm');
143
+ @include set-font-weight('semi-bold');
144
+
145
+ text-align: center;
146
+ }
147
+
148
+ &__details {
149
+ align-items: center;
150
+ background-color: $color-grey-000;
151
+ color: $color-font-dark;
152
+ display: flex;
153
+ justify-content: center;
154
+ }
155
+
156
+ &__text {
157
+ @include set-font-scale('04', 'm');
158
+ }
159
+
160
+ &__icon {
161
+ display: block;
162
+ height: $mu100;
163
+ width: $mu100;
164
+ }
165
+
166
+ // Modifier Size — Small
167
+ &--small {
168
+ #{$parent} {
169
+ &__content {
170
+ gap: $mu050;
171
+ }
172
+
173
+ &__value {
174
+ @include set-kpi-container();
175
+
176
+ padding: px-to-rem(3) px-to-rem(7);
177
+ }
178
+
179
+ &__details {
180
+ background-color: transparent;
181
+ }
161
182
  }
183
+ }
184
+
185
+ // Modifier Size — Medium
186
+ &--medium {
187
+ #{$parent} {
188
+ &__label {
189
+ color: $color-grey-999;
190
+ margin-bottom: px-to-rem(6);
191
+ }
192
+
193
+ &__content {
194
+ @include set-kpi-container();
195
+ }
196
+
197
+ &__value {
198
+ @include set-font-scale('05', 'm');
199
+
200
+ padding: $mu050 $mu050 $mu050 px-to-rem(7);
201
+ flex-grow: 1;
202
+ }
203
+
204
+ &__details {
205
+ padding-left: $mu075;
206
+ padding-right: px-to-rem(11);
207
+ }
208
+ }
209
+ }
210
+
211
+ // Modifier Size — Large
212
+ &--large {
213
+ @include set-kpi-container();
162
214
 
163
- &__icon-without-expected-value {
164
- width: 100% !important;
215
+ #{$parent} {
216
+ &__label,
217
+ &__value {
218
+ padding-right: px-to-rem(15);
219
+ padding-left: px-to-rem(15);
220
+ }
221
+
222
+ &__label {
223
+ @include set-font-scale('05', 'm');
224
+
225
+ padding-top: $mu100;
165
226
  text-align: center;
166
- margin: 0;
167
- }
227
+ }
168
228
 
169
- &__without-details-bar {
170
- height: 100% !important;
171
- }
229
+ &__content {
230
+ flex-direction: column;
231
+ width: 100%;
232
+ }
172
233
 
173
- /* size S */
174
- &-small {
175
- display: flex;
176
- max-width: 100px;
177
- height: 24px;
178
- justify-content: space-between;
179
- align-items: center;
180
-
181
- &__value {
182
- height: 100%;
183
- width: 75%;
184
- display: flex;
185
- align-items: center;
186
- justify-content: center;
187
- font-weight: 700;
188
- font-size: 14px;
189
- line-height: 18px;
190
- border-radius: 4px;
191
- border: 1px solid $color-info-500;
192
- background-color: $color-info-100;
193
- color: $color-info-700;
194
-
195
- &-info {
196
- border: 1px solid $color-info-600;
197
- background-color: $color-info-100;
198
- color: $color-info-700;
199
- }
200
-
201
- &-success {
202
- border: 1px solid $color-success-600;
203
- background-color: $color-success-100;
204
- color: $color-success-700;
205
- }
206
-
207
- &-danger {
208
- border: 1px solid $color-danger-600;
209
- background-color: $color-danger-100;
210
- color: $color-danger-700;
211
- }
212
-
213
- &-neutral {
214
- border: 1px solid $color-grey-600;
215
- background-color: $color-grey-100;
216
- color: $color-grey-700;
217
- }
218
-
219
- &-warning {
220
- border: 1px solid $color-warning-600;
221
- background-color: $color-warning-100;
222
- color: $color-warning-700;
223
- }
224
-
225
- }
226
-
227
- &__icon {
228
- height: 100%;
229
- width: 25%;
230
- display: flex;
231
- justify-content: end;
232
- align-items: center;
233
- }
234
- }
234
+ &__value {
235
+ @include set-font-scale('09', 'm');
235
236
 
236
- /* size M */
237
- &-medium {
238
- max-width: 167px;
239
- height: 64px;
240
-
241
- &__container {
242
- display: flex;
243
- align-items: center;
244
- justify-content: space-between;
245
- height: 60%;
246
- width: 100%;
247
- border-radius: 4px;
248
- border: 1px solid $color-info-500;
249
-
250
- &-info {
251
- border: 1px solid $color-info-600;
252
- }
253
-
254
- &-success {
255
- border: 1px solid $color-success-600;
256
- }
257
-
258
- &-danger {
259
- border: 1px solid $color-danger-600;
260
- }
261
-
262
- &-neutral {
263
- border: 1px solid $color-grey-600;
264
- }
265
-
266
- &-warning {
267
- border: 1px solid $color-warning-600;
268
- }
269
-
270
- }
271
-
272
- &__label {
273
- height: 40%;
274
- font-size: 14px;
275
- line-height: 18px;
276
- overflow-wrap: break-word;
277
- width: 100%;
278
- display: inline-block;
279
- white-space: nowrap;
280
- overflow: hidden !important;
281
- text-overflow: ellipsis;
282
- }
283
-
284
- &__value {
285
- color: $color-info-700;
286
- font-weight: 700;
287
- font-size: 16px;
288
- line-height: 22px;
289
- height: 100%;
290
- width: 75%;
291
- text-align: center;
292
- align-items: center;
293
- display: flex;
294
- justify-content: center;
295
- border-radius: 4px 0px 0px 4px;
296
- background-color: $color-info-100;
297
-
298
- &-info {
299
- background-color: $color-info-100;
300
- color: $color-info-700;
301
- }
302
-
303
- &-success {
304
- background-color: $color-success-100;
305
- color: $color-success-700;
306
- }
307
-
308
- &-danger {
309
- background-color: $color-danger-100;
310
- color: $color-danger-700;
311
- }
312
-
313
- &-neutral {
314
- background-color: $color-grey-100;
315
- color: $color-grey-700;
316
- }
317
-
318
- &-warning {
319
- background-color: $color-warning-100;
320
- color: $color-warning-700;
321
- }
322
-
323
- }
324
-
325
- &__icon {
326
- width: 25%;
327
- text-align: center;
328
- }
329
- }
237
+ padding-bottom: $mu100;
238
+ }
330
239
 
331
- /* size L or default */
332
- &-large {
333
- max-width: 167px;
334
- height: 147px;
335
- border-radius: 4px 4px 4px 4px;
336
- border: 1px solid $color-info-500;
337
-
338
- &__data {
339
- display: flex;
340
- align-items: center;
341
- justify-content: center;
342
- width: 100%;
343
- height: 70%;
344
- border-radius: 4px 4px 0px 0px;
345
- background-color: $color-info-100;
346
-
347
- &-info {
348
- background-color: $color-info-100;
349
- }
350
-
351
- &-success {
352
- background-color: $color-success-100;
353
- }
354
-
355
- &-danger {
356
- background-color: $color-danger-100;
357
- }
358
-
359
- &-neutral {
360
- background-color: $color-grey-100;
361
- }
362
-
363
- &-warning {
364
- background-color: $color-warning-100;
365
- }
366
- }
367
-
368
- &__container {
369
- width: 100%;
370
- text-align: center;
371
- }
372
-
373
- &__label {
374
- font-weight: 400;
375
- font-size: 16px;
376
- line-height: 22px;
377
- overflow-wrap: break-word;
378
- width: 80%;
379
- justify-content: center;
380
- display: inline-block;
381
- white-space: nowrap;
382
- overflow: hidden !important;
383
- text-overflow: ellipsis;
384
- color: $color-info-700;
385
- }
386
-
387
- &__value {
388
- overflow-wrap: break-word;
389
- width: 80%;
390
- font-weight: 700;
391
- font-size: 34px;
392
- line-height: 44px;
393
- justify-content: center;
394
- display: inline-block;
395
- white-space: nowrap;
396
- overflow: hidden !important;
397
- text-overflow: ellipsis;
398
- margin: 0;
399
- color: $color-info-700;
400
- }
401
-
402
- &__label,
403
- &__value {
404
-
405
- &-info {
406
- color: $color-info-700;
407
- }
408
-
409
- &-success {
410
- color: $color-success-700;
411
- }
412
-
413
- &-danger {
414
- color: $color-danger-700;
415
- }
416
-
417
- &-neutral {
418
- color: $color-grey-700;
419
- }
420
-
421
- &-warning {
422
- color: $color-warning-700;
423
- }
424
- }
425
-
426
- &__details {
427
- margin: 0 10px;
428
- display: flex;
429
- align-items: center;
430
- justify-content: space-between;
431
- height: 30%;
432
- }
433
-
434
- &__expected {
435
- display: inline-block;
436
- width: 80%;
437
- white-space: nowrap;
438
- overflow: hidden !important;
439
- text-overflow: ellipsis;
440
- }
441
-
442
- &-info {
443
- border: 1px solid $color-info-600;
444
- }
445
-
446
- &-success {
447
- border: 1px solid $color-success-600;
448
- }
449
-
450
- &-danger {
451
- border: 1px solid $color-danger-600;
452
- }
453
-
454
- &-neutral {
455
- border: 1px solid $color-grey-600;
456
- }
457
-
458
- &-warning {
459
- border: 1px solid $color-warning-600;
460
- }
240
+ &__details {
241
+ min-height: px-to-rem(47);
242
+ padding-right: px-to-rem(11);
243
+ padding-left: px-to-rem(11);
461
244
 
245
+ gap: $mu075;
246
+ }
462
247
  }
463
-
248
+ }
249
+
250
+ // Modifier Type
251
+ @each $type, $props in $kpi-type {
252
+ &--#{$type} {
253
+ @if ($type != 'information') {
254
+ --color-kpi-background: #{map-get($props, 'background')};
255
+ --color-kpi-border: #{map-get($props, 'border')};
256
+ --color-kpi-text: #{map-get($props, 'text')};
257
+ }
258
+ }
259
+ }
464
260
  }
465
261
  </style>
package/src/index.js CHANGED
@@ -34,8 +34,10 @@ export { MField } from './components/field';
34
34
  export { MDropdown } from './components/dropdown';
35
35
  export { MFileUploader } from './components/fileuploader';
36
36
  export { MFlag } from './components/flag';
37
+ export { MHeader } from './components/header';
37
38
  export { MHero } from './components/hero';
38
39
  export { MIcon } from './components/icon';
40
+ export { MKpi } from './components/kpi';
39
41
  export { MLayer } from './components/layer';
40
42
  export { MLink } from './components/link';
41
43
  export { MListBox, MListBoxActions } from './components/listbox';
@@ -61,4 +63,3 @@ export { MTextArea } from './components/textarea';
61
63
  export { MTextInput } from './components/textinput';
62
64
  export { MToggle } from './components/toggle';
63
65
  export { MTooltip } from './components/tooltip';
64
- export { MKpi } from './components/kpi';