livechat 0.3.0 → 0.3.2

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: 03a4a70e650dd115654bf8ab48e4afc02b5f628009732d3efbff4a7a36e278cc
4
- data.tar.gz: e74596da328480eacab3097e9c08cc78464369ab2e9db6f9c015904498d53809
3
+ metadata.gz: 5c30e19e783526543e297b77114a6e1d823799c22aca38a2048fc4bb476feb3f
4
+ data.tar.gz: 6746d78ed02867bd663d2d34c636f68530cc3b818678c1b4b5cd79cb70781eb6
5
5
  SHA512:
6
- metadata.gz: 83f87fff5df20fc4b6ba70190fd66fc01dd4a32920f5acd36069d94c6f15eb8ab07711a865020b639ce2bd0c7d6555d606415844f2f7b639575d61dfd211fd16
7
- data.tar.gz: ed3589f43b665ae857d6f9a918643feae0c239515f6413a41579a66e6caf4e4a1ca4bc356db9dfeeb274e6162c841649893dc87e535f91cb6733c4ca4f80dbc4
6
+ metadata.gz: 651eedbae0aabd2570b1690cb3f06e961abadbe3922670ed254b4c108f2553341e6a27e43e35b565c61004dd7ee6df751b38d62b6bd996aa1c97f50f377b71ef
7
+ data.tar.gz: ec6e305609121daf2182095c44bc2bccc098bee0a6d199ba54c46d3b8665c8de4c749eb6adfa34c5884992318701d157a8146a7155c7d9039a782456b7afd446
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2
4
+
5
+ - The chat panel is full-screen on phones (≤480px) — a conversation is an
6
+ app screen, not a floating card. Inputs are 16px on mobile so iOS Safari
7
+ never zoom-jumps on focus; the composer respects the home-indicator safe
8
+ area; thread scrolling no longer rubber-bands the page behind it.
9
+
10
+ ## 0.3.1
11
+
12
+ - The Agents column shows initials avatars (deterministic colors, full name
13
+ on hover) instead of a comma-joined list.
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  - Inbox search: visitor name, email, and full message text, scoped to the
data/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  [![CI](https://github.com/yshmarov/livechat/actions/workflows/ci.yml/badge.svg)](https://github.com/yshmarov/livechat/actions/workflows/ci.yml)
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](MIT-LICENSE)
6
6
 
7
- Open-source live chat for Rails. Self-hosted alternative to Crisp, Intercom
8
- and Chatwoot — as a gem, not another service to deploy.
7
+ Open-source live chat for Rails. Alternative to Crisp, Intercom and
8
+ Chatwoot — inside your Rails app, as a gem, not another service to deploy.
9
9
 
10
10
  Your users already have questions. `livechat` gives them a chat bubble and
11
11
  gives you an inbox, inside the app you already run. Visitors write — signed
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Livechat
4
+ module InboxHelper
5
+ # Agents have no avatar images (no FK to host users) — initials in a
6
+ # deterministically colored circle do the job: same label, same color,
7
+ # every page load. Full label rides the title tooltip.
8
+ AVATAR_COLORS = 6
9
+
10
+ def livechat_agent_avatar(label)
11
+ initials = label.to_s.split.first(2).map { |word| word[0] }.join.upcase
12
+ initials = label.to_s.first(2).upcase if initials.blank?
13
+ color = label.to_s.each_byte.sum % AVATAR_COLORS
14
+
15
+ tag.span(initials, class: "avatar color-#{color}", title: label)
16
+ end
17
+ end
18
+ end
@@ -65,6 +65,14 @@
65
65
  background: var(--surface); color: var(--text); font: inherit; }
66
66
  button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
67
67
  .case-id { color: var(--muted); font-weight: 400; font-size: 15px; }
68
+ .avatars { display: inline-flex; }
69
+ .avatars .avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex;
70
+ align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
71
+ color: #fff; border: 2px solid var(--surface); cursor: default; }
72
+ .avatars .avatar + .avatar { margin-left: -8px; }
73
+ .avatar.color-0 { background: #2563eb; } .avatar.color-1 { background: #16a34a; }
74
+ .avatar.color-2 { background: #d97706; } .avatar.color-3 { background: #dc2626; }
75
+ .avatar.color-4 { background: #7c3aed; } .avatar.color-5 { background: #0891b2; }
68
76
  .context-line { margin: -6px 0 16px; overflow-wrap: anywhere; }
69
77
  .thread { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
70
78
  .thread .who { font-size: 12px; color: var(--muted); margin: 10px 4px 2px; }
@@ -53,7 +53,13 @@
53
53
  <% end %>
54
54
  </td>
55
55
  <td class="muted"><%= conversation.last_message_preview %></td>
56
- <td class="muted"><%= @agents.fetch(conversation.id, []).join(', ') %></td>
56
+ <td>
57
+ <span class="avatars">
58
+ <% @agents.fetch(conversation.id, []).each do |label| %>
59
+ <%= livechat_agent_avatar(label) %>
60
+ <% end %>
61
+ </span>
62
+ </td>
57
63
  <td class="muted">
58
64
  <% if conversation.last_activity_at %>
59
65
  <%= time_ago_in_words(conversation.last_activity_at) %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Livechat
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.2'
5
5
  end
@@ -548,8 +548,6 @@
548
548
  "#lvc-panel[hidden]{display:none}" +
549
549
  "#lvc-root[dir=rtl] #lvc-panel{right:auto;left:20px}" +
550
550
  "#lvc-root.lvc-no-launcher #lvc-panel{bottom:20px;max-height:calc(100dvh - 40px)}" +
551
- "@media(max-width:480px){#lvc-panel{right:12px;bottom:80px}" +
552
- "#lvc-root.lvc-no-launcher #lvc-panel{right:12px;bottom:12px;max-height:calc(100dvh - 24px)}}" +
553
551
  "#lvc-header{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;" +
554
552
  "padding:14px 16px;background:var(--lvc-accent);color:var(--lvc-accent-text)}" +
555
553
  "#lvc-header strong{display:block;font-size:15px}" +
@@ -557,8 +555,8 @@
557
555
  "#lvc-close{border:none;background:none;color:var(--lvc-accent-text);font-size:22px;" +
558
556
  "line-height:1;cursor:pointer;padding:2px 6px;border-radius:6px}" +
559
557
  "#lvc-close:hover{background:rgba(255,255,255,.15)}" +
560
- "#lvc-list{flex:1;overflow-y:auto;padding:14px;background:var(--lvc-bg);display:flex;" +
561
- "flex-direction:column;gap:4px}" +
558
+ "#lvc-list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:14px;" +
559
+ "background:var(--lvc-bg);display:flex;flex-direction:column;gap:4px}" +
562
560
  // Class rules carry the #lvc-root prefix so they outrank the
563
561
  // id-level `#lvc-root *` reset above.
564
562
  "#lvc-root .lvc-greeting{color:var(--lvc-muted);font-size:13px;margin-bottom:8px}" +
@@ -594,6 +592,18 @@
594
592
  "display:flex;align-items:center;justify-content:center;cursor:pointer}" +
595
593
  "#lvc-form button:disabled{opacity:.6;cursor:default}" +
596
594
  "#lvc-root[dir=rtl] #lvc-form button svg{transform:scaleX(-1)}" +
595
+ // Phones get the whole screen — a chat is an app screen, not a popup.
596
+ // Selectors repeat the id twice so they outrank the rtl/no-launcher
597
+ // desktop rules regardless of source order.
598
+ "@media(max-width:480px){" +
599
+ "#lvc-root #lvc-panel,#lvc-root[dir=rtl] #lvc-panel,#lvc-root.lvc-no-launcher #lvc-panel" +
600
+ "{left:0;right:0;top:0;bottom:0;width:100%;max-width:100%;height:100dvh;max-height:100dvh;" +
601
+ "border-radius:0;border:none}" +
602
+ // 16px stops iOS Safari from zoom-jumping into focused fields.
603
+ "#lvc-root #lvc-form textarea,#lvc-root #lvc-email input{font-size:16px}" +
604
+ // Keep the composer above the iPhone home indicator.
605
+ "#lvc-root #lvc-form{padding-bottom:calc(10px + env(safe-area-inset-bottom))}" +
606
+ "}" +
597
607
  // Lives in host DOM (on data-livechat-open elements), so no #lvc-root prefix.
598
608
  ".lvc-opener-badge{display:inline-flex;min-width:18px;height:18px;padding:0 5px;" +
599
609
  "margin-inline-start:6px;border-radius:999px;background:#dc2626;color:#fff;" +
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.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov
@@ -47,6 +47,7 @@ files:
47
47
  - app/controllers/livechat/messages_controller.rb
48
48
  - app/controllers/livechat/visitor_controller.rb
49
49
  - app/controllers/livechat/widgets_controller.rb
50
+ - app/helpers/livechat/inbox_helper.rb
50
51
  - app/helpers/livechat/widget_helper.rb
51
52
  - app/mailers/livechat/mailer.rb
52
53
  - app/models/livechat/application_record.rb