Commit 648dd657 authored by Robert Knight's avatar Robert Knight

Collapse the search input when the search query is empty

When the new top-bar design is enabled,
collapse the search input unless the field is hovered,
focused or there is an active search query.

In the legacy top-bar design, the search field remains
expanded all the time

T-90
parent d1ebd263
...@@ -27,6 +27,11 @@ module.exports = ['$http', '$parse', ($http, $parse) -> ...@@ -27,6 +27,11 @@ module.exports = ['$http', '$parse', ($http, $parse) ->
restrict: 'E' restrict: 'E'
scope: scope:
# Specifies whether the search input field should always be expanded,
# regardless of whether the it is focused or has an active query.
#
# If false, it is only expanded when focused or when 'query' is non-empty
alwaysExpanded: '='
query: '=' query: '='
onSearch: '&' onSearch: '&'
onClear: '&' onClear: '&'
...@@ -34,7 +39,8 @@ module.exports = ['$http', '$parse', ($http, $parse) -> ...@@ -34,7 +39,8 @@ module.exports = ['$http', '$parse', ($http, $parse) ->
<form class="simple-search-form" ng-class="!searchtext && 'simple-search-inactive'" name="searchBox" ng-submit="search($event)"> <form class="simple-search-form" ng-class="!searchtext && 'simple-search-inactive'" name="searchBox" ng-submit="search($event)">
<input class="simple-search-input" type="text" ng-model="searchtext" name="searchText" <input class="simple-search-input" type="text" ng-model="searchtext" name="searchText"
placeholder="{{loading && 'Loading' || 'Search'}}…" placeholder="{{loading && 'Loading' || 'Search'}}…"
ng-disabled="loading" /> ng-disabled="loading"
ng-class="(alwaysExpanded || searchtext.length > 0) ? 'is-expanded' : ''"/>
<button class="simple-search-icon btn btn-clean" ng-hide="loading"> <button class="simple-search-icon btn btn-clean" ng-hide="loading">
<i class="h-icon-search btn-icon"></i> <i class="h-icon-search btn-icon"></i>
</button> </button>
......
...@@ -17,17 +17,32 @@ ...@@ -17,17 +17,32 @@
color: $gray-light; color: $gray-light;
} }
input.simple-search-input { @at-root {
flex-grow: 1; $expanded-max-width: 150px;
order: 1;
.simple-search-input {
color: $text-color; flex-grow: 1;
border: none; order: 1;
outline: none;
padding: 0; color: $text-color;
border: none;
&:disabled { outline: none;
background: none; padding: 0;
color: $gray-light;
max-width: 0px;
transition: max-width .3s ease-out;
&:disabled {
background: none;
color: $gray-light;
}
&:focus,&.is-expanded {
max-width: $expanded-max-width;
}
}
.simple-search-form:hover .simple-search-input {
max-width: $expanded-max-width;
} }
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
display: flex; display: flex;
flex-flow: row nowrap; flex-flow: row nowrap;
align-items: center; align-items: center;
justify-content: space-between; justify-content: flex-end;
padding-left: $h-padding; padding-left: $h-padding;
padding-right: $h-padding; padding-right: $h-padding;
...@@ -29,14 +29,14 @@ ...@@ -29,14 +29,14 @@
height: 28px; height: 28px;
} }
.top-bar__inner .simple-search { .top-bar__inner .group-list {
flex-grow: 1;
margin-right: .75em; margin-right: .75em;
overflow: hidden;
} }
.top-bar__inner .group-list { // an expander which adds spacing between the groups list
margin-right: .75em; // and the toolbar icons (in the new top-bar design)
.top-bar__expander {
flex-grow: 1;
} }
.top-bar__btn { .top-bar__btn {
......
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
<simple-search class="simple-search" <simple-search class="simple-search"
query="searchController.query" query="searchController.query"
on-search="searchController.update(query)" on-search="searchController.update(query)"
on-clear="searchController.clear()"></simple-search> on-clear="searchController.clear()"
always-expanded="true"></simple-search>
<div class="top-bar__expander"></div>
<group-list class="group-list" ng-if="groupsEnabled"> <group-list class="group-list" ng-if="groupsEnabled">
</group-list> </group-list>
...@@ -41,6 +44,7 @@ ...@@ -41,6 +44,7 @@
<div class="top-bar__inner content" ng-if="groupsEnabled"> <div class="top-bar__inner content" ng-if="groupsEnabled">
<group-list class="group-list"> <group-list class="group-list">
</group-list> </group-list>
<div class="top-bar__expander"></div>
<simple-search class="simple-search" <simple-search class="simple-search"
query="searchController.query" query="searchController.query"
on-search="searchController.update(query)" on-search="searchController.update(query)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment