Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Annotation Feature #1858

Merged
merged 78 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
408f8d7
Basic annoattion structure
ong6 Mar 20, 2022
698e984
Merge branch 'master' of https://github.com/MarkBind/markbind into an…
ong6 Mar 20, 2022
f9d46e2
basic working prototype
ong6 Mar 24, 2022
e2e3a06
Finished main functionality
ong6 Mar 27, 2022
625e7de
remove stuff from pic
ong6 Mar 27, 2022
de8b8e5
Fixed attribute processing
ong6 Mar 28, 2022
64983ac
Merge branch 'master' of https://github.com/MarkBind/markbind into an…
ong6 Mar 28, 2022
4bd1a79
temp changes
ong6 Apr 9, 2022
bb6a884
Merge branch 'master' of https://github.com/MarkBind/markbind into an…
ong6 Apr 9, 2022
9e6b7d4
Merge branch 'master' of https://github.com/MarkBind/markbind into an…
ong6 Apr 9, 2022
9bc3b05
temp change
ong6 Apr 10, 2022
4851c35
MVP for annotatepoint
ong6 Apr 11, 2022
edbf28e
removing temp files
ong6 Apr 11, 2022
b5bc052
added more attributes to annotatepoint
ong6 Apr 11, 2022
54eb6e2
refactoring work
ong6 Apr 11, 2022
39111c9
removed arrow implementation
ong6 Apr 11, 2022
0bef7b7
Bux fixes and updates
ong6 Apr 14, 2022
0e1becb
Fixed bugs and added more control
ong6 Apr 14, 2022
c3bb005
Merge branch 'master' of https://github.com/MarkBind/markbind into an…
ong6 Apr 14, 2022
a325d5b
fixed tests
ong6 Apr 14, 2022
4b50877
added more docs
ong6 Apr 14, 2022
c5dc1ca
improve reactivity, added more docs
ong6 Apr 16, 2022
16cf1b3
added more docs
ong6 Apr 16, 2022
34cad98
refactoring changes
ong6 Apr 16, 2022
499d7af
fixed large images not working with positioning
ong6 Apr 16, 2022
e845053
Merge branch 'master' of https://github.com/MarkBind/markbind into an…
ong6 Apr 16, 2022
1945abc
move to images and diagrams
ong6 Apr 17, 2022
3c11436
added sample image
ong6 Apr 17, 2022
ef525b8
update for responsiveness
ong6 Apr 17, 2022
cae447e
doc update
ong6 Apr 17, 2022
4200ea3
more documentation updates
ong6 Apr 17, 2022
6115b90
Update packages/vue-components/src/annotations/AnnotatePoint.vue
ong6 Apr 17, 2022
cfc994c
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
c6ac973
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
ff63ac0
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
4c0df91
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
9367365
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
4f3c686
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
01062f0
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
519771e
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
af880fe
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
5dabba1
Update docs/userGuide/syntax/annotations.md
ong6 Apr 17, 2022
7a18190
fix minor nits
ong6 Apr 17, 2022
ecdfc24
Merge branch 'annotation-feature' of https://github.com/ong6/markbind…
ong6 Apr 17, 2022
32d86ca
Standadize terms
ong6 Apr 17, 2022
aa50a43
fixed minor errors
ong6 Apr 17, 2022
cfe06c6
Added some text explaning the compute image method
ong6 Apr 17, 2022
0826808
fixed borken link
ong6 Apr 17, 2022
9a89c79
Other minor bug fixe
ong6 Apr 17, 2022
a8317d4
more feature improvements
ong6 Apr 18, 2022
6dddc9f
added cli tests
ong6 Apr 18, 2022
f024046
updated docs
ong6 Apr 18, 2022
87de069
fixed doc errors
ong6 Apr 18, 2022
78ea9da
Update docs/userGuide/syntax/annotations.md
ong6 Apr 18, 2022
18325ac
Merge branch 'annotation-feature' of https://github.com/ong6/markbind…
ong6 Apr 18, 2022
a5668a6
add one smaple use case
ong6 Apr 18, 2022
87504fb
Update docs/userGuide/syntax/annotations.md
ong6 Apr 18, 2022
2c3c340
Update docs/userGuide/syntax/annotations.md
ong6 Apr 18, 2022
cc30047
Update docs/userGuide/syntax/annotations.md
ong6 Apr 18, 2022
f278dad
fixed invalid links
ong6 Apr 18, 2022
9860640
Merge branch 'annotation-feature' of https://github.com/ong6/markbind…
ong6 Apr 18, 2022
5b89bfc
fixed examples
ong6 Apr 18, 2022
dacd26e
remove incorrect snapshots
ong6 Apr 18, 2022
11327a1
Update packages/vue-components/src/annotations/Annotate.vue
ong6 Apr 18, 2022
6328d64
Update packages/vue-components/src/annotations/AnnotatePoint.vue
ong6 Apr 18, 2022
a40ed07
remove whitespace
ong6 Apr 18, 2022
9993325
Merge branch 'annotation-feature' of https://github.com/ong6/markbind…
ong6 Apr 18, 2022
b1ea39b
Update docs/userGuide/syntax/annotations.md
ong6 Apr 19, 2022
00cde70
Update docs/userGuide/syntax/annotations.md
ong6 Apr 19, 2022
afd4677
Update docs/userGuide/syntax/annotations.md
ong6 Apr 19, 2022
ee5407c
grammer fix
ong6 Apr 19, 2022
961d966
fixed broken links
ong6 Apr 19, 2022
13ad72a
Update docs/userGuide/syntax/annotations.md
ong6 Apr 19, 2022
c4ac602
Update docs/userGuide/syntax/annotations.md
ong6 Apr 19, 2022
1945cbd
Update docs/userGuide/syntax/annotations.md
ong6 Apr 19, 2022
6e52766
add new trigger examples
ong6 Apr 19, 2022
14fe144
Merge branch 'annotation-feature' of https://github.com/ong6/markbind…
ong6 Apr 19, 2022
dbbb20e
wording
ong6 Apr 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/userGuide/fullSyntaxReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
tooltips : ['Tooltips', ['popups', 'reader-facing']],
popovers : ['Popovers', ['popups', 'reader-facing']],
modals : ['Modals', ['popups', 'reader-facing']],
annotations : ['Annotations', ['popups', 'reader-facing']],
ong6 marked this conversation as resolved.
Show resolved Hide resolved
dropdowns : ['Dropdowns', ['navigation', 'reader-facing']],
searchBars : ['Search Bars', ['navigation', 'reader-facing']],
navBars : ['Nav Bars', ['navigation', 'reader-facing']],
Expand Down
110 changes: 110 additions & 0 deletions docs/userGuide/syntax/annotations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{% from "userGuide/components/advanced.md" import slot_info_trigger %}

## Annotations

Annotation components allows you to easily add annotations over any image.
ong6 marked this conversation as resolved.
Show resolved Hide resolved

### Introduction

Annotation wrappers (`<annotate>`) are used in conjunction with annotation
points (`<a-point>`).

Annotation wrappers are used to hold the image and set the width and height of
said image.
ong6 marked this conversation as resolved.
Show resolved Hide resolved

Annotation points are used to define the position, text and style of each point
ong6 marked this conversation as resolved.
Show resolved Hide resolved
within the image. In use, the annotation points are directly inserted between
ong6 marked this conversation as resolved.
Show resolved Hide resolved
the annotate wrappers (`<annotate>...</annotate>`).
ong6 marked this conversation as resolved.
Show resolved Hide resolved

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">html</variable>
<variable name="code">

<annotate src="https://www.researchgate.net/profile/Chaiwat-Sakul/publication/228949121/figure/fig2/AS:300654661783574@1448693065750/The-previous-square-root-circuit-1.png" width="500">
<!-- Minimal Point -->
<a-point x="25%" y="25%" content="Lorem ipsum dolor sit amet" />
<!-- Customize Point Label (default is empty) -->
<a-point x="50%" y="25%" content="Lorem ipsum dolor sit amet" label="1a"/>
<!-- Customize Point Header (default is empty) -->
<a-point x="75%" y="25%" content="Lorem ipsum dolor sit amet" header="Lorem ipsum"/>
<!-- Customize Point Size (default size is 40px) -->
<a-point x="25%" y="50%" content="Lorem ipsum dolor sit amet" size="60"/>
<!-- Customize Point Color (default color is green) -->
<a-point x="50%" y="50%" content="Lorem ipsum dolor sit amet" color="red"/>
<!-- Customize Point Opacity (default opacity is 0.3) -->
<a-point x="75%" y="50%" content="Lorem ipsum dolor sit amet" opacity="0.7"/>
</annotate>
</variable>
</include>

**Using trigger for Annotate Point** <br>
ong6 marked this conversation as resolved.
Show resolved Hide resolved

Similar to popovers, annotation points also support different types of triggers for users with different needs.

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">html</variable>
<variable name="code">

<annotate src="https://www.researchgate.net/profile/Chaiwat-Sakul/publication/228949121/figure/fig2/AS:300654661783574@1448693065750/The-previous-square-root-circuit-1.png" width="500">
<!-- Default Trigger (click)-->
<a-point x="33%" y="50%" content="Lorem ipsum dolor sit amet" />
<!-- Set Trigger to hover focus -->
<a-point x="66%" y="50%" content="Lorem ipsum dolor sit amet" trigger="hover focus"/>
</annotate>
</variable>
</include>

<br>
ong6 marked this conversation as resolved.
Show resolved Hide resolved

**Displaying content as legends in Annotate Point** <br>
ong6 marked this conversation as resolved.
Show resolved Hide resolved

Annotate point also allows users to display its content as a legend below the diagram. However, this only works when a label is provided for the point.
ong6 marked this conversation as resolved.
Show resolved Hide resolved

<include src="codeAndOutput.md" boilerplate >
<variable name="highlightStyle">html</variable>
<variable name="code">

<annotate src="https://www.researchgate.net/profile/Chaiwat-Sakul/publication/228949121/figure/fig2/AS:300654661783574@1448693065750/The-previous-square-root-circuit-1.png" width="500">
<!-- Default Legend (popover only)-->
<a-point x="25%" y="50%" content="There is only text when you click me" label="1"/>
<!-- Set Legend to bottom only -->
<a-point x="50%" y="50%" content="Clicking on this does nothing" label="2" legend="bottom"/>
<!-- Set Legend to both -->
<a-point x="75%" y="50%" content="There is text at both locations" header="Headers are displayed as well" label="3" legend="both"/>
</annotate>
</variable>
</include>

<br>

****`<a-point>` Options****
ong6 marked this conversation as resolved.
Show resolved Hide resolved

| Name | Type | Default | Description |
| --------- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------- |
| x | `String` | `''` | How to position the x-coordinate of the point.<br>Supports range of values from `0%` to `100%`. |
| y | `String` | `''` | How to position the y-coordinate of the point.<br>Supports range of values from `0%` to `100%`. |
| content | `String` | `''` | The content to be inserted into the body of the text.<br>The body will be omitted if this is not provided |
| header | `String` | `''` | The content to be inserted into the header of the text.<br>The header will be omitted if this is not provided |
| trigger | `String` | `click` | How the Popover is triggered.<br>Supports: `click`, `focus`, `hover`, or any space-separated combination of these. |
| placement | `String` | `top` | How to position the Popover.<br>Supports: `top`, `left`, `right`, `bottom`. |
| label | `String` | `''` | The content to be shown over the point.<br>The label will be omitted if this is not provided |
| size | `String` | `'40'` | The size of the point in pixels. |
ong6 marked this conversation as resolved.
Show resolved Hide resolved
| color | `String` | `'green'` | The color of the point.<br>Supports any color in the CSS color format. E.g. `red`, `#ffffff`, `rgb(66, 135, 245)`, etc... |
| opacity | `String` | `'0.3'` | The opacity of the point.<br>Supports range of values from `0` to `1`. |
| legend | `String` | `'popover'` | The presence of a legend to be displayed.<br>Supports: `popover`, `bottom`, `both`. |
ong6 marked this conversation as resolved.
Show resolved Hide resolved

</div>

<div id="examples" class="d-none">

Hover over the <trigger for="pop:context-target">keyword</trigger> to see the
popover.

<popover id="pop:context-target" header="Popover header" placement="top">
<div slot="content">

description :+1:

</div>
</popover>
</div>
111 changes: 111 additions & 0 deletions packages/vue-components/src/annotations/Annotate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<template>
<div :class="['annotate-image-wrapper', addClass]">
<img
ref="pic"
:src="src"
:alt="alt"
:width="computedWidth"
class="annotate-image"
:loading="computedLoadType"
@load.once="getWidth"
/>
<span class="point-wrapper">
ong6 marked this conversation as resolved.
Show resolved Hide resolved
<slot></slot>
</span>
</div>
</template>

<script>
import { toNumber } from '../utils/utils';

export default {
props: {
src: {
type: String,
default: null,
},
alt: {
type: String,
default: null,
},
height: {
type: String,
default: '',
},
width: {
type: String,
default: '',
},
addClass: {
type: String,
default: '',
},
type: {
type: String,
default: '',
},
},
computed: {
hasWidth() {
return this.width !== '';
},
hasHeight() {
return this.height !== '';
},
computedWidth() {
if (this.hasWidth) {
return this.width;
}
return this.widthFromHeight;
},
computedLoadType() {
jovyntls marked this conversation as resolved.
Show resolved Hide resolved
return this.eager ? 'eager' : 'lazy';
},
ong6 marked this conversation as resolved.
Show resolved Hide resolved
},
data() {
return {
widthFromHeight: '',
offsetWidth: '',
};
},
methods: {
getWidth() {
if (!this.hasWidth && this.hasHeight) {
const renderedImg = this.$refs.pic;
const imgHeight = renderedImg.naturalHeight;
const imgWidth = renderedImg.naturalWidth;
const imageAspectRatio = imgWidth / imgHeight;
this.widthFromHeight = Math.round(toNumber(this.height) * imageAspectRatio).toString();
ong6 marked this conversation as resolved.
Show resolved Hide resolved
}
this.offsetWidth = this.getOffsetWidth();
},
getOffsetWidth() {
return this.imageEl.offsetWidth;
},
},
mounted() {
this.imageEl = this.$el.querySelector('.annotate-image');
},
provide() {
return {
width: this.width,
height: this.height,
src: this.src,
imageEl: this.offsetWidth,
};
},
};
</script>

<style>
.annotate-image-wrapper {
position: relative;
text-align: left;
display: inline-block;
}

.annotate-image {
max-width: 100%;
height: auto;
}
</style>
Loading