UX: composer use BEM + small tweaks to enabled/disabled styling (#21246)

- using BEM notation
- making animation linear instead of default ease
- small tweaks to composer state (disabled/send-disabled/send-enabled)
- fixing bug with disabled composer on mobile
This commit is contained in:
chapoi 2023-04-28 17:24:49 +09:00 committed by GitHub
parent eb0836e133
commit f29f131387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 42 deletions

View File

@ -17,14 +17,10 @@
aria-label={{i18n "chat.aria_roles.composer"}} aria-label={{i18n "chat.aria_roles.composer"}}
class={{concat-class class={{concat-class
"chat-composer" "chat-composer"
(if this.isFocused "chat-composer--focused") (if this.isFocused "is-focused")
(if this.pane.sending "chat-composer--sending") (if this.pane.sending "is-sending")
(if (if this.sendEnabled "is-send-enabled" "is-send-disabled")
this.sendEnabled (if this.disabled "is-disabled")
"chat-composer--send-enabled"
"chat-composer--send-disabled"
)
(if this.disabled "chat-composer--disabled")
}} }}
{{did-update this.didUpdateMessage this.currentMessage}} {{did-update this.didUpdateMessage this.currentMessage}}
{{did-update this.didUpdateInReplyTo this.currentMessage.inReplyTo}} {{did-update this.didUpdateInReplyTo this.currentMessage.inReplyTo}}

View File

@ -27,6 +27,14 @@
color: var(--primary-low); color: var(--primary-low);
} }
} }
.chat-composer.is-disabled & {
background: var(--primary-400);
&:hover {
cursor: not-allowed;
}
}
} }
.chat-composer-dropdown__list { .chat-composer-dropdown__list {

View File

@ -1,7 +1,4 @@
.chat-composer { .chat-composer {
display: flex;
align-items: center;
&__wrapper { &__wrapper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -39,12 +36,16 @@
padding-inline: 0.25rem; padding-inline: 0.25rem;
min-height: 42px; min-height: 42px;
.chat-composer--focused & { .chat-composer.is-focused & {
border-color: var(--primary-medium); border-color: var(--primary-medium);
} }
.chat-composer--disabled & { .chat-composer.is-disabled & {
background: var(--primary-low); background: var(--primary-low);
&:hover {
cursor: not-allowed;
}
} }
} }
@ -53,13 +54,24 @@
background: none; background: none;
will-change: scale; will-change: scale;
.chat-composer--send-enabled & { @keyframes sendingScales {
&:hover { 0% {
background: none; transform: scale(0.9);
} }
50% {
transform: scale(1.2);
}
100% {
transform: scale(0.9);
}
}
.chat-composer.is-sending & {
animation: sendingScales 1s infinite linear;
}
.chat-composer.is-send-enabled & {
background: var(--tertiary-50);
&:focus { &:focus {
background: none;
outline: auto; outline: auto;
} }
@ -68,26 +80,15 @@
} }
} }
@keyframes sendingScales { .chat-composer.is-send-disabled & {
0% {
transform: scale(0.8);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(0.8);
}
}
.chat-composer--sending & {
animation: sendingScales 1s infinite;
}
.chat-composer--send-disabled & {
cursor: default; cursor: default;
opacity: 0.6 !important; &:hover {
background: none !important;
}
}
.chat-composer.is-disabled & {
opacity: 0.4;
&:hover { &:hover {
background: none !important; background: none !important;
} }
@ -145,6 +146,7 @@
margin: 0; margin: 0;
padding: 0.25rem 0.5rem; padding: 0.25rem 0.5rem;
text-overflow: ellipsis; text-overflow: ellipsis;
cursor: inherit;
@include chat-scrollbar(); @include chat-scrollbar();

View File

@ -1,7 +1,11 @@
.chat-composer-container { .chat-composer {
padding: 0; &__wrapper {
padding: 0;
}
.chat-composer { &__input {
margin: 0.5rem 10px 0 10px; .ios-device & {
background-color: transparent;
}
} }
} }

View File

@ -321,7 +321,7 @@ RSpec.describe "Chat composer", type: :system, js: true do
chat.visit_channel(channel_1) chat.visit_channel(channel_1)
find("body").send_keys("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")
end end
end end
end end

View File

@ -18,7 +18,7 @@ module PageObjects
end end
def click_send_message def click_send_message
find(".chat-composer--send-enabled .chat-composer__send-btn").click find(".chat-composer.is-send-enabled .chat-composer__send-btn").click
end end
def message_by_id_selector(id) def message_by_id_selector(id)

View File

@ -50,7 +50,7 @@ module PageObjects
def click_send_message(id) def click_send_message(id)
find(thread_selector_by_id(id)).find( find(thread_selector_by_id(id)).find(
".chat-composer--send-enabled .chat-composer__send-btn", ".chat-composer.is-send-enabled .chat-composer__send-btn",
).click ).click
end end