Commit 32e7f102 authored by Robert Knight's avatar Robert Knight

Reduce contrast and color of hidden annotations

Provide additional visual cues to indicate that annotations have been
hidden by striking through their text and applying a greyscale and
contrast filter.

See https://github.com/hypothesis/product-backlog/issues/183 for
designs.
parent 7112851f
...@@ -505,6 +505,10 @@ function AnnotationController( ...@@ -505,6 +505,10 @@ function AnnotationController(
return streamer.hasPendingDeletion(vm.annotation.id); return streamer.hasPendingDeletion(vm.annotation.id);
}; };
vm.isHiddenByModerator = function () {
return annotationUI.isHiddenByModerator(vm.annotation.id);
};
vm.isReply = function () { vm.isReply = function () {
return isReply(vm.annotation); return isReply(vm.annotation);
}; };
......
...@@ -84,6 +84,7 @@ describe('annotation', function() { ...@@ -84,6 +84,7 @@ describe('annotation', function() {
var $window; var $window;
var fakeAnalytics; var fakeAnalytics;
var fakeAnnotationMapper; var fakeAnnotationMapper;
var fakeAnnotationUI;
var fakeDrafts; var fakeDrafts;
var fakeFlash; var fakeFlash;
var fakeGroups; var fakeGroups;
...@@ -116,7 +117,12 @@ describe('annotation', function() { ...@@ -116,7 +117,12 @@ describe('annotation', function() {
before(function() { before(function() {
angular.module('h', []) angular.module('h', [])
.component('annotation', annotationComponent()); .component('annotation', annotationComponent())
.component('markdown', {
bindings: {
textClass: '<?',
},
});
}); });
beforeEach(angular.mock.module('h')); beforeEach(angular.mock.module('h'));
...@@ -141,7 +147,9 @@ describe('annotation', function() { ...@@ -141,7 +147,9 @@ describe('annotation', function() {
flagAnnotation: sandbox.stub(), flagAnnotation: sandbox.stub(),
}; };
var fakeAnnotationUI = {}; fakeAnnotationUI = {
isHiddenByModerator: sandbox.stub().returns(false),
};
fakeDrafts = { fakeDrafts = {
update: sandbox.stub(), update: sandbox.stub(),
...@@ -1041,5 +1049,16 @@ describe('annotation', function() { ...@@ -1041,5 +1049,16 @@ describe('annotation', function() {
var el = createDirective(ann).element; var el = createDirective(ann).element;
assert.equal(el[0].querySelector('blockquote').textContent, '<<-&->>'); assert.equal(el[0].querySelector('blockquote').textContent, '<<-&->>');
}); });
it('renders hidden annotations with a custom text class', function () {
var ann = fixtures.defaultAnnotation();
fakeAnnotationUI.isHiddenByModerator.returns(true);
var el = createDirective(ann).element;
assert.deepEqual(el.find('markdown').controller('markdown'), {
textClass: {
'annotation-body is-hidden': true,
},
});
});
}); });
}); });
...@@ -167,6 +167,7 @@ module.exports = function($sanitize) { ...@@ -167,6 +167,7 @@ module.exports = function($sanitize) {
scope: { scope: {
readOnly: '<', readOnly: '<',
text: '<?', text: '<?',
textClass: '<?',
onEditText: '&', onEditText: '&',
}, },
template: require('../templates/markdown.html'), template: require('../templates/markdown.html'),
......
...@@ -250,4 +250,15 @@ describe('markdown', function () { ...@@ -250,4 +250,15 @@ describe('markdown', function () {
assert.isFalse(isPreviewing()); assert.isFalse(isPreviewing());
}); });
}); });
describe('custom text class', function () {
it('should apply custom text class to text container', function () {
var editor = util.createDirective(document, 'markdown', {
readOnly: true,
textClass: 'fancy-effect',
});
var viewEl = viewElement(editor);
assert.include(viewEl.className, 'fancy-effect');
});
});
}); });
...@@ -82,8 +82,9 @@ ...@@ -82,8 +82,9 @@
overflow-hysteresis="20" overflow-hysteresis="20"
content-data="vm.state().text"> content-data="vm.state().text">
<markdown text="vm.state().text" <markdown text="vm.state().text"
on-edit-text="vm.setText(text)" text-class="{'annotation-body is-hidden':vm.isHiddenByModerator()}"
read-only="!vm.editing()"> on-edit-text="vm.setText(text)"
read-only="!vm.editing()">
</markdown> </markdown>
</excerpt> </excerpt>
</section> </section>
......
...@@ -17,6 +17,6 @@ ...@@ -17,6 +17,6 @@
ng-show="showEditor()" ng-show="showEditor()"
ng-click="$event.stopPropagation()"></textarea> ng-click="$event.stopPropagation()"></textarea>
<div class="markdown-body js-markdown-preview" <div class="markdown-body js-markdown-preview"
ng-class="preview && 'markdown-preview'" ng-class="(preview && 'markdown-preview') || textClass"
ng-dblclick="togglePreview()" ng-dblclick="togglePreview()"
ng-show="!showEditor()"></div> ng-show="!showEditor()"></div>
...@@ -102,6 +102,11 @@ ...@@ -102,6 +102,11 @@
margin-left: 0px; margin-left: 0px;
} }
.annotation-body.is-hidden {
text-decoration: line-through;
filter: grayscale(100%) contrast(65%);
}
// the footer at the bottom of an annotation displaying // the footer at the bottom of an annotation displaying
// the annotation actions and reply counts // the annotation actions and reply counts
.annotation-footer { .annotation-footer {
......
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