Skip to content

A platform for community discussion. Free, open, simple.

UX: Starred chat channel icons (#36568)

chapoi590d970fcbae
diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
index d83fd660324..0715e1676b7 100644
--- a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
@@ -37,49 +37,40 @@ export default class ChatChannelIcon extends Component {
<template>
{{#if @channel.isDirectMessageChannel}}
- <div class="chat-channel-icon">
- {{#if @channel.iconUploadUrl}}
- <span class="chat-channel-icon --avatar --custom-icon">
- <img src={{@channel.iconUploadUrl}} />
- </span>
- {{else if this.groupDirectMessage}}
- <span
- class={{concatClass
- "chat-channel-icon"
- (unless @channel.emoji "--users-count")
- }}
- >
- {{this.directChannelIcon}}
- </span>
- {{else}}
- <div class="chat-channel-icon --avatar">
- <ChatUserAvatar @user={{this.firstUser}} @interactive={{false}} />
- </div>
- {{/if}}
- </div>
- {{else if @channel.isCategoryChannel}}
- <div class="chat-channel-icon">
- <span
- class="chat-channel-icon --category-badge"
- style={{this.channelColorStyle}}
+ {{#if @channel.iconUploadUrl}}
+ <div class="chat-channel-icon --avatar --custom-icon">
+ <img src={{@channel.iconUploadUrl}} />
+ </div>
+ {{else if this.groupDirectMessage}}
+ <div
+ class={{concatClass
+ "chat-channel-icon"
+ (unless @channel.emoji "--users-count" "--emoji")
+ }}
>
- {{this.categoryChannelIcon}}
- {{#if @channel.chatable.read_restricted}}
- {{icon "lock" class="chat-channel-icon__restricted-category-icon"}}
- {{/if}}
- </span>
+ {{this.directChannelIcon}}
+ </div>
+ {{else}}
+ <div class="chat-channel-icon --avatar">
+ <ChatUserAvatar @user={{this.firstUser}} @interactive={{false}} />
+ </div>
+ {{/if}}
+ {{else if @channel.isCategoryChannel}}
+ <div class="chat-channel-icon --icon" style={{this.channelColorStyle}}>
+ {{this.categoryChannelIcon}}
+ {{#if @channel.chatable.read_restricted}}
+ {{icon "lock" class="chat-channel-icon__restricted-category-icon"}}
+ {{/if}}
</div>
{{else if this.isThreadsList}}
- <div class="chat-channel-icon">
- <div class="chat-channel-icon --avatar">
- <ChatUserAvatar
- @user={{@thread.preview.lastReplyUser}}
- @interactive={{true}}
- @showPresence={{false}}
- />
- <div class="avatar-flair --threads">
- {{icon "discourse-threads"}}
- </div>
+ <div class="chat-channel-icon --avatar">
+ <ChatUserAvatar
+ @user={{@thread.preview.lastReplyUser}}
+ @interactive={{true}}
+ @showPresence={{false}}
+ />
+ <div class="avatar-flair --threads">
+ {{icon "discourse-threads"}}
</div>
</div>
{{/if}}
diff --git a/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss b/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss
index 995bdb1b675..6553aa70314 100644
--- a/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-channel-icon.scss
@@ -1,5 +1,23 @@
+@use "lib/viewport";
+
.chat-channel-icon {
flex-shrink: 0;
+ color: var(--primary-medium);
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ font-size: var(--font-up-1);
+ position: relative;
+
+ .--starred-channels & {
+ width: var(--channel-list-avatar-size);
+ height: var(--channel-list-avatar-size);
+ }
+
+ .chat-message-creator & {
+ justify-content: center;
+ width: 24px;
+ }
&.--users-count {
display: flex;
@@ -20,10 +38,19 @@
}
}
- img.emoji {
- .chat-channel-row .is-dm & {
- width: var(--channel-list-avatar-size);
- height: var(--channel-list-avatar-size);
+ &.--emoji,
+ &.--icon {
+ .--starred-channels & {
+ @include viewport.until(sm) {
+ background: var(--primary-low);
+ border-radius: 100%;
+ }
+
+ .emoji,
+ .d-icon:not(.chat-channel-icon__restricted-category-icon) {
+ width: calc(var(--channel-list-avatar-size) * 0.5);
+ height: calc(var(--channel-list-avatar-size) * 0.5);
+ }
}
}
@@ -42,18 +69,6 @@
border-radius: 50%;
}
- &.--category-badge {
- color: var(--primary-medium);
- display: flex;
- font-size: var(--font-up-1);
- position: relative;
-
- .chat-message-creator & {
- justify-content: center;
- width: 24px;
- }
- }
-
&__restricted-category-icon {
background-color: var(--secondary);
position: absolute;
@@ -64,5 +79,13 @@
width: 0.5rem;
right: -0.5rem;
top: -0.1rem;
+
+ @include viewport.until(sm) {
+ .--starred-channels & {
+ width: calc(var(--channel-list-avatar-size) * 0.25);
+ height: calc(var(--channel-list-avatar-size) * 0.25);
+ right: -0.25rem;
+ }
+ }
}
}
diff --git a/plugins/chat/assets/stylesheets/mobile/chat-channel-row.scss b/plugins/chat/assets/stylesheets/mobile/chat-channel-row.scss
index b706e57f9db..895272b9ad8 100644
--- a/plugins/chat/assets/stylesheets/mobile/chat-channel-row.scss
+++ b/plugins/chat/assets/stylesheets/mobile/chat-channel-row.scss
@@ -31,7 +31,7 @@
transition: border-radius 0.25s ease-in-out;
// for sliding delete animation
- background: var(--primary-very-low);
+ background: var(--secondary);
height: 100%;
&.-animate-reset {
diff --git a/plugins/chat/assets/stylesheets/mobile/chat-index.scss b/plugins/chat/assets/stylesheets/mobile/chat-index.scss
index dbfce18c04b..42f85df0898 100644
--- a/plugins/chat/assets/stylesheets/mobile/chat-index.scss
+++ b/plugins/chat/assets/stylesheets/mobile/chat-index.scss
@@ -16,7 +16,6 @@
.c-routes.--direct-messages,
.c-routes.--channels,
.c-routes.--threads {
- background: var(--primary-very-low);
max-width: 100vw;
}
diff --git a/plugins/chat/test/javascripts/components/channel-icon-test.gjs b/plugins/chat/test/javascripts/components/channel-icon-test.gjs
index a47eb585429..efbded84f60 100644
--- a/plugins/chat/test/javascripts/components/channel-icon-test.gjs
+++ b/plugins/chat/test/javascripts/components/channel-icon-test.gjs
@@ -16,7 +16,7 @@ module("Discourse Chat | Component | <ChannelIcon />", function (hooks) {
await render(<template><ChannelIcon @channel={{channel}} /></template>);
assert
- .dom(".chat-channel-icon.--category-badge")
+ .dom(".chat-channel-icon.--icon")
.hasAttribute("style", `color: #${channel.chatable.color}`);
});
diff --git a/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs b/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs
index d5cbd4288cc..367f4c96fcb 100644
--- a/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs
+++ b/plugins/chat/test/javascripts/components/chat-channel-preview-card-test.gjs
@@ -37,7 +37,7 @@ module(
.hasText(this.channel.title, "shows the channel title");
assert
- .dom(".chat-channel-icon.--category-badge")
+ .dom(".chat-channel-icon.--icon")
.exists("shows the category hashtag badge");
});