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.

search pills: Use grid to support pill overflow styling.

evykassirera39fe910d897
diff --git a/web/src/search.ts b/web/src/search.ts
index 190c604f13c..1093537c662 100644
--- a/web/src/search.ts
+++ b/web/src/search.ts
@@ -64,6 +64,14 @@ export function initialize({on_narrow_search}: {on_narrow_search: OnNarrowSearch
const $searchbox_form = $("#searchbox_form");
const $pill_container = $("#searchbox-input-container.pill-container");
+ $(".search-input-and-pills").on("focusin", () => {
+ $("#searchbox-input-container").toggleClass("focused", true);
+ });
+
+ $(".search-input-and-pills").on("focusout", () => {
+ $("#searchbox-input-container").toggleClass("focused", false);
+ });
+
search_pill_widget = search_pill.create_pills($pill_container);
search_pill_widget.onPillRemove(() => {
search_input_has_changed = true;
@@ -195,7 +203,7 @@ export function initialize({on_narrow_search}: {on_narrow_search: OnNarrowSearch
// when an option is selected and we're closing search).
// Instead we explicitly initiate search on click and on specific keyboard
// shortcuts.
- $search_query_box.on("click", (): void => {
+ $("#searchbox-input-container").on("click", (): void => {
if ($("#searchbox .navbar-search.expanded").length === 0) {
initiate_search();
}
diff --git a/web/styles/search.css b/web/styles/search.css
index 1a07d2cc03e..fa9762cdd86 100644
--- a/web/styles/search.css
+++ b/web/styles/search.css
@@ -3,12 +3,15 @@
height: var(--header-height);
.navbar-search {
- margin: 5.5px 0;
+ margin: 3.5px 0;
border-radius: 5px;
position: absolute;
+ overflow: hidden;
}
.search_icon {
+ grid-area: search-icon;
+ align-self: center;
text-decoration: none;
padding: 0 7px;
font-size: 17px;
@@ -29,6 +32,7 @@
}
.search_close_button {
+ grid-area: search-close;
width: 28px;
height: 100%;
background: none;
@@ -61,6 +65,15 @@
font-size: 10px;
}
+ .search-input-and-pills {
+ grid-area: search-pills;
+ display: flex;
+ padding: 3px 0;
+ flex-wrap: wrap;
+ gap: 2px 2px;
+ align-self: center;
+ }
+
.navbar-search:not(.expanded) {
right: 0;
@@ -75,9 +88,7 @@
.search-input {
border-radius: 5px;
color: var(--color-text-search);
-
box-shadow: none;
- cursor: pointer;
}
&:hover {
@@ -113,6 +124,10 @@
0 4px 20px var(--color-search-shadow-wide),
0 1px 5px var(--color-search-shadow-tight);
+ .search-input {
+ cursor: text;
+ }
+
@media (width < $md_min) {
/* 3px chosen so that the cursor clicks the search button
and close button from the same position. */
@@ -173,9 +188,6 @@
border-radius: 0;
font-family: "Source Sans 3 VF", sans-serif;
font-weight: 400;
- height: var(--search-box-height);
- /* override bootstrap min-height for input[type="text"] */
- min-height: var(--search-box-height);
background: transparent;
text-overflow: ellipsis;
overflow: hidden;
@@ -194,36 +206,31 @@
}
#searchbox-input-container {
- display: flex;
- align-items: center;
+ display: grid;
/* The next two styles override .input-append style from app_components.js */
letter-spacing: normal;
font-size: 100%;
- height: var(--search-box-height);
- /* Override styles for .pill-container that aren't relevant for search. */
- flex-wrap: nowrap;
- padding: 0;
+ /* Override style for .pill-container that isn't relevant for search. */
border: none;
+ grid-template:
+ "search-icon search-pills search-close" var(--search-box-height)
+ ". search-pills ." auto / auto minmax(0, 1fr) auto;
+ align-items: start;
+ cursor: pointer;
- .user-pill-container {
- padding: 2px;
- height: 22px;
- min-width: fit-content;
-
- > .pill-label {
- min-width: fit-content;
- white-space: nowrap;
- width: fit-content;
- }
+ /* Override styles for .pill-container that aren't relevant for search. */
+ .pill {
+ margin: 0;
+ min-width: unset;
+ }
- .pill {
- height: 22px;
- margin: 2px;
- }
+ &:not(.focused) {
+ max-height: var(--search-box-height);
+ overflow: hidden;
- .pill-image {
- width: 22px;
- height: 22px;
+ .search-input-and-pills {
+ flex-wrap: nowrap;
+ overflow: hidden;
}
}
}
diff --git a/web/templates/navbar.hbs b/web/templates/navbar.hbs
index d5ab77b678e..793004958c1 100644
--- a/web/templates/navbar.hbs
+++ b/web/templates/navbar.hbs
@@ -24,8 +24,10 @@
<form id="searchbox_form" class="navbar-search">
<div id="searchbox-input-container" class="input-append pill-container">
<i class="search_icon zulip-icon zulip-icon-search"></i>
- <div class="search-input input input-block-level home-page-input" id="search_query" type="text" data-placeholder-text="{{t 'Search' }}"
- autocomplete="off" contenteditable="true"></div>
+ <div class="search-input-and-pills">
+ <div class="search-input input input-block-level home-page-input" id="search_query" type="text" data-placeholder-text="{{t 'Search' }}"
+ autocomplete="off" contenteditable="true"></div>
+ </div>
<button class="search_close_button tippy-zulip-delayed-tooltip" type="button" id="search_exit" aria-label="{{t 'Exit search' }}" data-tippy-content="Close"><i class="zulip-icon zulip-icon-close" aria-hidden="true"></i></button>
</div>
</form>