Skip to content

Commit

Permalink
fix: update witness design
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpestov committed Aug 20, 2024
1 parent eab966e commit c71e79f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 28 deletions.
27 changes: 20 additions & 7 deletions src/components/annotations/variants/ActiveVariantsDetails.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup>
<script setup lang="ts">
import { useAnnotationsStore } from "@/stores/annotations";
import {computed} from "vue";
import colors from "tailwindcss/colors";
const annotationStore = useAnnotationsStore();
Expand All @@ -10,25 +11,37 @@
.filter(id => activeAnnotations[id].body['x-content-type'] === 'Variant')
.map(id => activeAnnotations[id])
});
function getWitnessColor(witness: string) {
return annotationStore.variantItemsColors[witness];
}
</script>

<template>
<div class="t-flex t-space-x-2 t-min-h-[200px]">
<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-flex-1 t-p-2"
class="t-border t-rounded-md t-min-w-[16rem] t-p-4"
>
<h3 class="t-font-semibold mb-2">
<h3 class="t-font-semibold t-mb-2">
{{ $t('original') }}
</h3>
<p>{{ activeVariants[0].target.source }}</p>
<p>{{ activeVariants[0].target[0].source }}</p>
</div>
<div
v-for="(variant, i) in activeVariants"
:key="i"
class="t-border t-rounded-md t-flex-1 t-p-2"
class="t-border t-rounded-md t-min-w-[16rem] t-p-4"
>
<h3 class="t-font-semibold mb-2">{{ variant.body.value.witness }}</h3>
<h3 class="t-font-semibold t-mb-2 t-flex t-whitespace-nowrap">
<span

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

View workflow job for this annotation

GitHub Actions / build (18)

Require self-closing on HTML elements (<span>)

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

View workflow job for this annotation

GitHub Actions / build (20)

Require self-closing on HTML elements (<span>)
class="t-rounded-full t-h-3 t-w-3 t-mt-2 t-mr-2 t-flex-shrink-0"
:style="{
'background': colors[getWitnessColor(variant.body.value.witness)]['500'],

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

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 12 spaces but found 10 spaces

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

View workflow job for this annotation

GitHub Actions / build (20)

Expected indentation of 12 spaces but found 10 spaces
}"

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

View workflow job for this annotation

GitHub Actions / build (18)

Expected indentation of 10 spaces but found 8 spaces

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

View workflow job for this annotation

GitHub Actions / build (20)

Expected indentation of 10 spaces but found 8 spaces
></span>
{{ variant.body.value.witness }}
</h3>
<p>{{ variant.body.value.entry }}</p>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions src/components/annotations/variants/VariantItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
<div
class="t-items-center t-flex t-mb-1 t-relative"
:class="[
't-py-1 t-px-2 t-mb-1 t-space-x-2 t-rounded-md',
't-py-2 t-px-2 t-mb-1 t-space-x-2 t-rounded-md',
{ 'hover:t-bg-gray-200 dark:hover:t-bg-gray-600 t-cursor-pointer': !isActive },
{ 't-bg-gray-300 dark:t-bg-gray-600 active': isActive}]"
:data-annotation-id="annotation.id"
@click="handleClick"
>
<div class="t-w-4/12 t-flex">
<div
class="t-relative t-rounded-3xl t-box-border t-border-2 t-px-2 t-py-1 t-text-xs t-flex-grow-0"
:style="{'border-color': getWitnessColor(witness)}"
class="t-relative t-rounded-3xl t-box-border t-px-2 t-py-1 t-text-xs t-flex-grow-0 t-flex t-items-center t-font-semibold"
:style="{
'background': colors[witnessColor]['100'],
'color': colors[witnessColor]['600']
}"
>
{{ witness ?? '-' }}
</div>
Expand All @@ -31,19 +34,18 @@

<script setup lang="ts">
import { computed } from 'vue';
import { useAnnotationsStore } from '@/stores/annotations';
import BaseButton from "@/components/base/BaseButton.vue";
import colors from "tailwindcss/colors";
const entry = computed(() => props.annotation.body.value.entry)
const witness = computed(() => props.annotation.body.value.witness)
const annotationStore = useAnnotationsStore();
export interface Props {
annotation: Annotation,
isActive: boolean,
toggle: (annotation: Annotation) => void,
witnessColor: string
}
const props = withDefaults(defineProps<Props>(), {
Expand All @@ -67,7 +69,5 @@ function handleDetailsClick(event: Event) {
emit('show-details')
}
function getWitnessColor(witness: string) {
return annotationStore.variantItemsColors[witness];
}
</script>
12 changes: 8 additions & 4 deletions src/components/annotations/variants/VariantsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:annotation="annotation"
:is-active="isActive(annotation)"
:toggle="toggle"
:witness-color="getWitnessColor(annotation.body.value.witness)"
@select="addAnnotation(annotation.id)"
@unselect="removeAnnotation(annotation.id)"
@show-details="openDetailsDialog"
Expand All @@ -24,7 +25,7 @@


<script setup lang="ts">
import {computed, onMounted, ref} from 'vue';
import {computed, ref} from 'vue';
import VariantItem from "@/components/annotations/variants/VariantItem.vue";
import {useAnnotationsStore} from "@/stores/annotations";
import BaseDialog from "@/components/base/BaseDialog.vue";
Expand All @@ -46,9 +47,8 @@ const props = withDefaults(defineProps<Props>(), {
const activeAnnotations = computed<ActiveAnnotation>(() => annotationStore.activeAnnotations);
onMounted(() => {
allocateWitnessColorInVariantItem()
})
allocateWitnessColorInVariantItem()
function allocateWitnessColorInVariantItem() {
const colors = props.annotations.reduce((acc, cur: Annotation, i) => {
Expand Down Expand Up @@ -85,4 +85,8 @@ function openDetailsDialog() {
variantsDetailsDialogOpen.value = true;
}
function getWitnessColor(witness: string) {
return annotationStore.variantItemsColors[witness];
}
</script>
2 changes: 1 addition & 1 deletion src/components/base/BaseDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const emit = defineEmits<{(event: 'update:modelValue', payload: boolean): void;
:append-to="configStore.config.container + ' .tido > *'"
:pt="{
root: {
class: 't-relative t-bg-white dark:t-bg-gray-800 t-p-4 t-rounded-lg lg:t-min-w-[33%] t-max-h-[80%] t-shadow-lg dark:t-border dark:t-border-gray-700'
class: 't-relative t-bg-white dark:t-bg-gray-800 t-p-4 t-rounded-lg t-max-w-[90%] lg:t-min-w-[33%] t-max-h-[80%] t-shadow-lg dark:t-border dark:t-border-gray-700'
},
header: {
class: 't-flex t-mb-4'
Expand Down
9 changes: 6 additions & 3 deletions src/utils/annotations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Utils from '@/utils/index';
import { getIcon } from '@/utils/icons';
import { i18n } from '@/i18n';
import colors from "tailwindcss/colors";


// utility functions that we can use as generic way for perform tranformation on annotations.
Expand Down Expand Up @@ -262,12 +263,14 @@ export function addWitness(targetHtmlEl, witness, color) {
}
}

function createCurrWitHtml(witness, borderColor) {
function createCurrWitHtml(witness, witnessColor) {
// create an html element of the selected witness
const witHtml = document.createElement("span");
witHtml.innerHTML = witness
witHtml.classList.add('t-rounded-3xl', 't-box-border', 't-w-75', 't-h-8', 't-border-2', 't-p-[2px]', 't-text-sm', 't-ml-[3px]')
witHtml.style.borderColor = borderColor
witHtml.classList.add('t-rounded-3xl', 't-box-border', 't-h-8', 't-py-0.5', 't-px-1.5', 't-text-xs', 't-font-semibold', 't-ml-[3px]')
witHtml.style.background = colors[witnessColor]['100']
witHtml.style.color = colors[witnessColor]['600']


return witHtml
}
Expand Down
6 changes: 2 additions & 4 deletions src/utils/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ export const getRGBColor = (hex, type) => {


export default function colors() {

const hexaDecimalColors = ['#FEF08A', '#BEF264', '#A8A29E', '#D8B4FE', '#A8A29E']
return hexaDecimalColors;
return ['rose', 'amber', 'violet' , 'lime', 'blue', 'teal',];
}

export function getItemColorBasedOnIndex(index){
return colors()[index]
}
}

0 comments on commit c71e79f

Please sign in to comment.