livechat 0.4.2 → 0.4.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f42dfde953e1643e5cc5fbfce81dc237376788709890a6254a4800bec927f51d
4
- data.tar.gz: 76e741f442b6b847d3aa4edd37432ee55f2fe6ac9d8d38a356bf716023f4e146
3
+ metadata.gz: d674110938432200c4426cfe1c4bb5c551759316ac2468406fa4aeb4dcbf5919
4
+ data.tar.gz: 5b68f89574ab49bc74b40697f37c05137f2e2082bd91fca3ec940c126977df0c
5
5
  SHA512:
6
- metadata.gz: 20ed071145a817ffa93933ea8db69585a64edc7bfd88931420126a2a82a5c096ff34b5b94fff2a12c3a092de20dd742e1df637355df20994f7d93c57965a0e7a
7
- data.tar.gz: d77df77a8b6c6a9bf050403fb05c791fa02dd5fa350aa663e0d23b2445d1269110690321c3f8f8f9593fecba1a9e3013cb30e4b6a5f3d9327f042ecba6b80ae7
6
+ metadata.gz: f55e9b8235489c32e792dcd947195a2332fa402cb35ee2923f653d3fc318dfdf6370f8ebcf493c551ff267a8e1f8ecb48739e15c7d35df882b9c5c6d62fcb01a
7
+ data.tar.gz: 919af379b17dc1baaf24ad0997d8fa1a6dc6167baba7104178c0c6821ab970c0530a0ef53825ea1de773e974b28c15ce09ed732be026d1ee660272d751dd5c76
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.3
4
+
5
+ - Unified composer. The message box, attach button and send button are now one
6
+ bordered container (the textarea on top, a toolbar row with the tools on the
7
+ left and a circular send on the right) that lights up on focus — instead of a
8
+ textarea flanked by loose buttons. Reads as a single control, closer to what
9
+ people expect from a chat composer. Pending-file chips ride inside the box.
10
+
3
11
  ## 0.4.2
4
12
 
5
13
  - Breathing room between the widget's pending-file chips and the composer —
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Livechat
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
@@ -245,9 +245,22 @@
245
245
  emailRowEl = buildEmailRow();
246
246
  panel.appendChild(emailRowEl);
247
247
 
248
+ // The composer is one bordered box: the textarea on top, a toolbar row
249
+ // (tools on the left, send on the right) below — so it reads as a single
250
+ // control, not a textarea flanked by loose buttons.
248
251
  formEl = document.createElement("form");
249
252
  formEl.id = "lvc-form";
253
+
254
+ // Pending-file chips sit at the top of the box, inside the border.
255
+ if (config.attachments) {
256
+ filesBarEl = document.createElement("div");
257
+ filesBarEl.id = "lvc-files";
258
+ filesBarEl.hidden = true;
259
+ formEl.appendChild(filesBarEl);
260
+ }
261
+
250
262
  inputEl = document.createElement("textarea");
263
+ inputEl.id = "lvc-input";
251
264
  inputEl.rows = 1;
252
265
  inputEl.placeholder = config.labels.placeholder;
253
266
  inputEl.setAttribute("aria-label", config.labels.placeholder);
@@ -258,32 +271,15 @@
258
271
  send();
259
272
  }
260
273
  });
261
- var sendButton = document.createElement("button");
262
- sendButton.type = "submit";
263
- sendButton.setAttribute("aria-label", config.labels.send);
264
- sendButton.title = config.labels.send;
265
- // Paper airplane (Heroicons, MIT). CSS mirrors it for RTL.
266
- sendButton.innerHTML =
267
- '<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">' +
268
- '<path fill="currentColor" d="M3.478 2.404a.75.75 0 0 0-.926.941l2.432 ' +
269
- "7.905H13.5a.75.75 0 0 1 0 1.5H4.984l-2.432 7.905a.75.75 0 0 0 .926.94 " +
270
- "60.519 60.519 0 0 0 18.445-8.986.75.75 0 0 0 0-1.218A60.517 60.517 0 0 " +
271
- '0 3.478 2.404Z"/></svg>';
272
274
  formEl.appendChild(inputEl);
273
- formEl.appendChild(sendButton);
274
- formEl.addEventListener("submit", function (event) {
275
- event.preventDefault();
276
- send();
277
- });
278
275
 
279
- // Attachments: a paperclip that opens the file picker, plus a bar of
280
- // chips for the files waiting to be sent. Only when the host has them on.
281
- if (config.attachments) {
282
- filesBarEl = document.createElement("div");
283
- filesBarEl.id = "lvc-files";
284
- filesBarEl.hidden = true;
285
- panel.appendChild(filesBarEl);
276
+ var toolbar = document.createElement("div");
277
+ toolbar.id = "lvc-toolbar";
278
+ var tools = document.createElement("div");
279
+ tools.id = "lvc-tools";
286
280
 
281
+ // Attachments: a paperclip in the toolbar that opens the file picker.
282
+ if (config.attachments) {
287
283
  fileInputEl = document.createElement("input");
288
284
  fileInputEl.type = "file";
289
285
  fileInputEl.multiple = true;
@@ -296,18 +292,40 @@
296
292
  var attach = document.createElement("button");
297
293
  attach.type = "button";
298
294
  attach.id = "lvc-attach";
295
+ attach.className = "lvc-tool";
299
296
  attach.setAttribute("aria-label", config.labels.attach);
300
297
  attach.title = config.labels.attach;
301
298
  // Paperclip (Heroicons, MIT).
302
299
  attach.innerHTML =
303
- '<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">' +
300
+ '<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">' +
304
301
  '<path fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" ' +
305
302
  'stroke-linejoin="round" d="M18.4 8.6 9.9 17a3.5 3.5 0 0 1-5-5l8.5-8.4a2.3 2.3 0 0 1 ' +
306
303
  '3.3 3.3l-8.5 8.4a1.1 1.1 0 0 1-1.6-1.6l7.8-7.8"/></svg>';
307
304
  attach.addEventListener("click", function () { fileInputEl.click(); });
308
- formEl.insertBefore(attach, inputEl);
305
+ tools.appendChild(attach);
309
306
  formEl.appendChild(fileInputEl);
310
307
  }
308
+ toolbar.appendChild(tools);
309
+
310
+ var sendButton = document.createElement("button");
311
+ sendButton.type = "submit";
312
+ sendButton.id = "lvc-send";
313
+ sendButton.setAttribute("aria-label", config.labels.send);
314
+ sendButton.title = config.labels.send;
315
+ // Paper airplane (Heroicons, MIT). CSS mirrors it for RTL.
316
+ sendButton.innerHTML =
317
+ '<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">' +
318
+ '<path fill="currentColor" d="M3.478 2.404a.75.75 0 0 0-.926.941l2.432 ' +
319
+ "7.905H13.5a.75.75 0 0 1 0 1.5H4.984l-2.432 7.905a.75.75 0 0 0 .926.94 " +
320
+ "60.519 60.519 0 0 0 18.445-8.986.75.75 0 0 0 0-1.218A60.517 60.517 0 0 " +
321
+ '0 3.478 2.404Z"/></svg>';
322
+ toolbar.appendChild(sendButton);
323
+
324
+ formEl.appendChild(toolbar);
325
+ formEl.addEventListener("submit", function (event) {
326
+ event.preventDefault();
327
+ send();
328
+ });
311
329
 
312
330
  panel.appendChild(formEl);
313
331
 
@@ -818,25 +836,28 @@
818
836
  "background:var(--lvc-bg);color:var(--lvc-text);font:inherit}" +
819
837
  "#lvc-email button{padding:6px 10px;border:1px solid var(--lvc-border);border-radius:8px;" +
820
838
  "background:var(--lvc-surface);color:var(--lvc-text);font:inherit;cursor:pointer}" +
821
- "#lvc-form{display:flex;gap:8px;padding:10px 12px;border-top:1px solid var(--lvc-border);" +
822
- "background:var(--lvc-surface)}" +
823
- "#lvc-form textarea{flex:1;resize:none;border:1px solid var(--lvc-border);border-radius:10px;" +
824
- "padding:8px 10px;font:inherit;background:var(--lvc-bg);color:var(--lvc-text);max-height:120px}" +
825
- "#lvc-form textarea:focus{outline:2px solid var(--lvc-accent);outline-offset:-1px}" +
826
- "#lvc-form button{border:none;border-radius:10px;background:var(--lvc-accent);" +
827
- "color:var(--lvc-accent-text);width:40px;min-width:40px;height:40px;align-self:flex-end;" +
828
- "display:flex;align-items:center;justify-content:center;cursor:pointer}" +
829
- "#lvc-form button:disabled{opacity:.6;cursor:default}" +
830
- "#lvc-root[dir=rtl] #lvc-form button svg{transform:scaleX(-1)}" +
831
- // Attach button sits alongside the send button, quieter (it's secondary).
832
- // Selector repeats the id twice so the quiet look outranks the shared
833
- // `#lvc-form button` accent-fill rule (else the paperclip goes solid blue).
834
- "#lvc-root #lvc-attach{border:none;background:none;color:var(--lvc-muted);width:38px;min-width:38px;" +
835
- "height:40px;align-self:flex-end;display:flex;align-items:center;justify-content:center;" +
836
- "cursor:pointer;border-radius:10px}" +
837
- "#lvc-root #lvc-attach:hover{background:var(--lvc-bg);color:var(--lvc-text)}" +
838
- // Pending-file chips above the composer.
839
- "#lvc-files{display:flex;flex-wrap:wrap;gap:6px;padding:10px 12px}" +
839
+ // The composer is one bordered box (Intercom-style): textarea on top, a
840
+ // toolbar row below. focus-within lights the whole box, so it reads as a
841
+ // single control.
842
+ "#lvc-form{display:flex;flex-direction:column;gap:6px;margin:10px 12px;padding:8px 10px;" +
843
+ "border:1px solid var(--lvc-border);border-radius:16px;background:var(--lvc-bg)}" +
844
+ "#lvc-form:focus-within{border-color:var(--lvc-accent);box-shadow:0 0 0 1px var(--lvc-accent)}" +
845
+ "#lvc-root #lvc-input{border:none;background:none;resize:none;font:inherit;color:var(--lvc-text);" +
846
+ "padding:4px 4px 0;max-height:120px;outline:none}" +
847
+ "#lvc-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px}" +
848
+ "#lvc-tools{display:flex;align-items:center;gap:2px}" +
849
+ // Tool buttons (attach, and room for more) are quiet — the accent is the
850
+ // send button's alone.
851
+ "#lvc-root .lvc-tool{border:none;background:none;color:var(--lvc-muted);width:32px;height:32px;" +
852
+ "display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:8px;padding:0}" +
853
+ "#lvc-root .lvc-tool:hover{background:var(--lvc-border);color:var(--lvc-text)}" +
854
+ "#lvc-send{border:none;border-radius:50%;background:var(--lvc-accent);color:var(--lvc-accent-text);" +
855
+ "width:32px;height:32px;min-width:32px;display:flex;align-items:center;justify-content:center;" +
856
+ "cursor:pointer;padding:0}" +
857
+ "#lvc-send:disabled{opacity:.5;cursor:default}" +
858
+ "#lvc-root[dir=rtl] #lvc-send svg{transform:scaleX(-1)}" +
859
+ // Pending-file chips ride at the top of the composer box.
860
+ "#lvc-files{display:flex;flex-wrap:wrap;gap:6px;padding:2px 2px 0}" +
840
861
  "#lvc-files[hidden]{display:none}" +
841
862
  "#lvc-root .lvc-chip{display:inline-flex;align-items:center;gap:6px;max-width:100%;" +
842
863
  "padding:4px 6px 4px 10px;border:1px solid var(--lvc-border);border-radius:999px;" +
@@ -862,9 +883,9 @@
862
883
  "{left:0;right:0;top:0;bottom:0;width:100%;max-width:100%;height:100dvh;max-height:100dvh;" +
863
884
  "border-radius:0;border:none}" +
864
885
  // 16px stops iOS Safari from zoom-jumping into focused fields.
865
- "#lvc-root #lvc-form textarea,#lvc-root #lvc-email input{font-size:16px}" +
866
- // Keep the composer above the iPhone home indicator.
867
- "#lvc-root #lvc-form{padding-bottom:calc(10px + env(safe-area-inset-bottom))}" +
886
+ "#lvc-root #lvc-input,#lvc-root #lvc-email input{font-size:16px}" +
887
+ // Keep the composer box above the iPhone home indicator.
888
+ "#lvc-root #lvc-form{margin-bottom:calc(10px + env(safe-area-inset-bottom))}" +
868
889
  "}" +
869
890
  // Lives in host DOM (on data-livechat-open elements), so no #lvc-root prefix.
870
891
  ".lvc-opener-badge{display:inline-flex;min-width:18px;height:18px;padding:0 5px;" +
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livechat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov