@kiva/kv-components 4.1.0 → 4.2.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.2.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@4.1.0...@kiva/kv-components@4.2.0) (2024-12-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix transition and remove unused code ([664b00e](https://github.com/kiva/kv-ui-elements/commit/664b00e1b27a6afd51ce9cc85069b9dd4f5dc5d7))
12
+ * remove bg ([43c8a0d](https://github.com/kiva/kv-ui-elements/commit/43c8a0db295be4dd86b414a41145ebcc6e2606f8))
13
+ * set default values for element ([c21852d](https://github.com/kiva/kv-ui-elements/commit/c21852d54e2c94f99098b5a234233addfe0a1ed2))
14
+
15
+
16
+ ### Features
17
+
18
+ * sidesheet expand effect ([4fbe553](https://github.com/kiva/kv-ui-elements/commit/4fbe5533d437af0d77b6d79b2f8ec8880f51c3dd))
19
+
20
+
21
+
22
+
23
+
6
24
  # [4.1.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@4.0.1...@kiva/kv-components@4.1.0) (2024-12-02)
7
25
 
8
26
 
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div
3
3
  v-if="visible"
4
- class="tw-block tw-absolute tw-inset-0
5
- tw-bg-black tw-transition-all tw-duration-150 tw-z-modal"
4
+ class="tw-block tw-fixed lg:tw-mt-0 md:tw-absolute tw-inset-0
5
+ tw-bg-black tw-transition-all md:tw-duration-150 tw-z-modal"
6
6
  :class="{
7
7
  'tw-bg-opacity-0 tw-delay-300': !open,
8
8
  'tw-bg-opacity-low': open,
@@ -10,13 +10,21 @@
10
10
  @click.self="closeSideSheet"
11
11
  >
12
12
  <div
13
- class="tw-absolute tw-right-0 tw-h-full tw-transition-all tw-duration-300 tw-bg-white"
13
+ class="tw-absolute tw-right-0 tw-h-full tw-transition-all tw-duration-300 tw-bg-white
14
+ tw-overflow-hidden"
14
15
  :class="{
15
- 'tw-w-0 tw-p-0 tw-delay-200': !open,
16
- 'lg:tw-w-1/2 tw-w-full tw-p-2': open,
16
+ 'tw-w-0 tw-p-0 tw-delay-200 tw-opacity-low': !open,
17
+ 'lg:tw-w-1/2 tw-w-full tw-p-2 tw-opacity-full': open,
17
18
  }"
19
+ :style="modalStyles"
18
20
  >
19
- <div class="tw-flex tw-justify-between">
21
+ <div
22
+ class="tw-flex tw-justify-between tw-transition-opacity tw-duration-500 tw-delay-200"
23
+ :class="{
24
+ 'tw-opacity-0': !open,
25
+ 'tw-opacity-full': open,
26
+ }"
27
+ >
20
28
  <button
21
29
  class="hover:tw-text-action-highlight"
22
30
  @click="closeSideSheet"
@@ -89,6 +97,13 @@ export default {
89
97
  type: String,
90
98
  default: '',
91
99
  },
100
+ /**
101
+ * Source element position for expand animation
102
+ */
103
+ animationSourceElement: {
104
+ type: Object,
105
+ default: () => ({}),
106
+ },
92
107
  },
93
108
  emits: [
94
109
  'side-sheet-closed',
@@ -98,13 +113,24 @@ export default {
98
113
  visible,
99
114
  kvTrackFunction,
100
115
  trackEventCategory,
116
+ animationSourceElement,
101
117
  } = toRefs(props);
102
118
 
103
119
  const open = ref(false);
120
+ const initialStyles = ref({});
121
+ const modalStyles = ref({});
104
122
 
105
123
  const closeSideSheet = () => {
106
124
  open.value = false;
107
125
  kvTrackFunction.value(trackEventCategory.value, 'click', 'side-sheet-closed');
126
+
127
+ if (animationSourceElement.value) {
128
+ modalStyles.value = {
129
+ ...initialStyles.value,
130
+ transition: 'all 0.5s ease-in-out',
131
+ };
132
+ }
133
+
108
134
  setTimeout(() => {
109
135
  emit('side-sheet-closed');
110
136
  }, '700');
@@ -118,7 +144,39 @@ export default {
118
144
  if (visible.value) {
119
145
  setTimeout(() => {
120
146
  open.value = true;
121
- }, '300');
147
+ }, 100);
148
+
149
+ const rect = animationSourceElement.value?.getBoundingClientRect();
150
+
151
+ const top = rect?.top ?? 0;
152
+ const left = rect?.left ?? 0;
153
+ const width = rect?.width ?? 0;
154
+ const height = rect?.height ?? 0;
155
+
156
+ if (top || left || width || height) {
157
+ initialStyles.value = {
158
+ position: 'fixed',
159
+ top: `${top}px`,
160
+ left: `${left}px`,
161
+ width: `${width}px`,
162
+ height: `${height}px`,
163
+ };
164
+
165
+ modalStyles.value = {
166
+ ...initialStyles.value,
167
+ transition: 'none',
168
+ };
169
+
170
+ setTimeout(() => {
171
+ modalStyles.value = {
172
+ top: '0',
173
+ left: '0',
174
+ width: '100vw',
175
+ height: '100vh',
176
+ transition: 'all 0.5s ease-in-out',
177
+ };
178
+ }, 10);
179
+ }
122
180
  }
123
181
  });
124
182
 
@@ -128,6 +186,7 @@ export default {
128
186
  open,
129
187
  closeSideSheet,
130
188
  goToLink,
189
+ modalStyles,
131
190
  };
132
191
  },
133
192
  };
@@ -14,16 +14,19 @@ const Template = (args, {
14
14
  KvSideSheet,
15
15
  KvButton,
16
16
  },
17
- setup() { return { args }; },
17
+ setup() {
18
+ return { args };
19
+ },
18
20
  template: `
19
21
  <div>
20
- <kv-button @click="isVisible = true">Show Side Sheet</kv-button>
22
+ <kv-button @click="openModal($event)">Show Side Sheet</kv-button>
21
23
  <kv-side-sheet
22
24
  :visible="isVisible"
23
25
  :kv-track-function="kvTrackMock"
24
26
  track-event-category="new-loan-card"
25
27
  :show-go-to-link="true"
26
28
  @side-sheet-closed="isVisible = false"
29
+ :animation-source-element="animationSourceElement"
27
30
  >
28
31
  <div>
29
32
  Some content
@@ -33,6 +36,8 @@ const Template = (args, {
33
36
  data() {
34
37
  return {
35
38
  isVisible: args.visible,
39
+ expandEffect: args.expandEffect,
40
+ animationSourceElement: null,
36
41
  };
37
42
  },
38
43
  methods: {
@@ -45,7 +50,18 @@ const Template = (args, {
45
50
  ) {
46
51
  console.log(category, action, label, property, value);
47
52
  },
53
+ openModal(event) {
54
+ if (this.expandEffect) {
55
+ this.animationSourceElement = event.currentTarget;
56
+ }
57
+ this.isVisible = true;
58
+ },
48
59
  },
49
60
  });
50
61
 
51
- export const Default = Template.bind({ visible: false });
62
+ export const Default = Template.bind({});
63
+
64
+ export const ExpandEffect = Template.bind({});
65
+ ExpandEffect.args = {
66
+ expandEffect: true,
67
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -96,5 +96,5 @@
96
96
  "peerDependencies": {
97
97
  "vue": ">=3.0.0"
98
98
  },
99
- "gitHead": "e954e011b7acc2fbfe1ff1c294709aa5dd0b98fa"
99
+ "gitHead": "eee1d0e0b5830392cae80d3d61264757c0f55dd2"
100
100
  }
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div
3
3
  v-if="visible"
4
- class="tw-block tw-absolute tw-inset-0
5
- tw-bg-black tw-transition-all tw-duration-150 tw-z-modal"
4
+ class="tw-block tw-fixed lg:tw-mt-0 md:tw-absolute tw-inset-0
5
+ tw-bg-black tw-transition-all md:tw-duration-150 tw-z-modal"
6
6
  :class="{
7
7
  'tw-bg-opacity-0 tw-delay-300': !open,
8
8
  'tw-bg-opacity-low': open,
@@ -10,13 +10,21 @@
10
10
  @click.self="closeSideSheet"
11
11
  >
12
12
  <div
13
- class="tw-absolute tw-right-0 tw-h-full tw-transition-all tw-duration-300 tw-bg-white"
13
+ class="tw-absolute tw-right-0 tw-h-full tw-transition-all tw-duration-300 tw-bg-white
14
+ tw-overflow-hidden"
14
15
  :class="{
15
- 'tw-w-0 tw-p-0 tw-delay-200': !open,
16
- 'lg:tw-w-1/2 tw-w-full tw-p-2': open,
16
+ 'tw-w-0 tw-p-0 tw-delay-200 tw-opacity-low': !open,
17
+ 'lg:tw-w-1/2 tw-w-full tw-p-2 tw-opacity-full': open,
17
18
  }"
19
+ :style="modalStyles"
18
20
  >
19
- <div class="tw-flex tw-justify-between">
21
+ <div
22
+ class="tw-flex tw-justify-between tw-transition-opacity tw-duration-500 tw-delay-200"
23
+ :class="{
24
+ 'tw-opacity-0': !open,
25
+ 'tw-opacity-full': open,
26
+ }"
27
+ >
20
28
  <button
21
29
  class="hover:tw-text-action-highlight"
22
30
  @click="closeSideSheet"
@@ -89,6 +97,13 @@ export default {
89
97
  type: String,
90
98
  default: '',
91
99
  },
100
+ /**
101
+ * Source element position for expand animation
102
+ */
103
+ animationSourceElement: {
104
+ type: Object,
105
+ default: () => ({}),
106
+ },
92
107
  },
93
108
  emits: [
94
109
  'side-sheet-closed',
@@ -98,13 +113,24 @@ export default {
98
113
  visible,
99
114
  kvTrackFunction,
100
115
  trackEventCategory,
116
+ animationSourceElement,
101
117
  } = toRefs(props);
102
118
 
103
119
  const open = ref(false);
120
+ const initialStyles = ref({});
121
+ const modalStyles = ref({});
104
122
 
105
123
  const closeSideSheet = () => {
106
124
  open.value = false;
107
125
  kvTrackFunction.value(trackEventCategory.value, 'click', 'side-sheet-closed');
126
+
127
+ if (animationSourceElement.value) {
128
+ modalStyles.value = {
129
+ ...initialStyles.value,
130
+ transition: 'all 0.5s ease-in-out',
131
+ };
132
+ }
133
+
108
134
  setTimeout(() => {
109
135
  emit('side-sheet-closed');
110
136
  }, '700');
@@ -118,7 +144,39 @@ export default {
118
144
  if (visible.value) {
119
145
  setTimeout(() => {
120
146
  open.value = true;
121
- }, '300');
147
+ }, 100);
148
+
149
+ const rect = animationSourceElement.value?.getBoundingClientRect();
150
+
151
+ const top = rect?.top ?? 0;
152
+ const left = rect?.left ?? 0;
153
+ const width = rect?.width ?? 0;
154
+ const height = rect?.height ?? 0;
155
+
156
+ if (top || left || width || height) {
157
+ initialStyles.value = {
158
+ position: 'fixed',
159
+ top: `${top}px`,
160
+ left: `${left}px`,
161
+ width: `${width}px`,
162
+ height: `${height}px`,
163
+ };
164
+
165
+ modalStyles.value = {
166
+ ...initialStyles.value,
167
+ transition: 'none',
168
+ };
169
+
170
+ setTimeout(() => {
171
+ modalStyles.value = {
172
+ top: '0',
173
+ left: '0',
174
+ width: '100vw',
175
+ height: '100vh',
176
+ transition: 'all 0.5s ease-in-out',
177
+ };
178
+ }, 10);
179
+ }
122
180
  }
123
181
  });
124
182
 
@@ -128,6 +186,7 @@ export default {
128
186
  open,
129
187
  closeSideSheet,
130
188
  goToLink,
189
+ modalStyles,
131
190
  };
132
191
  },
133
192
  };
@@ -14,16 +14,19 @@ const Template = (args, {
14
14
  KvSideSheet,
15
15
  KvButton,
16
16
  },
17
- setup() { return { args }; },
17
+ setup() {
18
+ return { args };
19
+ },
18
20
  template: `
19
21
  <div>
20
- <kv-button @click="isVisible = true">Show Side Sheet</kv-button>
22
+ <kv-button @click="openModal($event)">Show Side Sheet</kv-button>
21
23
  <kv-side-sheet
22
24
  :visible="isVisible"
23
25
  :kv-track-function="kvTrackMock"
24
26
  track-event-category="new-loan-card"
25
27
  :show-go-to-link="true"
26
28
  @side-sheet-closed="isVisible = false"
29
+ :animation-source-element="animationSourceElement"
27
30
  >
28
31
  <div>
29
32
  Some content
@@ -33,6 +36,8 @@ const Template = (args, {
33
36
  data() {
34
37
  return {
35
38
  isVisible: args.visible,
39
+ expandEffect: args.expandEffect,
40
+ animationSourceElement: null,
36
41
  };
37
42
  },
38
43
  methods: {
@@ -45,7 +50,18 @@ const Template = (args, {
45
50
  ) {
46
51
  console.log(category, action, label, property, value);
47
52
  },
53
+ openModal(event) {
54
+ if (this.expandEffect) {
55
+ this.animationSourceElement = event.currentTarget;
56
+ }
57
+ this.isVisible = true;
58
+ },
48
59
  },
49
60
  });
50
61
 
51
- export const Default = Template.bind({ visible: false });
62
+ export const Default = Template.bind({});
63
+
64
+ export const ExpandEffect = Template.bind({});
65
+ ExpandEffect.args = {
66
+ expandEffect: true,
67
+ };