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.

inbox: Add icon in search box to clear any text.

Aman Agrawalc2c1f1ac6d7b
diff --git a/web/images/icons/close-small.svg b/web/images/icons/close-small.svg
new file mode 100644
index 00000000000..d98c3fe8a3d
--- /dev/null
+++ b/web/images/icons/close-small.svg
@@ -0,0 +1 @@
+<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'><path fill='black' d='M12.971 3.971a.665.665 0 1 0-.94-.94L8 7.06 3.97 3.03a.665.665 0 1 0-.94.94L7.06 8l-4.03 4.03a.665.665 0 0 0 .94.94L8 8.94l4.03 4.03a.665.665 0 0 0 .94-.94L8.941 8l4.03-4.03Z'/></svg>
\ No newline at end of file
diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js
index 7ebbfec006b..6a4f2d37cf6 100644
--- a/web/src/inbox_ui.js
+++ b/web/src/inbox_ui.js
@@ -1046,4 +1046,10 @@ export function initialize() {
unread_ops.mark_stream_as_read(stream_id);
}
});
+
+ $("body").on("click", "#inbox-clear-search", () => {
+ $("#inbox-search").val("");
+ search_and_update();
+ focus_inbox_search();
+ });
}
diff --git a/web/styles/inbox.css b/web/styles/inbox.css
index 10a291bcbbf..647842720be 100644
--- a/web/styles/inbox.css
+++ b/web/styles/inbox.css
@@ -61,9 +61,49 @@
position: absolute;
top: 23px;
left: 6px;
- color: var(--color-icon-inbox-search);
+ color: var(--color-icons-inbox);
opacity: 0.4;
}
+
+ #inbox-clear-search {
+ border: 1px solid transparent;
+ background: transparent;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border-radius: 2px;
+ cursor: pointer;
+ font-size: 16px;
+ color: var(--color-icons-inbox);
+ opacity: 0.4;
+ transition: all 140ms;
+ padding: 5px;
+ margin: 0;
+ /* = -Width of the button. */
+ margin-right: -28px;
+ position: relative;
+ top: 0;
+ right: 30px;
+
+ &:focus {
+ outline: none;
+ }
+
+ &:hover,
+ &:focus-visible {
+ opacity: 1;
+ background-color: var(--color-background-icon-close-hover);
+ }
+
+ &:active {
+ opacity: 1;
+ transform: scale(0.9);
+ }
+ }
+ }
+
+ #inbox-search:placeholder-shown + #inbox-clear-search {
+ display: none;
}
#inbox-search {
@@ -72,7 +112,7 @@
overflow: hidden;
width: var(--width-inbox-search);
height: var(--height-inbox-search);
- padding-right: 20px;
+ padding-right: 28px;
padding-left: 30px;
font-size: 14px;
font-style: normal;
@@ -83,7 +123,8 @@
color: var(--color-inbox-search-text);
border: 1px solid var(--color-border-inbox-search);
- &:not(:placeholder-shown), &:hover {
+ &:not(:placeholder-shown),
+ &:hover {
background-color: var(--color-background-inbox-search-hover);
border: 1px solid var(--color-border-inbox-search-hover);
}
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index 4c017013bc1..f6489603850 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -255,6 +255,8 @@ body {
--color-background-btn-inbox-selected: hsl(0deg 0% 0% / 5%);
--color-background-btn-inbox-focus: hsl(0deg 0% 80%);
--color-border-inbox: hsl(0deg 0% 84.31%);
+ --color-icons-inbox: hsl(0deg 0% 0%);
+ --color-background-icon-close-hover: hsl(0deg 0% 0% / 5%);
}
%dark-theme {
@@ -348,6 +350,8 @@ body {
--color-background-btn-inbox-selected: hsl(0deg 0% 100% / 5%);
--color-background-btn-inbox-focus: hsl(0deg 0% 20%);
--color-border-inbox: hsl(0deg 0% 0% / 60%);
+ --color-icons-inbox: hsl(0deg 0% 100%);
+ --color-background-icon-close-hover: hsl(0deg 0% 100% / 5%);
}
@media screen {
diff --git a/web/templates/inbox_view/inbox_view.hbs b/web/templates/inbox_view/inbox_view.hbs
index 9575c78d315..5decb2c7a4f 100644
--- a/web/templates/inbox_view/inbox_view.hbs
+++ b/web/templates/inbox_view/inbox_view.hbs
@@ -1,6 +1,9 @@
<div id="inbox-main" class="no-select">
<div class="search_group" id="inbox-filters" role="group">
<input type="text" id="{{INBOX_SEARCH_ID}}" value="{{search_val}}" autocomplete="off" placeholder="{{t 'Filter' }}" />
+ <button id="inbox-clear-search">
+ <i class="zulip-icon zulip-icon-close-small"></i>
+ </button>
<i class="zulip-icon zulip-icon-search-inbox"></i>
<button data-filter="include_muted" id="{{MUTED_FILTER_ID}}" type="button" class="btn btn-default btn-inbox-filter {{#if is_spectator}}fake_disabled_button{{/if}}" role="checkbox" aria-checked="false" tabindex="0">
<i id="inbox_filter_mute_toggle" class="fa fa-square-o"></i>