Skip to content

Commit 03232c9

Browse files
committed
Add contrast toggle transaction action
Add contrast toggle that swaps messagebody background between light and dark theme colors for improved readability of emails with inline styles that clash with the current theme. The contrast toggle is only added for create, reply, and comment transactions.
1 parent 0901997 commit 03232c9

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

etc/RT_Config.pm.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,6 +2428,7 @@ Set(
24282428
'gear-fill' => '<path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"/>',
24292429
'info' => '<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/><path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/>',
24302430
'key' => '<path d="M0 8a4 4 0 0 1 7.465-2H14a.5.5 0 0 1 .354.146l1.5 1.5a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0L13 9.207l-.646.647a.5.5 0 0 1-.708 0L11 9.207l-.646.647a.5.5 0 0 1-.708 0L9 9.207l-.646.647A.5.5 0 0 1 8 10h-.535A4 4 0 0 1 0 8m4-3a3 3 0 1 0 2.712 4.285A.5.5 0 0 1 7.163 9h.63l.853-.854a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.793-.793-1-1h-6.63a.5.5 0 0 1-.451-.285A3 3 0 0 0 4 5"/><path d="M4 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/>',
2431+
'circle-half' => '<path d="M8 15A7 7 0 1 0 8 1zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16"/>',
24312432
'left' => '<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"/>',
24322433
'link' => '<path d="M6.354 5.5H4a3 3 0 0 0 0 6h3a3 3 0 0 0 2.83-4H9q-.13 0-.25.031A2 2 0 0 1 7 10.5H4a2 2 0 1 1 0-4h1.535c.218-.376.495-.714.82-1z"/><path d="M9 5.5a3 3 0 0 0-2.83 4h1.098A2 2 0 0 1 9 6.5h3a2 2 0 1 1 0 4h-1.535a4 4 0 0 1-.82 1H12a3 3 0 1 0 0-6z"/>',
24332434
'link-45deg' => '<path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1.002 1.002 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4.018 4.018 0 0 1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243L6.586 4.672z"/>',

share/html/Elements/ShowTransaction

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
%# END BPS TAGGED BLOCK }}}
4848
<div class="<% join ' ', @classes %>" data-transaction-id="<% $Transaction->id %>">
4949
<div class="metadata">
50-
% if ( @action_icons ) {
50+
% if ( $toggle_contrast || @action_icons ) {
5151
<span class="actions">
52+
% if ( $toggle_contrast ) {
53+
<span class="rt-inline-icon border rounded"><% $toggle_contrast |n %></span>
54+
% if ( @action_icons ) {
55+
<span class="vr"></span>
56+
% }
57+
% }
5258
% for my $action ( @action_icons ) {
5359
<span class="rt-inline-icon border rounded"><% $action |n %></span>
5460
% }
@@ -343,6 +349,14 @@ elsif ( %$Attachments && $ShowActions ) {
343349
}
344350
}
345351

352+
# Toggle contrast icon for message transactions with a messagebody
353+
my $toggle_contrast;
354+
if ( %$Attachments && $ShowBody && $txn_type =~ /^(?:Create|Correspond|Comment)$/ ) {
355+
$toggle_contrast = '<a href="#" class="toggle-contrast-link">'
356+
. GetSVGImage( Name => 'circle-half', Title => loc('Toggle contrast') )
357+
. '</a>';
358+
}
359+
346360
my $CreatorObj = $Transaction->CreatorObj;
347361

348362
$m->callback(

share/static/css/elevator/history.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ div.history-container {
2222
padding: 0.25em;
2323
}
2424

25+
.history .transaction .actions .vr {
26+
align-self: center;
27+
min-height: 0;
28+
height: 1.5em;
29+
opacity: 0.5;
30+
}
31+
32+
.history .transaction .actions .rt-inline-icon.active {
33+
border-color: var(--bs-primary) !important;
34+
}
35+
2536
.history .transaction div.metadata span.type {
2637
text-align: center;
2738
float: left;
@@ -405,6 +416,40 @@ div.history-container {
405416
}
406417
}
407418

419+
/* Toggle contrast: swap to the opposite theme's colors for readable email content */
420+
421+
/* In dark mode, toggle to light theme colors */
422+
[data-bs-theme=dark] .history .transaction .messagebody.toggle-contrast {
423+
background-color: var(--bs-light);
424+
color: var(--bs-dark);
425+
border-radius: 0.25em;
426+
border-top-color: transparent;
427+
}
428+
429+
[data-bs-theme=dark] .history .transaction .messagebody.toggle-contrast a {
430+
color: var(--bs-primary);
431+
}
432+
433+
[data-bs-theme=dark] .history .transaction .messagebody.toggle-contrast a:visited {
434+
color: var(--bs-indigo);
435+
}
436+
437+
/* In light mode, toggle to dark theme colors */
438+
[data-bs-theme=light] .history .transaction .messagebody.toggle-contrast {
439+
background-color: var(--bs-dark);
440+
color: var(--bs-light);
441+
border-radius: 0.25em;
442+
border-top-color: transparent;
443+
}
444+
445+
[data-bs-theme=light] .history .transaction .messagebody.toggle-contrast a {
446+
color: var(--bs-info);
447+
}
448+
449+
[data-bs-theme=light] .history .transaction .messagebody.toggle-contrast a:visited {
450+
color: var(--bs-purple);
451+
}
452+
408453
/* Transaction filter dropdown styles */
409454
.transaction-filter-dropdown {
410455
width: fit-content;

share/static/js/init.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,13 @@ jQuery(document).on('click', '.toggle-txn-details', function (e) {
11371137
return toggleTransactionDetails.apply(this);
11381138
});
11391139

1140+
jQuery(document).on('click', '.toggle-contrast-link', function (e) {
1141+
e.preventDefault();
1142+
jQuery(this).closest('.rt-inline-icon').toggleClass('active');
1143+
var txn = jQuery(this).closest('.transaction');
1144+
txn.find('.messagebody').toggleClass('toggle-contrast');
1145+
});
1146+
11401147
jQuery(document).on('change', '.article-basics [name="Type"]', function () {
11411148
if (jQuery(this).val() == 'Content') {
11421149
jQuery('#article-type-links').addClass('hidden');

0 commit comments

Comments
 (0)