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.

modals: Add subtitle and compact mode support to modals.

Sayam Samal0e180e58dde2
diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.ts
index f6dbed0993e..733e813eee2 100644
--- a/web/src/dialog_widget.ts
+++ b/web/src/dialog_widget.ts
@@ -64,6 +64,8 @@ export type DialogWidgetConfig = {
modal_title_html?: string;
modal_title_text?: string;
modal_content_html: string;
+ modal_subtitle_html?: string;
+ is_compact?: boolean;
on_click?: (e: JQuery.ClickEvent) => void;
hide_footer?: boolean;
modal_submit_button_text?: string;
@@ -169,6 +171,11 @@ export function launch(conf: DialogWidgetConfig): string {
// templates.
// Optional parameters:
+ // * modal_subtitle_html: Provides additional context
+ // below the modal title.
+ // * is_compact: If true, enables the compact version where the modal
+ // content area is not rendered, and the modal_content_html is
+ // passed to the modal_subtitle_html to be displayed as the subtitle.
// * on_click: Callback to run when submit button is clicked and footer is enabled.
// * hide_footer: Whether to disable footer and hide its associated buttons.
// * modal_submit_button_text: Submit button text.
@@ -199,10 +206,15 @@ export function launch(conf: DialogWidgetConfig): string {
const modal_submit_button_text =
conf.modal_submit_button_text ?? $t({defaultMessage: "Save changes"});
const modal_exit_button_text = conf.modal_exit_button_text ?? $t({defaultMessage: "Cancel"});
+ if (conf.is_compact) {
+ conf.modal_subtitle_html = conf.modal_content_html;
+ }
const html = render_dialog_widget({
modal_unique_id,
modal_title_html: conf.modal_title_html,
modal_title_text: conf.modal_title_text,
+ modal_subtitle_html: conf.modal_subtitle_html,
+ is_compact: conf.is_compact,
link: conf.help_link,
modal_submit_button_text,
modal_exit_button_text,
diff --git a/web/src/message_delete.ts b/web/src/message_delete.ts
index f7def02b6fe..5556177d6a9 100644
--- a/web/src/message_delete.ts
+++ b/web/src/message_delete.ts
@@ -2,8 +2,6 @@ import $ from "jquery";
import assert from "minimalistic-assert";
import * as z from "zod/mini";
-import render_delete_message_modal from "../templates/confirm_dialog/confirm_delete_message.hbs";
-
import * as channel from "./channel.ts";
import * as confirm_dialog from "./confirm_dialog.ts";
import * as dialog_widget from "./dialog_widget.ts";
@@ -91,8 +89,6 @@ export function get_deletability(message: Message): boolean {
}
export function delete_message(msg_id: number): void {
- const modal_content_html = render_delete_message_modal();
-
function do_delete_message(): void {
currently_deleting_messages.push(msg_id);
void channel.del({
@@ -121,7 +117,10 @@ export function delete_message(msg_id: number): void {
confirm_dialog.launch({
modal_title_html: $t_html({defaultMessage: "Delete message?"}),
- modal_content_html,
+ modal_content_html: $t_html({
+ defaultMessage: "Deleting a message permanently removes it for everyone.",
+ }),
+ is_compact: true,
help_link: "/help/delete-a-message#delete-a-message-completely",
on_click: do_delete_message,
loading_spinner: true,
diff --git a/web/styles/app_variables.css b/web/styles/app_variables.css
index 7bd44f3e3ee..bcc1d1ba6c6 100644
--- a/web/styles/app_variables.css
+++ b/web/styles/app_variables.css
@@ -862,6 +862,11 @@
hsl(0deg 0% 15%),
color-mix(in oklch, hsl(0deg 0% 100%) 85%, transparent)
);
+ --color-modal-subtitle-text: color-mix(
+ in oklch,
+ var(--color-modal-heading-text) 75%,
+ transparent
+ );
--color-background-modal: light-dark(hsl(0deg 0% 93%), hsl(0deg 0% 14%));
--color-background-modal-bar: light-dark(
hsl(0deg 0% 96%),
diff --git a/web/styles/modal.css b/web/styles/modal.css
index 454b007fc5d..7d9daf08657 100644
--- a/web/styles/modal.css
+++ b/web/styles/modal.css
@@ -59,14 +59,15 @@
display: flex;
justify-content: flex-end;
align-items: center;
- /* 12px 16px at 16px/1em */
- padding: 0.75em 1em;
+ /* 8px 16px 12px 16px at 16px/1em */
+ padding: 0.5em 1em 0.75em;
background-color: var(--color-background-modal-bar);
}
.modal__content + .modal__footer {
/* These styles apply only when the modal content
is present in the modal. */
+ padding: 0.75em 1em; /* 12px 16px at 16px/1em */
border-top: 1px solid var(--color-border-modal-bar);
}
@@ -115,6 +116,12 @@
}
}
+.modal__subtitle {
+ margin-top: 0.25em; /* 4px at 16px/1em */
+ line-height: 1.25; /* 20px at 16px/1em */
+ color: var(--color-modal-subtitle-text);
+}
+
.modal__close {
grid-area: modal-close-button;
diff --git a/web/templates/confirm_dialog/confirm_delete_message.hbs b/web/templates/confirm_dialog/confirm_delete_message.hbs
deleted file mode 100644
index 125c52009d1..00000000000
--- a/web/templates/confirm_dialog/confirm_delete_message.hbs
+++ /dev/null
@@ -1 +0,0 @@
-<p>{{t "Deleting a message permanently removes it for everyone."}}</p>
diff --git a/web/templates/dialog_widget.hbs b/web/templates/dialog_widget.hbs
index 1873216468e..4222433e6d2 100644
--- a/web/templates/dialog_widget.hbs
+++ b/web/templates/dialog_widget.hbs
@@ -13,13 +13,20 @@
{{> help_link_widget . }}
{{/if}}
</h1>
+ {{#if modal_subtitle_html}}
+ <div class="modal__subtitle">
+ {{{ modal_subtitle_html }}}
+ </div>
+ {{/if}}
</div>
{{> components/icon_button icon="close" intent="neutral" custom_classes="modal__close" aria-label=(t 'Close modal') data-micromodal-close=true }}
</header>
+ {{#unless is_compact}}
<main class="modal__content {{#if hide_footer}} footer-hidden {{/if}}" data-simplebar data-simplebar-tab-index="-1" {{#if always_visible_scrollbar}}data-simplebar-auto-hide="false"{{/if}}>
<div class="alert" id="dialog_error"></div>
{{{ modal_content_html }}}
</main>
+ {{/unless}}
{{#unless hide_footer}}
<footer class="modal__footer">
{{#if footer_minor_text }}