Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent-view: Use dynamic width for time column.
Aman Agrawal8d2ff68326df
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.tsindex 1f0f2e1ba83..f6395e20195 100644--- a/web/src/recent_view_ui.ts+++ b/web/src/recent_view_ui.ts@@ -1505,6 +1505,29 @@ function get_list_data_for_widget(): ConversationData[] {return [...recent_view_data.get_conversations().values()];}+function set_time_column_width_css_variable(): void {+ if (page_params.is_node_test) {+ return;+ }+ // Measure representative localized time strings to find the+ // longest one. These cover all formats used by+ // timerender.relative_time_string_from_date().+ const candidate_strings = [+ $t({defaultMessage: "Just now"}),+ $t({defaultMessage: "{minutes} min ago"}, {minutes: 59}),+ $t({defaultMessage: "An hour ago"}),+ $t({defaultMessage: "{hours} hours ago"}, {hours: 23}),+ $t({defaultMessage: "Yesterday"}),+ $t({defaultMessage: "{days_old} days ago"}, {days_old: 89}),+ // Localized short date with year, using a 2-digit day for+ // maximum width (e.g., "Sep 28, 2000").+ timerender.get_localized_date_or_time_for_format(new Date(2000, 8, 28), "dayofyear_year"),+ ];+ const max_width = util.max_text_content_width(candidate_strings);+ // The icon and padding space is added via calc() in CSS.+ $(":root").css("--recent-view-time-text-width", `${Math.ceil(max_width)}px`);+}+export function update_participants_column_class(): void {if (!page_params.is_node_test) {max_avatars = Number.parseInt($(":root").css("--recent-view-max-avatars"), 10);@@ -1526,6 +1549,7 @@ export function complete_rerender(coming_from_other_views = false): void {}update_participants_column_class();+ set_time_column_width_css_variable();// Show topics listconst mapped_topic_values = get_list_data_for_widget();diff --git a/web/styles/recent_view.css b/web/styles/recent_view.cssindex 0edc853e8bc..863af36d382 100644--- a/web/styles/recent_view.css+++ b/web/styles/recent_view.css@@ -624,12 +624,6 @@.recent-view-participants-header {display: none;}-- /* Increase space for time column. */- .recent_topic_timestamp,- .recent-view-last-msg-time-header {- width: 25%;- }}.recent-view-participants-header .recent-view-header-wrapper {@@ -641,7 +635,13 @@.recent_topic_timestamp,.recent-view-last-msg-time-header {- width: 20%;+ /* Time text width is measured from JS and set as+ --recent-view-time-text-width. Add the visibility+ icon width (1em), cell padding (2 × 0.5em), and space+ for the icon's focus outline (0.5em). Falls back to+ 25% before JS has set the variable. */+ width: 25%;+ width: calc(var(--recent-view-time-text-width) + 2.5em);}.recent_topic_name {@@ -829,13 +829,8 @@}#recent_view .recent_topic_timestamp .flex_container {+ /* Push the visibility icon to the right edge of the cell. */justify-content: space-between;-- /* To avoid time text from wrapping, keep extra margin- as small as possible. */- .recent_topic_actions {- margin-right: 0.125em; /* 2px at 16px/1em */- }}.recent-view-unread-mention-and-count-wrapper {