mp-design-system 2.0.75 → 2.0.76

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.
@@ -1119,29 +1119,10 @@
1119
1119
  document.querySelectorAll('[data-carousel="cards"]').forEach((el) => {
1120
1120
  const type = el.dataset.carouselType || "slide";
1121
1121
  const rewind = el.dataset.carouselRewind === "true";
1122
- let perPage = parseInt(el.dataset.carouselPerPage) || 4;
1123
1122
  const perMove = parseInt(el.dataset.carouselPerMove) || 1;
1124
- const wrapper = getComputedStyle(document.documentElement).getPropertyValue("--wrapper").trim();
1125
- const wrapperWidth = parseInt(wrapper);
1126
- const gap = parseInt(getComputedStyle(el).getPropertyValue("--row-gap"));
1127
- let cardWidth;
1128
- if (window.innerWidth >= 1024) {
1129
- cardWidth = (wrapperWidth - (perPage - 1) * gap) / perPage;
1130
- } else if (window.innerWidth >= 768) {
1131
- cardWidth = (wrapperWidth - 2 * gap) / 3;
1132
- } else if (window.innerWidth >= 680) {
1133
- cardWidth = (wrapperWidth - gap) / 2;
1134
- } else {
1135
- cardWidth = wrapperWidth;
1136
- }
1137
- el.querySelectorAll(".splide__slide").forEach((slide) => {
1138
- slide.style.width = `${cardWidth}`;
1139
- });
1140
1123
  const splide = new import_splide_min.default(el, {
1141
1124
  type,
1142
- perPage,
1143
1125
  perMove,
1144
- gap,
1145
1126
  focus: 0,
1146
1127
  arrows: false,
1147
1128
  drag: true,
@@ -1149,13 +1130,28 @@
1149
1130
  preventClick: true,
1150
1131
  rewind,
1151
1132
  clones: 0,
1152
- autoWidth: true,
1153
- breakpoints: {
1154
- 768: { perPage: 3 },
1155
- 608: { perPage: 2 },
1156
- 320: { perPage: 1 }
1157
- }
1133
+ autoWidth: true
1158
1134
  });
1135
+ function setSlideWidths() {
1136
+ const wrapperWidth = parseInt(
1137
+ getComputedStyle(document.documentElement).getPropertyValue(
1138
+ "--wrapper"
1139
+ )
1140
+ );
1141
+ const gap = parseInt(getComputedStyle(el).getPropertyValue("--row-gap"));
1142
+ let cardWidth;
1143
+ if (window.innerWidth >= 1024) cardWidth = (wrapperWidth - 3 * gap) / 4;
1144
+ else if (window.innerWidth >= 768)
1145
+ cardWidth = (wrapperWidth - 2 * gap) / 3;
1146
+ else if (window.innerWidth >= 680) cardWidth = (wrapperWidth - gap) / 2;
1147
+ else cardWidth = wrapperWidth;
1148
+ el.querySelectorAll(".splide__slide").forEach((slide) => {
1149
+ slide.style.width = `${cardWidth}px`;
1150
+ });
1151
+ splide.refresh();
1152
+ }
1153
+ window.addEventListener("resize", setSlideWidths);
1154
+ setSlideWidths();
1159
1155
  el.querySelector(".c-carousel__arrow--prev")?.addEventListener(
1160
1156
  "click",
1161
1157
  () => splide.go("<")
@@ -1164,12 +1160,6 @@
1164
1160
  "click",
1165
1161
  () => splide.go(">")
1166
1162
  );
1167
- const list = el.querySelector(".splide__list");
1168
- if (list) {
1169
- const padding = `calc((100vw - var(--wrapper)) * 0.5)`;
1170
- list.style.paddingInlineStart = padding;
1171
- list.style.paddingInlineEnd = padding;
1172
- }
1173
1163
  el.querySelectorAll("a").forEach((link) => {
1174
1164
  link.addEventListener("click", (e) => e.stopPropagation());
1175
1165
  });