Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Experiment with adjusted privacy icon colors.

Karl Stolleye0860a763551
diff --git a/web/src/compose_recipient.ts b/web/src/compose_recipient.ts
index d31470e25ec..89a839ce47f 100644
--- a/web/src/compose_recipient.ts
+++ b/web/src/compose_recipient.ts
@@ -20,6 +20,7 @@ import type {DropdownWidget, Option} from "./dropdown_widget.ts";
import {$t} from "./i18n.ts";
import * as narrow_state from "./narrow_state.ts";
import {realm} from "./state_data.ts";
+import * as stream_color from "./stream_color.ts";
import * as stream_data from "./stream_data.ts";
import * as ui_util from "./ui_util.ts";
import * as user_groups from "./user_groups.ts";
@@ -46,6 +47,16 @@ function composing_to_current_private_message_narrow(): boolean {
}
export let maybe_mute_recipient_row = (): void => {
+ // We need to adjust the privacy-icon colors in the muted state
+ const message_type = compose_state.get_message_type();
+ if (message_type === "stream") {
+ const stream_id = compose_state.stream_id();
+ const channel_picker_icon_selector =
+ "#compose_select_recipient_widget .channel-privacy-type-icon";
+
+ stream_color.adjust_stream_privacy_icon_colors(stream_id, channel_picker_icon_selector);
+ }
+
// We're piggy-backing here, in a roundabout way, on
// compose_ui.set_focus(). Any time the topic or recipient
// row is focused, that puts us outside the muted
diff --git a/web/src/stream_color.ts b/web/src/stream_color.ts
index 2a4029ec165..b448065c35c 100644
--- a/web/src/stream_color.ts
+++ b/web/src/stream_color.ts
@@ -2,6 +2,7 @@ import type {Colord} from "colord";
import {colord, extend} from "colord";
import lchPlugin from "colord/plugins/lch";
import mixPlugin from "colord/plugins/mix";
+import assert from "minimalistic-assert";
import * as settings_data from "./settings_data.ts";
import * as stream_data from "./stream_data.ts";
@@ -42,12 +43,23 @@ export function get_corrected_color(hex_color: string): Colord {
return colord(color);
}
-export function get_stream_privacy_icon_color(hex_color: string): string {
+export function get_stream_privacy_icon_color(
+ hex_color: string,
+ return_light_and_dark = false,
+): string {
const corrected_color = get_corrected_color(hex_color);
+ const corrected_color_light = corrected_color.darken(0.12).toHex();
+ const corrected_color_dark = corrected_color.toHex();
+
+ if (return_light_and_dark) {
+ return `${corrected_color_light}, ${corrected_color_dark}`;
+ }
+
if (settings_data.using_dark_theme()) {
- return corrected_color.toHex();
+ return corrected_color_dark;
}
- return corrected_color.darken(0.12).toHex();
+
+ return corrected_color_light;
}
export function get_recipient_bar_color(color: string): string {
@@ -59,6 +71,35 @@ export function get_recipient_bar_color(color: string): string {
.toHex();
}
+export function adjust_stream_privacy_icon_colors(
+ stream_id: number | undefined,
+ icon_selector: string,
+): void {
+ if (stream_id !== undefined) {
+ const privacy_icon_color = stream_data.get_sub_by_id(stream_id)?.color;
+
+ assert(privacy_icon_color);
+ const privacy_icon_colors_modified = get_stream_privacy_icon_color(
+ privacy_icon_color,
+ true,
+ );
+
+ // We set a couple of CSS variables on the privacy icon, and let the
+ // stylesheets decide when and how to use them. This gives us the
+ // ability to present different colors based on the presence or
+ // absence of containing classes, etc. as well as handle hover states,
+ // which would be otherwise impossible by specifying `color:` directly
+ // in the `style` attribute in HTML.
+ const original_color_css_variable = `--privacy-icon-color-original: ${privacy_icon_color};`;
+ const modified_colors_css_variable = `--privacy-icon-color-modified: light-dark(${privacy_icon_colors_modified});`;
+
+ const stream_privacy_icon = document.querySelector<HTMLElement>(icon_selector);
+
+ assert(stream_privacy_icon);
+ stream_privacy_icon.style.cssText = `${original_color_css_variable}${modified_colors_css_variable}`;
+ }
+}
+
export const stream_color_palette = [
["#a47462", "#c2726a", "#e4523d", "#e7664d", "#ee7e4a", "#f4ae55"],
["#76ce90", "#53a063", "#94c849", "#bfd56f", "#fae589", "#f5ce6e"],
diff --git a/web/styles/compose.css b/web/styles/compose.css
index aac050607b9..7418eeb7750 100644
--- a/web/styles/compose.css
+++ b/web/styles/compose.css
@@ -1238,6 +1238,14 @@ textarea.new_message_textarea {
transition-property: background-color, border-color;
}
+ #compose_select_recipient_widget .channel-privacy-type-icon {
+ transition: var(--compose-muted-recipient-row-transition);
+ transition-delay: var(
+ --compose-muted-recipient-row-transition-delay
+ );
+ transition-property: color;
+ }
+
#recipient_box_clear_topic_button {
transition: var(--compose-muted-recipient-row-transition);
transition-delay: var(
@@ -1319,13 +1327,27 @@ textarea.new_message_textarea {
}
}
- #compose_select_recipient_widget.widget-open {
- background-color: var(--color-background-dropdown-widget-button);
- border-color: var(--color-compose-recipient-box-border-color);
+ #compose_select_recipient_widget {
+ .channel-privacy-type-icon.zulip-icon {
+ color: var(--privacy-icon-color-modified);
+ }
- .decorated-channel-name,
- .zulip-icon-chevron-down {
- opacity: 1;
+ &:hover .channel-privacy-type-icon.zulip-icon {
+ color: var(--privacy-icon-color-original);
+ }
+
+ &.widget-open {
+ background-color: var(--color-background-dropdown-widget-button);
+ border-color: var(--color-compose-recipient-box-border-color);
+
+ .channel-privacy-type-icon {
+ color: var(--privacy-icon-color-original);
+ }
+
+ .decorated-channel-name,
+ .zulip-icon-chevron-down {
+ opacity: 1;
+ }
}
}
}
@@ -1688,6 +1710,7 @@ textarea.new_message_textarea {
place-self: center;
font-size: 0.95em; /* 19px at 20px/1em */
margin-top: -0.0579em; /* Eyeball work; 1.1px at 19px/1em */
+ color: var(--privacy-icon-color-original);
/* Eliminate inherited component styles. */
position: static;
padding: 0;