Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_feed: Replace the top-of-feed logo with a thin loading line.
Shubham Padia92dd9c7188ff
diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.htmlindex 28745d17a70..b1b96ceeae8 100644--- a/templates/zerver/app/index.html+++ b/templates/zerver/app/index.html@@ -253,13 +253,7 @@ Accessing messages requires an account and Zulip API key.</div><div id="message_feed_container"><div class="message-feed" id="main_div">- <div class="top-messages-logo">- <svg class="messages-logo-svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 774 774">- <circle cx="387" cy="387" r="370"/>- <path d="M567.32 527.81c0 33.07-24.26 60.11-53.91 60.11H260.59c-29.65 0-53.91-27.04-53.91-60.11 0-20.24 9.10-38.25 22.95-49.14l134.50-120.12c2.50-2.14 5.75 1.31 3.94 4.20l-49.34 98.79c-1.38 2.76.41 6.17 3.25 6.17h191.42c29.65 0 53.91 27.04 53.91 60.11zm0-281.75c0 20.24-9.10 38.25-22.95 49.14l-134.50 120.12c-2.50 2.14-5.75-1.31-3.94-4.20l49.34-98.79c1.38-2.76-.41-6.17-3.25-6.17H260.59c-29.65 0-53.91-27.04-53.91-60.11s24.26-60.11 53.91-60.11h252.81c29.65 0 53.91 27.04 53.91 60.11z"/>- </svg>- </div>- <div id="top-of-feed-loading-indicator"></div>+ <div id="top-of-feed-loading-indicator" aria-hidden="true"></div><div id="message_feed_errors_container"></div><div id="message-lists-container"></div><div id="scheduled_message_indicator">diff --git a/web/src/message_feed_loading.ts b/web/src/message_feed_loading.tsindex a0f12f2e2c9..31194d95fa5 100644--- a/web/src/message_feed_loading.ts+++ b/web/src/message_feed_loading.ts@@ -2,7 +2,7 @@ import {$} from "jquery";import * as loading from "./loading.ts";-let loading_older_messages_indicator_showing = false;+let top_of_feed_indicator_showing = false;let loading_newer_messages_indicator_showing = false;// The indicator at the top of the feed is shown for two reasons: the@@ -13,17 +13,15 @@ let fetching_older_messages = false;function update_top_of_feed_indicator(): void {const should_show_indicator = initial_page_load_pending || fetching_older_messages;- if (should_show_indicator === loading_older_messages_indicator_showing) {+ if (should_show_indicator === top_of_feed_indicator_showing) {return;}if (should_show_indicator) {- $(".top-messages-logo").toggleClass("loading", true);- loading.make_indicator($("#top-of-feed-loading-indicator"), {abs_positioned: true});- loading_older_messages_indicator_showing = true;+ $("#top-of-feed-loading-indicator").addClass("loading");+ top_of_feed_indicator_showing = true;} else {- $(".top-messages-logo").toggleClass("loading", false);- loading.destroy_indicator($("#top-of-feed-loading-indicator"));- loading_older_messages_indicator_showing = false;+ $("#top-of-feed-loading-indicator").removeClass("loading");+ top_of_feed_indicator_showing = false;}}diff --git a/web/src/message_feed_top_notices.ts b/web/src/message_feed_top_notices.tsindex 3807b1d801e..85ab66d4543 100644--- a/web/src/message_feed_top_notices.ts+++ b/web/src/message_feed_top_notices.ts@@ -46,14 +46,6 @@ function show_end_of_results_notice(): void {$(".all-messages-search-caution .search-shared-history").attr("data-url", update_hash);}-export function update_top_of_feed_logo(): void {- if (message_lists.current?.data.fetch_status.has_found_oldest()) {- $(".top-messages-logo").hide();- } else {- $(".top-messages-logo").show();- }-}-export function update_top_of_narrow_notices(msg_list: MessageList): void {// Assumes that the current state is all notices hidden (i.e. this// will not hide a notice that should not be there)@@ -61,8 +53,6 @@ export function update_top_of_narrow_notices(msg_list: MessageList): void {return;}- update_top_of_feed_logo();-if (msg_list.data.fetch_status.has_found_oldest()) {const filter = narrow_state.filter();// Potentially display the notice that lets users know@@ -82,11 +72,6 @@ export function update_top_of_narrow_notices(msg_list: MessageList): void {}export function hide_top_of_narrow_notices(): void {- // Restore the top-of-feed logo; this runs when resetting for a new- // narrow, whose fetch status we don't know yet. It is hidden again- // once we learn we have the narrow's oldest message (see- // update_top_of_feed_logo).- $(".top-messages-logo").show();hide_end_of_results_notice();hide_history_limit_notice();}diff --git a/web/src/message_view.ts b/web/src/message_view.tsindex 298ea10129f..5dcf1c9ee99 100644--- a/web/src/message_view.ts+++ b/web/src/message_view.ts@@ -355,8 +355,8 @@ function get_selected_message_top_offset(is_first_message_in_narrow = false): nu// the top of the message and the sticky header.if (is_first_message_in_narrow) {final_offset +=- ($("#message_feed_errors_container").outerHeight(true) ?? 0) +- ($(".top-messages-logo").outerHeight(true) ?? 0);+ ($("#top-of-feed-loading-indicator").outerHeight(true) ?? 0) ++ ($("#message_feed_errors_container").outerHeight(true) ?? 0);}return final_offset;}diff --git a/web/src/narrow_banner.ts b/web/src/narrow_banner.tsindex 2d44a111d59..190727cb897 100644--- a/web/src/narrow_banner.ts+++ b/web/src/narrow_banner.ts@@ -644,12 +644,8 @@ export function show_empty_narrow_message(current_filter: Filter, invalid_narrow// Removing messages from the current narrow can leave a stale// top-of-feed notice visible, so hide all of them before showing- // the empty-narrow banner. Hiding the notices restores the- // top-of-feed logo, so re-evaluate whether it should be visible;- // an empty narrow whose history is fully fetched should not- // suggest that more messages may load above.+ // the empty-narrow banner.message_feed_top_notices.hide_top_of_narrow_notices();- message_feed_top_notices.update_top_of_feed_logo();if (current_filter.may_have_incomplete_message_history()) {$(".empty_feed_notice .empty-feed-notice-action").show();diff --git a/web/styles/app_variables.css b/web/styles/app_variables.cssindex e95c39a6b33..31f7db890a8 100644--- a/web/styles/app_variables.css+++ b/web/styles/app_variables.css@@ -2120,6 +2120,15 @@hsl(0deg 0% 100% / 60%));--color-zulip-logo-z: light-dark(hsl(0deg 0% 100%), hsl(214deg 27% 18%));+ --color-top-of-feed-loading-line: light-dark(+ hsl(0deg 0% 27% / 70%),+ hsl(0deg 0% 100% / 70%)+ );+ /* The track is darker than the background in both themes. */+ --color-top-of-feed-loading-line-track: light-dark(+ hsl(0deg 0% 0% / 15%),+ hsl(0deg 0% 0% / 45%)+ );/* Message collapsing/condensing button colors */--color-show-more-less-button-background: light-dark(diff --git a/web/styles/dark_theme.css b/web/styles/dark_theme.cssindex bb479cfbbc4..a187e1f460d 100644--- a/web/styles/dark_theme.css+++ b/web/styles/dark_theme.css@@ -196,10 +196,6 @@}}- .top-messages-logo {- opacity: 0.7;- }-.searching-for-more-topics img {filter: invert(100%);}diff --git a/web/styles/print.css b/web/styles/print.cssindex 073ae3d495c..85a7d394142 100644--- a/web/styles/print.css+++ b/web/styles/print.css@@ -13,7 +13,6 @@#left-sidebar-container,#right-sidebar-container,.column-left,- .top-messages-logo,#userlist-toggle,.message_length_controller,#top-of-feed-loading-indicator,diff --git a/web/styles/zulip.css b/web/styles/zulip.cssindex 01de8d0764a..4b8b87413f5 100644--- a/web/styles/zulip.css+++ b/web/styles/zulip.css@@ -243,10 +243,6 @@ p.n-margin {.bottom-messages-logo {display: none;-}--.top-messages-logo,-.bottom-messages-logo {width: 1.7143em; /* 24px at 14px/em */height: 1.7143em;margin: 0 auto 0.8571em; /* 12px at 14px/em */@@ -269,12 +265,6 @@ p.n-margin {}}-.top-messages-logo {- /* Since padding under message header is not transparent- we need to position it below the padding. */- padding-top: var(--header-padding-bottom);-}-/* See https://web.dev/animations-guide/#triggers before adding any funny animation properties here. */@keyframes feedback-slide-in {from {@@ -590,12 +580,10 @@ body.has-overlay-scrollbar {z-index: 15;}-#message_feed_container,-.app-main .column-left .left-sidebar,-.app-main .column-right .right-sidebar {- padding-top: calc(- var(--navbar-fixed-height) + var(--header-padding-bottom)- );+#message_feed_container {+ /* The gutter below the navbar is the top-of-feed loading box; see+ #top-of-feed-loading-indicator. */+ padding-top: var(--navbar-fixed-height);}.app-main {@@ -615,6 +603,9 @@ body.has-overlay-scrollbar {.column-right .right-sidebar {position: fixed;z-index: 100;+ padding-top: calc(+ var(--navbar-fixed-height) + var(--header-padding-bottom)+ );}.column-left .left-sidebar {@@ -1239,16 +1230,103 @@ nav {font-family: "Source Code Pro", monospace;}-#top-of-feed-loading-indicator,-#loading_more_indicator {- margin: 10px;+#top-of-feed-loading-indicator {+ /* How much of the line the pulse covers; the sweep keyframes+ use this to travel the full width of the line. */+ --loading-pulse-fraction: 0.3;++ position: relative;+ height: var(--header-padding-bottom);+ /* Above the first recipient bar (see .message-feed .message_header+ in message_header.css), whose empty top margin the line hangs+ into. */+ z-index: 5;+ /* Clip the pulse as it sweeps past the sides, but let the line+ hang out below, over the recipient bar's empty top margin. */+ overflow: clip visible;++ &::before,+ &::after {+ content: "";+ position: absolute;+ /* Centered in the space between the navbar and the recipient+ bar's contents, which is the gutter plus the bar's equal top+ margin: that is, centered on the gutter's bottom edge. */+ bottom: -1.5px;+ left: 0;+ height: 3px;+ /* Fade in and out rather than popping. */+ opacity: 0;+ transition: opacity 200ms ease-in-out;+ }++ /* The line's track. */+ &::before {+ right: 0;+ background-color: var(--color-top-of-feed-loading-line-track);+ }++ /* The pulse that sweeps along the line, left to right. Its ends are+ transparent so that it eases in at the left edge of the line and+ out at the right edge, instead of being cut off there. */+ &::after {+ width: calc(100% * var(--loading-pulse-fraction));+ background-image: linear-gradient(+ to right,+ transparent,+ var(--color-top-of-feed-loading-line),+ transparent+ );++ @media (prefers-reduced-motion) {+ width: 100%;+ background-image: none;+ background-color: var(--color-top-of-feed-loading-line);+ }+ }++ &.loading::before,+ &.loading::after {+ opacity: 1;+ }++ /* The pulse only moves while the line is up, so that each time+ the line shows up the sweep starts over from the left edge. */+ &.loading::after {+ animation: top-of-feed-loading-pulse 750ms ease-in-out infinite;++ @media (prefers-reduced-motion) {+ animation: top-of-feed-loading-fade 750ms ease-in-out infinite;+ }+ }+}++@keyframes top-of-feed-loading-pulse {+ from {+ transform: translateX(-100%);+ }++ to {+ /* The line's full width, measured in pulse widths. */+ transform: translateX(calc(100% / var(--loading-pulse-fraction)));+ }+}++@keyframes top-of-feed-loading-fade {+ 0%,+ 100% {+ opacity: 0;+ }++ 50% {+ opacity: 1;+ }}-#top-of-feed-loading-indicator path {- fill: var(--color-zulip-logo-loading);+#loading_more_indicator {+ margin: 10px;}-#loading_older_messages_indicator_box_container,#loading_more_indicator_box_container {position: absolute;left: 50%;@@ -1261,7 +1339,6 @@ nav {}}-#loading_older_messages_indicator_box,#loading_more_indicator_box {position: relative;left: -1.3571em; /* 50% of 38px = 19px at 14px/em */diff --git a/web/tests/message_feed_loading.test.cjs b/web/tests/message_feed_loading.test.cjsindex 12c96522244..b17cfb969e5 100644--- a/web/tests/message_feed_loading.test.cjs+++ b/web/tests/message_feed_loading.test.cjs@@ -2,19 +2,14 @@const assert = require("node:assert/strict");-const {mock_esm, zrequire} = require("./lib/namespace.cjs");-const {run_test, noop} = require("./lib/test.cjs");+const {zrequire} = require("./lib/namespace.cjs");+const {run_test} = require("./lib/test.cjs");const {$} = require("./lib/zjquery.cjs");-mock_esm("../src/loading", {- make_indicator: noop,- destroy_indicator: noop,-});-const message_feed_loading = zrequire("message_feed_loading");function is_loading() {- return $(".top-messages-logo").hasClass("loading");+ return $("#top-of-feed-loading-indicator").hasClass("loading");}run_test("initial page load and older fetches share the indicator", () => {