@vcita/design-system 0.6.24 → 0.6.25-beta.1
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 +6 -0
- package/config/locales/ds.en.yml +9 -0
- package/dist/@vcita/design-system.esm.js +24 -10
- package/dist/@vcita/design-system.min.js +1 -1
- package/dist/@vcita/design-system.ssr.js +26 -12
- package/init/initI18n.js +5 -1
- package/package.json +1 -1
- package/src/components/VcInputPopover/VcInputPopover.stories.js +7 -1
- package/src/components/VcInputPopover/VcInputPopover.vue +5 -1
- package/src/components/VcRadio/VcRadio.stories.js +1 -1
- package/src/components/VcRadioGroup/VcRadioGroup.stories.js +1 -1
- package/src/components/VcSwitch/VcSwitch.stories.js +2 -1
- package/src/components/VcSwitch/VcSwitch.vue +22 -3
- package/src/components/VcTimeSince/VcTimeSince.spec.js +86 -0
- package/src/components/VcTimeSince/VcTimeSince.stories.js +29 -0
- package/src/components/VcTimeSince/VcTimeSince.vue +47 -0
|
@@ -4117,11 +4117,15 @@ var __vue_component__$u = /*#__PURE__*/normalizeComponent({
|
|
|
4117
4117
|
icon: {
|
|
4118
4118
|
type: Boolean,
|
|
4119
4119
|
default: false
|
|
4120
|
+
},
|
|
4121
|
+
preLabel: {
|
|
4122
|
+
type: Boolean,
|
|
4123
|
+
default: false
|
|
4120
4124
|
}
|
|
4121
4125
|
},
|
|
4122
4126
|
methods: {
|
|
4123
|
-
onChange: function onChange(
|
|
4124
|
-
this.$emit('input',
|
|
4127
|
+
onChange: function onChange(value) {
|
|
4128
|
+
this.$emit('input', value);
|
|
4125
4129
|
}
|
|
4126
4130
|
}
|
|
4127
4131
|
};/* script */
|
|
@@ -4144,7 +4148,8 @@ var __vue_render__$t = function __vue_render__() {
|
|
|
4144
4148
|
staticClass: "VcSwitch",
|
|
4145
4149
|
class: {
|
|
4146
4150
|
'is-active': _vm.value,
|
|
4147
|
-
'with-icon': _vm.icon
|
|
4151
|
+
'with-icon': _vm.icon,
|
|
4152
|
+
'pre-label': _vm.preLabel
|
|
4148
4153
|
},
|
|
4149
4154
|
attrs: {
|
|
4150
4155
|
"inset": "",
|
|
@@ -4158,6 +4163,11 @@ var __vue_render__$t = function __vue_render__() {
|
|
|
4158
4163
|
on: {
|
|
4159
4164
|
"change": _vm.onChange
|
|
4160
4165
|
},
|
|
4166
|
+
nativeOn: {
|
|
4167
|
+
"click": function click($event) {
|
|
4168
|
+
$event.stopPropagation();
|
|
4169
|
+
}
|
|
4170
|
+
},
|
|
4161
4171
|
scopedSlots: _vm._u([{
|
|
4162
4172
|
key: "label",
|
|
4163
4173
|
fn: function fn() {
|
|
@@ -4183,8 +4193,8 @@ var __vue_staticRenderFns__$t = [];
|
|
|
4183
4193
|
|
|
4184
4194
|
var __vue_inject_styles__$t = function __vue_inject_styles__(inject) {
|
|
4185
4195
|
if (!inject) return;
|
|
4186
|
-
inject("data-v-
|
|
4187
|
-
source: ".switchContainer .VcSwitch[data-v-
|
|
4196
|
+
inject("data-v-4d89683c_0", {
|
|
4197
|
+
source: ".switchContainer .VcSwitch[data-v-4d89683c]{padding:0;margin:0}.switchContainer .VcSwitch[data-v-4d89683c] label{font-size:var(--font-size-small);font-weight:var(--font-weight-medium);line-height:var(--size-value6);color:var(--neutral-lighten-1)}.switchContainer .VcSwitch[data-v-4d89683c] input{height:var(--size-value5)}.switchContainer .VcSwitch[data-v-4d89683c] .v-input--selection-controls__input{margin-left:0;margin-right:var(--size-value3);height:var(--size-value5);width:var(--size-value8)}#app[dir=rtl] .switchContainer .VcSwitch[data-v-4d89683c] .v-input--selection-controls__input{margin-left:var(--size-value3)}#app[dir=rtl] .switchContainer .VcSwitch[data-v-4d89683c] .v-input--selection-controls__input{margin-right:0}.switchContainer .VcSwitch[data-v-4d89683c] .v-input--switch__track{top:0;left:0}#app[dir=rtl] .switchContainer .VcSwitch[data-v-4d89683c] .v-input--switch__track{left:auto;right:0}.switchContainer .VcSwitch[data-v-4d89683c] .v-input--selection-controls__ripple{left:-10px;height:25px;width:25px}#app[dir=rtl] .switchContainer .VcSwitch[data-v-4d89683c] .v-input--selection-controls__ripple{left:auto;right:-10px}.switchContainer .VcSwitch[data-v-4d89683c] .v-input--switch__thumb{height:14px;width:14px;background-color:#fff;top:calc(50% - 7px);transform:translateX(3px)!important;box-shadow:var(--shadow-5)}#app[dir=rtl] .switchContainer .VcSwitch[data-v-4d89683c] .v-input--switch__thumb{transform:translateX(-3px)!important}.switchContainer .VcSwitch.v-input--is-disabled[data-v-4d89683c] {opacity:1}.switchContainer .VcSwitch.v-input--is-disabled[data-v-4d89683c] .v-input--switch__track{color:var(--gray-lighten-2)!important}.switchContainer .VcSwitch.v-input--is-disabled[data-v-4d89683c] .v-input--switch__thumb{background-color:var(--gray)!important;box-shadow:none}.switchContainer .VcSwitch.is-active[data-v-4d89683c] .v-input--switch__track{opacity:1;background-color:currentColor}.switchContainer .VcSwitch.is-active[data-v-4d89683c] .v-input--selection-controls__ripple{transform:translateX(14px)!important}#app[dir=rtl] .switchContainer .VcSwitch.is-active[data-v-4d89683c] .v-input--selection-controls__ripple{transform:translateX(-14px)!important}.switchContainer .VcSwitch.is-active[data-v-4d89683c] .v-input--switch__thumb{transform:translateX(17px)!important}#app[dir=rtl] .switchContainer .VcSwitch.is-active[data-v-4d89683c] .v-input--switch__thumb{transform:translateX(-17px)!important}.switchContainer .VcSwitch.pre-label[data-v-4d89683c] label{order:-1;flex:unset;margin-left:0;margin-right:var(--size-value2)}#app[dir=rtl] .switchContainer .VcSwitch.pre-label[data-v-4d89683c] label{margin-left:var(--size-value2)}#app[dir=rtl] .switchContainer .VcSwitch.pre-label[data-v-4d89683c] label{margin-right:0}.switchContainer .VcSwitch.pre-label[data-v-4d89683c] .v-input--selection-controls__input{margin:unset}.switchContainer .VcSwitch.with-icon[data-v-4d89683c] input{height:var(--size-value6)}.switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--selection-controls__input{margin-left:0;margin-right:var(--size-value3);height:var(--size-value6);width:var(--size-value12)}#app[dir=rtl] .switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--selection-controls__input{margin-left:var(--size-value3)}#app[dir=rtl] .switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--selection-controls__input{margin-right:0}.switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--switch__track{top:0;left:0;height:var(--size-value6);width:var(--size-value12)}#app[dir=rtl] .switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--switch__track{left:auto;right:0}.switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--selection-controls__ripple{left:-9px;height:29px;width:29px;top:calc(50% - 21.5px)}#app[dir=rtl] .switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--selection-controls__ripple{left:auto;right:-9px}.switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--switch__thumb{height:18px;width:18px;top:calc(50% - 9px);transform:translateX(3.5px)!important}#app[dir=rtl] .switchContainer .VcSwitch.with-icon[data-v-4d89683c] .v-input--switch__thumb{transform:translateX(-3.5px)!important}.switchContainer .VcSwitch.with-icon.v-input--is-disabled[data-v-4d89683c] {opacity:1}.switchContainer .VcSwitch.with-icon.v-input--is-disabled[data-v-4d89683c] .v-input--switch__track{color:var(--gray-lighten-2)!important}.switchContainer .VcSwitch.with-icon.v-input--is-disabled[data-v-4d89683c] .v-input--switch__thumb{background-color:var(--gray)!important;box-shadow:none}.switchContainer .VcSwitch.with-icon.v-input--is-disabled+.VcSwitchIcon[data-v-4d89683c]{fill:var(--gray-lighten-2)!important}.switchContainer .VcSwitch.with-icon.is-active[data-v-4d89683c] .v-input--switch__track{opacity:1;background-color:currentColor}.switchContainer .VcSwitch.with-icon.is-active[data-v-4d89683c] .v-input--selection-controls__ripple{transform:translateX(23.5px)!important}#app[dir=rtl] .switchContainer .VcSwitch.with-icon.is-active[data-v-4d89683c] .v-input--selection-controls__ripple{transform:translateX(-23.5px)!important}.switchContainer .VcSwitch.with-icon.is-active[data-v-4d89683c] .v-input--switch__thumb{transform:translateX(26px)!important}#app[dir=rtl] .switchContainer .VcSwitch.with-icon.is-active[data-v-4d89683c] .v-input--switch__thumb{transform:translateX(-26px)!important}.switchContainer .VcSwitchIcon[data-v-4d89683c]{cursor:pointer;pointer-events:none;margin:17px;left:-10px}.switchContainer .VcSwitchIconV[data-v-4d89683c]{top:-33px;transform:translateX(23px);fill:var(--v-secondary-base)}.switchContainer .VcSwitchIconX[data-v-4d89683c]{top:-34px;transform:translate(0,0);fill:var(--neutral-lighten-1)}.switchContainer.with-icon[data-v-4d89683c]{height:var(--size-value6)}",
|
|
4188
4198
|
map: undefined,
|
|
4189
4199
|
media: undefined
|
|
4190
4200
|
});
|
|
@@ -4192,10 +4202,10 @@ var __vue_inject_styles__$t = function __vue_inject_styles__(inject) {
|
|
|
4192
4202
|
/* scoped */
|
|
4193
4203
|
|
|
4194
4204
|
|
|
4195
|
-
var __vue_scope_id__$t = "data-v-
|
|
4205
|
+
var __vue_scope_id__$t = "data-v-4d89683c";
|
|
4196
4206
|
/* module identifier */
|
|
4197
4207
|
|
|
4198
|
-
var __vue_module_identifier__$t = "data-v-
|
|
4208
|
+
var __vue_module_identifier__$t = "data-v-4d89683c";
|
|
4199
4209
|
/* functional template */
|
|
4200
4210
|
|
|
4201
4211
|
var __vue_is_functional_template__$t = false;
|
|
@@ -4611,6 +4621,10 @@ var __vue_component__$r = /*#__PURE__*/normalizeComponent({
|
|
|
4611
4621
|
toggleInitialValue: {
|
|
4612
4622
|
type: Boolean,
|
|
4613
4623
|
default: true
|
|
4624
|
+
},
|
|
4625
|
+
closeOnClick: {
|
|
4626
|
+
type: Boolean,
|
|
4627
|
+
default: true
|
|
4614
4628
|
}
|
|
4615
4629
|
},
|
|
4616
4630
|
data: function data() {
|
|
@@ -4657,7 +4671,7 @@ var __vue_render__$q = function __vue_render__() {
|
|
|
4657
4671
|
|
|
4658
4672
|
return _c('VcPopover', {
|
|
4659
4673
|
attrs: {
|
|
4660
|
-
"close-on-click": _vm.validForm,
|
|
4674
|
+
"close-on-click": _vm.validForm && _vm.closeOnClick,
|
|
4661
4675
|
"value": _vm.value,
|
|
4662
4676
|
"top": _vm.top,
|
|
4663
4677
|
"right": _vm.right,
|
|
@@ -4763,8 +4777,8 @@ var __vue_staticRenderFns__$q = [];
|
|
|
4763
4777
|
|
|
4764
4778
|
var __vue_inject_styles__$q = function __vue_inject_styles__(inject) {
|
|
4765
4779
|
if (!inject) return;
|
|
4766
|
-
inject("data-v-
|
|
4767
|
-
source: "[data-v-
|
|
4780
|
+
inject("data-v-97aa8f28_0", {
|
|
4781
|
+
source: "[data-v-97aa8f28]:root{--primary-font-family:Montserrat;--font-size-xxx-small:9px;--font-size-xx-small:12px;--font-size-x-small:13px;--font-size-small:14px;--font-size-small2:15px;--font-size-small3:17px;--font-size-medium:18px;--font-size-medium1:22px;--font-size-medium2:24px;--font-size-large:28px;--font-weight-light:300;--font-weight-medium:400;--font-weight-medium2:500;--font-weight-large:600;--font-weight-large2:700;--font-weight-xl:800;--letter-spacing:0.003em;--size-value0:0px;--size-value1:4px;--size-value2:8px;--size-value3:12px;--size-value4:16px;--size-value5:20px;--size-value6:24px;--size-value7:28px;--size-value8:32px;--size-value9:36px;--size-value10:40px;--size-value11:44px;--size-value12:48px;--size-value13:52px;--size-value14:56px;--size-value15:60px;--size-value16:64px;--size-value17:68px;--size-value18:72px;--size-value19:76px;--size-value20:80px;--border-radius:6px;--border-frame:1px solid #e0e0e0;--border-focused-frame:1px solid var(--v-secondary-base);--shadow-focused-frame:0px 0px 0px 3px var(--v-secondary-lighten1);--popover-width:360px;--popover-max-height:464px;--popover-border-radius:10px;--modal-desktop-offset:-112px;--modal-bg-color:#ffffff;--modal-box-shadow:0px 7px 8px -4px rgba(0, 0, 0, 0.2),2px 13px 19px 2px rgba(0, 0, 0, 0.14),0px 5px 24px rgba(0, 0, 0, 0.12);--modal-border-radius:10px;--modal-width-small:384px;--modal-width-medium:576px;--modal-width-large:816px;--modal-width-x-large:972px;--avatar-x-sm:24px;--avatar-sm:32px;--avatar-md:40px;--avatar-lg:48px;--dropzone-active-border-color:#1e93b7;--dropzone-active-second-border-color:#95cddb;--gray-darken-5:#212121;--gray-darken-4:#616161;--gray-darken-3:#757575;--gray-darken-2:#999999;--gray-darken-1:#b3b3b3;--gray:#cccccc;--gray-lighten-1:#e0e0e0;--gray-lighten-2:#ededed;--gray-lighten-3:#f7f7f7;--gray-lighten-4:#fafafa;--neutral:#586E8C;--neutral-lighten-1:#D6DBE6;--neutral-lighten-2:#EAEDF2;--neutral-lighten-3:#F8F9FB;--red:#F2514A;--red-lighten-1:#F79792;--red-lighten-2:#FBCBC9;--red-lighten-3:#FDE8E7;--yellow:#FFC511;--yellow-lighten-1:#FFDC70;--yellow-lighten-2:#FFEDB8;--yellow-lighten-3:#FFF7E0;--green:#54D28C;--green-lighten-1:#98E4BA;--green-lighten-2:#CFF8E1;--green-lighten-3:#EAFCF2;--blue:#478FFF;--blue-lighten-1:#91BCFF;--blue-lighten-2:#C8DDFF;--blue-lighten-3:#E7F0FF;--orange:#FF8F00;--orange-lighten-1:#FCB965;--orange-lighten-2:#FAD9B0;--orange-lighten-3:#F9EBDA;--shadow-1:0px 1px 4px rgba(0, 0, 0, 0.11);--shadow-2:0px 2px 5px rgba(0, 0, 0, 0.1),0px 2px 2px rgba(0, 0, 0, 0.06),0px 3px 1px -2px rgba(0, 0, 0, 0.06);--shadow-3:0px 3px 2px rgba(0, 0, 0, 0.101961);--shadow-4:0px 1px 1px rgba(0, 0, 0, 0.06),0px 3px 8px rgba(0, 0, 0, 0.15);--shadow-5:0px 4px 18px rgba(0, 0, 0, 0.1);--shadow-6:0px 1px 10px rgba(0, 0, 0, 0.12),0px 4px 7px rgba(0, 0, 0, 0.14),0px 2px 4px -1px rgba(0, 0, 0, 0.2);--shadow-7:0px 3px 5px -1px rgba(0, 0, 0, 0.2),0px 6px 10px rgba(0, 0, 0, 0.14),0px 1px 18px rgba(0, 0, 0, 0.12);--shadow-8:0px 5px 7px 3px rgba(0, 0, 0, 0.26);--shadow-9:0px 7px 8px -4px rgba(0, 0, 0, 0.2),2px 13px 19px 2px rgba(0, 0, 0, 0.14),0px 5px 24px rgba(0, 0, 0, 0.12);--shadow-10:0px 4px 8px #cccccc}.vc-popover[data-v-97aa8f28]{width:var(--popover-width);max-height:var(--popover-max-height);display:flex;box-shadow:var(--modal-box-shadow)}.vc-popover .vc-popover-content[data-v-97aa8f28]{padding:var(--size-value4) var(--size-value6);overflow-y:auto}.vc-popover .vc-popover-footer[data-v-97aa8f28]{padding:var(--size-value3) var(--size-value6)}",
|
|
4768
4782
|
map: undefined,
|
|
4769
4783
|
media: undefined
|
|
4770
4784
|
});
|
|
@@ -4772,10 +4786,10 @@ var __vue_inject_styles__$q = function __vue_inject_styles__(inject) {
|
|
|
4772
4786
|
/* scoped */
|
|
4773
4787
|
|
|
4774
4788
|
|
|
4775
|
-
var __vue_scope_id__$q = "data-v-
|
|
4789
|
+
var __vue_scope_id__$q = "data-v-97aa8f28";
|
|
4776
4790
|
/* module identifier */
|
|
4777
4791
|
|
|
4778
|
-
var __vue_module_identifier__$q = "data-v-
|
|
4792
|
+
var __vue_module_identifier__$q = "data-v-97aa8f28";
|
|
4779
4793
|
/* functional template */
|
|
4780
4794
|
|
|
4781
4795
|
var __vue_is_functional_template__$q = false;
|
package/init/initI18n.js
CHANGED
|
@@ -27,7 +27,7 @@ const initI18n = (locale = 'en') => {
|
|
|
27
27
|
|
|
28
28
|
Vue.prototype.$ds.setLocale(locale);
|
|
29
29
|
|
|
30
|
-
Vue.prototype.$dst = (key) => {
|
|
30
|
+
Vue.prototype.$dst = (key, params) => {
|
|
31
31
|
const language = messages[Vue.prototype.$ds.locale] || messages['en'];
|
|
32
32
|
|
|
33
33
|
const path = key.split('.');
|
|
@@ -36,6 +36,10 @@ const initI18n = (locale = 'en') => {
|
|
|
36
36
|
for (let item of path) {
|
|
37
37
|
result = result[item];
|
|
38
38
|
}
|
|
39
|
+
for (let param in params) {
|
|
40
|
+
let regex = new RegExp(`%{${param}}`,'gi')
|
|
41
|
+
result = result.replace(regex, params[param])
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
catch {
|
|
41
45
|
result = key;
|
package/package.json
CHANGED
|
@@ -36,6 +36,9 @@ const GeneralTemplate = (args, {argTypes}) => ({
|
|
|
36
36
|
:data-qa="dataQa"
|
|
37
37
|
:show-header-toggle="showHeaderToggle"
|
|
38
38
|
:toggle-initial-value="toggleInitialValue"
|
|
39
|
+
:ok-button-label="okButtonLabel"
|
|
40
|
+
:cancel-button-label="cancelButtonLabel"
|
|
41
|
+
:close-on-click="closeOnClick"
|
|
39
42
|
@input="onInput"
|
|
40
43
|
@onOkClicked="onSubmit"
|
|
41
44
|
@onCancelClicked="onCancel"
|
|
@@ -73,6 +76,9 @@ Playground.args = {
|
|
|
73
76
|
dataQa: 'vc-input-popover',
|
|
74
77
|
showHeaderToggle: true,
|
|
75
78
|
toggleInitialValue: true,
|
|
79
|
+
closeOnClick: true,
|
|
80
|
+
okButtonLabel: 'Done',
|
|
81
|
+
cancelButtonLabel: 'Cancel',
|
|
76
82
|
onInput: action('input'),
|
|
77
83
|
onSubmit: action('submit'),
|
|
78
84
|
onCancel: action('cancel'),
|
|
@@ -89,7 +95,7 @@ export default {
|
|
|
89
95
|
url: 'https://www.figma.com/file/xIOY6fBoA1wpy1tHv3i5js/vcita---ui-library?node-id=7305%3A60442',
|
|
90
96
|
},
|
|
91
97
|
status: {
|
|
92
|
-
type: '
|
|
98
|
+
type: 'stable', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
|
|
93
99
|
url: 'https://vuetifyjs.com/en/components/menus/',
|
|
94
100
|
}
|
|
95
101
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<VcPopover :close-on-click="validForm"
|
|
2
|
+
<VcPopover :close-on-click="validForm && closeOnClick"
|
|
3
3
|
:value="value"
|
|
4
4
|
:top="top"
|
|
5
5
|
:right="right"
|
|
@@ -97,6 +97,10 @@ export default {
|
|
|
97
97
|
type: Boolean,
|
|
98
98
|
default: true
|
|
99
99
|
},
|
|
100
|
+
closeOnClick: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
default: true
|
|
103
|
+
},
|
|
100
104
|
},
|
|
101
105
|
data() {
|
|
102
106
|
return {
|
|
@@ -9,7 +9,7 @@ const Template = (args, {argTypes}) => ({
|
|
|
9
9
|
data: () => ({
|
|
10
10
|
itemValue: true,
|
|
11
11
|
}),
|
|
12
|
-
template: '<div><VcSwitch v-model="itemValue" color="secondary" :label="label" :ripple="ripple" :disabled="disabled" @input="onChange" :icon="icon" /></div>',
|
|
12
|
+
template: '<div><VcSwitch v-model="itemValue" color="secondary" :label="label" :preLabel="preLabel" :ripple="ripple" :disabled="disabled" @input="onChange" :icon="icon" /></div>',
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
export const Playground = Template.bind({});
|
|
@@ -48,6 +48,7 @@ WithLabel.args = {
|
|
|
48
48
|
onChange: action("input"),
|
|
49
49
|
label: 'my switch',
|
|
50
50
|
disabled: false,
|
|
51
|
+
preLabel: true
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
const TemplateWithSlot = (args, {argTypes}) => ({
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
<div class="switchContainer" :class="{'with-icon': icon}">
|
|
3
3
|
<v-switch inset hide-details
|
|
4
4
|
class="VcSwitch"
|
|
5
|
-
:class="{'is-active': value, 'with-icon': icon}"
|
|
5
|
+
:class="{'is-active': value, 'with-icon': icon, 'pre-label': preLabel}"
|
|
6
6
|
:label="label"
|
|
7
7
|
:ripple="ripple"
|
|
8
8
|
:input-value="value"
|
|
9
9
|
:color="color"
|
|
10
10
|
:disabled="disabled"
|
|
11
|
+
@click.native.stop
|
|
11
12
|
@change="onChange">
|
|
12
13
|
<template #label>
|
|
13
14
|
<slot name="label"/>
|
|
@@ -47,11 +48,15 @@ export default {
|
|
|
47
48
|
icon: {
|
|
48
49
|
type: Boolean,
|
|
49
50
|
default: false
|
|
51
|
+
},
|
|
52
|
+
preLabel: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
50
55
|
}
|
|
51
56
|
},
|
|
52
57
|
methods:{
|
|
53
|
-
onChange: function (
|
|
54
|
-
this.$emit('input',
|
|
58
|
+
onChange: function (value) {
|
|
59
|
+
this.$emit('input', value)
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
}
|
|
@@ -135,6 +140,20 @@ export default {
|
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
|
|
143
|
+
&.pre-label{
|
|
144
|
+
::v-deep {
|
|
145
|
+
label{
|
|
146
|
+
order: -1;
|
|
147
|
+
flex: unset;
|
|
148
|
+
@include i-margin-mirror(0, var(--size-value2));
|
|
149
|
+
}
|
|
150
|
+
.v-input--selection-controls__input {
|
|
151
|
+
margin: unset;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
138
157
|
&.with-icon {
|
|
139
158
|
::v-deep {
|
|
140
159
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
2
|
+
import VcTimeSince from "./VcTimeSince"
|
|
3
|
+
import init from "../../../testing-library.config"
|
|
4
|
+
import Vuetify from 'vuetify'
|
|
5
|
+
import {render} from "@testing-library/vue";
|
|
6
|
+
|
|
7
|
+
init();
|
|
8
|
+
|
|
9
|
+
const props = {
|
|
10
|
+
timestamp: Math.floor(Date.now() - 600000)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe("VcTimeSince.vue", () => {
|
|
14
|
+
|
|
15
|
+
const renderWithVuetify = (component, options, callback) => {
|
|
16
|
+
const root = document.createElement('div')
|
|
17
|
+
root.setAttribute('data-app', 'true')
|
|
18
|
+
|
|
19
|
+
return render(
|
|
20
|
+
component,
|
|
21
|
+
{
|
|
22
|
+
container: document.body.appendChild(root),
|
|
23
|
+
// for Vuetify components that use the vuetify instance property
|
|
24
|
+
vuetify: new Vuetify(),
|
|
25
|
+
...options,
|
|
26
|
+
mocks: {
|
|
27
|
+
$dst: value => value,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
callback,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
it("mounts", () => {
|
|
35
|
+
// Queries: https://testing-library.com/docs/queries/about#types-of-queries
|
|
36
|
+
const {container} = renderWithVuetify(VcTimeSince, {
|
|
37
|
+
props: props
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Expect options: https://github.com/testing-library/jest-dom
|
|
41
|
+
expect(container).toHaveAttribute('data-app', 'true')
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('3 years ago',() => {
|
|
45
|
+
const {getByText} = renderWithVuetify(VcTimeSince, {
|
|
46
|
+
props: {timestamp: Math.floor(Date.now() - 1000 * 60 * 60 * 24 * 31 * 12 * 3)}
|
|
47
|
+
})
|
|
48
|
+
expect(getByText('3 years ago')).toBeInTheDocument()
|
|
49
|
+
})
|
|
50
|
+
it('4 months ago',() => {
|
|
51
|
+
const {getByText} = renderWithVuetify(VcTimeSince, {
|
|
52
|
+
props: {timestamp: Math.floor(Date.now() - 1000 * 60 * 60 * 24 * 30 * 4)}
|
|
53
|
+
})
|
|
54
|
+
expect(getByText('4 months ago')).toBeInTheDocument()
|
|
55
|
+
})
|
|
56
|
+
it('11 days ago',() => {
|
|
57
|
+
const {getByText} = renderWithVuetify(VcTimeSince, {
|
|
58
|
+
props: {timestamp: Math.floor(Date.now() - 1000 * 60 * 60 * 24 * 11)}
|
|
59
|
+
})
|
|
60
|
+
expect(getByText('11 days ago')).toBeInTheDocument()
|
|
61
|
+
})
|
|
62
|
+
it('5 hours ago',() => {
|
|
63
|
+
const {getByText} = renderWithVuetify(VcTimeSince, {
|
|
64
|
+
props: {timestamp: Math.floor(Date.now() - 1000 * 60 * 60 * 5)}
|
|
65
|
+
})
|
|
66
|
+
expect(getByText('5 hours ago')).toBeInTheDocument()
|
|
67
|
+
})
|
|
68
|
+
it('10 minutes ago',() => {
|
|
69
|
+
const {getByText} = renderWithVuetify(VcTimeSince, {
|
|
70
|
+
props: props
|
|
71
|
+
})
|
|
72
|
+
expect(getByText('10 minutes ago')).toBeInTheDocument()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('2 second ago',() => {
|
|
76
|
+
const {getByText} = renderWithVuetify(VcTimeSince, {
|
|
77
|
+
props: {timestamp: Math.floor(Date.now() - 2000)}
|
|
78
|
+
})
|
|
79
|
+
expect(getByText('2 seconds ago')).toBeInTheDocument()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import VcTimeSince from './VcTimeSince';
|
|
2
|
+
|
|
3
|
+
const Template = (args, {argTypes}) => ({
|
|
4
|
+
components: {VcTimeSince: VcTimeSince},
|
|
5
|
+
props: Object.keys(argTypes),
|
|
6
|
+
template: '<div><VcTimeSince :timestamp="timestamp" /></div>',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const Playground = Template.bind({});
|
|
10
|
+
|
|
11
|
+
// Set default values
|
|
12
|
+
Playground.args = {
|
|
13
|
+
timestamp: Math.floor(Date.now() - 1400000)
|
|
14
|
+
}
|
|
15
|
+
export default {
|
|
16
|
+
title: 'VcTimeSince',
|
|
17
|
+
id: 'VcTimeSince',
|
|
18
|
+
component: VcTimeSince,
|
|
19
|
+
parameters: {
|
|
20
|
+
design: {
|
|
21
|
+
type: 'figma',
|
|
22
|
+
url: 'https://www.figma.com/file/2n9LGK4TXFmJMtsfrBzdGS/Notification?node-id=60%3A12168',
|
|
23
|
+
},
|
|
24
|
+
status: {
|
|
25
|
+
type: 'stable', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
|
|
26
|
+
url: 'http://www.url.com/status', // will make the tag a link
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span>
|
|
3
|
+
{{timeSince}}
|
|
4
|
+
</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: "VcTimeSince",
|
|
10
|
+
props: {
|
|
11
|
+
timestamp: {
|
|
12
|
+
required: true,
|
|
13
|
+
type: Number,
|
|
14
|
+
validator: prop => Date.now() > prop
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
computed: {
|
|
18
|
+
timeSince () {
|
|
19
|
+
let seconds = Math.floor((new Date() - this.timestamp) / 1000);
|
|
20
|
+
let interval = seconds / 31536000;
|
|
21
|
+
if (interval > 1) {
|
|
22
|
+
return `${this.$dst("ds.time_since.years",{years: Math.floor(interval)})}`;
|
|
23
|
+
}
|
|
24
|
+
interval = seconds / 2592000;
|
|
25
|
+
if (interval > 1) {
|
|
26
|
+
return `${this.$dst("ds.time_since.months",{months: Math.floor(interval)})}`;
|
|
27
|
+
}
|
|
28
|
+
interval = seconds / 86400;
|
|
29
|
+
if (Math.floor(interval) === 1) {
|
|
30
|
+
return `${this.$dst("ds.time_since.yesterday")}`;
|
|
31
|
+
}
|
|
32
|
+
if (interval > 1) {
|
|
33
|
+
return `${this.$dst("ds.time_since.days",{days: Math.floor(interval)})}`;
|
|
34
|
+
}
|
|
35
|
+
interval = seconds / 3600;
|
|
36
|
+
if (interval > 1) {
|
|
37
|
+
return `${this.$dst("ds.time_since.hours",{hours: Math.floor(interval)})}`;
|
|
38
|
+
}
|
|
39
|
+
interval = seconds / 60;
|
|
40
|
+
if (interval > 1) {
|
|
41
|
+
return `${this.$dst("ds.time_since.minutes",{minutes: Math.floor(interval)})}`;
|
|
42
|
+
}
|
|
43
|
+
return `${this.$dst("ds.time_since.now")}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|