Skip to content

Commit

Permalink
feat: display all targets with their respective variants in variants …
Browse files Browse the repository at this point in the history
…details popup
  • Loading branch information
paulpestov committed Aug 28, 2024
1 parent a9e99a1 commit a6b44c6
Showing 1 changed file with 45 additions and 22 deletions.
67 changes: 45 additions & 22 deletions src/components/annotations/variants/ActiveVariantsDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,60 @@
.map(id => activeAnnotations[id])
});
const activeVariantsGroupedByTarget = computed(() =>
activeVariants.value.reduce((acc, cur) => {
cur.target
.forEach(target => {
const cssSelector = target.selector.value;
if (!acc[cssSelector]) {
acc[cssSelector] = {
content: target.source,
variants: [cur]
}
} else {
acc[cssSelector].variants.push(cur)
}
})
return acc
}, {})
)
function getWitnessColor(witness: string) {
return annotationStore.variantItemsColors[witness];
}
</script>

<template>
<div class="t-flex t-space-x-2 t-min-h-[200px] t-overflow-x-auto">
<div
v-if="activeVariants.length > 0"
class="t-border t-rounded-md t-min-w-[16rem] t-flex-1 t-p-4"
>
<h3 class="t-font-semibold t-mb-2">
{{ $t('original') }}
</h3>
<p>{{ activeVariants[0].target[0].source }}</p>
</div>
<div class="t-space-y-4">
<div
v-for="(variant, i) in activeVariants"
v-for="(selector, i) in Object.keys(activeVariantsGroupedByTarget)"
:key="i"
class="t-border t-rounded-md t-min-w-[16rem] t-flex-1 t-p-4"
class="t-flex t-space-x-2 t-min-h-[100px] t-overflow-x-auto"
>
<h3 class="t-font-semibold t-mb-2 t-flex t-whitespace-nowrap">
<span
class="t-rounded-full t-h-3 t-w-3 t-mt-1.5 t-mr-2 t-flex-shrink-0"
:style="{
'background': colors[getWitnessColor(variant.body.value.witness)]['500'],
}"
/>
{{ variant.body.value.witness }}
</h3>
<p>{{ variant.body.value.entry }}</p>
<div
class="t-border t-rounded-md t-min-w-[16rem] t-p-4"
>
<h3 class="t-font-semibold t-mb-2">
{{ $t('original') }}
</h3>
<p>{{ activeVariantsGroupedByTarget[selector].content }}</p>
</div>
<div
v-for="(variant, i) in activeVariantsGroupedByTarget[selector].variants"

Check warning on line 54 in src/components/annotations/variants/ActiveVariantsDetails.vue

View workflow job for this annotation

GitHub Actions / build (18)

Variable 'i' is already declared in the upper scope

Check warning on line 54 in src/components/annotations/variants/ActiveVariantsDetails.vue

View workflow job for this annotation

GitHub Actions / build (20)

Variable 'i' is already declared in the upper scope
:key="i"
class="t-border t-rounded-md t-min-w-[16rem] t-p-4"
>
<h3 class="t-font-semibold t-mb-2 t-flex t-whitespace-nowrap">
<span
class="t-rounded-full t-h-3 t-w-3 t-mt-1.5 t-mr-2 t-flex-shrink-0"
:style="{
'background': colors[getWitnessColor(variant.body.value.witness)]['500'],
}"
/>
{{ variant.body.value.witness }}
</h3>
<p>{{ variant.body.value.entry }}</p>
</div>
</div>
</div>
</template>

0 comments on commit a6b44c6

Please sign in to comment.