Skip to content
Snippets Groups Projects
Commit 8674290a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

annotation list is extracted to a component

parent e6ef7e64
No related branches found
No related tags found
1 merge request!340Resolve "[MIN-251] Clicking on a protein: annotation"
import { Icon } from '@/shared/Icon';
import { Reference } from '@/types/models'; import { Reference } from '@/types/models';
import { twMerge } from 'tailwind-merge';
type AnnotationItemProps = Pick<Reference, 'link' | 'type' | 'resource'>; type AnnotationItemProps = Pick<Reference, 'link' | 'type' | 'resource'>;
export const AnnotationItem = ({ link, type, resource }: AnnotationItemProps): JSX.Element => ( export const AnnotationItem = ({ link, type, resource }: AnnotationItemProps): JSX.Element => (
<a className="pl-3 text-sm font-normal" href={link?.toString()} target="_blank"> <a
className={twMerge('pl-3 text-sm font-normal', link ? 'underline' : '')}
href={link?.toString()}
target="_blank"
>
<div className="flex justify-between"> <div className="flex justify-between">
<span> <span className="w-full font-semibold">
Source:{' '} {type} ({resource})
<b className="font-semibold">
{type} ({resource})
</b>
</span> </span>
<Icon name="arrow" className="h-6 w-6 fill-font-500" />
</div> </div>
</a> </a>
); );
import { Reference } from '@/types/models';
import { AnnotationItem } from '@/components/Map/Drawer/BioEntityDrawer/AnnotationItem/AnnotationItem.component';
import React from 'react';
import { ZERO } from '@/constants/common';
type AnnotationItemListProps = {
references: Reference[];
};
export const AnnotationItemList = ({ references }: AnnotationItemListProps): React.ReactNode => {
const isReferenceAvailable = references.length > ZERO;
return (
<div>
<h3 className="font-semibold">
Annotations: {!isReferenceAvailable && <span className="font-normal">No annotations</span>}
</h3>
<div className="flex max-h-full flex-col gap-2 overflow-x-hidden pt-2">
{isReferenceAvailable &&
references.map(reference => (
<AnnotationItem
key={reference.id}
type={reference.type}
link={reference.link}
resource={reference.resource}
/>
))}
</div>
</div>
);
};
...@@ -16,8 +16,8 @@ import { CommentItem } from '@/components/Map/Drawer/BioEntityDrawer/Comments/Co ...@@ -16,8 +16,8 @@ import { CommentItem } from '@/components/Map/Drawer/BioEntityDrawer/Comments/Co
import { getTypeBySBOTerm } from '@/utils/bioEntity/getTypeBySBOTerm'; import { getTypeBySBOTerm } from '@/utils/bioEntity/getTypeBySBOTerm';
import { ModificationResidueItem } from '@/components/Map/Drawer/BioEntityDrawer/ModificationResidueItem'; import { ModificationResidueItem } from '@/components/Map/Drawer/BioEntityDrawer/ModificationResidueItem';
import React from 'react'; import React from 'react';
import { AnnotationItemList } from '@/components/Map/Drawer/BioEntityDrawer/AnnotationItem/AnnotationItemList.component';
import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection'; import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection';
import { AnnotationItem } from './AnnotationItem';
import { AssociatedSubmap } from './AssociatedSubmap'; import { AssociatedSubmap } from './AssociatedSubmap';
import { ChemicalsList } from './ChemicalsList'; import { ChemicalsList } from './ChemicalsList';
import { DrugsList } from './DrugsList'; import { DrugsList } from './DrugsList';
...@@ -42,7 +42,6 @@ export const BioEntityDrawer = (): React.ReactNode => { ...@@ -42,7 +42,6 @@ export const BioEntityDrawer = (): React.ReactNode => {
return null; return null;
} }
const isReferenceAvailable = bioEntityData.references.length > ZERO;
const isCommentAvailable = commentsData.length > ZERO; const isCommentAvailable = commentsData.length > ZERO;
const modificationResidues = ( const modificationResidues = (
bioEntityData.modificationResidues ? bioEntityData.modificationResidues : [] bioEntityData.modificationResidues ? bioEntityData.modificationResidues : []
...@@ -92,19 +91,7 @@ export const BioEntityDrawer = (): React.ReactNode => { ...@@ -92,19 +91,7 @@ export const BioEntityDrawer = (): React.ReactNode => {
))} ))}
</ul> </ul>
)} )}
<h3 className="font-semibold"> <AnnotationItemList references={bioEntityData.references} />
Annotations:{' '}
{!isReferenceAvailable && <span className="font-normal">No annotations</span>}
</h3>
{isReferenceAvailable &&
bioEntityData.references.map(reference => (
<AnnotationItem
key={reference.id}
type={reference.type}
link={reference.link}
resource={reference.resource}
/>
))}
<AssociatedSubmap /> <AssociatedSubmap />
{!relatedSubmap && ( {!relatedSubmap && (
<> <>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment