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,7 +17,10 @@ ...@@ -17,7 +17,10 @@
color: $gray-light; color: $gray-light;
} }
input.simple-search-input { @at-root {
$expanded-max-width: 150px;
.simple-search-input {
flex-grow: 1; flex-grow: 1;
order: 1; order: 1;
...@@ -26,8 +29,20 @@ input.simple-search-input { ...@@ -26,8 +29,20 @@ input.simple-search-input {
outline: none; outline: none;
padding: 0; padding: 0;
max-width: 0px;
transition: max-width .3s ease-out;
&:disabled { &:disabled {
background: none; background: none;
color: $gray-light; 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