@meetelise/chat 1.53.3 → 1.53.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.53.3",
3
+ "version": "1.53.4",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -6734,12 +6734,14 @@ xmlns="http://www.w3.org/2000/svg"
6734
6734
  </div>
6735
6735
  `)}
6736
6736
  </div>
6737
- ${this.message.media.length>1?R` <button class="button prev" @click=${this.prevImage}>
6737
+ ${this.message.media.length>1?R`<div class="controls">
6738
+ <button class="button prev" @click=${this.prevImage}>
6738
6739
  &#10094;
6739
6740
  </button>
6740
6741
  <button class="button next" @click=${this.nextImage}>
6741
6742
  &#10095;
6742
- </button>`:""}
6743
+ </button>
6744
+ </div>`:""}
6743
6745
  </div>
6744
6746
  </div>`:R`<div class="message-inner-body">
6745
6747
  ${this.message.media.map(e=>R`<a
@@ -6756,6 +6758,9 @@ xmlns="http://www.w3.org/2000/svg"
6756
6758
  min-width: 0;
6757
6759
  }
6758
6760
  .carousel {
6761
+ /* Every photo is drawn in a box of this shape, so slides of
6762
+ different shapes neither resize the card nor move the arrows. */
6763
+ --photo-aspect-ratio: 4 / 3;
6759
6764
  position: relative;
6760
6765
  max-width: 400px;
6761
6766
  height: max-content;
@@ -6780,8 +6785,9 @@ xmlns="http://www.w3.org/2000/svg"
6780
6785
  flex-shrink: 0;
6781
6786
  opacity: 0.5;
6782
6787
  transition: opacity 0.5s ease;
6783
- height: 100%;
6788
+ aspect-ratio: var(--photo-aspect-ratio);
6784
6789
  object-fit: contain;
6790
+ background-color: #f2f2f2;
6785
6791
  display: block;
6786
6792
  }
6787
6793
  .image-item {
@@ -6800,11 +6806,23 @@ xmlns="http://www.w3.org/2000/svg"
6800
6806
  .carousel img.active {
6801
6807
  opacity: 1;
6802
6808
  }
6803
- .button {
6809
+ /* Covers the photo, not the caption, so the arrows centre on the photo. */
6810
+ .controls {
6804
6811
  position: absolute;
6805
- top: 50%;
6806
- transform: translateY(-50%);
6807
- background-color: rgba(0, 0, 0, 0.1);
6812
+ top: 0;
6813
+ left: 0;
6814
+ width: 100%;
6815
+ aspect-ratio: var(--photo-aspect-ratio);
6816
+ display: flex;
6817
+ align-items: center;
6818
+ justify-content: space-between;
6819
+ padding: 0 2px;
6820
+ box-sizing: border-box;
6821
+ pointer-events: none;
6822
+ }
6823
+ .button {
6824
+ pointer-events: auto;
6825
+ background-color: rgba(0, 0, 0, 0.6);
6808
6826
  color: white;
6809
6827
  border: none;
6810
6828
  border-radius: 2px;
@@ -6816,13 +6834,7 @@ xmlns="http://www.w3.org/2000/svg"
6816
6834
  transition: background-color 0.3s ease;
6817
6835
  }
6818
6836
  .button:hover {
6819
- background-color: rgba(0, 0, 0, 0.5);
6820
- }
6821
- .prev {
6822
- left: 2px;
6823
- }
6824
- .next {
6825
- right: 2px;
6837
+ background-color: rgba(0, 0, 0, 0.8);
6826
6838
  }
6827
6839
  .image-info {
6828
6840
  display: flex;
@@ -18,6 +18,9 @@ export class PubnubMedia extends LitElement {
18
18
  min-width: 0;
19
19
  }
20
20
  .carousel {
21
+ /* Every photo is drawn in a box of this shape, so slides of
22
+ different shapes neither resize the card nor move the arrows. */
23
+ --photo-aspect-ratio: 4 / 3;
21
24
  position: relative;
22
25
  max-width: 400px;
23
26
  height: max-content;
@@ -42,8 +45,9 @@ export class PubnubMedia extends LitElement {
42
45
  flex-shrink: 0;
43
46
  opacity: 0.5;
44
47
  transition: opacity 0.5s ease;
45
- height: 100%;
48
+ aspect-ratio: var(--photo-aspect-ratio);
46
49
  object-fit: contain;
50
+ background-color: #f2f2f2;
47
51
  display: block;
48
52
  }
49
53
  .image-item {
@@ -62,11 +66,23 @@ export class PubnubMedia extends LitElement {
62
66
  .carousel img.active {
63
67
  opacity: 1;
64
68
  }
65
- .button {
69
+ /* Covers the photo, not the caption, so the arrows centre on the photo. */
70
+ .controls {
66
71
  position: absolute;
67
- top: 50%;
68
- transform: translateY(-50%);
69
- background-color: rgba(0, 0, 0, 0.1);
72
+ top: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ aspect-ratio: var(--photo-aspect-ratio);
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: space-between;
79
+ padding: 0 2px;
80
+ box-sizing: border-box;
81
+ pointer-events: none;
82
+ }
83
+ .button {
84
+ pointer-events: auto;
85
+ background-color: rgba(0, 0, 0, 0.6);
70
86
  color: white;
71
87
  border: none;
72
88
  border-radius: 2px;
@@ -78,13 +94,7 @@ export class PubnubMedia extends LitElement {
78
94
  transition: background-color 0.3s ease;
79
95
  }
80
96
  .button:hover {
81
- background-color: rgba(0, 0, 0, 0.5);
82
- }
83
- .prev {
84
- left: 2px;
85
- }
86
- .next {
87
- right: 2px;
97
+ background-color: rgba(0, 0, 0, 0.8);
88
98
  }
89
99
  .image-info {
90
100
  display: flex;
@@ -189,12 +199,14 @@ export class PubnubMedia extends LitElement {
189
199
  )}
190
200
  </div>
191
201
  ${this.message.media.length > 1
192
- ? html` <button class="button prev" @click=${this.prevImage}>
202
+ ? html`<div class="controls">
203
+ <button class="button prev" @click=${this.prevImage}>
193
204
  &#10094;
194
205
  </button>
195
206
  <button class="button next" @click=${this.nextImage}>
196
207
  &#10095;
197
- </button>`
208
+ </button>
209
+ </div>`
198
210
  : ""}
199
211
  </div>
200
212
  </div>`;
@@ -238,7 +238,14 @@ it("keeps a photo carousel and its arrows inside the message bubble", async () =
238
238
  const next = media.shadowRoot
239
239
  ?.querySelector(".next")
240
240
  ?.getBoundingClientRect();
241
- if (!bubble || !carousel || !next) throw new Error("Expected a carousel");
241
+ const photo = media.shadowRoot
242
+ ?.querySelector("img.active")
243
+ ?.getBoundingClientRect();
244
+ if (!bubble || !carousel || !next || !photo)
245
+ throw new Error("Expected a carousel");
242
246
  expect(carousel.right).to.be.at.most(bubble.right);
243
247
  expect(next.right).to.be.at.most(bubble.right);
248
+ // Centred on the photo, not on the photo and its caption together.
249
+ const centreY = (box: DOMRect) => (box.top + box.bottom) / 2;
250
+ expect(centreY(next)).to.be.closeTo(centreY(photo), 1);
244
251
  });