Skip to content

Commit 47e54e4

Browse files
authored
Merge pull request doccano#254 from clarus/add-annotation-tooltip
Add a tooltip under each annotation to name them
2 parents 9ce28ab + 3cfa22f commit 47e54e4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

app/server/static/components/annotator.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
div(@click="setSelectedRange")
33
span.text-sequence(
44
v-for="r in chunksWithLabel"
5-
v-bind:class="{ tag: id2label[r.label].text_color }"
5+
v-bind:class="getChunkClass(r)"
6+
v-bind:data-tooltip="id2label[r.label].text"
67
v-bind:style="{ \
78
color: id2label[r.label].text_color, \
89
backgroundColor: id2label[r.label].background_color \
@@ -83,6 +84,18 @@ export default {
8384
},
8485
8586
methods: {
87+
getChunkClass(chunk) {
88+
if (!chunk.id) {
89+
return {};
90+
}
91+
92+
const label = this.id2label[chunk.label];
93+
return [
94+
'tooltip is-tooltip-bottom',
95+
{ tag: label.text_color },
96+
];
97+
},
98+
8699
setSelectedRange() {
87100
let start;
88101
let end;

app/server/templates/base.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" crossorigin="anonymous">
1616
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/bulma-divider/dist/css/bulma-divider.min.css" crossorigin="anonymous">
1717
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/bulma-checkradio/dist/css/bulma-checkradio.min.css" crossorigin="anonymous">
18+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/bulma-tooltip/dist/css/bulma-tooltip.min.css" crossorigin="anonymous">
1819
<link rel="stylesheet" href="{% static 'assets/css/forum.css' %}">
1920
<!-- favicon settings -->
2021
<link rel="apple-touch-icon" sizes="57x57" href="{% static 'static/apple-icon-57x57.png' %}">
@@ -99,4 +100,4 @@
99100

100101
{% block footer %}{% endblock %}
101102
</body>
102-
</html>
103+
</html>

0 commit comments

Comments
 (0)