@kiva/kv-components 3.83.1 → 3.84.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,28 @@
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
+ # [3.84.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.83.2...@kiva/kv-components@3.84.0) (2024-07-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * aside controls variant added to carousel component ([#420](https://github.com/kiva/kv-ui-elements/issues/420)) ([d50ca9e](https://github.com/kiva/kv-ui-elements/commit/d50ca9eaa9023d437a5b9e385b95bfdecee7b122))
12
+
13
+
14
+
15
+
16
+
17
+ ## [3.83.2](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.83.1...@kiva/kv-components@3.83.2) (2024-06-25)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * max dimensions on kvContentfulImg ([#419](https://github.com/kiva/kv-ui-elements/issues/419)) ([4496979](https://github.com/kiva/kv-ui-elements/commit/4496979544fa7d9d941111bff234aae58aa5ca16))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [3.83.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.83.0...@kiva/kv-components@3.83.1) (2024-06-07)
7
29
 
8
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.83.1",
3
+ "version": "3.84.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,5 +75,5 @@
75
75
  "optional": true
76
76
  }
77
77
  },
78
- "gitHead": "fd9613c908f4eeaddb1a8395e864c5c0448c53af"
78
+ "gitHead": "5e75a9b1c10233bd13cd5b897dcbbb2990d03647"
79
79
  }
@@ -2,11 +2,13 @@
2
2
  <section
3
3
  ref="rootEl"
4
4
  class="kv-carousel tw-overflow-hidden tw-w-full"
5
+ :class="{ 'lg:tw-relative': asideControls }"
5
6
  aria-label="carousel"
6
7
  >
7
8
  <!-- Carousel Content -->
8
9
  <div
9
10
  class="tw-flex tw-gap-x-4"
11
+ :class="{ 'tw-mx-auto aside-controls-content': asideControls }"
10
12
  @click.capture="onCarouselContainerClick"
11
13
  >
12
14
  <div
@@ -32,6 +34,7 @@
32
34
  class="kv-carousel__controls tw-flex
33
35
  tw-justify-between md:tw-justify-center tw-items-center
34
36
  tw-mt-4 tw-w-full"
37
+ :class="{ 'lg:tw-hidden': asideControls }"
35
38
  >
36
39
  <button
37
40
  class="tw-text-primary
@@ -72,6 +75,50 @@
72
75
  <span class="tw-sr-only">Show next slide</span>
73
76
  </button>
74
77
  </div>
78
+ <!-- Aside Buttons -->
79
+ <template v-if="asideControls">
80
+ <div
81
+ class="tw-hidden lg:tw-flex tw-absolute tw-h-full tw-top-0 tw-items-center"
82
+ style="background: linear-gradient(90deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 100%); width: 8%;"
83
+ >
84
+ <button
85
+ class="tw-text-primary tw-bg-gray-100
86
+ tw-rounded-full
87
+ tw-h-6 tw-w-6 tw-ml-3
88
+ tw-flex tw-items-center tw-justify-center
89
+ disabled:tw-opacity-low disabled:tw-cursor-default"
90
+ :disabled="embla && !embla.canScrollPrev()"
91
+ @click="handleUserInteraction(previousIndex, 'click-left-arrow')"
92
+ >
93
+ <kv-material-icon
94
+ class="tw-w-4"
95
+ :icon="mdiArrowLeft"
96
+ />
97
+ <span class="tw-sr-only">Show previous slide</span>
98
+ </button>
99
+ </div>
100
+ <div
101
+ class="tw-hidden lg:tw-flex tw-absolute tw-h-full
102
+ tw-top-0 tw-right-0 tw-items-center tw-justify-end tw-w-16"
103
+ style="background: linear-gradient(270deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 100%); width: 8%;"
104
+ >
105
+ <button
106
+ class="tw-text-primary tw-bg-gray-100
107
+ tw-rounded-full
108
+ tw-h-6 tw-w-6 tw-mr-3
109
+ tw-flex tw-items-center tw-justify-center
110
+ disabled:tw-opacity-low disabled:tw-cursor-default"
111
+ :disabled="embla && !embla.canScrollNext()"
112
+ @click="handleUserInteraction(nextIndex, 'click-right-arrow')"
113
+ >
114
+ <kv-material-icon
115
+ class="tw-w-4"
116
+ :icon="mdiArrowRight"
117
+ />
118
+ <span class="tw-sr-only">Show next slide</span>
119
+ </button>
120
+ </div>
121
+ </template>
75
122
  </section>
76
123
  </template>
77
124
 
@@ -85,7 +132,12 @@ import {
85
132
  nextTick,
86
133
  } from 'vue-demi';
87
134
  import EmblaCarousel from 'embla-carousel';
88
- import { mdiChevronLeft, mdiChevronRight } from '@mdi/js';
135
+ import {
136
+ mdiChevronLeft,
137
+ mdiChevronRight,
138
+ mdiArrowLeft,
139
+ mdiArrowRight,
140
+ } from '@mdi/js';
89
141
  import { throttle } from '../utils/throttle';
90
142
 
91
143
  import KvMaterialIcon from './KvMaterialIcon.vue';
@@ -133,6 +185,13 @@ export default {
133
185
  type: String,
134
186
  default: '',
135
187
  },
188
+ /**
189
+ * Aside controls version of the carousel
190
+ * */
191
+ asideControls: {
192
+ type: Boolean,
193
+ default: false,
194
+ },
136
195
  },
137
196
  emits: [
138
197
  'change',
@@ -301,6 +360,8 @@ export default {
301
360
  rootEl,
302
361
  mdiChevronLeft,
303
362
  mdiChevronRight,
363
+ mdiArrowLeft,
364
+ mdiArrowRight,
304
365
  embla,
305
366
  slides,
306
367
  currentIndex,
@@ -319,3 +380,11 @@ export default {
319
380
  },
320
381
  };
321
382
  </script>
383
+
384
+ <style scoped>
385
+ .aside-controls-content {
386
+ @screen lg {
387
+ width: 82%;
388
+ }
389
+ }
390
+ </style>
@@ -213,9 +213,22 @@ export default {
213
213
 
214
214
  const buildUrl = (image = null, multiplier = 1) => {
215
215
  let src = image && image.url ? `${image.url}?` : `${contentfulSrc.value}?`;
216
- const imgWidth = image ? image.width : width.value;
217
- const imgHeight = image ? image.height : height.value;
218
-
216
+ let imgWidth = image ? image.width : width.value;
217
+ let imgHeight = image ? image.height : height.value;
218
+ // The max contentful image size is 4000px so we have to
219
+ // impose a limit of 2000px here for both height and width
220
+ // so when we request the retina x2 image we don't go over the 4000px limit
221
+ let newMultiplier;
222
+ if (imgWidth >= 2000) {
223
+ newMultiplier = imgWidth / 1999;
224
+ imgWidth = 1999;
225
+ imgHeight = Math.round(imgHeight / newMultiplier);
226
+ }
227
+ if (imgHeight >= 2000) {
228
+ newMultiplier = imgHeight / 1999;
229
+ imgHeight = 1999;
230
+ imgWidth = Math.round(imgWidth / newMultiplier);
231
+ }
219
232
  if (imgWidth) {
220
233
  src += `w=${imgWidth * multiplier}`;
221
234
  }
@@ -353,3 +353,44 @@ export const CustomStartIndex = () => ({
353
353
  </kv-carousel>
354
354
  `,
355
355
  });
356
+
357
+ export const AsideControls = () => ({
358
+ components: {
359
+ KvCarousel,
360
+ KvButton,
361
+ },
362
+ template: `
363
+ <kv-carousel
364
+ :embla-options="{ loop: false }"
365
+ :multiple-slides-visible="true"
366
+ :aside-controls="true"
367
+ slides-to-scroll="visible"
368
+ class="tw-w-full"
369
+ >
370
+ <template #slide1>
371
+ ${generateLoanCardTemplate(1)}
372
+ </template>
373
+ <template #slide2>
374
+ ${generateLoanCardTemplate(2)}
375
+ </template>
376
+ <template #slide3>
377
+ ${generateLoanCardTemplate(3)}
378
+ </template>
379
+ <template #slide4>
380
+ ${generateLoanCardTemplate(4)}
381
+ </template>
382
+ <template #slide5>
383
+ ${generateLoanCardTemplate(5)}
384
+ </template>
385
+ <template #slide6>
386
+ ${generateLoanCardTemplate(6)}
387
+ </template>
388
+ <template #slide7>
389
+ ${generateLoanCardTemplate(7)}
390
+ </template>
391
+ <template #slide8>
392
+ ${generateLoanCardTemplate(8)}
393
+ </template>
394
+ </kv-carousel>
395
+ `,
396
+ });
@@ -4,7 +4,7 @@ export default {
4
4
  title: 'KvContentfulImg',
5
5
  component: KvContentfulImg,
6
6
  args: {
7
- contentfulSrc: 'https://images.ctfassets.net/j0p9a6ql0rn7/2TWV32iioxapwjn26ZpigZ/84ac39a1396d6be9eea472cf8791faa7/Cynthia.png',
7
+ contentfulSrc: 'https://images.ctfassets.net/j0p9a6ql0rn7/35lkLRfbLxzFPlDVgA4aKI/c435630d811f9ad35ddfc88eaea22b08/Blog-import-1082518_us_shawn_16.jpg',
8
8
  fallbackFormat: 'jpg',
9
9
  width: 200,
10
10
  height: null,
@@ -77,6 +77,7 @@ export const ResponsiveImageSet = (args, { argTypes }) => ({
77
77
  />
78
78
  `,
79
79
  });
80
+
80
81
  ResponsiveImageSet.args = {
81
82
  fit: 'fill',
82
83
  focus: 'face',
@@ -168,3 +169,28 @@ export const WithCaption = (args, { argTypes }) => ({
168
169
  />
169
170
  `,
170
171
  });
172
+
173
+ export const GiantImage = (args, { argTypes }) => ({
174
+ props: Object.keys(argTypes),
175
+ components: {
176
+ KvContentfulImg,
177
+ },
178
+ template: `
179
+ <kv-contentful-img
180
+ :contentful-src="contentfulSrc"
181
+ :fallback-format="fallbackFormat"
182
+ :width="width"
183
+ :height="height"
184
+ alt="Descriptive alt text"
185
+ :loading="loading"
186
+ :fit="fit"
187
+ :focus="focus"
188
+ />
189
+ `,
190
+ });
191
+
192
+ GiantImage.args = {
193
+ contentfulSrc: 'https://images.ctfassets.net/j0p9a6ql0rn7/7dVINOyAxRaXM8p6aq7p5s/9213f63ff10dec57c5f740c056afe8a8/gradient-hero-bg__1_.jpg',
194
+ width: 4000,
195
+ height: 2000,
196
+ };