Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

rendered_markdown: Underline links and update their colors.

sandeep62da4137fb8b
diff --git a/web/styles/app_variables.css b/web/styles/app_variables.css
index 31f7db890a8..d7f2f42733c 100644
--- a/web/styles/app_variables.css
+++ b/web/styles/app_variables.css
@@ -1914,19 +1914,42 @@
--color-text-search-highlight: light-dark(currentcolor, hsl(0deg 0% 0%));
--color-text-alert-word: light-dark(currentcolor, hsl(0deg 0% 0%));
--color-markdown-link: light-dark(
- hsl(200deg 100% 40%),
- var(--color-text-generic-link)
+ hsl(200deg 100% 36%),
+ hsl(200deg 100% 50%)
+ );
+ --color-markdown-link-decoration: color-mix(
+ in oklch,
+ var(--color-markdown-link) 30%,
+ transparent
);
--color-markdown-code-link: var(--color-markdown-link);
--color-markdown-link-hover: light-dark(
- hsl(200deg 100% 25%),
- var(--color-text-generic-link-interactive)
+ hsl(200deg 100% 33%),
+ hsl(200deg 100% 66%)
+ );
+ --color-markdown-link-decoration-hover: color-mix(
+ in oklch,
+ var(--color-markdown-link-hover) 70%,
+ transparent
);
--color-markdown-code-link-hover: var(--color-markdown-link-hover);
+ --color-markdown-link-active: light-dark(
+ hsl(200deg 100% 30%),
+ hsl(200deg 100% 80%)
+ );
+ --color-markdown-link-decoration-active: var(--color-markdown-link-active);
+ --color-markdown-code-link-active: var(--color-markdown-link-active);
--color-markdown-link-highlight: light-dark(
hsl(200deg 100% 40%),
hsl(210deg 100% 25%)
);
+ /* Alert words share this underline color, since they share the
+ link color it is mixed from. */
+ --color-markdown-link-highlight-decoration: color-mix(
+ in oklch,
+ var(--color-markdown-link-highlight) 30%,
+ transparent
+ );
--color-markdown-link-highlight-hover: light-dark(
hsl(200deg 100% 25%),
hsl(210deg 100% 18%)
diff --git a/web/styles/message_edit_history.css b/web/styles/message_edit_history.css
index b6d9b220ef6..4214a31ad5c 100644
--- a/web/styles/message_edit_history.css
+++ b/web/styles/message_edit_history.css
@@ -72,6 +72,64 @@
}
}
+ /* A link that was added or removed outright is wrapped by the
+ highlight, so its own underline takes the diff color. */
+ .highlight_text_inserted > a {
+ --color-message-edit-history-diff-text: var(
+ --color-message-edit-history-text-inserted
+ );
+ }
+
+ .highlight_text_deleted > a {
+ --color-message-edit-history-diff-text: var(
+ --color-message-edit-history-text-deleted
+ );
+ }
+
+ .highlight_text_inserted > a,
+ .highlight_text_deleted > a {
+ text-decoration-color: color-mix(
+ in oklch,
+ var(--color-message-edit-history-diff-text) 30%,
+ transparent
+ );
+
+ &:hover,
+ &:focus {
+ text-decoration-color: color-mix(
+ in oklch,
+ var(--color-message-edit-history-diff-text) 70%,
+ transparent
+ );
+ }
+
+ &:active {
+ text-decoration-color: var(--color-message-edit-history-diff-text);
+ }
+ }
+
+ /* When only part of a link changed, the highlights sit inside
+ the link, which keeps its own underline under the unchanged
+ text. Each changed run underlines itself in its own color,
+ drawn over the link's underline. */
+ a > .highlight_text_inserted,
+ a > .highlight_text_deleted {
+ text-decoration-thickness: 1px;
+ /* 3px at 14px em */
+ text-underline-offset: 0.2143em;
+ }
+
+ a > .highlight_text_inserted {
+ text-decoration-line: underline;
+ }
+
+ /* This run is already struck through, and both lines share one
+ color, so leaving the color alone keeps the strikethrough as
+ it was. */
+ a > .highlight_text_deleted {
+ text-decoration-line: underline line-through;
+ }
+
/* Show `Link:` text of media beside it
to clarify click area for opening media
in new tab vs in lightbox. */
diff --git a/web/styles/message_view_header.css b/web/styles/message_view_header.css
index f840d080e99..e43f3479c23 100644
--- a/web/styles/message_view_header.css
+++ b/web/styles/message_view_header.css
@@ -87,6 +87,9 @@
search box--with a pleasing equidistant space in both
places. */
padding: 0 10px;
+ /* Room for the link underline, which would otherwise be
+ clipped. 3px at 14px em */
+ padding-bottom: 0.2143em;
overflow: hidden;
text-overflow: ellipsis;
/* The very last element in the navbar is the search icon, the second
diff --git a/web/styles/rendered_markdown.css b/web/styles/rendered_markdown.css
index 44c0725e696..cd306823904 100644
--- a/web/styles/rendered_markdown.css
+++ b/web/styles/rendered_markdown.css
@@ -828,6 +828,16 @@
unless we set the anchor to display as
a block. */
display: block;
+ /* A clamped title's ellipsis can't take an
+ underline, so we keep this to hover only,
+ as it was before. Only the line is toggled,
+ so the color and thickness above still apply. */
+ text-decoration-line: none;
+
+ &:hover,
+ &:focus {
+ text-decoration-line: underline;
+ }
}
}
@@ -859,7 +869,11 @@
& a:not(.icon-button) {
color: var(--color-markdown-link);
- text-decoration: none;
+ text-decoration: underline;
+ text-decoration-color: var(--color-markdown-link-decoration);
+ text-decoration-thickness: 1px;
+ /* 3px at 14px em */
+ text-underline-offset: 0.2143em;
& code {
color: var(--color-markdown-code-link);
@@ -868,21 +882,40 @@
&:hover,
&:focus {
color: var(--color-markdown-link-hover);
- text-decoration: underline;
+ text-decoration-color: var(--color-markdown-link-decoration-hover);
& code {
color: var(--color-markdown-code-link-hover);
}
}
+ &:active {
+ color: var(--color-markdown-link-active);
+ text-decoration-color: var(--color-markdown-link-decoration-active);
+
+ & code {
+ color: var(--color-markdown-code-link-active);
+ }
+ }
+
/* Link styles that are also related to alert words */
&:has(.alert-word) {
+ text-decoration-color: var(
+ --color-markdown-link-highlight-decoration
+ );
+
&:hover,
&:focus {
text-decoration-color: var(
--color-markdown-link-alert-word-hover
);
}
+
+ &:active {
+ text-decoration-color: var(
+ --color-markdown-link-alert-word-hover
+ );
+ }
}
& .alert-word {
@@ -896,6 +929,15 @@
}
}
+ /* An underline would be drawn across the media. The last two
+ selectors cover legacy Twitter and Dropbox preview markup,
+ which predates the media-anchor-element class. */
+ & a.media-anchor-element,
+ .twitter-image > a,
+ .message_inline_ref > a {
+ text-decoration: none;
+ }
+
& pre {
direction: ltr;
/* code block text is a bit smaller than normal text */
@@ -1129,10 +1171,16 @@
/* Link styles that are also related to search highlights */
a:not(.icon-button) {
&:has(.highlight) {
+ text-decoration-color: var(--color-markdown-link-highlight-decoration);
+
&:hover,
&:focus {
text-decoration-color: var(--color-markdown-link-highlight-hover);
}
+
+ &:active {
+ text-decoration-color: var(--color-markdown-link-highlight-hover);
+ }
}
& .highlight {
diff --git a/web/styles/typeahead.css b/web/styles/typeahead.css
index 2ae80817d8b..d55a2c8495e 100644
--- a/web/styles/typeahead.css
+++ b/web/styles/typeahead.css
@@ -125,6 +125,9 @@
color: var(--color-dropdown-item);
text-decoration: underline 1px;
text-decoration-color: var(--color-dropdown-item-link-underline);
+ /* This clips its overflow, and has no room below the
+ baseline for the offset message links take. */
+ text-underline-offset: auto;
opacity: 0.6;
}
}
diff --git a/web/templates/markdown_help.hbs b/web/templates/markdown_help.hbs
index 595d6db2c5d..28ddf7a7619 100644
--- a/web/templates/markdown_help.hbs
+++ b/web/templates/markdown_help.hbs
@@ -14,7 +14,7 @@
{{#each markdown_help_rows}}
<tr>
{{#if note_html}}
- <td colspan="2">{{{note_html}}}</td>
+ <td colspan="2" class="rendered_markdown">{{{note_html}}}</td>
{{else}}
<td><div class="preserve_spaces">{{markdown}}</div> {{#if usage_html}}{{{usage_html}}}{{/if}}</td>
<td class="rendered_markdown">{{{output_html}}} {{#if effect_html}}{{{effect_html}}}{{/if}}</td>