cheogram-www

created pr with cheogram-www/style-overhaul-for-real-v2.1 on 2026-11-25T15:28:10Z · by 3c31bc8c
commented on 2026-11-25T15:28:10Z · by 3c31bc8c
Changes are available at https://tangled.org/mrry.band/cheogram-www style-overhaul-for-real-v2
added cheogram-www/style-overhaul-for-real-v2.2 on 2026-11-25T15:38:17Z · by 3c31bc8c
1: 7b21cbd ! 1: 894cb5f Design refresh + dark mode + custom themes
added cheogram-www/style-overhaul-for-real-v2.3 on 2026-11-25T15:51:03Z · by 3c31bc8c
1: 894cb5f ! 1: 13476dc Design refresh + dark mode + custom themes
added cheogram-www/style-overhaul-for-real-v2.4 on 2026-11-25T20:42:04Z · by 3c31bc8c
1: 13476dc ! 1: 8658664 Design refresh + dark mode + custom themes
added cheogram-www/style-overhaul-for-real-v2.5 on 2026-11-25T21:14:39Z · by 3c31bc8c
1: 8658664 ! 1: 3a9bdd1 Design refresh + dark mode + custom themes
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www:style-overhaul-for-real-v2 | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:style-overhaul-for-real-v2 [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:style-overhaul-for-real-v2
add comment to patch request:
ssh pr.pico.sh comment cheogram-www:style-overhaul-for-real-v2 "lgtm!"

Patchset cheogram-www/style-overhaul-for-real-v2.5 on 2026-11-25T21:14:39Z · commit 3a9bdd1

Design refresh + dark mode + custom themes
Eric Roberts 2026-10-29T19:01:59Z
Tweaks a lot of things about the design, adds multiple colour schemes,
and allows users to set custom colour schemes.

Our internal colour schemes have a few extra colour options so we can
customize them further than the custom editor allows. Trying to keep the
custom editor minimal while still allowing for us to have some more
freedom for in house themes.
Diff stat
23 files changed, 1995 insertions(+), 649 deletions(-)
Semantic diff summary
16 added, 0 modified, 0 signature changed, 0 removed across 19 analyzed files (4 files skipped: unsupported file type)
+2 -1 index.html #
......@@ -5,7 +5,7 @@
55 <link rel="icon" href="/favicon.ico" />
66 <meta
77 name="viewport"
8- content="width=device-width, initial-scale=1, interactive-widget=resizes-content"
8+ content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content"
99 />
1010 <meta name="theme-color" content="#7401cf" />
1111 <base target="_blank" />
......@@ -13,6 +13,7 @@
1313 <script type="module" src="/src/bootstrap.ts"></script>
1414 </head>
1515 <body>
16+ <div id="ios-status-bar-surface" aria-hidden="true"></div>
1617 <noscript>You need to enable JavaScript to run this app.</noscript>
1718 <a class="sr-only" href="https://wiki.soprani.ca/CheogramWWW/Orca?action=raw">Information about using this app with a screen reader</a>
1819 <div id="root">
+2 -1 src-tauri/capabilities/default.json #
......@@ -10,6 +10,7 @@
1010 "sql:default",
1111 "core:window:allow-show",
1212 "core:window:allow-unminimize",
13- "core:window:allow-set-focus"
13+ "core:window:allow-set-focus",
14+ "core:window:allow-start-dragging"
1415 ]
1516 }
+1 -1 src-tauri/tauri.conf.json #
......@@ -14,7 +14,7 @@
1414 {
1515 "create": false,
1616 "title": "Cheogram",
17- "titleBarStyle": "Transparent",
17+ "titleBarStyle": "Overlay",
1818 "backgroundColor": "#7401cf",
1919 "width": 1200,
2020 "height": 800,
+852 -340 src/App.scss #
......@@ -1,6 +1,7 @@
1-@use "sass:color";
1+@use "sass:meta";
22 @import "@chatscope/chat-ui-kit-styles/themes/default/helpers/_functions.scss";
33 $default-font-family: system-ui, sans-serif;
4+$default-border-radius: 6px;
45 $conversation-font-family: $default-font-family;
56 $conversation-header-font-family: $default-font-family;
67 $expansion-panel-font-family: $default-font-family;
......@@ -14,18 +15,6 @@ $message-input-content-editor-font-family: $default-font-family;
1415 $message-separator-font-family: $default-font-family;
1516 $typing-indicator-font-family: $default-font-family;
1617
17-$perpy: #7401cf;
18-$color-primary: color.scale($perpy, $lightness: 70%, $saturation: -25%);
19-$color-primary-light: color.scale($color-primary, $lightness: 30%);
20-$color-primary-dark: $perpy;
21-
22-$yeller: #ffc700;
23-$color-secondary: color.scale($yeller, $lightness: 70%, $saturation: -25%);
24-$color-secondary-light: color.scale($color-secondary, $lightness: 30%);
25-$color-secondary-dark: $yeller;
26-
27-$search-border-radius: 10em;
28-
2918 $conversation-header-font-size: 1.5em;
3019 $conversation-header-bg-color: transparent;
3120 $conversation-header-color: inherit;
......@@ -35,79 +24,245 @@ $main-container-sidebar-left-max-width: 22em;
3524 $main-container-sidebar-right-max-width: 22em;
3625
3726 :root {
38- --color-primary: #{$color-primary};
39- --color-primary-light: #{$color-primary-light};
40- --color-primary-dark: #{$color-primary-dark};
41- --color-secondary: #{$color-secondary};
42- --color-secondary-light: #{$color-secondary-light};
43- --color-secondary-dark: #{$color-secondary-dark};
44- --color-on-secondary: #1e0038;
27+ --accent-surface: var(--theme-light-accent-surface);
28+ color-scheme: light;
29+ --theme-primary: var(--theme-light-primary, #7401cf);
30+ --theme-secondary: var(--theme-light-secondary, #ffc700);
31+ --theme-on-primary: var(--theme-light-on-primary, white);
32+ --theme-on-secondary: var(--theme-light-on-secondary, #212121);
33+ --surface-base: var(--theme-light-background, white);
34+ --text-base: var(--theme-light-text, #212121);
35+ --app-background: var(--theme-primary);
36+ --color-on-app: var(--theme-light-on-app, white);
37+ --default-bg-color: var(--surface-base);
38+ --paper-background: var(--default-bg-color);
39+ --color-primary: var(
40+ --accent-surface,
41+ color-mix(in srgb, var(--theme-primary) 13%, var(--surface-base))
42+ );
43+ --color-primary-light: var(
44+ --accent-surface,
45+ color-mix(in srgb, var(--theme-primary) 8%, var(--surface-base))
46+ );
47+ --color-primary-dark: var(--theme-light-link, #7401cf);
48+ --theme-secondary-surface: var(--theme-light-secondary-surface);
49+ --color-secondary: var(
50+ --theme-secondary-surface,
51+ color-mix(in srgb, var(--theme-secondary) 30%, var(--surface-base))
52+ );
53+ --color-secondary-light: color-mix(
54+ in srgb,
55+ var(--theme-secondary) 20%,
56+ white
57+ );
58+ --color-secondary-dark: var(--theme-secondary);
59+ --color-on-secondary: var(--theme-on-secondary);
4560 --color-danger: rgb(211, 47, 47);
46- --color-on-danger: #fff;
47- --default-border-color: #{rgba-to-rgb(
48- rgba(scale-color($color-primary-dark, $saturation: -55%), 0.4),
49- #fff
50- )};
51- --color-bg-hover: #{rgba-to-rgb(rgba($color-primary-dark, 0.08), #fff)};
52- --color-bg-focus: #{rgba-to-rgb(
53- rgba($color-primary-dark, 0.24),
54- $color-primary-light
55- )};
56- --default-bg-color: #fff;
57- --color-text: rgba(0, 0, 0, 0.87);
58- --color-text-medium: rgba(0, 0, 0, 0.6);
59- --color-text-disabled: rgba(0, 0, 0, 0.38);
60- --message-outgoing-color: var(--color-text);
61-}
62-
63-/*@media (prefers-color-scheme: dark) {
64- :root {
65- --color-primary: #{color.scale($perpy, $saturation: -60%)};
66- --color-secondary: #{color.scale($yeller, $saturation: -60%)};
67- --default-bg-color: #000;
68- --color-text: rgba(255, 255, 255, 0.87);
69- --color-text-medium: rgba(255, 255, 255, 0.6);
70- --color-text-disabled: rgba(255, 255, 255, 0.38);
71- --message-outgoing-color: rgba(0, 0, 0, 0.87);
72- --default-border-color: #{rgba-to-rgb(
73- rgba(scale-color($color-primary-dark, $saturation: -55%), 0.6),
74- #000
75- )};
76- --color-bg-hover: #{rgba-to-rgb(rgba($color-primary-dark, 0.2), #000)};
77- }
78-}*/
61+ --color-on-danger: white;
62+ --color-text: var(--text-base);
63+ --color-text-medium: color-mix(
64+ in srgb,
65+ var(--text-base) 70%,
66+ var(--surface-base)
67+ );
68+ --color-text-disabled: color-mix(
69+ in srgb,
70+ var(--text-base) 45%,
71+ var(--surface-base)
72+ );
73+ --default-border-color: color-mix(
74+ in srgb,
75+ var(--text-base) 20%,
76+ var(--surface-base)
77+ );
78+ --divider-color: var(--default-border-color);
79+ --color-bg-hover: var(
80+ --accent-surface,
81+ color-mix(in srgb, var(--theme-primary) 8%, var(--surface-base))
82+ );
83+ --color-bg-focus: var(
84+ --accent-surface,
85+ color-mix(in srgb, var(--theme-primary) 24%, var(--surface-base))
86+ );
87+ --chat-panel-border: var(--surface-base);
88+ --chat-panel-background: color-mix(
89+ in srgb,
90+ var(--surface-base) 85%,
91+ transparent
92+ );
93+ --border-radius: #{$default-border-radius};
94+ --message-incoming-background: var(
95+ --theme-incoming-background,
96+ color-mix(in srgb, var(--text-base) 7%, var(--surface-base))
97+ );
98+ --theme-incoming-background: var(--theme-light-incoming-background);
99+ --message-outgoing-background: var(
100+ --theme-light-outgoing-background,
101+ var(--theme-primary)
102+ );
103+ --message-outgoing-color: var(
104+ --theme-light-outgoing-color,
105+ var(--theme-on-primary)
106+ );
107+ --gloop-start: color-mix(in srgb, var(--app-background) 94%, white);
108+ --gloop-end: color-mix(in srgb, var(--app-background) 88%, white);
109+}
110+
111+:root[data-theme="dark"] {
112+ --accent-surface: var(--theme-dark-accent-surface);
113+ color-scheme: dark;
114+ --theme-incoming-background: var(--theme-dark-incoming-background);
115+ --message-outgoing-background: var(
116+ --theme-dark-outgoing-background,
117+ var(--theme-primary)
118+ );
119+ --message-outgoing-color: var(
120+ --theme-dark-outgoing-color,
121+ var(--theme-on-primary)
122+ );
123+ --theme-primary: var(--theme-dark-primary, #7401cf);
124+ --theme-secondary: var(--theme-dark-secondary, #ffc700);
125+ --theme-secondary-surface: var(--theme-dark-secondary-surface);
126+ --theme-on-primary: var(--theme-dark-on-primary, white);
127+ --theme-on-secondary: var(--theme-dark-on-secondary, #212121);
128+ --surface-base: var(--theme-dark-background, #191919);
129+ --text-base: var(--theme-dark-text, #f1f1f1);
130+ --color-on-app: var(--theme-dark-on-app, white);
131+ --paper-background: color-mix(
132+ in srgb,
133+ var(--text-base) 3%,
134+ var(--surface-base)
135+ );
136+ --color-primary-light: var(
137+ --accent-surface,
138+ color-mix(in srgb, var(--theme-primary) 24%, var(--surface-base))
139+ );
140+ --color-primary-dark: var(--theme-dark-link, #c99aff);
141+ --chat-panel-border: color-mix(in srgb, var(--text-base) 12%, transparent);
142+ --chat-panel-background: color-mix(
143+ in srgb,
144+ var(--paper-background) 90%,
145+ transparent
146+ );
147+
148+ @include meta.load-css("highlight.js/styles/github-dark.css");
149+
150+ .ql-snow {
151+ .ql-stroke {
152+ stroke: var(--color-text-medium);
153+ }
154+
155+ .ql-fill {
156+ fill: var(--color-text-medium);
157+ }
158+
159+ .ql-picker {
160+ color: var(--color-text-medium);
161+ }
162+
163+ .ql-picker-options,
164+ .ql-tooltip {
165+ background: var(--default-bg-color);
166+ color: var(--color-text);
167+ border-color: var(--default-border-color);
168+ }
169+
170+ .ql-editor.ql-blank::before {
171+ color: var(--color-text-disabled);
172+ }
173+ }
174+}
79175
80176 $default-bg-color: var(--default-bg-color);
81-$typing-indicator-indicator-bg-color: transparent;
82-//$color-text: var(--color-text);
83177 $color-text-medium: var(--color-text-medium);
84178 $color-text-disabled: var(--color-text-disabled);
85179 $default-border-color: var(--default-border-color);
86180 $color-bg-hover: var(--color-bg-hover);
87181 $color-bg-focus: var(--color-bg-focus);
88-$message-header-color: color-mix(in srgb, var(--color-text), white 30%);
89-$message-footer-color: color-mix(in srgb, var(--color-text), white 30%);
182+$message-header-color: color-mix(
183+ in srgb,
184+ var(--color-text),
185+ var(--default-bg-color) 30%
186+);
187+$message-footer-color: $message-header-color;
90188 $color-selected: color-mix(in srgb, var(--color-primary-dark), black 25%);
91-$color-activated: color-mix(in srgb, var(--color-primary-dark), black 25%);
189+$color-activated: $color-selected;
92190 $color-primary: var(--color-primary);
93191 $color-primary-light: var(--color-primary-light);
94192 $color-primary-dark: var(--color-primary-dark);
95-$color-secondary: var(--color-secondary);
96-$color-secondary-light: var(--color-secondary-light);
97-$color-secondary-dark: var(--color-secondary-dark);
193+$button-color: var(--theme-primary);
194+
195+$conversation-unread-bg-color: var(--theme-primary);
196+$conversation-unread-color: var(--theme-on-primary);
98197
99-$conversation-unread-bg-color: var(--color-primary-dark);
198+$message-list-typing-indicator-bg-color: $default-bg-color;
199+$message-list-loading-more-bg-color: $default-bg-color;
100200
101201 $message-outgoing-color: var(--message-outgoing-color);
102202 $message-content-outgoing-color: var(--message-outgoing-color);
103203 $message-group-message-content-outgoing-color: var(--message-outgoing-color);
104-$message-content-outgoing-bg-color: $color-secondary;
204+$message-content-incoming-bg-color: var(--message-incoming-background);
205+$message-group-message-content-incoming-bg-color: $message-content-incoming-bg-color;
206+$message-content-outgoing-bg-color: var(--message-outgoing-background);
105207 $message-group-message-content-outgoing-bg-color: $message-content-outgoing-bg-color;
208+$conversation-activated-bg-color: $color-primary;
209+$conversation-hover-bg-color: $conversation-activated-bg-color;
210+$conversation-name-activated-color: var(--color-text);
211+$conversation-info-activated-color: var(--color-text-medium);
212+
213+// ChatScope uses its base text color in Sass color functions.
214+$main-container-color: var(--color-text);
215+$chat-container-color: var(--color-text);
216+$chat-container-message-input-color: var(--color-text);
217+$chat-container-input-toolbox-color: var(--color-text);
218+$conversation-color: var(--color-text);
219+$conversation-name-color: var(--color-text);
220+$conversation-header-actions-color: var(--color-text);
221+$conversation-list-color: var(--color-text);
222+$expansion-panel-color: var(--color-text);
223+$expansion-panel-content-color: var(--color-text);
224+$loader-color: var(--color-text);
225+$message-color: var(--color-text);
226+$message-content-color: var(--color-text);
227+$message-content-incoming-color: var(--color-text);
228+$message-group-message-content-incoming-color: var(--color-text);
229+$message-input-content-editor-color: var(--color-text);
230+$message-list-color: var(--color-text);
231+$search-color: var(--color-text);
232+$search-placeholder-color: var(--color-text);
233+$status-list-color: var(--color-text);
234+$status-list-item-active-color: var(--color-text);
106235
107236 @import "@chatscope/chat-ui-kit-styles/themes/default/main.scss";
108237
238+.cs-conversation__unread-dot {
239+ background: radial-gradient(
240+ circle at 3px 3px,
241+ color-mix(in srgb, var(--theme-primary), white 30%),
242+ var(--theme-primary)
243+ );
244+}
245+
109246 * {
110247 box-sizing: border-box;
248+ scrollbar-width: thin;
249+ scrollbar-color: var(--color-primary) transparent;
250+}
251+
252+@supports not (scrollbar-color: auto) {
253+ ::-webkit-scrollbar {
254+ width: 6px;
255+ height: 6px;
256+ }
257+
258+ ::-webkit-scrollbar-thumb {
259+ background: var(--color-primary);
260+ border-radius: $default-border-radius;
261+ }
262+
263+ ::-webkit-scrollbar-track {
264+ background: transparent;
265+ }
111266 }
112267
113268 html,
......@@ -115,6 +270,7 @@ body {
115270 color: var(--color-text);
116271 background-color: var(--default-bg-color);
117272 font-family: system-ui, sans-serif;
273+ -webkit-font-smoothing: antialiased;
118274 }
119275
120276 body,
......@@ -124,14 +280,62 @@ html,
124280 height: 100%;
125281 margin: 0;
126282 padding: 0;
127- box-sizing: border-box;
128283 font-size: 16px;
129284 }
130285
286+#ios-status-bar-surface {
287+ display: none;
288+}
289+
290+@media (display-mode: standalone) {
291+ @supports (-webkit-touch-callout: none) and (-webkit-background-clip: text) {
292+ // Avoid iOS 27's system blur over page content. Keep a nontransparent
293+ // background for WebKit's sampler; empty-text clipping prevents painting.
294+ // https://github.com/HKUDS/nanobot/blob/main/docs/guides/ios-pwa-status-bar.md
295+ #ios-status-bar-surface {
296+ display: block;
297+ position: fixed;
298+ inset: 0 0 auto;
299+ height: 11px;
300+ z-index: 2147483647;
301+ pointer-events: none;
302+ background-color: var(--app-background);
303+ -webkit-background-clip: text;
304+ background-clip: text;
305+ }
306+
307+ body:has(.cs-chat-container[role="main"].active) #ios-status-bar-surface {
308+ background-color: var(--default-bg-color);
309+ }
310+
311+ .cs-chat-container[role="main"].active {
312+ --chat-message-gutter: 1rem;
313+
314+ --chat-composer-bottom-offset: 1.2rem;
315+
316+ > .chat-composer {
317+ margin-bottom: 0;
318+ }
319+ }
320+ }
321+}
322+
131323 input {
132324 font-size: inherit;
133325 }
134326
327+#root.tauri-overlay {
328+ padding-top: 28px;
329+}
330+
331+.tauri-titlebar {
332+ position: fixed;
333+ top: 0;
334+ left: 0;
335+ right: 0;
336+ height: 28px;
337+}
338+
135339 .form-option-icon {
136340 display: flex;
137341 align-items: center;
......@@ -199,9 +403,42 @@ li.MuiListSubheader-root {
199403 object-fit: cover;
200404 }
201405
406+#root:not(.tauri-overlay):not(:has(.cs-chat-container[role="main"].active)) {
407+ padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0
408+ env(safe-area-inset-left, 0px);
409+}
410+
202411 #root {
203412 display: flex;
204- padding-bottom: env(safe-area-inset-bottom, 0px);
413+ position: relative;
414+ isolation: isolate;
415+ background: var(--app-background);
416+
417+ &::before,
418+ &::after {
419+ content: "";
420+ position: absolute;
421+ z-index: -1;
422+ pointer-events: none;
423+ width: 50vh;
424+ max-width: 100%;
425+ background: linear-gradient(135deg, var(--gloop-start), var(--gloop-end));
426+ mask: var(--gloop-mask) center / contain no-repeat;
427+ }
428+
429+ &::before {
430+ --gloop-mask: url(/gloop01.svg);
431+ top: 0;
432+ left: 0;
433+ aspect-ratio: 748 / 660;
434+ }
435+
436+ &::after {
437+ --gloop-mask: url(/gloop02.svg);
438+ bottom: 0;
439+ right: 0;
440+ aspect-ratio: 1260 / 1852;
441+ }
205442
206443 > main {
207444 display: flex;
......@@ -222,17 +459,12 @@ li.MuiListSubheader-root {
222459 margin: auto;
223460 min-width: 25em;
224461 max-width: 100vw;
225- border: 1px solid var(--default-border-color);
226462 border-radius: 2em;
227463 text-align: center;
228- background: var(--color-primary-dark) url(/gloop01.svg) no-repeat;
229- background-size: 40%;
230464 overflow: hidden;
231- color: white;
465+ color: var(--color-on-app);
232466
233467 > form {
234- background: url(/gloop02.svg) no-repeat right bottom;
235- background-size: 60%;
236468 padding: 2em;
237469 }
238470
......@@ -249,7 +481,7 @@ li.MuiListSubheader-root {
249481 button {
250482 display: block;
251483 border-radius: 10em;
252- color: #1e0038;
484+ color: #212121;
253485 background: var(--color-secondary-light);
254486 padding: 1em;
255487 width: 100%;
......@@ -257,6 +489,7 @@ li.MuiListSubheader-root {
257489 }
258490
259491 button {
492+ color: var(--color-on-secondary);
260493 background: var(--color-secondary-dark);
261494 }
262495
......@@ -266,12 +499,12 @@ li.MuiListSubheader-root {
266499 gap: 1em;
267500 width: 21em;
268501 margin-top: 1em;
269- background: rgba(96, 14, 181, 0.4);
502+ background: color-mix(in srgb, var(--app-background) 80%, black);
270503 border-radius: 10em;
271- border: 1px solid #550ca1;
272- box-shadow: 0 1px 0 #550ca1;
504+ border: 1px solid var(--app-background);
505+ box-shadow: 0 1px 0 var(--app-background);
273506 padding: 1em;
274- text-shadow: 0 2px 1px #550ca1;
507+ text-shadow: 0 2px 1px var(--app-background);
275508
276509 span {
277510 flex: 1;
......@@ -324,6 +557,107 @@ li.MuiListSubheader-root {
324557 }
325558 }
326559
560+.cs-chat-container[role="main"] {
561+ --chat-message-gutter: 0.5rem;
562+ --chat-composer-bottom-offset: env(safe-area-inset-bottom, 0px);
563+ position: relative;
564+ min-height: 0;
565+
566+ > .cs-conversation-header,
567+ > .chat-composer {
568+ position: absolute;
569+ left: env(safe-area-inset-left, 0px);
570+ right: env(safe-area-inset-right, 0px);
571+ z-index: 2;
572+ margin: 10px var(--chat-message-gutter);
573+ margin-right: calc(
574+ var(--chat-message-gutter) + var(--chat-scrollbar-width, 0px)
575+ );
576+ }
577+
578+ > .cs-conversation-header,
579+ #message-input-root,
580+ .chat-typing-overlay {
581+ border: 1px solid var(--chat-panel-border);
582+ border-radius: 6px;
583+ -webkit-backdrop-filter: blur(12px);
584+ backdrop-filter: blur(12px);
585+ background: var(--chat-panel-background);
586+ }
587+
588+ > .cs-conversation-header,
589+ #message-input-root {
590+ box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
591+ }
592+
593+ > .cs-conversation-header {
594+ top: env(safe-area-inset-top, 0px);
595+ margin-top: var(--chat-message-gutter);
596+ }
597+
598+ > .chat-composer {
599+ bottom: var(--chat-composer-bottom-offset);
600+ }
601+
602+ #message-input-root {
603+ .cs-message-input {
604+ border: 0;
605+ background: transparent;
606+ }
607+
608+ .cs-message-input__content-editor-wrapper {
609+ background: transparent;
610+ }
611+ }
612+
613+ .chat-typing-overlay {
614+ width: fit-content;
615+ max-width: 100%;
616+ margin-bottom: 8px;
617+ padding: 0.4em 0.75em;
618+ pointer-events: none;
619+ }
620+
621+ > .cs-message-list {
622+ min-height: 0;
623+ height: 100%;
624+
625+ .virtuoso-container {
626+ min-height: 0;
627+ }
628+
629+ .jump-to-bottom {
630+ bottom: calc(
631+ var(--chat-composer-height, 0px) + var(--chat-composer-bottom-offset) +
632+ 1rem
633+ );
634+ }
635+ }
636+
637+ > .cs-message-list:has(> .MuiTabs-root) {
638+ padding-top: calc(
639+ var(--chat-header-height, 0px) + env(safe-area-inset-top, 0px) + 20px
640+ );
641+
642+ .chat-header-spacer {
643+ height: 0;
644+ }
645+ }
646+
647+ .chat-header-spacer {
648+ height: calc(
649+ var(--chat-header-height, 0px) + env(safe-area-inset-top, 0px)
650+ );
651+ }
652+
653+ .chat-composer-spacer {
654+ height: calc(
655+ var(--chat-composer-height, 0px) + var(--chat-composer-bottom-offset) +
656+ 12px
657+ );
658+ }
659+}
660+
327661 .cs-message-list {
328662 display: flex;
329663 flex-direction: column;
......@@ -347,7 +681,7 @@ li.MuiListSubheader-root {
347681 background: var(--color-danger);
348682 color: var(--color-on-danger);
349683 padding: 0.5em 1em;
350- border-radius: 10em;
684+ border-radius: $default-border-radius;
351685
352686 &:first-of-type {
353687 color: var(--color-on-secondary);
......@@ -399,8 +733,7 @@ li.MuiListSubheader-root {
399733 section {
400734 display: grid;
401735 grid-template-columns: max-content 1fr;
402- row-gap: 0.5em;
403- column-gap: 1em;
736+ gap: 0.5em 1em;
404737
405738 h1 {
406739 font-size: 1em;
......@@ -412,7 +745,6 @@ li.MuiListSubheader-root {
412745
413746 > .field {
414747 display: contents;
415- align-items: start;
416748
417749 label {
418750 font-style: italic;
......@@ -431,7 +763,6 @@ li.MuiListSubheader-root {
431763 flex-direction: column;
432764 overflow: auto;
433765 flex: 1;
434- field-sizing: content;
435766
436767 > iframe {
437768 flex: 1;
......@@ -479,36 +810,21 @@ li.MuiListSubheader-root {
479810
480811 [readonly] {
481812 caret-color: transparent;
482-
483- ~ fieldset.MuiOutlinedInput-notchedOutline:hover {
484- border-color: rgba(0, 0, 0, 0.23);
485- border-width: 1px;
486- }
487813 }
488814
489- .MuiInputBase-root:hover {
490- [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline {
491- border-color: rgba(0, 0, 0, 0.23);
492- border-width: 1px;
493- }
494- }
495-
496- .MuiInputBase-root.Mui-readOnly:hover {
497- fieldset.MuiOutlinedInput-notchedOutline {
498- border-color: rgba(0, 0, 0, 0.23);
499- border-width: 1px;
500- }
815+ [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline:hover,
816+ .MuiInputBase-root:hover
817+ [readonly]
818+ ~ fieldset.MuiOutlinedInput-notchedOutline,
819+ .MuiInputBase-root.Mui-readOnly:hover
820+ fieldset.MuiOutlinedInput-notchedOutline,
821+ div.Mui-focused [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline {
822+ border-color: var(--mui-palette-divider);
823+ border-width: 1px;
501824 }
502825
503826 label.Mui-focused:has(~ .MuiInputBase-root [readonly]) {
504- color: rgba(0, 0, 0, 0.6);
505- }
506-
507- div.Mui-focused {
508- [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline {
509- border-color: rgba(0, 0, 0, 0.23);
510- border-width: 1px;
511- }
827+ color: var(--color-text-medium);
512828 }
513829
514830 .command-actions {
......@@ -531,10 +847,6 @@ li.MuiListSubheader-root {
531847 margin: auto;
532848 }
533849
534- .cs-typing-indicator {
535- position: static;
536- }
537-
538850 .jump-to-bottom {
539851 opacity: 0;
540852 position: absolute;
......@@ -566,8 +878,8 @@ li.MuiListSubheader-root {
566878
567879 section.cs-message-group {
568880 margin: 0;
569- padding-left: 0.5em;
570- padding-right: 0.5em;
881+ padding-left: var(--chat-message-gutter, 0.5rem);
882+ padding-right: var(--chat-message-gutter, 0.5rem);
571883 padding-bottom: 0.5em;
572884
573885 * {
......@@ -579,32 +891,33 @@ li.MuiListSubheader-root {
579891 padding-bottom: 0.5em;
580892 }
581893
582- &.back-in-time .meta time {
583- font-weight: bold;
584- color: var(--color-primary-dark);
585- }
586-
587894 .cs-message-group__content {
588895 flex: 1;
896+ min-width: 0;
589897 max-width: 80em;
590898 }
591899
592900 .cs-message:not(:only-child) {
593901 margin: 0;
594902 padding-top: 0.2em;
903+
904+ &:first-child {
905+ padding-top: 0;
906+ }
595907 }
596908
597909 &.cs-message-group--incoming {
598- padding-right: 0.5em;
910+ padding-right: calc(
911+ var(--chat-message-gutter, 0.5rem) +
912+ var(--chat-avatar-size, #{$avatar-md-width}) + 8px - 2rem
913+ );
599914 }
600915
601916 &.cs-message-group--outgoing {
602- padding-left: 0.5em;
603- }
604-
605- .cs-message-group__footer {
606- margin: 0;
607- padding-top: 0.2em;
917+ padding-left: calc(
918+ var(--chat-message-gutter, 0.5rem) +
919+ var(--chat-avatar-size, #{$avatar-md-width}) + 8px - 2em
920+ );
608921 }
609922
610923 .call {
......@@ -624,34 +937,8 @@ li.MuiListSubheader-root {
624937 }
625938 }
626939
627- button.cs-button:has(~ .u-in-reply-to) {
628- padding: 0;
629- }
630-
631940 .cs-message--outgoing .cs-message__content button.cs-button {
632- color: var(--color-primary-dark);
633- }
634-
635- .cs-message--incoming .meta {
636- display: flex;
637- flex-wrap: wrap;
638- flex-direction: row;
639- div:not(.h-card.sender) {
640- order: 2;
641- flex: 1;
642- }
643- .h-card.sender {
644- margin-right: 1em;
645- order: 1;
646- }
647- }
648-
649- .small.cs-message--incoming .meta {
650- flex-direction: column;
651- div:not(.h-card.sender) {
652- margin-left: 0;
653- order: 0;
654- }
941+ color: inherit;
655942 }
656943 }
657944
......@@ -673,7 +960,7 @@ li.MuiListSubheader-root {
673960 display: flex;
674961 flex-direction: row;
675962 align-items: center;
676- border-radius: 10em;
963+ border-radius: $default-border-radius;
677964 padding: 0.6em 0.6em;
678965 margin: 0.5em auto;
679966 width: fit-content;
......@@ -738,7 +1025,7 @@ div.cs-message__content {
7381025 white-space-collapse: preserve-spaces;
7391026
7401027 blockquote {
741- border-left: 1px solid black;
1028+ border-left: 1px solid currentColor;
7421029 padding-left: 0.5em;
7431030 opacity: 0.7;
7441031 margin: 0;
......@@ -754,7 +1041,7 @@ div.cs-message__content {
7541041 max-width: 60vw;
7551042 }
7561043
757- .moderated:has(~ .meta),
1044+ .cs-message__custom-content > div > .moderated,
7581045 .u-in-reply-to > .moderated {
7591046 opacity: 0.5;
7601047 font-style: italic;
......@@ -785,7 +1072,7 @@ div.cs-message__content {
7851072 text-decoration: none;
7861073 color: var(--color-text);
7871074 background: var(--color-bg-focus);
788- border-radius: 3em;
1075+ border-radius: $default-border-radius;
7891076 margin: 1em;
7901077 padding: 1.5em;
7911078
......@@ -795,7 +1082,7 @@ div.cs-message__content {
7951082 margin-bottom: 0.5em;
7961083 max-height: 10em;
7971084 max-width: 80vw;
798- border-radius: 1em;
1085+ border-radius: $default-border-radius;
7991086 }
8001087
8011088 .p-name {
......@@ -862,11 +1149,6 @@ div.cs-message__content {
8621149 }
8631150 }
8641151
865-.cs-conversation-header__avatar {
866- margin-top: auto;
867- margin-bottom: auto;
868-}
869-
8701152 .cs-conversation-header__content {
8711153 overflow: hidden;
8721154 text-overflow: ellipsis;
......@@ -927,6 +1209,16 @@ div.cs-message__content {
9271209 }
9281210
9291211 &.cs-sidebar--left {
1212+ [data-index] {
1213+ padding: 0 0.35em;
1214+ border-bottom: 1px solid transparent;
1215+ }
1216+
1217+ .cs-conversation:hover,
1218+ .cs-conversation--active {
1219+ border-radius: $default-border-radius;
1220+ }
1221+
9301222 .cs-conversation-header {
9311223 padding-top: 0.5em;
9321224 padding-bottom: 0.7em;
......@@ -992,7 +1284,7 @@ div.cs-message__content {
9921284 }
9931285
9941286 &:not(.h-card) {
995- border-bottom: 1px solid #ccc;
1287+ border-bottom: 1px solid var(--divider-color);
9961288 }
9971289
9981290 > .MuiBadge-root > button {
......@@ -1013,7 +1305,7 @@ div.cs-message__content {
10131305 li {
10141306 list-style-type: none;
10151307 padding: 0.2em 0;
1016- border-bottom: 1px solid #ccc;
1308+ border-bottom: 1px solid var(--divider-color);
10171309 margin-bottom: 0.5em;
10181310 }
10191311 }
......@@ -1054,10 +1346,10 @@ div.cs-message__content {
10541346
10551347 #tag-nav {
10561348 width: fit-content;
1057- margin: 0 0.5rem 0.5rem;
1349+ margin: 0 0.5rem 0.5em;
10581350 padding: 0.3rem 0.9rem;
10591351 border: none;
1060- border-radius: 2em;
1352+ border-radius: $default-border-radius;
10611353 background: var(--color-secondary);
10621354 }
10631355
......@@ -1112,7 +1404,7 @@ div.cs-message__content {
11121404 margin: 1em auto;
11131405 }
11141406
1115- > .status > .text {
1407+ .status > .text {
11161408 font-style: italic;
11171409 }
11181410
......@@ -1124,7 +1416,7 @@ div.cs-message__content {
11241416 display: inline-block;
11251417 padding: 0.2em 0.5em;
11261418 margin: 0.5em;
1127- border-radius: 2em;
1419+ border-radius: $default-border-radius;
11281420 color: var(--color-on-danger);
11291421 text-transform: lowercase;
11301422 font-variant: small-caps;
......@@ -1145,19 +1437,13 @@ div.cs-message__content {
11451437 }
11461438
11471439 #message-input-root {
1148- border-top: 1px solid var(--default-border-color);
1149-
1150- &:has(.reply) {
1151- border-top: none;
1152- }
1153-
11541440 .reply {
11551441 display: flex;
11561442 flex-direction: row;
11571443
1158- background: var(--color-primary-dark);
1159- color: var(--default-bg-color);
1160- border-radius: 1em 1em 0 0;
1444+ background: var(--theme-primary);
1445+ color: var(--theme-on-primary);
1446+ border-radius: $default-border-radius $default-border-radius 0 0;
11611447 padding: 0 1em;
11621448 line-height: 2;
11631449
......@@ -1167,14 +1453,13 @@ div.cs-message__content {
11671453
11681454 button {
11691455 margin-left: auto;
1170- color: var(--default-bg-color);
1456+ color: var(--theme-on-primary);
11711457 padding: 0;
11721458 }
11731459 }
11741460
11751461 .attachments {
11761462 display: flex;
1177- flex-direction: flex-row;
11781463 padding: 0.5em;
11791464
11801465 img {
......@@ -1205,9 +1490,6 @@ div.cs-message__content {
12051490 }
12061491
12071492 .cs-message-input {
1208- display: "flex";
1209- flex-direction: "row";
1210-
12111493 .cs-message-input__tools {
12121494 margin: auto 0;
12131495
......@@ -1241,6 +1523,10 @@ div.cs-message__content {
12411523 }
12421524
12431525 .ql-toolbar {
1526+ // Quill's bold icon starts 4px into its SVG, after 5px of button padding.
1527+ // The negative margin visually aligns the B with the "Send message" placeholder below.
1528+ margin-left: -9px;
1529+ margin-bottom: 0.25rem;
12441530 white-space: nowrap;
12451531 overflow: hidden;
12461532 }
......@@ -1271,58 +1557,58 @@ div.cs-message__content {
12711557 cursor: pointer;
12721558 }
12731559
1274-.cs-message:has(.cs-message__footer.reactions) {
1275- padding-bottom: 0.55em;
1276-}
1277-
1278-.cs-message__footer.reactions {
1279- position: absolute;
1280- bottom: -0.2em;
1281- right: 0;
1560+section.cs-message .cs-message__footer.reactions {
1561+ position: relative;
1562+ margin: -8px -1px -1px -1px;
1563+ display: flex;
1564+ flex-wrap: wrap;
1565+ gap: 2px;
12821566
12831567 .cs-button.reaction {
1284- padding: 0 0.2em;
1285- border-color: var(--default-border-color);
1568+ margin: 0;
1569+ padding: 0 4px;
1570+ border-radius: 6px;
1571+ border: 1px solid var(--default-bg-color);
12861572 color: var(--color-text);
1287- background: color-mix(in srgb, var(--color-primary-light), transparent 35%);
1573+ background: var(--color-primary-light);
12881574 width: max-content;
1289- }
1575+ opacity: 1;
1576+ transition:
1577+ background-color 120ms ease,
1578+ color 120ms ease;
1579+ height: 22px;
1580+ line-height: 20px;
1581+ font-size: 10px;
1582+ display: flex;
1583+ align-items: center;
1584+ gap: 4px;
12901585
1291- .cs-button.reaction.mine {
1292- color: var(--default-bg-color);
1293- background: color-mix(in srgb, var(--color-primary-dark), transparent 35%);
1294- }
1586+ > span {
1587+ font-size: 16px;
1588+ }
12951589
1296- .cs-button.reaction img {
1297- max-height: 1rem;
1298- }
1299-}
1590+ img {
1591+ max-height: 1rem;
1592+ }
13001593
1301-.cs-message.cs-message--single:has(.cs-message__footer.reactions),
1302-.cs-message.cs-message--last:has(.cs-message__footer.reactions) {
1303- padding-bottom: 0em;
1594+ &.mine,
1595+ &:hover,
1596+ &:focus-visible {
1597+ background: var(--color-secondary-dark);
1598+ color: var(--color-on-secondary);
1599+ }
13041600
1305- .cs-message__footer.reactions {
1306- bottom: -0.6em;
1601+ &.mine:hover,
1602+ &.mine:focus-visible {
1603+ color: var(--color-text);
1604+ background: $color-primary;
1605+ }
13071606 }
13081607 }
13091608
1310-.cs-message--outgoing .cs-message__footer.reactions {
1311- .cs-button.reaction {
1312- background: color-mix(
1313- in srgb,
1314- var(--color-secondary-light),
1315- transparent 35%
1316- );
1317- }
1318-
1319- .cs-button.reaction.mine {
1320- background: color-mix(
1321- in srgb,
1322- var(--color-secondary-dark),
1323- transparent 35%
1324- );
1325- }
1609+.cs-message-group--outgoing section.cs-message .cs-message__footer.reactions,
1610+section.cs-message--outgoing .cs-message__footer.reactions {
1611+ justify-content: flex-end;
13261612 }
13271613
13281614 img.thread {
......@@ -1351,26 +1637,56 @@ img.thread {
13511637 }
13521638
13531639 .cs-message__custom-content {
1354- .meta {
1355- line-height: 1.3;
1640+ .message-timed-text {
1641+ position: relative;
13561642
1357- img.thread {
1358- float: right;
1359- margin-top: 0.25em;
1360- margin-left: 0.5em;
1643+ &::after {
1644+ content: attr(data-time);
1645+ display: inline-block;
1646+ visibility: hidden;
1647+ padding-right: calc(var(--message-status-count, 0) * 1.5em);
13611648 }
13621649
1363- time,
1364- svg {
1365- font-size: 0.8em;
1366- opacity: 0.6;
1650+ > .message-time {
1651+ position: absolute;
1652+ right: 0;
1653+ bottom: 0;
13671654 }
1655+ }
13681656
1369- svg {
1370- padding-left: 0.5em;
1657+ .message-timed-text::after,
1658+ .message-time {
1659+ font-size: 0.75rem;
1660+ font-weight: normal;
1661+ font-style: normal;
1662+ white-space: nowrap;
1663+ padding-left: 0.75em;
1664+ line-height: 1.5;
1665+ }
1666+
1667+ .message-time {
1668+ display: inline-flex;
1669+ align-items: center;
1670+
1671+ .message-badge {
1672+ width: 1.5em;
1673+ color: inherit;
1674+
1675+ svg {
1676+ font-size: 1em;
1677+ }
1678+ }
1679+
1680+ > :not(:has(.thread)) {
1681+ color: color-mix(in srgb, currentColor 60%, transparent);
13711682 }
13721683 }
13731684
1685+ .message-time-row {
1686+ display: block;
1687+ text-align: right;
1688+ }
1689+
13741690 .action {
13751691 font-style: italic;
13761692 &:before {
......@@ -1383,8 +1699,15 @@ img.thread {
13831699 }
13841700 }
13851701
1386- .cs-message__html-content:has(.action) ~ .meta .sender {
1387- display: none;
1702+ div:has(> .cs-message__html-content .action) > .message-heading {
1703+ .sender,
1704+ .subject-separator {
1705+ display: none;
1706+ }
1707+ }
1708+
1709+ .message-heading {
1710+ font-weight: 500;
13881711 }
13891712
13901713 .h-card.sender {
......@@ -1392,9 +1715,68 @@ img.thread {
13921715 }
13931716 }
13941717
1718+.back-in-time .cs-message__custom-content {
1719+ .message-timed-text::after,
1720+ .message-time > time {
1721+ font-weight: bold;
1722+ }
1723+}
1724+
13951725 section.cs-message {
13961726 overflow: visible;
13971727 position: relative;
1728+ max-width: 100%;
1729+
1730+ button.cs-button:has(+ .u-in-reply-to) {
1731+ padding: 0;
1732+ color: inherit;
1733+ }
1734+
1735+ .cs-message__content {
1736+ position: relative;
1737+ }
1738+
1739+ .message-badge {
1740+ display: flex;
1741+ align-items: center;
1742+ justify-content: center;
1743+ font: inherit;
1744+ color: var(--color-text-disabled);
1745+ padding: 0;
1746+ border: 0;
1747+ background: transparent;
1748+
1749+ svg {
1750+ font-size: 0.75em;
1751+ }
1752+
1753+ img {
1754+ height: 0.75em;
1755+ object-fit: contain;
1756+ }
1757+ }
1758+
1759+ button.message-badge {
1760+ cursor: pointer;
1761+ }
1762+
1763+ .cs-message__custom-content a {
1764+ color: var(--color-primary-dark);
1765+ text-decoration: underline;
1766+ text-underline-offset: 0.15em;
1767+ text-decoration-thickness: 1px;
1768+ text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
1769+ transition: text-decoration-color 250ms ease;
1770+
1771+ &:hover,
1772+ &:focus-visible {
1773+ text-decoration-color: currentColor;
1774+ }
1775+ }
1776+
1777+ &.cs-message--outgoing .cs-message__custom-content a {
1778+ color: var(--message-outgoing-color);
1779+ }
13981780
13991781 .cs-message__header {
14001782 opacity: 0;
......@@ -1417,12 +1799,11 @@ section.cs-message {
14171799 content: "Private invite only to you";
14181800 font-style: italic;
14191801 opacity: 0.9;
1420- text-size: 0.9em;
14211802 color: var(--color-primary-dark);
14221803 }
14231804
14241805 &.highlight .cs-message__content {
1425- border: 3px solid var(--color-primary-dark);
1806+ border: 3px solid var(--accent-surface, var(--color-primary-dark));
14261807 }
14271808
14281809 &.cs-message--incoming {
......@@ -1433,10 +1814,6 @@ section.cs-message {
14331814 float: right;
14341815 margin-right: -2em;
14351816 }
1436-
1437- .cs-message__footer {
1438- margin-right: 2em;
1439- }
14401817 }
14411818
14421819 &.cs-message--outgoing {
......@@ -1450,6 +1827,9 @@ section.cs-message {
14501827
14511828 .cs-message__content-wrapper {
14521829 display: block;
1830+ position: relative;
1831+ min-width: 0;
1832+ max-width: 100%;
14531833 }
14541834 }
14551835
......@@ -1472,38 +1852,29 @@ section.cs-message {
14721852
14731853 .embed-responsive {
14741854 position: relative;
1475- display: block;
1476- width: 100%;
1855+ aspect-ratio: 4 / 3;
14771856 overflow: hidden;
1478- padding: 0;
1479-
1480- &::before {
1481- content: "";
1482- display: block;
1483- padding-top: 75%;
1484- }
14851857
14861858 video {
14871859 position: absolute;
1488- top: 0;
1489- bottom: 0;
1490- left: 0;
1860+ inset: 0;
14911861 width: 100%;
14921862 height: 100%;
14931863 }
14941864 }
14951865
1496- .h-card {
1866+ .h-card,
1867+ .call-account {
14971868 display: flex;
14981869 align-items: center;
14991870 justify-content: center;
1871+ }
1872+
1873+ .h-card {
15001874 margin-top: 1.5em;
15011875 }
15021876
15031877 .call-account {
1504- display: flex;
1505- align-items: center;
1506- justify-content: center;
15071878 gap: 0.5em;
15081879 font-size: 0.85em;
15091880 line-height: 1;
......@@ -1531,17 +1902,24 @@ section.cs-message {
15311902 width: 100%;
15321903 text-align: left;
15331904 border-radius: 0;
1534- border-bottom: 1px solid #ccc;
1905+ border-bottom: 1px solid var(--divider-color);
15351906 margin-bottom: 0.5em;
15361907 padding: 0.2em 0;
15371908 line-height: 1;
15381909 gap: 0.5em;
15391910 }
15401911
1541- a.u-email::before {
1912+ a.u-email::before,
1913+ a.u-tel::before,
1914+ a.u-url::before,
1915+ a.u-impp::before,
1916+ .p-org::before,
1917+ .p-pronouns::before,
1918+ .p-tz::before,
1919+ time::before,
1920+ .dt-bday::before {
15421921 content: "";
1543- mask: url(@fortawesome/fontawesome-free/svgs/solid/envelope.svg) no-repeat
1544- center;
1922+ mask: none no-repeat center;
15451923 background: var(--color-text);
15461924 height: 1em;
15471925 width: 1em;
......@@ -1549,98 +1927,43 @@ section.cs-message {
15491927 flex-shrink: 0;
15501928 }
15511929
1930+ a.u-email::before {
1931+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/envelope.svg);
1932+ }
1933+
15521934 a.u-tel::before {
1553- content: "";
1554- mask: url(@fortawesome/fontawesome-free/svgs/solid/phone.svg) no-repeat
1555- center;
1556- background: var(--color-text);
1557- height: 1em;
1558- width: 1em;
1559- display: block;
1560- flex-shrink: 0;
1935+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/phone.svg);
15611936 }
15621937
15631938 a.u-url::before {
1564- content: "";
1565- mask: url(@fortawesome/fontawesome-free/svgs/solid/link.svg) no-repeat
1566- center;
1567- background: var(--color-text);
1568- height: 1em;
1569- width: 1em;
1570- display: block;
1571- flex-shrink: 0;
1939+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/link.svg);
15721940 }
15731941
15741942 a.u-impp::before {
1575- content: "";
1576- mask: url(@fortawesome/fontawesome-free/svgs/solid/message.svg) no-repeat
1577- center;
1578- background: var(--color-text);
1579- height: 1em;
1580- width: 1em;
1581- display: block;
1582- flex-shrink: 0;
1943+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/message.svg);
15831944 }
15841945
15851946 .p-org::before {
1586- content: "";
1587- mask: url(@fortawesome/fontawesome-free/svgs/solid/building.svg) no-repeat
1588- center;
1589- background: var(--color-text);
1590- height: 1em;
1591- width: 1em;
1592- display: block;
1593- flex-shrink: 0;
1947+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/building.svg);
15941948 }
15951949
15961950 .p-pronouns::before {
1597- content: "";
1598- mask: url(@fortawesome/fontawesome-free/svgs/solid/genderless.svg) no-repeat
1599- center;
1600- background: var(--color-text);
1601- height: 1em;
1602- width: 1em;
1603- display: block;
1604- flex-shrink: 0;
1951+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/genderless.svg);
16051952 }
16061953
16071954 .p-tz::before {
1608- content: "";
1609- mask: url(@fortawesome/fontawesome-free/svgs/solid/user-clock.svg) no-repeat
1610- center;
1611- background: var(--color-text);
1612- height: 1em;
1613- width: 1em;
1614- display: block;
1615- flex-shrink: 0;
1955+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/user-clock.svg);
16161956 }
16171957
16181958 time::before {
1619- content: "";
1620- mask: url(@fortawesome/fontawesome-free/svgs/solid/calendar.svg) no-repeat
1621- center;
1622- background: var(--color-text);
1623- height: 1em;
1624- width: 1em;
1625- display: block;
1626- flex-shrink: 0;
1959+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/calendar.svg);
16271960 }
16281961
16291962 .dt-bday::before {
1630- content: "";
1631- mask: url(@fortawesome/fontawesome-free/svgs/solid/cake-candles.svg)
1632- no-repeat center;
1633- background: var(--color-text);
1634- height: 1em;
1635- width: 1em;
1636- display: block;
1637- flex-shrink: 0;
1638- }
1639-
1640- a.u-url[href^="https://www.patreon.com/c/"]::before {
1641- mask-image: url(@fortawesome/fontawesome-free/svgs/brands/patreon.svg);
1963+ mask-image: url(@fortawesome/fontawesome-free/svgs/solid/cake-candles.svg);
16421964 }
16431965
1966+ a.u-url[href^="https://www.patreon.com/c/"]::before,
16441967 a.u-url[href^="https://patreon.com/c/"]::before {
16451968 mask-image: url(@fortawesome/fontawesome-free/svgs/brands/patreon.svg);
16461969 }
......@@ -1718,6 +2041,17 @@ button.MuiFab-root {
17182041 }
17192042
17202043 @media (max-width: 576px) {
2044+ .cs-main-container {
2045+ --chat-avatar-size: 28px;
2046+
2047+ .cs-avatar.cs-avatar--md {
2048+ width: var(--chat-avatar-size);
2049+ height: var(--chat-avatar-size);
2050+ min-width: var(--chat-avatar-size);
2051+ min-height: var(--chat-avatar-size);
2052+ }
2053+ }
2054+
17212055 .cs-main-container--responsive {
17222056 .cs-sidebar .cs-search {
17232057 display: flex;
......@@ -1727,6 +2061,7 @@ button.MuiFab-root {
17272061 display: flex;
17282062 flex-basis: 100%;
17292063 max-width: 100%;
2064+ border-right: 0;
17302065 }
17312066
17322067 > .cs-chat-container {
......@@ -1734,12 +2069,14 @@ button.MuiFab-root {
17342069 }
17352070 }
17362071
1737- #account-nav:has(~ .cs-main-container) {
2072+ #account-nav:has(~ main > .cs-main-container) {
17382073 display: none;
17392074 }
17402075
1741- #account-nav:has(~ .cs-main-container > .cs-sidebar--left.active),
1742- #account-nav:has(~ .cs-main-container > .active > .cs-message-list.account) {
2076+ #account-nav:has(~ main > .cs-main-container > .cs-sidebar--left.active),
2077+ #account-nav:has(
2078+ ~ main > .cs-main-container > .active > .cs-message-list.account
2079+ ) {
17432080 display: flex;
17442081 }
17452082 }
......@@ -1759,17 +2096,102 @@ button.MuiFab-root {
17592096 }
17602097 }
17612098
2099+.cs-main-container {
2100+ border: 0;
2101+
2102+ &.page {
2103+ flex: 1;
2104+ min-height: 0;
2105+
2106+ .page-back {
2107+ display: none;
2108+ font-size: $conversation-header-font-size;
2109+ padding: 0;
2110+ @media (max-width: 576px) {
2111+ display: inline-flex;
2112+ }
2113+ }
2114+
2115+ > section {
2116+ margin: 0 auto;
2117+ max-width: 100%;
2118+ overflow: auto;
2119+ scrollbar-gutter: stable;
2120+ padding: 1em 2em;
2121+
2122+ &:has(> .settings-appearance) {
2123+ width: 40rem;
2124+ }
2125+ }
2126+ }
2127+
2128+ &.tauri {
2129+ flex: 1;
2130+ min-height: 0;
2131+ height: auto;
2132+ border-radius: $default-border-radius;
2133+ border-bottom-right-radius: 13px;
2134+ overflow: hidden;
2135+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
2136+ }
2137+}
2138+
2139+main:has(> .cs-main-container.tauri) {
2140+ padding: 0.35em 0.35em 0.35em 0;
2141+}
2142+
2143+#account-nav:has(~ main > .cs-main-container.tauri) {
2144+ isolation: auto;
2145+ box-shadow: none;
2146+
2147+ .active-account,
2148+ > a.active {
2149+ z-index: 1;
2150+ }
2151+
2152+ > .active-account:first-child::after {
2153+ background-image: radial-gradient(
2154+ circle at bottom left,
2155+ transparent 70%,
2156+ var(--default-bg-color) 72%
2157+ );
2158+ background-position: bottom;
2159+ }
2160+}
2161+
2162+#account-nav:has(> .active-account:first-child)
2163+ ~ main
2164+ > .cs-main-container.tauri {
2165+ border-top-left-radius: 0;
2166+}
2167+
17622168 #account-nav {
1763- background: var(--color-primary-dark) url(/gloop01.svg) no-repeat;
1764- background-size: 40vh;
2169+ flex: 0 0 5.5em;
2170+ width: 5.5em;
2171+ padding-block: 0.35em;
2172+ isolation: isolate;
2173+ overflow: hidden;
2174+ box-shadow: inset -12px 0 12px -8px rgba(0, 0, 0, 0.2);
17652175 display: flex;
17662176 flex-direction: column;
2177+ gap: 0.35em;
2178+
2179+ .account-nav-group {
2180+ position: relative;
2181+ margin-left: 0.35em;
2182+ padding: 0.35em 0;
2183+ display: flex;
2184+ flex-direction: column;
2185+ gap: 0.35em;
2186+ }
17672187
1768- > a {
2188+ > a,
2189+ .account-nav-group > a {
17692190 position: relative;
17702191 display: block;
2192+ margin-left: 0.35em;
17712193 padding: 0.5em;
1772- color: white;
2194+ color: inherit;
17732195 text-decoration: none;
17742196
17752197 .cs-avatar {
......@@ -1803,9 +2225,62 @@ button.MuiFab-root {
18032225 }
18042226 }
18052227
1806- a.active {
1807- background: $color-primary-light;
1808- color: $color-primary-dark;
2228+ color: var(--color-on-app);
2229+
2230+ .account-nav-group > a {
2231+ margin: 0 0.35em;
2232+ }
2233+
2234+ .account-nav-group .cs-avatar {
2235+ border: 2px solid var(--color-on-app);
2236+ }
2237+
2238+ .active-account > a.active {
2239+ border-radius: $default-border-radius;
2240+ background: $conversation-activated-bg-color;
2241+ }
2242+
2243+ .active-account::after,
2244+ > a.active::after {
2245+ content: "";
2246+ position: absolute;
2247+ right: 0;
2248+ top: -$default-border-radius;
2249+ bottom: -$default-border-radius;
2250+ width: $default-border-radius;
2251+ background:
2252+ radial-gradient(
2253+ circle at top left,
2254+ transparent 70%,
2255+ var(--default-bg-color) 72%
2256+ )
2257+ top,
2258+ radial-gradient(
2259+ circle at bottom left,
2260+ transparent 70%,
2261+ var(--default-bg-color) 72%
2262+ )
2263+ bottom;
2264+ background-size: 100% $default-border-radius;
2265+ background-repeat: no-repeat;
2266+ pointer-events: none;
2267+ }
2268+
2269+ .active-account,
2270+ > a.active {
2271+ border-radius: $default-border-radius 0 0 $default-border-radius;
2272+ background: var(--default-bg-color);
2273+ color: var(--color-primary-dark);
2274+
2275+ &::before {
2276+ content: "";
2277+ position: absolute;
2278+ inset: 0;
2279+ border-radius: inherit;
2280+ z-index: -1;
2281+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
2282+ pointer-events: none;
2283+ }
18092284 }
18102285 }
18112286
......@@ -1873,6 +2348,12 @@ em-emoji-picker {
18732348 }
18742349 }
18752350
2351+.message-attachments .message-attachment-media {
2352+ max-height: 15em;
2353+ max-width: min(100%, 35em);
2354+ object-fit: scale-down;
2355+}
2356+
18762357 .message-attachments-toggle {
18772358 display: inline-flex;
18782359 align-items: center;
......@@ -1881,6 +2362,7 @@ em-emoji-picker {
18812362 border: 0;
18822363 background: transparent;
18832364 font-size: 0.8em;
2365+ color: inherit;
18842366 opacity: 0.6;
18852367 text-align: left;
18862368 cursor: pointer;
......@@ -1889,3 +2371,33 @@ em-emoji-picker {
18892371 font-size: 0.75em;
18902372 }
18912373 }
2374+
2375+.settings-appearance {
2376+ > .MuiFormControl-root {
2377+ margin-bottom: 1em;
2378+ }
2379+
2380+ display: flex;
2381+ flex-direction: column;
2382+ gap: 1em;
2383+ margin-top: 2em;
2384+ padding-top: 1em;
2385+ border-top: 1px solid var(--divider-color);
2386+
2387+ h2 {
2388+ margin: 0;
2389+ }
2390+
2391+ .theme-colour {
2392+ display: flex;
2393+ align-items: flex-start;
2394+ gap: 0.75em;
2395+
2396+ input[type="color"] {
2397+ flex-shrink: 0;
2398+ width: 2.5em;
2399+ height: 2.5em;
2400+ cursor: pointer;
2401+ }
2402+ }
2403+}
+25 -1 src/App.tsx #
......@@ -1,6 +1,12 @@
1+import {
2+ applyTheme,
3+ defaultCustomPalette,
4+ defaultTheme,
5+ type Theme,
6+} from "./theme";
17 import { assertNever } from "./assert-never";
28 import "./App.scss";
3-import { CircularProgress } from "@mui/material";
9+import { CircularProgress, useColorScheme } from "@mui/material";
410 import { newAccount } from "./components/Login";
511 import { Suspense, useEffect, useState } from "react";
612 import * as borogove from "borogove";
......@@ -83,6 +89,13 @@ const AppInner = () => {
8389 };
8490 const [accounts, setAccounts] = useState(initialAccounts);
8591 const [settings, setSettings] = useState<SettingsData>(initialSettings);
92+ const { setMode } = useColorScheme();
93+ useEffect(() => {
94+ setMode(settings.appearance);
95+ }, [setMode, settings.appearance]);
96+ useEffect(() => {
97+ applyTheme(settings.theme, settings.customPalette);
98+ }, [settings.theme, settings.customPalette]);
8699 const params = useParams();
87100 const { showNotification, onNotificationClick, onNotificationClose } =
88101 useNotifications();
......@@ -242,12 +255,23 @@ const initialP = (async () => {
242255 const accountIds = await persistence.listAccounts();
243256 const initialSelectedAccount =
244257 (await persistence.get("ui#selectedAccount")) || accountIds[0];
258+ const appearance = await persistence.get("config#appearance");
259+ const savedTheme = (await persistence.get(
260+ "config#themePreset",
261+ )) as Theme | null;
262+ const savedCustomPalette = await persistence.get("config#customPalette");
245263 return {
246264 initialAccounts: Object.fromEntries(
247265 accountIds.map((id: string) => [id, newAccount(id, idbp, persistence)]),
248266 ),
249267 initialSelectedAccount,
250268 initialSettings: {
269+ theme: savedTheme ?? defaultTheme,
270+ customPalette: savedCustomPalette
271+ ? JSON.parse(savedCustomPalette)
272+ : defaultCustomPalette,
273+ appearance:
274+ appearance === "light" || appearance === "dark" ? appearance : "system",
251275 enterIsSend:
252276 "" + (await persistence.get("config#enterIsSend")) !== "false",
253277 richTextToolbar:
+3 -2 src/components/About.tsx #
......@@ -1,9 +1,10 @@
1+import { Page } from "./Page";
12 import { sha, describe } from "~build/git";
23 import * as borogove from "borogove";
34
45 export const About = () => {
56 return (
6- <section>
7+ <Page>
78 <h1>About</h1>
89 <p>
910 This is AGPLv3 licensed software, version{" "}
......@@ -14,6 +15,6 @@ export const About = () => {
1415 <a href="https://borogove.dev">Borogove {borogove.VERSION}</a>
1516 </p>
1617 <p>This is an alpha test version.</p>
17- </section>
18+ </Page>
1819 );
1920 };
+10 -4 src/components/Accounts.tsx #
......@@ -8,7 +8,7 @@ import {
88 useParams,
99 useNavigate,
1010 } from "react-router";
11-import { Fragment, useContext, useEffect, useState } from "react";
11+import { useContext, useEffect, useState } from "react";
1212 import { useHotkeys } from "react-hotkeys-hook";
1313 import { Context } from "../App";
1414 import { AvatarWithPlaceholder } from "./AvatarWithPlaceholder";
......@@ -231,8 +231,14 @@ export const Accounts = () => {
231231 const client = accounts[accountId].client;
232232 const selfChat = client.getChat(accountId);
233233 return (
234- <Fragment key={`account-${accountId}`}>
235- <NavLink to={href("/accounts/:accountId", { accountId })}>
234+ <div
235+ key={`account-${accountId}`}
236+ className={
237+ "account-nav-group" +
238+ (params.accountId === accountId ? " active-account" : "")
239+ }
240+ >
241+ <NavLink end to={href("/accounts/:accountId", { accountId })}>
236242 <AvatarWithPlaceholder
237243 displayName={`Account: ${accountId}`}
238244 placeholderUri={selfChat?.getPlaceholder()}
......@@ -279,7 +285,7 @@ export const Accounts = () => {
279285 <div className="label">Requests</div>
280286 </NavLink>
281287 )}
282- </Fragment>
288+ </div>
283289 );
284290 })}
285291 <NavLink to="/login" title="Add Account">
+141 -0 src/components/AppearanceSettings.tsx #
......@@ -0,0 +1,141 @@
1+import type { persistence } from "borogove";
2+import { useState } from "react";
3+import { contrast, themePresets, type Palette, type Theme } from "../theme";
4+import type { SettingsData } from "./Settings";
5+import {
6+ MenuItem,
7+ TextField,
8+ FormLabel,
9+ FormControl,
10+ RadioGroup,
11+ Radio,
12+ FormControlLabel,
13+ useColorScheme,
14+} from "@mui/material";
15+import { capitalize } from "@mui/material/utils";
16+
17+const colourRoles = ["background", "text", "primary", "secondary"] as const;
18+
19+function ColourField({
20+ role,
21+ value,
22+ onChange,
23+}: {
24+ role: keyof Palette;
25+ value: string;
26+ onChange: (value: string) => void;
27+}) {
28+ const [draft, setDraft] = useState(value);
29+ const isColour = (value: string) => /^#[\da-f]{6}$/i.test(value);
30+ const change = (value: string) => {
31+ setDraft(value);
32+ if (isColour(value.trim())) onChange(value.trim());
33+ };
34+ const invalid = !isColour(draft.trim());
35+ return (
36+ <div className="theme-colour">
37+ <TextField
38+ fullWidth
39+ size="small"
40+ label={`${capitalize(role)} colour`}
41+ value={draft}
42+ error={invalid}
43+ helperText={invalid ? "Use a six-digit hex colour." : undefined}
44+ onChange={(event) => change(event.target.value)}
45+ />
46+ <input
47+ type="color"
48+ aria-label={`Choose ${role} colour`}
49+ value={value}
50+ onChange={(event) => change(event.target.value)}
51+ />
52+ </div>
53+ );
54+}
55+
56+export function AppearanceSettings({
57+ settings,
58+ setSettings,
59+ persistence,
60+}: {
61+ settings: SettingsData;
62+ setSettings: (settings: SettingsData) => void;
63+ persistence: persistence.KeyValueStore;
64+}) {
65+ const { customPalette } = settings;
66+ const { systemMode } = useColorScheme();
67+ return (
68+ <section className="settings-appearance" aria-labelledby="appearance-title">
69+ <h2 id="appearance-title">Appearance</h2>
70+
71+ <FormControl>
72+ <FormLabel id="appearance-label">Mode</FormLabel>
73+ <RadioGroup
74+ aria-labelledby="appearance-label"
75+ row
76+ value={settings.appearance}
77+ onChange={(_, value) => {
78+ const appearance = value as SettingsData["appearance"];
79+ persistence.set("config#appearance", appearance);
80+ setSettings({ ...settings, appearance });
81+ }}
82+ >
83+ <FormControlLabel value="system" control={<Radio />} label="System" />
84+ <FormControlLabel value="light" control={<Radio />} label="Light" />
85+ <FormControlLabel value="dark" control={<Radio />} label="Dark" />
86+ </RadioGroup>
87+ </FormControl>
88+
89+ <TextField
90+ select
91+ label="Theme"
92+ value={settings.theme}
93+ onChange={(event) => {
94+ const theme = event.target.value as Theme;
95+ let palette = customPalette;
96+ if (theme === "custom" && settings.theme !== "custom") {
97+ const mode =
98+ settings.appearance === "system"
99+ ? systemMode
100+ : settings.appearance;
101+ const { background, text, primary, secondary } =
102+ themePresets[settings.theme][mode ?? "light"];
103+ palette = { background, text, primary, secondary };
104+ persistence.set("config#customPalette", JSON.stringify(palette));
105+ }
106+ persistence.set("config#themePreset", theme);
107+ setSettings({ ...settings, theme, customPalette: palette });
108+ }}
109+ >
110+ {Object.entries(themePresets).map(([id, preset]) => (
111+ <MenuItem key={id} value={id}>
112+ {preset.name}
113+ </MenuItem>
114+ ))}
115+ <MenuItem value="custom">Custom</MenuItem>
116+ </TextField>
117+ {settings.theme === "custom" && (
118+ <>
119+ {colourRoles.map((role) => (
120+ <ColourField
121+ key={role}
122+ role={role}
123+ value={customPalette[role]}
124+ onChange={(value) => {
125+ const palette = { ...customPalette, [role]: value };
126+ persistence.set(
127+ "config#customPalette",
128+ JSON.stringify(palette),
129+ );
130+ setSettings({ ...settings, customPalette: palette });
131+ }}
132+ />
133+ ))}
134+ {contrast(customPalette.text, customPalette.background) < 4.5 && (
135+ <p role="status">Text and background have low contrast.</p>
136+ )}
137+ </>
138+ )}
139+ </section>
140+ );
141+}
+6 -6 src/components/Call.tsx #
......@@ -347,7 +347,7 @@ export const Call = ({
347347 transform: "translateX(-50%)",
348348 border: "1px solid red",
349349 padding: "0.5em 1em",
350- borderRadius: "1em",
350+ borderRadius: "var(--border-radius)",
351351 }}
352352 >
353353 {call.videoTracks().length > 0 &&
......@@ -515,7 +515,7 @@ export const Call = ({
515515 sx={{
516516 transform: "translateX(-50%)",
517517 padding: "1em 4em",
518- borderRadius: "1em",
518+ borderRadius: "var(--border-radius)",
519519 textAlign: "center",
520520 }}
521521 >
......@@ -558,7 +558,7 @@ export const Call = ({
558558 onClick={() => call.hangup()}
559559 style={{
560560 background: "red",
561- borderRadius: "10em",
561+ borderRadius: "var(--border-radius)",
562562 color: "white",
563563 padding: "0.5em 2em",
564564 marginTop: "1.5em",
......@@ -581,7 +581,7 @@ export const Call = ({
581581 sx={{
582582 transform: "translateX(-50%)",
583583 padding: "1em 4em",
584- borderRadius: "1em",
584+ borderRadius: "var(--border-radius)",
585585 textAlign: "center",
586586 }}
587587 >
......@@ -618,7 +618,7 @@ export const Call = ({
618618 border
619619 onClick={() => call.accept()}
620620 style={{
621- borderRadius: "10em",
621+ borderRadius: "var(--border-radius)",
622622 padding: "0.5em 2em",
623623 }}
624624 >
......@@ -628,7 +628,7 @@ export const Call = ({
628628 onClick={() => call.hangup()}
629629 style={{
630630 background: "red",
631- borderRadius: "10em",
631+ borderRadius: "var(--border-radius)",
632632 color: "white",
633633 padding: "0.5em 2em",
634634 }}
+232 -173 src/components/Chat.tsx #
......@@ -31,6 +31,7 @@ import {
3131 Suspense,
3232 useState,
3333 useEffect,
34+ useLayoutEffect,
3435 useMemo,
3536 useRef,
3637 useCallback,
......@@ -49,6 +50,7 @@ import {
4950 Message,
5051 MessageList,
5152 MessageInput,
53+ InputToolbox,
5254 SendButton,
5355 TypingIndicator,
5456 } from "@chatscope/chat-ui-kit-react";
......@@ -135,6 +137,23 @@ type Group = {
135137 messages: borogove.ChatMessage[];
136138 };
137139
140+const messageListComponents = {
141+ Header: () => <div className="chat-header-spacer" />,
142+ Footer: () => <div className="chat-composer-spacer" />,
143+};
144+
145+function measureScrollbarWidth(scroller: HTMLElement | null) {
146+ if (!scroller) return 0;
147+ const style = getComputedStyle(scroller);
148+ return Math.max(
149+ 0,
150+ scroller.offsetWidth -
151+ scroller.clientWidth -
152+ parseFloat(style.borderLeftWidth) -
153+ parseFloat(style.borderRightWidth),
154+ );
155+}
156+
138157 export const ChatInner = () => {
139158 const { enterIsSend, richTextToolbar, messageRequests } =
140159 useContext(SettingsContext);
......@@ -189,8 +208,13 @@ export const ChatInner = () => {
189208 const scrollTop = useRef<string | null>(null);
190209 const inputRef = useRef<QuillInner>();
191210 const messageListContainer = useRef<HTMLDivElement | null>(null);
192- const virtuosoContainer = useRef<HTMLDivElement | null>(null);
211+ const composerRef = useRef<HTMLDivElement | null>(null);
212+ const [scroller, setScroller] = useState<HTMLElement | null>(null);
213+ const setScrollerRef = useCallback((node: HTMLElement | Window | null) => {
214+ setScroller(node instanceof HTMLElement ? node : null);
215+ }, []);
193216 const messageList = useRef<VirtuosoHandle | null>(null);
217+ const headerHeight = useRef(0);
194218 const {
195219 messages: initialMessages,
196220 members: initialMembers,
......@@ -235,11 +259,10 @@ export const ChatInner = () => {
235259 idx + 1 < messages.length
236260 ? ["readUpToMarker"]
237261 : [];
238- // There is a group less than 5 messages from the same sender and thread not more than 2 minutes long
239262 if (
240263 lastGroup &&
241264 lastGroup !== "readUpToMarker" &&
242- lastGroup.messages.length < 5 &&
265+ lastGroup.messages.length < 10 &&
243266 (message.moderationReason() ||
244267 lastGroup.senderId === message.senderId) &&
245268 lastGroup.threadId === message.threadId &&
......@@ -249,7 +272,8 @@ export const ChatInner = () => {
249272 Math.abs(
250273 new Date(lastGroup.messages[0].timeSent).getTime() -
251274 new Date(message.timeSent).getTime(),
252- ) < 120000
275+ ) <
276+ 10 * 60 * 1000
253277 ) {
254278 return [
255279 ...groups.slice(0, -1),
......@@ -415,7 +439,10 @@ export const ChatInner = () => {
415439 if (!messageList.current) return;
416440
417441 if (hashIndex) {
418- messageList.current.scrollToIndex({ index: hashIndex });
442+ messageList.current.scrollToIndex({
443+ index: hashIndex,
444+ offset: -headerHeight.current,
445+ });
419446 } else if (messageId) {
420447 const chat = activeChat;
421448 const message = await persistence.getMessage(
......@@ -937,7 +964,11 @@ export const ChatInner = () => {
937964 );
938965 if (!typingText) return null;
939966
940- return <TypingIndicator content={typingText} />;
967+ return (
968+ <div as={InputToolbox} className="chat-typing-overlay">
969+ <TypingIndicator content={typingText} />
970+ </div>
971+ );
941972 };
942973
943974 const waitForImagesLoaded = useCallback(() => {
......@@ -1051,37 +1082,61 @@ export const ChatInner = () => {
10511082 setAtBottom(nowAtBottom);
10521083 };
10531084
1054- useEffect(() => {
1055- if (atBottom) {
1056- (async () => {
1057- await waitForImagesLoaded();
1058- setTimeout(() => {
1059- console.log("XYZZY force to bottom", atBottom);
1060- messageList.current?.scrollToIndex({
1061- index: Number.MAX_SAFE_INTEGER,
1062- align: "end",
1063- });
1064- }, 400);
1065- })();
1066- }
1067- }, [messages.length, atBottom, waitForImagesLoaded]);
1068-
1069- useEffect(() => {
1070- const container = virtuosoContainer.current;
1071- if (!container) return;
1072-
1073- const observer = new ResizeObserver(() => {
1074- if (!atBottom) return;
1075-
1085+ const forceToBottom = useCallback(async () => {
1086+ await waitForImagesLoaded();
1087+ setTimeout(() => {
1088+ console.log("XYZZY force to bottom", atBottom);
10761089 messageList.current?.scrollToIndex({
10771090 index: Number.MAX_SAFE_INTEGER,
10781091 align: "end",
10791092 });
1080- });
1081- observer.observe(container);
1093+ }, 400);
1094+ }, [atBottom, waitForImagesLoaded]);
1095+
1096+ useEffect(() => {
1097+ if (atBottom) void forceToBottom();
1098+ }, [messages.length, atBottom, forceToBottom]);
1099+
1100+ const followComposerResize = useEffectEvent((heightChange: number) => {
1101+ if (atBottom && heightChange > 0)
1102+ messageList.current?.scrollBy({ top: heightChange, behavior: "auto" });
1103+ });
1104+
1105+ useLayoutEffect(() => {
1106+ const container = messageListContainer.current?.parentElement;
1107+ const header = container?.querySelector<HTMLElement>(
1108+ ":scope > .cs-conversation-header",
1109+ );
1110+ if (!container || !header) return;
1111+ const composer = composerRef.current;
1112+
1113+ // Keep the message spacer stable when the floating header wraps or resizes.
1114+ if (!headerHeight.current)
1115+ headerHeight.current = header.getBoundingClientRect().height;
1116+ container.style.setProperty(
1117+ "--chat-header-height",
1118+ `${headerHeight.current}px`,
1119+ );
1120+
1121+ const update = () => {
1122+ container.style.setProperty(
1123+ "--chat-scrollbar-width",
1124+ `${measureScrollbarWidth(scroller)}px`,
1125+ );
1126+ const previousHeight = parseFloat(
1127+ container.style.getPropertyValue("--chat-composer-height"),
1128+ );
1129+ const height = composer?.getBoundingClientRect().height ?? 0;
1130+ container.style.setProperty("--chat-composer-height", `${height}px`);
1131+ followComposerResize(height - previousHeight);
1132+ };
1133+ const observer = new ResizeObserver(update);
1134+ if (composer) observer.observe(composer);
1135+ if (scroller) observer.observe(scroller);
1136+ update();
10821137
10831138 return () => observer.disconnect();
1084- }, [atBottom]);
1139+ }, [active, tabIndex, isInvite, scroller, virtuosoGeneration]);
10851140
10861141 const pgUpRef = useHotkeys(
10871142 "PageUp",
......@@ -1318,14 +1373,15 @@ export const ChatInner = () => {
13181373 />
13191374 )}
13201375 <div
1321- ref={virtuosoContainer}
13221376 className="virtuoso-container"
13231377 style={{ display: tabIndex === 0 ? "block" : "none" }}
13241378 >
13251379 <Virtuoso
13261380 aria-label="Chat Messages"
1381+ components={messageListComponents}
13271382 key={virtuosoGeneration}
13281383 ref={messageList}
1384+ scrollerRef={setScrollerRef}
13291385 followOutput={() => atBottom}
13301386 alignToBottom={true}
13311387 startReached={onYReachStart}
......@@ -1431,20 +1487,17 @@ export const ChatInner = () => {
14311487 />
14321488 </div>
14331489 {tabIndex === 0 && (
1434- <>
1435- {getTypingIndicator()}
1436- <Button
1437- title="Jump to bottom"
1438- className={"jump-to-bottom " + (atBottom ? "" : "visible")}
1439- {...{ inert: atBottom ? "" : undefined }}
1440- icon={
1441- <FontAwesomeIcon
1442- icon={faAnglesDown}
1443- onClick={() => jumpToBottom()}
1444- />
1445- }
1446- />
1447- </>
1490+ <Button
1491+ title="Jump to bottom"
1492+ className={"jump-to-bottom " + (atBottom ? "" : "visible")}
1493+ {...{ inert: atBottom ? "" : undefined }}
1494+ icon={
1495+ <FontAwesomeIcon
1496+ icon={faAnglesDown}
1497+ onClick={() => jumpToBottom()}
1498+ />
1499+ }
1500+ />
14481501 )}
14491502 {isInvite && (
14501503 <div className="invite-approve">
......@@ -1498,148 +1551,154 @@ export const ChatInner = () => {
14981551 </div>
14991552
15001553 {tabIndex === 0 && !isInvite && (
1501- <div as={MessageInput} id="message-input-root">
1502- {replyTo && (
1503- <div className="reply">
1504- <span>
1505- Replying to{" "}
1506- <span className="h-card">
1507- {members.get(replyTo.senderId)?.displayName}
1554+ <div as={MessageInput} className="chat-composer" ref={composerRef}>
1555+ {getTypingIndicator()}
1556+ <div id="message-input-root">
1557+ {replyTo && (
1558+ <div className="reply">
1559+ <span>
1560+ Replying to{" "}
1561+ <span className="h-card">
1562+ {members.get(replyTo.senderId)?.displayName}
1563+ </span>
15081564 </span>
1509- </span>
1510- <Button
1511- onClick={() => {
1512- setReplyTo(null);
1513- setSelectedThread(null);
1514- }}
1515- title="Cancel reply"
1516- icon={<FontAwesomeIcon icon={faCircleXmark} />}
1517- />
1518- </div>
1519- )}
1520- {attachmentError && (
1521- <Alert severity="error" onClose={() => setAttachmentError(null)}>
1522- {attachmentError}
1523- </Alert>
1524- )}
1525- {(attachmentProgress || attachments.length > 0) && (
1526- <div className="attachments">
1527- {attachments.map((attachment) => (
1528- <img
1529- crossOrigin="anonymous"
1530- key={attachment.uri}
1531- src={attachment.uri}
1532- alt={attachment.attachment.name ?? undefined}
1533- title="Click to remove"
1534- onClick={() => removeAttachment(attachment)}
1535- />
1536- ))}
1537- {attachmentProgress && <CircularProgress />}
1538- </div>
1539- )}
1540- <div className="cs-message-input" ref={inputHotkeyRef}>
1541- <div className="cs-message-input__tools">
1542- {activeChat.hasCommands() && (
1543- <CommandMenu
1544- chat={activeChat}
1545- addSession={addCommandSession}
1565+ <Button
1566+ onClick={() => {
1567+ setReplyTo(null);
1568+ setSelectedThread(null);
1569+ }}
1570+ title="Cancel reply"
1571+ icon={<FontAwesomeIcon icon={faCircleXmark} />}
15461572 />
1547- )}
1548- {activeChat.canSend() && (
1549- <>
1550- <Button
1551- onClick={() => setSelectedThread(uuidv7())}
1552- onContextMenu={(event) => {
1553- event.preventDefault();
1554- setSelectedThread(null);
1555- }}
1556- title={
1557- currentThread
1558- ? "Thread to send this message to. Click to start a new thread or right-click to clear"
1559- : "Click to start a new thread"
1560- }
1561- icon={
1562- currentThread ? (
1563- <img
1564- src={borogove.Identicon.svg(currentThread ?? "")}
1565- alt="Thread icon"
1566- className="svg-inline--fa"
1567- />
1568- ) : (
1569- <SpoolIcon />
1570- )
1571- }
1573+ </div>
1574+ )}
1575+ {attachmentError && (
1576+ <Alert
1577+ severity="error"
1578+ onClose={() => setAttachmentError(null)}
1579+ >
1580+ {attachmentError}
1581+ </Alert>
1582+ )}
1583+ {(attachmentProgress || attachments.length > 0) && (
1584+ <div className="attachments">
1585+ {attachments.map((attachment) => (
1586+ <img
1587+ crossOrigin="anonymous"
1588+ key={attachment.uri}
1589+ src={attachment.uri}
1590+ alt={attachment.attachment.name ?? undefined}
1591+ title="Click to remove"
1592+ onClick={() => removeAttachment(attachment)}
15721593 />
1573- <AttachmentButton
1574- title="Attach media to message"
1575- onClick={handleAttach}
1594+ ))}
1595+ {attachmentProgress && <CircularProgress />}
1596+ </div>
1597+ )}
1598+ <div className="cs-message-input" ref={inputHotkeyRef}>
1599+ <div className="cs-message-input__tools">
1600+ {activeChat.hasCommands() && (
1601+ <CommandMenu
1602+ chat={activeChat}
1603+ addSession={addCommandSession}
15761604 />
1605+ )}
1606+ {activeChat.canSend() && (
1607+ <>
1608+ <Button
1609+ onClick={() => setSelectedThread(uuidv7())}
1610+ onContextMenu={(event) => {
1611+ event.preventDefault();
1612+ setSelectedThread(null);
1613+ }}
1614+ title={
1615+ currentThread
1616+ ? "Thread to send this message to. Click to start a new thread or right-click to clear"
1617+ : "Click to start a new thread"
1618+ }
1619+ icon={
1620+ currentThread ? (
1621+ <img
1622+ src={borogove.Identicon.svg(currentThread ?? "")}
1623+ alt="Thread icon"
1624+ className="svg-inline--fa"
1625+ />
1626+ ) : (
1627+ <SpoolIcon />
1628+ )
1629+ }
1630+ />
1631+ <AttachmentButton
1632+ title="Attach media to message"
1633+ onClick={handleAttach}
1634+ />
1635+ </>
1636+ )}
1637+ </div>
1638+ {activeChat.canSend() ? (
1639+ <>
1640+ <Quill
1641+ aria-label="Compose message"
1642+ className="cs-message-input__content-editor-wrapper"
1643+ ref={inputRef}
1644+ toolbar={richTextToolbar}
1645+ onTextChange={handleChange}
1646+ triggerRecentEdit={triggerRecentEdit}
1647+ enterIsSend={enterIsSend && handleSend}
1648+ mentionHandler={mentionHandler}
1649+ mentionClose={mentionClose}
1650+ attachFiles={attachFiles}
1651+ placeholder="Send message"
1652+ />
1653+ {!editing && (
1654+ <div className="cs-message-input__tools">
1655+ <SendButton
1656+ title="Send message"
1657+ onClick={handleSend}
1658+ disabled={inputEmpty && attachments.length < 1}
1659+ />
1660+ </div>
1661+ )}
15771662 </>
1663+ ) : (
1664+ activeChat instanceof borogove.Channel && (
1665+ <Button
1666+ style={{ marginLeft: "auto" }}
1667+ border
1668+ onClick={() => {
1669+ activeChat.requestToSend();
1670+ setRequestToSpeakSent(true);
1671+ }}
1672+ disabled={requestToSpeakSent}
1673+ >
1674+ {requestToSpeakSent ? "Request Sent" : "Request to Speak"}
1675+ </Button>
1676+ )
15781677 )}
15791678 </div>
1580- {activeChat.canSend() ? (
1581- <>
1582- <Quill
1583- aria-label="Compose message"
1584- className="cs-message-input__content-editor-wrapper"
1585- ref={inputRef}
1586- toolbar={richTextToolbar}
1587- onTextChange={handleChange}
1588- triggerRecentEdit={triggerRecentEdit}
1589- enterIsSend={enterIsSend && handleSend}
1590- mentionHandler={mentionHandler}
1591- mentionClose={mentionClose}
1592- attachFiles={attachFiles}
1593- placeholder="Send message"
1594- />
1595- {!editing && (
1596- <div className="cs-message-input__tools">
1597- <SendButton
1598- title="Send message"
1599- onClick={handleSend}
1600- disabled={inputEmpty && attachments.length < 1}
1601- />
1602- </div>
1603- )}
1604- </>
1605- ) : (
1606- activeChat instanceof borogove.Channel && (
1679+ {editing && (
1680+ <div className="edit-tools">
1681+ <small>editing</small>
16071682 <Button
1608- style={{ marginLeft: "auto" }}
16091683 border
16101684 onClick={() => {
1611- activeChat.requestToSend();
1612- setRequestToSpeakSent(true);
1685+ setEditing(null);
1686+ inputRef.current?.setText("");
1687+ clearAttachments();
16131688 }}
1614- disabled={requestToSpeakSent}
16151689 >
1616- {requestToSpeakSent ? "Request Sent" : "Request to Speak"}
1690+ Cancel
16171691 </Button>
1618- )
1692+ <Button
1693+ border
1694+ onClick={handleSend}
1695+ disabled={inputEmpty && attachments.length < 1}
1696+ >
1697+ Save
1698+ </Button>
1699+ </div>
16191700 )}
16201701 </div>
1621- {editing && (
1622- <div className="edit-tools">
1623- <small>editing</small>
1624- <Button
1625- border
1626- onClick={() => {
1627- setEditing(null);
1628- inputRef.current?.setText("");
1629- clearAttachments();
1630- }}
1631- >
1632- Cancel
1633- </Button>
1634- <Button
1635- border
1636- onClick={handleSend}
1637- disabled={inputEmpty && attachments.length < 1}
1638- >
1639- Save
1640- </Button>
1641- </div>
1642- )}
16431702 </div>
16441703 )}
16451704 </ChatContainer>
+3 -5 src/components/Chats.tsx #
......@@ -1,4 +1,5 @@
11 import * as borogove from "borogove";
2+import { isTauri } from "@tauri-apps/api/core";
23 import Fuse from "fuse.js";
34 import {
45 Button as MuiButton,
......@@ -503,7 +504,7 @@ export const Chats = () => {
503504 );
504505
505506 return (
506- <MainContainer responsive>
507+ <MainContainer responsive className={isTauri() ? "tauri" : ""}>
507508 <Sidebar
508509 position="left"
509510 scrollable={false}
......@@ -777,10 +778,7 @@ export const Chats = () => {
777778 visible={c.uiState === borogove.UiState.Pinned}
778779 >
779780 <Button
780- style={{
781- opacity:
782- c.uiState === borogove.UiState.Pinned ? 0.9 : 0.5,
783- }}
781+ style={{ opacity: 1 }}
784782 icon={<FontAwesomeIcon icon={faThumbtack} />}
785783 title={
786784 c.uiState === borogove.UiState.Pinned
+3 -4 src/components/CommandMenu.tsx #
......@@ -56,17 +56,16 @@ export const CommandMenu = ({
5656 return (
5757 <>
5858 <Button
59+ aria-label="Menu"
5960 aria-haspopup="menu"
60- border
61+ aria-expanded={!!menu}
6162 icon={<FontAwesomeIcon icon={faBars} />}
6263 onClick={(e) => {
6364 setMenu(e.currentTarget);
6465 setPromise(chat.commands());
6566 setKey(key + 1);
6667 }}
67- >
68- Menu
69- </Button>
68+ />
7069 <Menu
7170 open={!!menu}
7271 anchorEl={menu}
+3 -3 src/components/LoginRequest.tsx #
......@@ -52,7 +52,7 @@ export const LoginRequest = ({
5252 sx={{
5353 transform: "translateX(-50%)",
5454 padding: "1em 4em",
55- borderRadius: "1em",
55+ borderRadius: "var(--border-radius)",
5656 textAlign: "center",
5757 }}
5858 >
......@@ -77,7 +77,7 @@ export const LoginRequest = ({
7777 setLoginRequest(null);
7878 }}
7979 style={{
80- borderRadius: "10em",
80+ borderRadius: "var(--border-radius)",
8181 padding: "0.5em 2em",
8282 }}
8383 >
......@@ -93,7 +93,7 @@ export const LoginRequest = ({
9393 }}
9494 style={{
9595 background: "red",
96- borderRadius: "10em",
96+ borderRadius: "var(--border-radius)",
9797 color: "white",
9898 padding: "0.5em 2em",
9999 }}
+2 -2 src/components/MessageAttachments.tsx #
......@@ -133,7 +133,7 @@ const AttachmentContent = ({
133133 alt={attachment.name || "attachment"}
134134 crossOrigin="anonymous"
135135 src={uri}
136- style={{ height: "15em", objectFit: "scale-down" }}
136+ className="message-attachment-media"
137137 />
138138 </a>
139139 );
......@@ -144,7 +144,7 @@ const AttachmentContent = ({
144144 <video
145145 crossOrigin="anonymous"
146146 src={uri}
147- style={{ height: "15em", objectFit: "scale-down" }}
147+ className="message-attachment-media"
148148 controls
149149 ></video>
150150 );
+0 -1 src/components/MessageBubble.test.tsx #
......@@ -10,7 +10,6 @@ import { MessageBubble } from "./MessageBubble";
1010 afterEach(cleanup);
1111
1212 const html = {
13- reduce: () => [0],
1413 asDOM: () => document.createDocumentFragment(),
1514 toPlainText: () => "",
1615 } as unknown as borogove.Html;
+128 -92 src/components/MessageBubble.tsx #
......@@ -1,5 +1,6 @@
11 import * as borogove from "borogove";
22 import { MessageDebugger } from "./MessageDebugger";
3+import { MessageHeading } from "./MessageHeading";
34 import DOMPurify from "dompurify";
45 import { Button, Message } from "@chatscope/chat-ui-kit-react";
56 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
......@@ -8,6 +9,7 @@ import { useNavigate } from "react-router";
89 import { MessageAttachments } from "./MessageAttachments";
910 import { ReactNode, useRef, useLayoutEffect, useState } from "react";
1011 import hljs from "highlight.js";
12+import { createPortal } from "react-dom";
1113 import { shortDateTimeOnlyToday } from "../util";
1214 import {
1315 Dialog,
......@@ -25,6 +27,29 @@ import {
2527 faPencil,
2628 faReply,
2729 } from "@fortawesome/free-solid-svg-icons";
30+import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
31+
32+const deliveryByStatus = {
33+ [borogove.MessageStatus.MessagePending]: {
34+ icon: faClock,
35+ text: "Sending...",
36+ },
37+ [borogove.MessageStatus.MessageFailedToSend]: {
38+ icon: faCircleExclamation,
39+ text: "Error",
40+ },
41+ [borogove.MessageStatus.MessageDeliveredToServer]: {
42+ icon: faCheck,
43+ text: "Sent",
44+ },
45+ [borogove.MessageStatus.MessageDeliveredToDevice]: {
46+ icon: faCheckDouble,
47+ text: "Received",
48+ },
49+} satisfies Record<
50+ borogove.ChatMessage["status"],
51+ { icon: IconDefinition; text: string }
52+>;
2853
2954 const renderReaction = (reaction: borogove.Reaction) => {
3055 return reaction.render<JSX.Element | string>(
......@@ -97,14 +122,25 @@ const MessageContent = ({
97122 selfName,
98123 sender,
99124 hook,
125+ timestamp,
126+ metadata,
127+ statusCount = 0,
100128 }: {
101129 m: borogove.ChatMessage;
102130 selfName: string;
103131 sender: borogove.Member | undefined;
104132 hook?: (frag: DocumentFragment) => DocumentFragment;
133+ timestamp?: string;
134+ metadata?: ReactNode;
135+ statusCount?: number;
105136 }) => {
106137 const contentRef = useRef<HTMLDivElement | null>(null);
107138 const senderRef = useRef(sender);
139+ const [metadataHost] = useState(() => {
140+ const host = document.createElement("span");
141+ host.className = "message-time";
142+ return host;
143+ });
108144
109145 useLayoutEffect(() => {
110146 if (!contentRef.current) return;
......@@ -113,6 +149,8 @@ const MessageContent = ({
113149 DOMPurify.sanitize(formatMention(html, selfName));
114150 const toInsert = hook ? hook(html) : html;
115151
152+ contentRef.current.classList.remove("message-timed-text");
153+ delete contentRef.current.dataset.time;
116154 contentRef.current.replaceChildren(toInsert);
117155 for (const el of contentRef.current.querySelectorAll<HTMLElement>(
118156 "pre > code",
......@@ -121,10 +159,21 @@ const MessageContent = ({
121159 if (!el.className) el.className = "language-plaintext";
122160 hljs.highlightElement(el);
123161 }
124- }, [m, selfName, hook]);
162+ if (timestamp || statusCount) {
163+ let target = contentRef.current;
164+ while (target.lastElementChild?.matches("div, p, blockquote")) {
165+ target = target.lastElementChild as HTMLDivElement;
166+ }
167+ target.classList.add("message-timed-text");
168+ target.dataset.time = timestamp ?? "";
169+ target.style.setProperty("--message-status-count", String(statusCount));
170+ target.append(metadataHost);
171+ }
172+ }, [m, selfName, hook, timestamp, statusCount, metadataHost]);
125173
126174 return (
127175 <>
176+ {createPortal(metadata, metadataHost)}
128177 {!m.moderationReason() &&
129178 m.encryption?.status !==
130179 borogove.EncryptionStatus.DecryptionFailure && (
......@@ -250,12 +299,6 @@ export const MessageBubble = ({
250299 };
251300
252301 const [showEdits, setShowEdits] = useState(false);
253- const bodyLength = m
254- .body()
255- .reduce((txt, isTag, _, kids: number[] | null) =>
256- isTag ? (kids ?? []).reduce((x, y) => x + y, 0) : txt.length,
257- )
258- .reduce((x, y) => x + y, 0);
259302 const parentMessage = m.replyToMessage;
260303 const reactionEntries = [...(m.reactions.entries() || [])];
261304 const shortDateTimeHuman = shortDateTimeOnlyToday(new Date(m.timeSent));
......@@ -266,14 +309,73 @@ export const MessageBubble = ({
266309 })
267310 .replace(/\s*\b[A-Z]{2,4}$/, ""); // remove trailing TZ abbrev
268311
312+ const delivery = m.isIncoming() ? undefined : deliveryByStatus[m.status];
313+
314+ const timestamp = ["last", "single"].includes(position)
315+ ? shortDateTimeHuman
316+ : undefined;
317+ const inlineTime =
318+ !m.attachments.length &&
319+ !m.linkMetadata.length &&
320+ !m.moderationReason() &&
321+ m.encryption?.status !== borogove.EncryptionStatus.DecryptionFailure;
269322 const sender = members.get(m.senderId);
323+ const subject = m.subject();
270324 const showSender =
271325 m.senderId !== chat.chatId &&
272- ["last", "single"].includes(position) &&
326+ ["first", "single"].includes(position) &&
273327 !m.moderationReason() &&
274328 m.isIncoming();
275329 const mention = sender && onMention ? () => onMention(sender) : undefined;
276330
331+ const encrypted =
332+ m.encryption?.status === borogove.EncryptionStatus.EncryptionInfoSuccess;
333+ const statusCount =
334+ Number(m.versions.length > 0) +
335+ Number(!!delivery) +
336+ Number(!!m.threadId) +
337+ Number(encrypted);
338+ const metadata = (timestamp || statusCount > 0) && (
339+ <>
340+ {timestamp && <time dateTime={m.timeSent}>{timestamp}</time>}
341+ {m.versions.length > 0 && (
342+ <button
343+ type="button"
344+ className="message-badge"
345+ title={"Edited " + (m.versions.length - 1) + " times"}
346+ onClick={() => setShowEdits(true)}
347+ >
348+ <FontAwesomeIcon icon={faPencil} />
349+ </button>
350+ )}
351+ {delivery && (
352+ <span className="message-badge">
353+ <FontAwesomeIcon
354+ icon={delivery.icon}
355+ title={m.statusText ?? delivery.text}
356+ />
357+ </span>
358+ )}
359+ {m.threadId && (
360+ <span className="message-badge">
361+ <img
362+ src={m.threadIcon() ?? undefined}
363+ alt={"thread " + m.threadId.substring(0, 5)}
364+ className="thread"
365+ />
366+ </span>
367+ )}
368+ {encrypted && (
369+ <span className="message-badge">
370+ <FontAwesomeIcon
371+ icon={faLock}
372+ title={m.encryption!.methodName ?? m.encryption!.method}
373+ />
374+ </span>
375+ )}
376+ </>
377+ );
378+
277379 return (
278380 <Message
279381 model={{
......@@ -285,17 +387,20 @@ export const MessageBubble = ({
285387 data-server-id={m.serverId}
286388 data-local-id={m.localId}
287389 className={
288- (bodyLength < 25 && !m.replyToMessage ? "small " : "") +
289- (m.type === borogove.MessageType.MessageChannelPrivate
290- ? "invite"
291- : "") +
292- " " +
293- className
390+ m.type === borogove.MessageType.MessageChannelPrivate
391+ ? `invite ${className ?? ""}`
392+ : className
294393 }
295394 >
296395 {children}
297396 <Message.CustomContent>
298397 <div title={fullDateTimeHuman}>
398+ <MessageHeading
399+ sender={sender}
400+ showSender={showSender}
401+ subject={subject}
402+ mention={mention}
403+ />
299404 <MessageDebugger m={m} />
300405 {parentMessage && (
301406 <>
......@@ -327,88 +432,19 @@ export const MessageBubble = ({
327432 m={m}
328433 selfName={client.displayName()}
329434 sender={sender}
435+ timestamp={inlineTime ? timestamp : undefined}
436+ statusCount={inlineTime ? statusCount : 0}
437+ metadata={metadata}
330438 />
331439 {m.attachments.length > 0 && (
332440 <MessageAttachments client={client} chat={chat} message={m} />
333441 )}
334442 {m.linkMetadata.map((meta) => linkMeta(meta))}
335- <div className="meta">
336- <div
337- className={
338- (showSender ? "" : "sr-only") +
339- " h-card sender " +
340- (mention ? "clickable" : "")
341- }
342- onClick={mention}
343- >
344- {sender?.displayName}
443+ {!inlineTime && metadata && (
444+ <div className="message-time-row">
445+ <span className="message-time">{metadata}</span>
345446 </div>
346-
347- <div>
348- {m.subject() && (
349- <>
350- <strong>{m.subject()}</strong>{" "}
351- </>
352- )}
353- {m.timeSent && ["last", "single"].includes(position) && (
354- <time dateTime={m.timeSent} title={fullDateTimeHuman}>
355- {shortDateTimeHuman}
356- </time>
357- )}
358- {m.versions.length > 0 && (
359- <FontAwesomeIcon
360- icon={faPencil}
361- title={"Edited " + (m.versions.length - 1) + " times"}
362- onClick={() => setShowEdits(true)}
363- />
364- )}
365- {m.threadId && (
366- <img
367- src={m.threadIcon() ?? undefined}
368- alt={"thread " + m.threadId.substring(0, 5)}
369- className="thread"
370- />
371- )}
372- {m.encryption &&
373- m.encryption?.status ===
374- borogove.EncryptionStatus.EncryptionInfoSuccess && (
375- <FontAwesomeIcon
376- icon={faLock}
377- title={m.encryption.methodName ?? m.encryption.method}
378- />
379- )}
380- {!m.isIncoming() &&
381- m.status === borogove.MessageStatus.MessagePending && (
382- <FontAwesomeIcon
383- icon={faClock}
384- title={m.statusText ?? "Sending..."}
385- />
386- )}
387- {!m.isIncoming() &&
388- m.status === borogove.MessageStatus.MessageFailedToSend && (
389- <FontAwesomeIcon
390- icon={faCircleExclamation}
391- title={m.statusText ?? "Error"}
392- />
393- )}
394- {!m.isIncoming() &&
395- m.status ===
396- borogove.MessageStatus.MessageDeliveredToServer && (
397- <FontAwesomeIcon
398- icon={faCheck}
399- title={m.statusText ?? "Sent"}
400- />
401- )}
402- {!m.isIncoming() &&
403- m.status ===
404- borogove.MessageStatus.MessageDeliveredToDevice && (
405- <FontAwesomeIcon
406- icon={faCheckDouble}
407- title={m.statusText ?? "Received"}
408- />
409- )}
410- </div>
411- </div>
447+ )}
412448 </div>
413449 <EditHistory
414450 open={showEdits}
......@@ -422,7 +458,6 @@ export const MessageBubble = ({
422458 <Message.Footer className="reactions">
423459 {reactionEntries.map(([key, reactions]) => (
424460 <Button
425- border
426461 onClick={() =>
427462 toggleReaction(
428463 m,
......@@ -445,7 +480,8 @@ export const MessageBubble = ({
445480 )
446481 .join("\n")}
447482 >
448- {renderReaction(reactions[0])} {" " + reactions.length}
483+ <span>{renderReaction(reactions[0])}</span>
484+ {reactions.length > 1 && " " + reactions.length}
449485 </Button>
450486 ))}
451487 </Message.Footer>
+91 -0 src/components/MessageHeading.test.tsx #
......@@ -0,0 +1,91 @@
1+// @vitest-environment jsdom
2+
3+import { cleanup, fireEvent, render, within } from "@testing-library/react";
4+import type { Member } from "borogove";
5+import type { ComponentProps } from "react";
6+import { afterEach, expect, it, vi } from "vitest";
7+import { mock } from "vitest-mock-extended";
8+import { MessageHeading } from "./MessageHeading";
9+
10+afterEach(cleanup);
11+
12+const sender = mock<Member>({ displayName: "Alice" });
13+
14+function renderHeading(props: Partial<ComponentProps<typeof MessageHeading>>) {
15+ return render(
16+ <MessageHeading
17+ sender={sender}
18+ showSender
19+ subject={null}
20+ mention={undefined}
21+ {...props}
22+ />,
23+ );
24+}
25+
26+it("renders nothing without a sender or subject", () => {
27+ const { container } = renderHeading({
28+ sender: undefined,
29+ subject: null,
30+ });
31+
32+ expect(container.textContent).toBe("");
33+});
34+
35+it("renders the subject without a sender", () => {
36+ const { container } = renderHeading({
37+ sender: undefined,
38+ subject: "Project updates",
39+ });
40+
41+ expect(container.textContent).toBe("Project updates");
42+});
43+
44+it("shows the sender name on its own when there is no subject", () => {
45+ const { container } = renderHeading({
46+ sender,
47+ showSender: true,
48+ subject: null,
49+ });
50+
51+ expect(container.textContent).toBe("Alice");
52+});
53+
54+it("appends the subject after a separator", () => {
55+ const { container } = renderHeading({
56+ sender,
57+ showSender: true,
58+ subject: "Project updates",
59+ });
60+
61+ expect(container.textContent).toBe("Alice · Project updates");
62+});
63+
64+it("keeps the hidden sender name available to screen readers", () => {
65+ const { container } = renderHeading({
66+ sender,
67+ showSender: false,
68+ });
69+
70+ expect(container.querySelector(".sr-only")?.textContent).toBe("Alice");
71+});
72+
73+it("renders the subject without a separator when the sender is hidden", () => {
74+ const { container } = renderHeading({
75+ sender,
76+ showSender: false,
77+ subject: "Project updates",
78+ });
79+
80+ expect(container.textContent).toContain("Project updates");
81+ expect(container.querySelector(".subject-separator")).toBeNull();
82+});
83+
84+it("calls the mention handler when the sender name is clicked", () => {
85+ const mention = vi.fn();
86+ const { container } = renderHeading({ sender, showSender: true, mention });
87+
88+ fireEvent.click(within(container).getByText("Alice"));
89+
90+ expect(mention).toHaveBeenCalledOnce();
91+});
+60 -0 src/components/MessageHeading.tsx #
......@@ -0,0 +1,60 @@
1+import type { Member } from "borogove";
2+import type { ReactElement } from "react";
3+
4+type MessageHeadingProps = {
5+ sender: Member | undefined;
6+ showSender: boolean;
7+ subject: string | null;
8+ mention: (() => void) | undefined;
9+};
10+
11+export function MessageHeading({
12+ sender,
13+ showSender,
14+ subject,
15+ mention,
16+}: MessageHeadingProps) {
17+ const senderName = makeSenderName({ sender, showSender, mention });
18+ const showSeparator = senderName.visible && subject;
19+
20+ return (
21+ <div className="message-heading">
22+ {senderName.el}
23+ {showSeparator && <span className="subject-separator">{" · "}</span>}
24+ {subject}
25+ </div>
26+ );
27+}
28+
29+function makeSenderName({
30+ sender,
31+ showSender,
32+ mention,
33+}: Pick<MessageHeadingProps, "sender" | "showSender" | "mention">): {
34+ el: ReactElement | null;
35+ visible: boolean;
36+} {
37+ if (!sender)
38+ return {
39+ el: null,
40+ visible: false,
41+ };
42+
43+ if (!showSender)
44+ return {
45+ el: <span className="sr-only sender">{sender.displayName}</span>,
46+ visible: false,
47+ };
48+
49+ return {
50+ el: (
51+ <span
52+ className={mention ? "h-card sender clickable" : "h-card sender"}
53+ onClick={mention}
54+ >
55+ {sender.displayName}
56+ </span>
57+ ),
58+ visible: true,
59+ };
60+}
+24 -0 src/components/Page.tsx #
......@@ -0,0 +1,24 @@
1+import { ArrowButton, MainContainer } from "@chatscope/chat-ui-kit-react";
2+import { isTauri } from "@tauri-apps/api/core";
3+import type { ReactNode } from "react";
4+import { useNavigate } from "react-router";
5+
6+export const Page = ({ children }: { children: ReactNode }) => {
7+ const navigate = useNavigate();
8+ return (
9+ <MainContainer className={isTauri() ? "page tauri" : "page"}>
10+ <section>
11+ <ArrowButton
12+ className="page-back"
13+ direction="left"
14+ aria-label="Back"
15+ onClick={() => {
16+ if (window.history.state?.idx > 0) navigate(-1);
17+ else navigate("/");
18+ }}
19+ />
20+ {children}
21+ </section>
22+ </MainContainer>
23+ );
24+};
+21 -2 src/components/Settings.tsx #
......@@ -1,3 +1,11 @@
1+import {
2+ defaultCustomPalette,
3+ defaultTheme,
4+ type Palette,
5+ type Theme,
6+} from "../theme";
7+import { AppearanceSettings } from "./AppearanceSettings";
8+import { Page } from "./Page";
19 import * as borogove from "borogove";
210 import { createContext, useContext } from "react";
311 import { useOutletContext } from "react-router";
......@@ -12,6 +20,9 @@ import {
1220 } from "@mui/material";
1321
1422 export type SettingsData = {
23+ theme: Theme;
24+ customPalette: Palette;
25+ appearance: "system" | "light" | "dark";
1526 enterIsSend: boolean;
1627 richTextToolbar: boolean;
1728 audibleNotifications: boolean;
......@@ -19,6 +30,9 @@ export type SettingsData = {
1930 e2ee: "none" | "pfs";
2031 };
2132 export const SettingsContext = createContext<SettingsData>({
33+ theme: defaultTheme,
34+ customPalette: defaultCustomPalette,
35+ appearance: "system",
2236 enterIsSend: true,
2337 richTextToolbar: false,
2438 audibleNotifications: false,
......@@ -41,7 +55,7 @@ export const Settings = () => {
4155 } = settings;
4256
4357 return (
44- <section>
58+ <Page>
4559 <h1>Settings</h1>
4660
4761 <FormGroup>
......@@ -154,6 +168,11 @@ export const Settings = () => {
154168 </RadioGroup>
155169 </FormControl>
156170 </FormGroup>
157- </section>
171+ <AppearanceSettings
172+ settings={settings}
173+ setSettings={setSettings}
174+ persistence={persistence}
175+ />
176+ </Page>
158177 );
159178 };
+45 -11 src/index.tsx #
......@@ -1,4 +1,5 @@
11 import { StrictMode } from "react";
2+import { isTauri } from "@tauri-apps/api/core";
23 import { readyServiceWorker, serviceWorker } from "./util";
34 import ReactDOM from "react-dom/client";
45 import { About } from "./components/About";
......@@ -26,21 +27,54 @@ import "~build/console";
2627 window.libsignal = libsignal;
2728
2829 const muiTheme = createTheme({
29- cssVariables: { nativeColor: true },
30- palette: {
31- primary: {
32- main: "var(--color-primary-dark)",
33- },
34- secondary: {
35- main: "var(--color-secondary-dark)",
36- },
37- },
30+ cssVariables: { nativeColor: true, colorSchemeSelector: "data-theme" },
31+ shape: { borderRadius: 6 },
32+ components: { MuiIconButton: { defaultProps: { color: "primary" } } },
33+ colorSchemes: Object.fromEntries(
34+ ["light", "dark"].map((mode) => [
35+ mode,
36+ {
37+ palette: {
38+ primary: {
39+ main: "var(--theme-primary)",
40+ contrastText: "var(--theme-on-primary)",
41+ },
42+ secondary: {
43+ main: "var(--theme-secondary)",
44+ contrastText: "var(--theme-on-secondary)",
45+ },
46+ background: {
47+ default: "var(--default-bg-color)",
48+ paper: "var(--paper-background)",
49+ },
50+ text: {
51+ primary: "var(--color-text)",
52+ secondary: "var(--color-text-medium)",
53+ disabled: "var(--color-text-disabled)",
54+ },
55+ divider: "var(--divider-color)",
56+ action: {
57+ hover: "var(--color-bg-hover)",
58+ selected: "var(--color-bg-focus)",
59+ focus: "var(--color-bg-focus)",
60+ disabled: "var(--color-text-disabled)",
61+ },
62+ },
63+ },
64+ ]),
65+ ),
3866 });
3967
40-const root = ReactDOM.createRoot(document.getElementById("root")!);
68+const overlayTitlebar = isTauri() && navigator.platform.startsWith("Mac");
69+const rootElement = document.getElementById("root")!;
70+rootElement.classList.toggle("tauri-overlay", overlayTitlebar);
71+const root = ReactDOM.createRoot(rootElement);
4172 root.render(
4273 <StrictMode>
43- <MuiThemeProvider theme={muiTheme}>
74+ {overlayTitlebar && (
75+ <div className="tauri-titlebar" data-tauri-drag-region />
76+ )}
77+ <MuiThemeProvider theme={muiTheme} storageManager={null}>
4478 <ConfirmDialog />
4579 <div
4680 id="chat-messages-aria-live"
+89 -0 src/theme.test.ts #
......@@ -0,0 +1,89 @@
1+import { describe, expect, it } from "vitest";
2+import { contrast, defaultTheme, themePresets, themeVariables } from "./theme";
3+
4+describe("theme presets", () => {
5+ it("preserves the default Cheogram overrides", () => {
6+ const vars = themeVariables(themePresets[defaultTheme]);
7+ expect(vars["--theme-light-accent-surface"]).toBe("#f3daff");
8+ expect(vars["--theme-light-outgoing-background"]).toBe("#f3daff");
9+ expect(vars["--theme-light-outgoing-color"]).toBe("#27123a");
10+ expect(vars["--theme-dark-outgoing-background"]).toBe(
11+ themePresets[defaultTheme].dark.primary,
12+ );
13+ expect(
14+ contrast(vars["--theme-light-link"], "#f3daff"),
15+ ).toBeGreaterThanOrEqual(4.5);
16+ });
17+
18+ it("uses the original Classic bubble colours", () => {
19+ const vars = themeVariables(themePresets.classic);
20+ expect(vars["--theme-light-incoming-background"]).toBe("#d6b0f3");
21+ expect(vars["--theme-light-outgoing-background"]).toBe("#f5e9bc");
22+ expect(vars["--theme-dark-outgoing-background"]).toBe(
23+ vars["--theme-dark-secondary-surface"],
24+ );
25+ expect(
26+ contrast(vars["--theme-light-link"], "#d6b0f3"),
27+ ).toBeGreaterThanOrEqual(4.5);
28+ });
29+
30+ for (const [preset, palette] of Object.entries(themePresets)) {
31+ it(`keeps ${preset} text and accent foregrounds readable`, () => {
32+ const vars = themeVariables(palette);
33+ for (const mode of ["light", "dark"] as const) {
34+ const colours = palette[mode];
35+ const incoming = vars[`--theme-${mode}-incoming-background`];
36+ const accent = vars[`--theme-${mode}-accent-surface`];
37+ for (const surface of [incoming, accent]) {
38+ if (surface === "initial") continue;
39+ expect(contrast(colours.text, surface)).toBeGreaterThanOrEqual(4.5);
40+ expect(
41+ contrast(vars[`--theme-${mode}-link`], surface),
42+ ).toBeGreaterThanOrEqual(4.5);
43+ }
44+ expect(
45+ contrast(
46+ vars[`--theme-${mode}-outgoing-color`],
47+ vars[`--theme-${mode}-outgoing-background`],
48+ ),
49+ ).toBeGreaterThanOrEqual(4.5);
50+ expect(
51+ contrast(colours.text, colours.background),
52+ ).toBeGreaterThanOrEqual(4.5);
53+ expect(
54+ contrast(vars[`--theme-${mode}-link`], colours.background),
55+ ).toBeGreaterThanOrEqual(4.5);
56+ for (const role of ["primary", "secondary"] as const)
57+ expect(
58+ contrast(colours[role], vars[`--theme-${mode}-on-${role}`]),
59+ ).toBeGreaterThanOrEqual(4.5);
60+ }
61+ });
62+ }
63+
64+ const base = themePresets[defaultTheme];
65+ for (const primary of [
66+ "#ffffff",
67+ "#000000",
68+ "#ffff00",
69+ "#00ff00",
70+ "#ff0000",
71+ "#0000ff",
72+ "#777777",
73+ ]) {
74+ it(`keeps accent text readable with ${primary}`, () => {
75+ const vars = themeVariables({
76+ light: { ...base.light, primary },
77+ dark: { ...base.dark, primary },
78+ });
79+ for (const mode of ["light", "dark"] as const) {
80+ expect(
81+ contrast(primary, vars[`--theme-${mode}-on-primary`]),
82+ ).toBeGreaterThanOrEqual(4.5);
83+ expect(
84+ contrast(vars[`--theme-${mode}-link`], base[mode].background),
85+ ).toBeGreaterThanOrEqual(4.5);
86+ }
87+ });
88+ }
89+});
+252 -0 src/theme.ts #
......@@ -0,0 +1,252 @@
1+export type Palette = {
2+ background: string;
3+ text: string;
4+ primary: string;
5+ secondary: string;
6+};
7+
8+type PresetPalette = Palette & {
9+ accentSurface?: string;
10+ incomingBackground?: string;
11+ outgoingBackground?: string;
12+ outgoingColor?: string;
13+};
14+
15+const cheogramDark: Palette = {
16+ background: "#191919",
17+ text: "#f1f1f1",
18+ primary: "#7401cf",
19+ secondary: "#ffc700",
20+};
21+
22+export const themePresets = {
23+ cheogram: {
24+ name: "Cheogram",
25+ light: {
26+ background: "#f7f5f0",
27+ text: "#212121",
28+ primary: "#7401cf",
29+ secondary: "#ffc700",
30+ accentSurface: "#f3daff",
31+ outgoingBackground: "#f3daff",
32+ outgoingColor: "#27123a",
33+ },
34+ dark: cheogramDark,
35+ },
36+ classic: {
37+ name: "Cheogram Classic",
38+ light: {
39+ background: "#ffffff",
40+ text: "#212121",
41+ primary: "#7401cf",
42+ secondary: "#ffc700",
43+ incomingBackground: "#d6b0f3",
44+ outgoingBackground: "#f5e9bc",
45+ outgoingColor: "#212121",
46+ },
47+ dark: {
48+ ...cheogramDark,
49+ incomingBackground: "#3c2951",
50+ outgoingBackground: "secondarySurface",
51+ },
52+ },
53+ velvet: {
54+ name: "Velvet",
55+ light: {
56+ background: "#eff1f5",
57+ text: "#4c4f69",
58+ primary: "#8839ef",
59+ secondary: "#df8e1d",
60+ accentSurface: "#ccd0da",
61+ incomingBackground: "#e6e9ef",
62+ outgoingBackground: "#e3d5f5",
63+ outgoingColor: "#4c4f69",
64+ },
65+ dark: {
66+ background: "#1e1e2e",
67+ text: "#cdd6f4",
68+ primary: "#a779d6",
69+ secondary: "#f9e2af",
70+ accentSurface: "#45475a",
71+ incomingBackground: "#313244",
72+ outgoingBackground: "#45365e",
73+ outgoingColor: "#cdd6f4",
74+ },
75+ },
76+ plum: {
77+ name: "Plum",
78+ light: {
79+ background: "#faf4ed",
80+ text: "#464261",
81+ primary: "#826b9b",
82+ secondary: "#d7827e",
83+ accentSurface: "#dfdad9",
84+ incomingBackground: "#f2e9e1",
85+ outgoingBackground: "#ece2f1",
86+ outgoingColor: "#464261",
87+ },
88+ dark: {
89+ background: "#191724",
90+ text: "#e0def4",
91+ primary: "#744c9b",
92+ secondary: "#f6c177",
93+ accentSurface: "#403d52",
94+ incomingBackground: "#26233a",
95+ outgoingBackground: "#40314c",
96+ outgoingColor: "#e0def4",
97+ },
98+ },
99+ solarized: {
100+ name: "Solarized",
101+ light: {
102+ background: "#fdf6e3",
103+ text: "#51666d",
104+ primary: "#268bd2",
105+ secondary: "#b58900",
106+ accentSurface: "#eee8d5",
107+ incomingBackground: "#eee8d5",
108+ outgoingBackground: "#d9ebee",
109+ outgoingColor: "#51666d",
110+ },
111+ dark: {
112+ background: "#002b36",
113+ text: "#93a1a1",
114+ primary: "#268bd2",
115+ secondary: "#b58900",
116+ accentSurface: "#073642",
117+ incomingBackground: "#073642",
118+ outgoingBackground: "#164654",
119+ outgoingColor: "#eee8d5",
120+ },
121+ },
122+ hotdogstand: {
123+ name: "Hot Dog Stand",
124+ light: {
125+ background: "#fec701",
126+ text: "#561029",
127+ primary: "#b51b00",
128+ secondary: "#5a1c00",
129+ },
130+ dark: {
131+ background: "#b51b00",
132+ text: "#fff2cf",
133+ primary: "#fec701",
134+ secondary: "#5a1c00",
135+ },
136+ },
137+};
138+
139+export type Theme = keyof typeof themePresets | "custom";
140+export const defaultTheme = "cheogram";
141+export const defaultCustomPalette: Palette = {
142+ background: themePresets.cheogram.light.background,
143+ text: themePresets.cheogram.light.text,
144+ primary: themePresets.cheogram.light.primary,
145+ secondary: themePresets.cheogram.light.secondary,
146+};
147+
148+const channels = (hex: string) =>
149+ [1, 3, 5].map((offset) => parseInt(hex.slice(offset, offset + 2), 16));
150+
151+function mix(color: string, background: string, weight: number) {
152+ const base = channels(background);
153+ return (
154+ "#" +
155+ channels(color)
156+ .map((channel, i) =>
157+ Math.round(channel * weight + base[i] * (1 - weight))
158+ .toString(16)
159+ .padStart(2, "0"),
160+ )
161+ .join("")
162+ );
163+}
164+
165+// https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html#dfn-relative-luminance
166+function luminance(color: string) {
167+ return channels(color).reduce((sum, channel, i) => {
168+ const value = channel / 255;
169+ return (
170+ sum +
171+ (value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4) *
172+ [0.2126, 0.7152, 0.0722][i]
173+ );
174+ }, 0);
175+}
176+
177+export function contrast(a: string, b: string) {
178+ const values = [luminance(a), luminance(b)].sort((x, y) => y - x);
179+ return (values[0] + 0.05) / (values[1] + 0.05);
180+}
181+
182+function foreground(background: string) {
183+ return contrast(background, "#ffffff") > contrast(background, "#000000")
184+ ? "#ffffff"
185+ : "#000000";
186+}
187+
188+export function themeVariables(theme: {
189+ light: PresetPalette;
190+ dark: PresetPalette;
191+}) {
192+ const variables: Record<string, string> = {};
193+ for (const mode of ["light", "dark"] as const) {
194+ const {
195+ background,
196+ text,
197+ primary,
198+ secondary,
199+ accentSurface,
200+ incomingBackground,
201+ } = theme[mode];
202+ const secondarySurface = mix(secondary, background, 0.3);
203+ const outgoingBackground =
204+ theme[mode].outgoingBackground === "secondarySurface"
205+ ? secondarySurface
206+ : (theme[mode].outgoingBackground ?? primary);
207+ const outgoingColor =
208+ theme[mode].outgoingColor ?? foreground(outgoingBackground);
209+ const backgrounds = [
210+ background,
211+ incomingBackground ?? mix(text, background, 0.07),
212+ accentSurface ?? mix(primary, background, 0.13),
213+ accentSurface ?? mix(primary, background, 0.24),
214+ secondarySurface,
215+ ];
216+ const target = foreground(background);
217+ let link = primary;
218+ for (
219+ let step = 1;
220+ backgrounds.some((bg) => contrast(link, bg) < 4.5) && step <= 100;
221+ step++
222+ )
223+ link = mix(primary, target, 1 - step / 100);
224+ const colours = {
225+ background,
226+ text,
227+ primary,
228+ secondary,
229+ "secondary-surface": secondarySurface,
230+ "accent-surface": accentSurface ?? "initial",
231+ "incoming-background": incomingBackground ?? "initial",
232+ "outgoing-background": outgoingBackground,
233+ "outgoing-color": outgoingColor,
234+ "on-primary": foreground(primary),
235+ "on-secondary": foreground(secondary),
236+ "on-app": foreground(primary),
237+ link,
238+ };
239+ for (const [role, colour] of Object.entries(colours))
240+ variables[`--theme-${mode}-${role}`] = colour;
241+ }
242+ return variables;
243+}
244+
245+export function applyTheme(theme: Theme, customPalette: Palette) {
246+ const palettes =
247+ theme === "custom"
248+ ? { light: customPalette, dark: customPalette }
249+ : themePresets[theme];
250+ for (const [name, colour] of Object.entries(themeVariables(palettes)))
251+ document.documentElement.style.setProperty(name, colour);
252+}
Back to top