-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): History menu in modal (#1972)
* refactor sequence entry history modal to its own react component * use react component in modal where there are multiple options * fix types
- Loading branch information
1 parent
9781881
commit 75251b0
Showing
5 changed files
with
79 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
website/src/components/SequenceDetailsPage/SequenceEntryHistoryMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { sentenceCase } from 'change-case'; | ||
import React from 'react'; | ||
|
||
import { routes } from '../../routes/routes'; | ||
import { type SequenceEntryHistory } from '../../types/lapis'; | ||
import { getVersionStatusColor } from '../../utils/getVersionStatusColor'; | ||
import IcBaselineHistory from '~icons/ic/baseline-history'; | ||
import Arrow from '~icons/ic/sharp-keyboard-arrow-down'; | ||
|
||
interface Props { | ||
sequenceEntryHistory: SequenceEntryHistory; | ||
accessionVersion: string; | ||
setPreviewedSeqId?: (seqId: string | null) => void; | ||
} | ||
|
||
export const SequenceEntryHistoryMenu: React.FC<Props> = ({ | ||
sequenceEntryHistory, | ||
accessionVersion, | ||
setPreviewedSeqId, | ||
}) => { | ||
return ( | ||
<> | ||
<div className='dropdown dropdown-hover hidden sm:inline-block'> | ||
<label tabIndex={0} className='btn btn-sm btn-outline py-1'> | ||
<a href={routes.versionPage(accessionVersion)} className='text-sm'> | ||
All versions | ||
</a> | ||
<Arrow /> | ||
</label> | ||
<ul | ||
tabIndex={0} | ||
className='dropdown-content z-[1] menu p-1 shadow bg-base-100 rounded-box absolute top-full left-0 text-sm' | ||
> | ||
{sequenceEntryHistory.map((version) => ( | ||
<li key={version.accessionVersion}> | ||
<a | ||
href={routes.sequencesDetailsPage(version.accessionVersion)} | ||
onClick={(e) => { | ||
if (setPreviewedSeqId) { | ||
setPreviewedSeqId(version.accessionVersion); | ||
e.preventDefault(); | ||
} | ||
}} | ||
> | ||
{version.accessionVersion} | ||
<p className={`font-bold ${getVersionStatusColor(version.versionStatus)}`}> | ||
({sentenceCase(version.versionStatus)}) | ||
</p> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
<div className='sm:hidden inline-block'> | ||
<a href={routes.versionPage(accessionVersion)} className='text-xl'> | ||
<IcBaselineHistory /> | ||
</a> | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters