Commit f15a78c0 authored by Robert Knight's avatar Robert Knight

Implement new design for search status bar

This provides a clearer design for the search status
button.

The new design is part of the groups roll-out and
is only shown when the groups feature is enabled.

T-93
parent cd2af8f3
// @ngInject
module.exports = function () { module.exports = function () {
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
/** Specifies whether to use the new design that is part of
* the groups roll-out.
* See https://trello.com/c/GxVkM1eN/
*/
newDesign: '=',
filterActive: '=', filterActive: '=',
filterMatchCount: '=', filterMatchCount: '=',
onClearSelection: '&', onClearSelection: '&',
......
...@@ -13,18 +13,39 @@ describe('searchStatusBar', function () { ...@@ -13,18 +13,39 @@ describe('searchStatusBar', function () {
angular.mock.module('h.templates'); angular.mock.module('h.templates');
}); });
it('should display the filter count', function () { describe('old design', function () {
var elem = util.createDirective(document, 'searchStatusBar', { it('should display the filter count', function () {
filterActive: true, var elem = util.createDirective(document, 'searchStatusBar', {
filterMatchCount: 5 filterActive: true,
filterMatchCount: 5
});
assert.include($(elem).text(), "Found 5 results");
});
it('should display the selection count', function () {
var elem = util.createDirective(document, 'searchStatusBar', {
selectionCount: 1
});
assert.include($(elem).text(), 'Showing 1 selected annotation');
}); });
assert.include($(elem).text(), "Found 5 results");
}); });
it('should display the selection count', function () { describe('new design', function () {
var elem = util.createDirective(document, 'searchStatusBar', { it('should display the filter count', function () {
selectionCount: 1 var elem = util.createDirective(document, 'searchStatusBar', {
newDesign: true,
filterActive: true,
filterMatchCount: 5
});
assert.include($(elem).text(), "5 search results");
});
it('should display the selection count', function () {
var elem = util.createDirective(document, 'searchStatusBar', {
newDesign: true,
selectionCount: 2
});
assert.include($(elem).text(), '2 selected annotations');
}); });
assert.include($(elem).text(), 'Showing 1 selected annotation');
}); });
}); });
...@@ -12,6 +12,7 @@ $base-line-height: 20px; ...@@ -12,6 +12,7 @@ $base-line-height: 20px;
@import './primary-action-btn'; @import './primary-action-btn';
@import './dropdown-menu-btn'; @import './dropdown-menu-btn';
@import './publish-annotation-btn'; @import './publish-annotation-btn';
@import './search-status-bar';
@import './share-link'; @import './share-link';
body { body {
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
font-weight: bold; font-weight: bold;
font-size: $body1-font-size; font-size: $body1-font-size;
padding-left: 12px;
padding-right: 12px;
&:disabled { &:disabled {
color: $gray-light; color: $gray-light;
} }
...@@ -20,3 +23,16 @@ ...@@ -20,3 +23,16 @@
background-color: $color-mine-shaft; background-color: $color-mine-shaft;
} }
} }
.primary-action-btn--short {
height: 30px;
}
.primary-action-btn__icon {
color: $color-silver-chalice;
display: inline-block;
font-weight: bold;
margin-left: -3px;
margin-right: 3px;
transform: translateY(1px);
}
.search-status-bar {
margin-bottom: 10px;
}
.search-status-bar > button {
margin-right: 10px;
}
<li ng-show="filterActive"> <div ng-if="newDesign" class="search-status-bar" ng-show="filterActive">
<button class="primary-action-btn primary-action-btn--short"
ng-click="onClearSelection()"
title="Clear the search filter and show all annotations"
>
<i class="primary-action-btn__icon h-icon-close"></i> Clear search
</button>
<span ng-pluralize
count="filterMatchCount"
when="{'0': 'No results for “{{searchQuery}}”',
'one': '1 search result',
'other': '{} search results'}"></span>
</div>
<div ng-if="newDesign" class="search-status-bar" ng-show="!filterActive && selectionCount > 0">
<button class="primary-action-btn primary-action-btn--short"
ng-click="onClearSelection()"
title="Clear the selection and show all annotations"
>
<i class="primary-action-btn__icon h-icon-close"></i> Clear selection
</button>
<span ng-pluralize
count="selectionCount"
when="{'0': 'No annotations selected',
'one': '1 selected annotation',
'other': '{} selected annotations'}"></span>
</div>
<div ng-if="!newDesign" class="search-status-bar" ng-show="filterActive">
<span ng-pluralize <span ng-pluralize
count="filterMatchCount" count="filterMatchCount"
when="{'0': 'No results for “{{searchQuery}}”.', when="{'0': 'No results for “{{searchQuery}}”.',
'one': 'Found one result.', 'one': 'Found one result.',
'other': 'Found {} results.'}"></span> 'other': 'Found {} results.'}"></span>
<a href="" ng-click="onClearSelection()">Clear search</a>. <a href="" ng-click="onClearSelection()">Clear search</a>.
</li> </div>
<li ng-show="!filterActive && selectionCount > 0"> <div ng-if="!newDesign" class="search-status-bar"
ng-show="!filterActive && selectionCount > 0">
<span ng-pluralize <span ng-pluralize
count="selectionCount" count="selectionCount"
when="{'0': 'No annotations selected.', when="{'0': 'No annotations selected.',
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
thread-filter="search.query" thread-filter="search.query"
window-scroll="loadMore(20)"> window-scroll="loadMore(20)">
<search-status-bar <search-status-bar
new-design="feature('groups')"
filter-active="threadFilter.active()" filter-active="threadFilter.active()"
filter-match-count="count('match')" filter-match-count="count('match')"
search-query="search ? search.query : ''" search-query="search ? search.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