Skip to content

Commit

Permalink
Add examples in docs for sidebar trigger and annotation count display.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheetal Umesh Kumar committed Feb 8, 2017
1 parent 07a12c1 commit 5cb22b4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
38 changes: 38 additions & 0 deletions docs/host-page-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Interacting with the sidebar

## Show the sidebar:

If you need to have a custom trigger on your third party page to bring up the embedded Hypothesis
sidebar, add the `data-hypothesis-trigger` attribute to the element that you want to enable.
Clicking that element will cause the sidebar to open.
Note, however, subsequent clicks do not hide the sidebar.

Example:

To add a `button` on a page to open the sidebar, simply
add the `data-hypothesis-trigger` attribute.

```html
<button data-hypothesis-trigger>
Open sidebar
</button>
```

## Show the public annotation count:

If you need to show the total number of public annotations, page notes and orphaned annotations
on your third party page where the Hypothesis sidebar is embedded, add the `data-hypothesis-annotation-count`
attribute to the element that you want to enable.
The contents of the enabled element will be replaced with the count of public annotations and if there are no
public annotations, with 0.

Example:

To display the annotation count in a `div` element, simply
add the `data-hypothesis-annotation-count` attribute to the `div`:

```html
<div data-hypothesis-annotation-count>
Annotation count will appear here
</div>
```
3 changes: 1 addition & 2 deletions src/sidebar/test/annotation-metadata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ describe('annotation-metadata', function () {
}]);

it('returns false if an annotation is missing permissions', function () {
var annotation = Object.assign(fixtures.defaultAnnotation());
assert.isFalse(annotationMetadata.isPublic(annotation));
assert.isFalse(annotationMetadata.isPublic(fixtures.defaultAnnotation()));
});
});

Expand Down

0 comments on commit 5cb22b4

Please sign in to comment.