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

wip: variants view #456

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
177 changes: 177 additions & 0 deletions examples/ahiqar-arabic-karshuni-with-variants-local.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<!DOCTYPE html>
<html>
<head><title>TIDO</title>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1,maximum-scale=5,minimum-scale=1,width=device-width">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="dist/tido.css">
<style>
html, body {
margin: 0;
}
#app {
height: 100vh;
}
</style>
</head>
<body>
<noscript><strong>We're sorry but TIDO doesn't work properly without JavaScript enabled. Please enable it to
continue.</strong></noscript>

<div id="app"></div>
<script src="dist/tido.js"></script>
<script>
window.addEventListener('load', function () {
window.tido = new window.Tido({
"collection": "http://localhost:8181/ahiqar/textapi/ahiqar/arabic-karshuni/collection.json",
"labels": {
"item": "Sheet",
"manifest": "Manuscript"
},
"colors": {
"forceMode": "light"
},
"panels": [
{
"label": "contents_and_metadata",
"views": [
{
"id": "tree",
"label": "contents",
"connector": {
"id": 1
}
},
{
"id": "metadata",
"label": "metadata",
"connector": {
"id": 2,
"options": {
"collection": {
"all": true
},
"manifest": {
"all": true
},
"item": {
"all": true
}
}
}
}
]
},
{
"label": "image",
"views": [
{
"id": "image",
"label": "Image",
"connector": {
"id": 3
}
}]
},
{
"label": "text",
"views": [
{
"id": "text1",
"label": "Transcription",
"default": true,
"connector": {
"id": 4,
"options": {
"type": "transcription"
}
}
},
{
"id": "text2",
"label": "Transliteration",
"connector": {
"id": 4,
"options": {
"type": "transliteration"
}
}
}
]
},
{
"label": "annotations",
"views": [
{
"id": "annotations1",
"label": "Editorial",
"connector": {
"id": 5,
"options": {
"types": [
{
"name": "Person",
"icon": "biPersonFill"
},
{
"name": "Place",
"icon": "biGeoAltFill"
},
{
"name": "Editorial Comment",
"icon": "biChatFill"
},
{
"name": "Reference",
"icon": "biBoxArrowUpRight"
}
]
}
}
},
{
"id": "annotations2",
"label": "Motif",
"connector": {
"id": 5,
"options": {
"types": [
{
"name": "Motif",
"icon": "biPenFill"
}
]
}
}
},
{
"id": "annotations3",
"label": "Variants",
"connector": {
"id": 5,
"options": {
"types": [
{
"name": "Variant",
"icon": "biPenFill"
}
]
}
}
}
]
}
],
"translations": {
"en": {
"contents_and_metadata": "Contents & Metadata"
}
}
});
});
</script>
</body>
</html>
27 changes: 27 additions & 0 deletions src/components/annotations/AnnotationVariantItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div v-for="(variant, i) in annotation.body.value" :key="i" class="t-items-center t-flex">
<span v-if="variant.witness" v-html="variant.witness" class="t-mr-7"/>
<span v-else class="t-mr-7"> - </span>
<span v-html="variant.entry"/>
</div>
</template>



<script setup lang="ts">

export interface Props {
annotation: Annotation
}

const props = withDefaults(defineProps<Props>(), {
annotation: () => <Annotation>{},
})

</script>



<style scoped>

</style>
30 changes: 25 additions & 5 deletions src/components/annotations/AnnotationsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,30 @@
]"
@click="isText(annotation) ? ()=>{} : toggle(annotation)"
>
<div class="t-flex t-items-center t-space-x-2">
<AnnotationIcon

<div v-if="!isVariant(annotation)" class="t-flex t-items-center t-space-x-2">
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
<AnnotationIcon
v-if="!isText(annotation)"
:name="getIconName(annotation.body['x-content-type'])"
/>
/>
<span v-html="annotation.body.value"/>
</div>

<div v-else>
<AnnotationVariantItem :annotation="annotation" />
</div>

<!-- eslint-disable -- https://eslint.vuejs.org/rules/no-v-html.html -->
<span v-html="annotation.body.value" />
</div>

</div>
</div>
</template>

<script setup lang="ts">
import { computed } from 'vue';
import AnnotationIcon from '@/components/annotations/AnnotationIcon.vue';
import AnnotationVariantItem from '@/components/annotations/AnnotationVariantItem.vue'

interface AnnotationTypesMapping {
[key: string]: string | 'annotation'
Expand Down Expand Up @@ -62,4 +71,15 @@ function isText(annotation: Annotation): boolean {
function getIconName(typeName: string): string {
return props.types.find(({ name }) => name === typeName)?.icon || 'pencil';
}

function isVariant(annotation) {
return annotation.body['x-content-type'] === 'Variant';
}

</script>


<style lang="scss" scoped>


</style>
4 changes: 4 additions & 0 deletions src/utils/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const components = {
component: 'AnnotationsView',
label: 'annotations',
},
6: {
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
component: 'AnnotationsView',
label: 'Variant',
},
};

export const findComponent = (id) => ({
Expand Down