diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.ts index 21b721719f..45a50e8b14 100644 --- a/web/src/compose_validate.ts +++ b/web/src/compose_validate.ts @@ -66,7 +66,10 @@ function update_send_button_status(): void { export function get_disabled_send_tooltip(): string { if (message_too_long) { - return $t({defaultMessage: "Message length shouldn't be greater than 10000 characters."}); + return $t( + {defaultMessage: `Message length shouldn't be greater than {max_length} characters.`}, + {max_length: realm.max_message_length}, + ); } else if (upload_in_progress) { return $t({defaultMessage: "Cannot send message while files are being uploaded."}); } @@ -689,6 +692,7 @@ export function check_overflow_text(): number { // expensive. const text = compose_state.message_content(); const max_length = realm.max_message_length; + const remaining_characters = max_length - text.length; const $indicator = $("#compose-limit-indicator"); if (text.length > max_length) { @@ -696,8 +700,7 @@ export function check_overflow_text(): number { $("textarea#compose-textarea").addClass("over_limit"); $indicator.html( render_compose_limit_indicator({ - text_length: text.length, - max_length, + remaining_characters, }), ); compose_banner.show_error_message( @@ -712,13 +715,12 @@ export function check_overflow_text(): number { $("#compose_banners"), ); set_message_too_long(true); - } else if (text.length > 0.9 * max_length) { + } else if (remaining_characters <= 900) { $indicator.removeClass("over_limit"); $("textarea#compose-textarea").removeClass("over_limit"); $indicator.html( render_compose_limit_indicator({ - text_length: text.length, - max_length, + remaining_characters, }), ); set_message_too_long(false); diff --git a/web/src/ui_init.js b/web/src/ui_init.js index 7cf66cb466..fb6ea0bb6c 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -181,6 +181,7 @@ function initialize_compose_box() { giphy_enabled: giphy.is_giphy_enabled(), max_stream_name_length: realm.max_stream_name_length, max_topic_length: realm.max_topic_length, + max_message_length: realm.max_message_length, }), ), ); diff --git a/web/styles/app_variables.css b/web/styles/app_variables.css index b92931f731..7b6bf37a89 100644 --- a/web/styles/app_variables.css +++ b/web/styles/app_variables.css @@ -276,6 +276,8 @@ 231deg 100% 90% / 50% ); --color-compose-chevron-arrow: hsl(0deg 0% 58%); + --color-limit-indicator: hsl(38deg 100% 36%); + --color-limit-indicator-over-limit: hsl(3deg 80% 40%); /* Text colors */ --color-text-default: hsl(0deg 0% 20%); @@ -585,6 +587,8 @@ 235deg 100% 70% / 11% ); --color-background-popover: hsl(212deg 32% 14%); + --color-limit-indicator: hsl(38deg 100% 70%); + --color-limit-indicator-over-limit: hsl(3deg 80% 60%); /* Text colors */ --color-text-default: hsl(0deg 0% 100% / 75%); diff --git a/web/styles/compose.css b/web/styles/compose.css index c954b3d4b7..1c92537aee 100644 --- a/web/styles/compose.css +++ b/web/styles/compose.css @@ -304,14 +304,16 @@ #compose-limit-indicator { font-size: 12px; - color: hsl(39deg 100% 50%); + color: var(--color-limit-indicator); + width: max-content; - /* Keep the limit indicator - just above the send button */ + /* Keep the limit indicator just above + and aligned with the send button */ margin-top: auto; + padding: 3px 3px 3px 0; &.over_limit { - color: hsl(0deg 76% 65%); + color: var(--color-limit-indicator-over-limit); font-weight: bold; } } diff --git a/web/templates/compose.hbs b/web/templates/compose.hbs index eccc4a4a52..9e479f50bb 100644 --- a/web/templates/compose.hbs +++ b/web/templates/compose.hbs @@ -89,7 +89,7 @@ {{t 'Drafts' }}() - +