Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
modal: Redesign footer buttons.
Evy Kassirer1751810642b5
diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.tsindex b5181f99dbb..c333eaa7cb6 100644--- a/web/src/dialog_widget.ts+++ b/web/src/dialog_widget.ts@@ -88,6 +88,7 @@ export type DialogWidgetConfig = {always_visible_scrollbar?: boolean;footer_minor_text?: string;close_on_overlay_click?: boolean;+ dangerous_action?: boolean;};type RequestOpts = {@@ -203,6 +204,8 @@ export function launch(conf: DialogWidgetConfig): string {// has scrollable content. Default behaviour is to hide the scrollbar when it is// not in use.// * close_on_overlay_click: Whether to close modal on clicking overlay.+ // * dangerous_action: If true, styles the submit button as a danger+ // button (e.g., for delete or deactivate actions).widget_id_counter += 1;const modal_unique_id = current_dialog_widget_id();@@ -229,6 +232,7 @@ export function launch(conf: DialogWidgetConfig): string {footer_minor_text: conf.footer_minor_text,close_on_overlay_click: conf.close_on_overlay_click ?? true,hide_footer: conf.hide_footer,+ dangerous_action: conf.dangerous_action,});const $dialog = $(html);$("body").append($dialog);diff --git a/web/src/message_delete.ts b/web/src/message_delete.tsindex 87395e7175f..965adc8c1ea 100644--- a/web/src/message_delete.ts+++ b/web/src/message_delete.ts@@ -5,7 +5,7 @@ import * as z from "zod/mini";import * as channel from "./channel.ts";import * as confirm_dialog from "./confirm_dialog.ts";import * as dialog_widget from "./dialog_widget.ts";-import {$t_html} from "./i18n.ts";+import {$t, $t_html} from "./i18n.ts";import type {Message} from "./message_store.ts";import * as people from "./people.ts";import * as settings_data from "./settings_data.ts";@@ -120,10 +120,12 @@ export function delete_message(msg_id: number): void {modal_content_html: $t_html({defaultMessage: "Deleting a message permanently removes it for everyone.",}),+ modal_submit_button_text: $t({defaultMessage: "Delete"}),is_compact: true,help_link: "/help/delete-a-message#delete-a-message-completely",on_click: do_delete_message,loading_spinner: true,+ dangerous_action: true,});}diff --git a/web/styles/app_variables.css b/web/styles/app_variables.cssindex 56ca50dc309..6001089a39c 100644--- a/web/styles/app_variables.css+++ b/web/styles/app_variables.css@@ -2721,7 +2721,7 @@color-mix(in oklch, hsl(0deg 0% 100%) 85%, transparent));--color-background-danger-solid-action-button: light-dark(- hsl(4deg 75% 53%),+ hsl(4deg 75% 51%),hsl(2deg 74% 47%));--color-background-danger-solid-action-button-hover: light-dark(diff --git a/web/styles/modal.css b/web/styles/modal.cssindex 6d55d8fc183..bc82c79a69e 100644--- a/web/styles/modal.css+++ b/web/styles/modal.css@@ -3,9 +3,32 @@/* Exit buttons are sometimes Cancel, but sometimesother "Nah, forget it" actions. */--color-exit-button-text: hsl(0deg 0% 0%);- --color-exit-button-border: hsl(300deg 2% 11% / 30%);--color-exit-button-background: hsl(226deg 1% 42% / 20%);--color-exit-button-background-interactive: hsl(226deg 1% 42% / 27%);+ --color-background-modal-confirm-button: light-dark(+ hsl(240deg 80% 66%),+ hsl(245deg 55% 50%)+ );+ --color-background-modal-confirm-button-hover: light-dark(+ hsl(240deg 63% 59%),+ hsl(245deg 60% 58%)+ );+ --color-background-modal-confirm-button-active: light-dark(+ hsl(240deg 55% 51%),+ hsl(245deg 65% 42%)+ );+ --color-text-modal-cancel-button: light-dark(+ hsl(229deg 9% 36%),+ hsl(229deg 10% 70%)+ );+ --color-background-modal-cancel-button-hover: light-dark(+ hsl(229deg 9% 36% / 7%),+ hsl(230deg 9% 60% / 14%)+ );+ --color-background-modal-cancel-button-active: light-dark(+ hsl(229deg 9% 36% / 11%),+ hsl(230deg 9% 60% / 18%)+ );/* Since modals are also present in portico and billing pages, we definethe modal related variables directly here in the modal.css — which is@@ -206,8 +229,8 @@}}-.modal__button:focus,-.modal__button:hover {+.modal__button:focus:not(.dialog_submit_button, .dialog_exit_button),+.modal__button:hover:not(.dialog_submit_button, .dialog_exit_button) {transform: scale(1.05);/* The extremely subtle 1.05 scale can causea gap to appear between the outline and@@ -218,19 +241,46 @@}.dialog_exit_button {- color: var(--color-exit-button-text);- background: var(--color-exit-button-background);- border: 1px solid var(--color-exit-button-border);+ color: var(--color-text-modal-cancel-button);+ background: transparent;&:hover {- background: var(--color-exit-button-background-interactive);+ background: var(--color-background-modal-cancel-button-hover);+ }++ &:active {+ background: var(--color-background-modal-cancel-button-active);}}.dialog_submit_button {margin-left: 12px;- background-color: hsl(240deg 96% 68%);+ background-color: var(--color-background-modal-confirm-button);color: hsl(0deg 0% 100%) !important;++ &:hover {+ background-color: var(--color-background-modal-confirm-button-hover);+ }++ &:active {+ background-color: var(--color-background-modal-confirm-button-active);+ }++ &.dangerous_action_button {+ background-color: var(--color-background-danger-solid-action-button);++ &:hover {+ background-color: var(+ --color-background-danger-solid-action-button-hover+ );+ }++ &:active {+ background-color: var(+ --color-background-danger-solid-action-button-active+ );+ }+ }}.modal__tab-switcher-container {diff --git a/web/templates/dialog_widget.hbs b/web/templates/dialog_widget.hbsindex c3b68b45a46..2de82f6280a 100644--- a/web/templates/dialog_widget.hbs+++ b/web/templates/dialog_widget.hbs@@ -42,7 +42,7 @@<button class="modal__button dialog_exit_button" aria-label="{{t 'Close this dialog window' }}" data-micromodal-close>{{ modal_exit_button_text }}</button>{{/unless}}<div class="dialog_submit_button_container">- <button class="modal__button dialog_submit_button"{{#if single_footer_button}} aria-label="{{t 'Close this dialog window' }}" data-micromodal-close{{/if}}>+ <button class="modal__button dialog_submit_button{{#if dangerous_action}} dangerous_action_button{{/if}}"{{#if single_footer_button}} aria-label="{{t 'Close this dialog window' }}" data-micromodal-close{{/if}}><span class="submit-button-text">{{ modal_submit_button_text }}</span><span class="modal__spinner"></span></button>