A platform for community discussion. Free, open, simple.
UX: composer use BEM + small tweaks to enabled/disabled styling (#21246)
chapoif29f1313876c
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbsindex 8c6953fcfbb..fbb555f026e 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs@@ -17,14 +17,10 @@aria-label={{i18n "chat.aria_roles.composer"}}class={{concat-class"chat-composer"- (if this.isFocused "chat-composer--focused")- (if this.pane.sending "chat-composer--sending")- (if- this.sendEnabled- "chat-composer--send-enabled"- "chat-composer--send-disabled"- )- (if this.disabled "chat-composer--disabled")+ (if this.isFocused "is-focused")+ (if this.pane.sending "is-sending")+ (if this.sendEnabled "is-send-enabled" "is-send-disabled")+ (if this.disabled "is-disabled")}}{{did-update this.didUpdateMessage this.currentMessage}}{{did-update this.didUpdateInReplyTo this.currentMessage.inReplyTo}}diff --git a/plugins/chat/assets/stylesheets/common/chat-composer-dropdown.scss b/plugins/chat/assets/stylesheets/common/chat-composer-dropdown.scssindex 93dd7af86cb..e1e457beb21 100644--- a/plugins/chat/assets/stylesheets/common/chat-composer-dropdown.scss+++ b/plugins/chat/assets/stylesheets/common/chat-composer-dropdown.scss@@ -27,6 +27,14 @@color: var(--primary-low);}}++ .chat-composer.is-disabled & {+ background: var(--primary-400);++ &:hover {+ cursor: not-allowed;+ }+ }}.chat-composer-dropdown__list {diff --git a/plugins/chat/assets/stylesheets/common/chat-composer.scss b/plugins/chat/assets/stylesheets/common/chat-composer.scssindex bd5ea8c3e42..d724cda7a04 100644--- a/plugins/chat/assets/stylesheets/common/chat-composer.scss+++ b/plugins/chat/assets/stylesheets/common/chat-composer.scss@@ -1,7 +1,4 @@.chat-composer {- display: flex;- align-items: center;-&__wrapper {display: flex;flex-direction: column;@@ -39,12 +36,16 @@padding-inline: 0.25rem;min-height: 42px;- .chat-composer--focused & {+ .chat-composer.is-focused & {border-color: var(--primary-medium);}- .chat-composer--disabled & {+ .chat-composer.is-disabled & {background: var(--primary-low);++ &:hover {+ cursor: not-allowed;+ }}}@@ -53,41 +54,41 @@background: none;will-change: scale;- .chat-composer--send-enabled & {- &:hover {- background: none;- }-- &:focus {- background: none;- outline: auto;- }-- .d-icon {- color: var(--tertiary) !important;- }- }-@keyframes sendingScales {0% {- transform: scale(0.8);+ transform: scale(0.9);}50% {transform: scale(1.2);}100% {- transform: scale(0.8);+ transform: scale(0.9);}}+ .chat-composer.is-sending & {+ animation: sendingScales 1s infinite linear;+ }++ .chat-composer.is-send-enabled & {+ background: var(--tertiary-50);+ &:focus {+ outline: auto;+ }- .chat-composer--sending & {- animation: sendingScales 1s infinite;+ .d-icon {+ color: var(--tertiary) !important;+ }}- .chat-composer--send-disabled & {+ .chat-composer.is-send-disabled & {cursor: default;- opacity: 0.6 !important;+ &:hover {+ background: none !important;+ }+ }+ .chat-composer.is-disabled & {+ opacity: 0.4;&:hover {background: none !important;}@@ -145,6 +146,7 @@margin: 0;padding: 0.25rem 0.5rem;text-overflow: ellipsis;+ cursor: inherit;@include chat-scrollbar();diff --git a/plugins/chat/assets/stylesheets/mobile/chat-composer.scss b/plugins/chat/assets/stylesheets/mobile/chat-composer.scssindex edbc974c9dd..487c2b61055 100644--- a/plugins/chat/assets/stylesheets/mobile/chat-composer.scss+++ b/plugins/chat/assets/stylesheets/mobile/chat-composer.scss@@ -1,7 +1,11 @@-.chat-composer-container {- padding: 0;+.chat-composer {+ &__wrapper {+ padding: 0;+ }- .chat-composer {- margin: 0.5rem 10px 0 10px;+ &__input {+ .ios-device & {+ background-color: transparent;+ }}}diff --git a/plugins/chat/spec/system/chat_composer_spec.rb b/plugins/chat/spec/system/chat_composer_spec.rbindex 9b2095d4743..472346a060a 100644--- a/plugins/chat/spec/system/chat_composer_spec.rb+++ b/plugins/chat/spec/system/chat_composer_spec.rb@@ -321,7 +321,7 @@ RSpec.describe "Chat composer", type: :system, js: true dochat.visit_channel(channel_1)find("body").send_keys("1")- expect(page).to have_css(".chat-composer--send-disabled")+ expect(page).to have_css(".chat-composer.is-send-disabled")endendenddiff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rbindex 6975f561410..d59d96aaeac 100644--- a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb@@ -18,7 +18,7 @@ module PageObjectsenddef click_send_message- find(".chat-composer--send-enabled .chat-composer__send-btn").click+ find(".chat-composer.is-send-enabled .chat-composer__send-btn").clickenddef message_by_id_selector(id)diff --git a/plugins/chat/spec/system/page_objects/chat/chat_thread.rb b/plugins/chat/spec/system/page_objects/chat/chat_thread.rbindex 6b744ef0439..ed6016b9f42 100644--- a/plugins/chat/spec/system/page_objects/chat/chat_thread.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat_thread.rb@@ -50,7 +50,7 @@ module PageObjectsdef click_send_message(id)find(thread_selector_by_id(id)).find(- ".chat-composer--send-enabled .chat-composer__send-btn",+ ".chat-composer.is-send-enabled .chat-composer__send-btn",).clickend