dropdown_list_widget: Colorize stream privacy icons.

This commit adds code to colorize the stream privacy icons in
dropdown list widget. Both the selected option in button and
options in the menu are colorized as per the stream color.

Fixes #25282.
This commit is contained in:
Sahil Batra 2023-04-26 21:18:20 +05:30 committed by Tim Abbott
parent b8a6de95d2
commit 9ec3608569
4 changed files with 7 additions and 7 deletions

View File

@ -68,7 +68,7 @@ export class DropdownListWidget {
if (item.stream !== undefined) {
const stream = item.stream;
const rendered_stream_name_with_privacy_symbol_html =
render_inline_decorated_stream_name({stream});
render_inline_decorated_stream_name({stream, show_colored_icon: true});
$elem.html(rendered_stream_name_with_privacy_symbol_html);
} else {
const text = this.render_text(item.name);

View File

@ -1,8 +1,8 @@
{{! This controls whether the swatch next to streams in the left sidebar has a lock icon. }}
{{#if stream.invite_only }}
<i class="zulip-icon zulip-icon-lock stream-privacy-type-icon" aria-hidden="true"></i> {{stream.name ~}}
<i class="zulip-icon zulip-icon-lock stream-privacy-type-icon" {{#if show_colored_icon}}style="color: {{stream.color}}"{{/if}} aria-hidden="true"></i> {{stream.name ~}}
{{ else if stream.is_web_public }}
<i class="zulip-icon zulip-icon-globe stream-privacy-type-icon" aria-hidden="true"></i> {{stream.name ~}}
<i class="zulip-icon zulip-icon-globe stream-privacy-type-icon" {{#if show_colored_icon}}style="color: {{stream.color}}"{{/if}} aria-hidden="true"></i> {{stream.name ~}}
{{ else }}
<i class="zulip-icon zulip-icon-hashtag stream-privacy-type-icon"></i> {{stream.name ~}}
<i class="zulip-icon zulip-icon-hashtag stream-privacy-type-icon" {{#if show_colored_icon}}style="color: {{stream.color}}"{{/if}}></i> {{stream.name ~}}
{{/if}}

View File

@ -2,7 +2,7 @@
<li class="list_item" role="presentation" data-value="{{value}}">
<a role="menuitem" tabindex="0">
{{#if stream}}
{{> ../inline_decorated_stream_name stream=stream}}
{{> ../inline_decorated_stream_name stream=stream show_colored_icon=true}}
{{else}}
{{name}}
{{/if}}

View File

@ -842,8 +842,8 @@ test("misc", ({override_rewire, mock_template}) => {
assert.ok(!$("#user-avatar-upload-widget .image_upload_button").hasClass("hide"));
override_rewire(stream_settings_data, "get_streams_for_settings_page", () => [
{name: "some_stream", stream_id: 75, invite_only: true},
{name: "some_stream", stream_id: 42},
{name: "some_stream", stream_id: 75, invite_only: true, color: "red"},
{name: "some_stream", stream_id: 42, color: "blue"},
]);
// Set stubs for dropdown_list_widget: