From 70013d0f2878c5e3edf5aa35ff7af03dedae92fe Mon Sep 17 00:00:00 2001 From: Sayam Samal Date: Thu, 7 Mar 2024 00:36:30 +0530 Subject: [PATCH] navbar: Add navigate to home view tooltip to the organization logo. The organization logo in the upper left navigates to the user's home view. We add a tooltip to make this easier to discover. We show `Esc` as the keyboard shortcut here, unless the user has disabled it, in which case we show the alt shortcut `Ctrl` + `[`. Fixes #29185. --- web/src/tippyjs.ts | 18 ++++++++++++++++++ web/src/user_settings.ts | 2 +- web/templates/org_logo_tooltip.hbs | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 web/templates/org_logo_tooltip.hbs diff --git a/web/src/tippyjs.ts b/web/src/tippyjs.ts index d960f75e61..46e91172d0 100644 --- a/web/src/tippyjs.ts +++ b/web/src/tippyjs.ts @@ -3,11 +3,13 @@ import assert from "minimalistic-assert"; import tippy, {delegate} from "tippy.js"; import render_buddy_list_title_tooltip from "../templates/buddy_list/title_tooltip.hbs"; +import render_org_logo_tooltip from "../templates/org_logo_tooltip.hbs"; import render_tooltip_templates from "../templates/tooltip_templates.hbs"; import {$t} from "./i18n"; import * as people from "./people"; import * as popovers from "./popovers"; +import * as settings_config from "./settings_config"; import * as ui_util from "./ui_util"; import {user_settings} from "./user_settings"; @@ -575,4 +577,20 @@ export function initialize(): void { ); }, }); + + delegate("body", { + target: "#realm-logo", + placement: "right", + appendTo: () => document.body, + onShow(instance) { + const escape_navigates_to_home_view = user_settings.web_escape_navigates_to_home_view; + const home_view = + settings_config.web_home_view_values[user_settings.web_home_view].description; + instance.setContent( + ui_util.parse_html( + render_org_logo_tooltip({home_view, escape_navigates_to_home_view}), + ), + ); + }, + }); } diff --git a/web/src/user_settings.ts b/web/src/user_settings.ts index b02f7c63c5..cd7dddb9f0 100644 --- a/web/src/user_settings.ts +++ b/web/src/user_settings.ts @@ -26,7 +26,7 @@ export type UserSettings = (StreamNotificationSettings & FollowedTopicNotificationSettings) & { color_scheme: number; default_language: string; - web_home_view: string; + web_home_view: "inbox" | "recent_topics" | "all_messages"; desktop_icon_count_display: number; demote_inactive_streams: number; dense_mode: boolean; diff --git a/web/templates/org_logo_tooltip.hbs b/web/templates/org_logo_tooltip.hbs new file mode 100644 index 0000000000..faf0c8d0c9 --- /dev/null +++ b/web/templates/org_logo_tooltip.hbs @@ -0,0 +1,8 @@ +
+
{{t "Go to home view"}} ({{home_view}})
+
+{{#if escape_navigates_to_home_view}} + {{tooltip_hotkey_hints "Esc"}} +{{else}} + {{tooltip_hotkey_hints "Ctrl" "["}} +{{/if}}