Skip to content

Commit

Permalink
feat(website): move FASTA download button and improve sequence viewer (
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoran-chen authored and theosanderson committed May 7, 2024
1 parent ff6c9eb commit b47e13f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ export const DownloadDialog: FC<DownloadDialogProps> = ({

return (
<>
<button
className='normal-case
py-2 rounded-md font-semibold px-4 text-sm
border-primary-600 border
text-primary-600 bg-white
w-full
hover:bg-primary-600 hover:text-white'
onClick={openDialog}
>
<button className='outlineButton' onClick={openDialog}>
Download
</button>

Expand Down
14 changes: 1 addition & 13 deletions website/src/components/SearchPage/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,7 @@ const SearchField: FC<AutoCompleteFieldProps> = (props) => {
};

const SearchButton: FC<{ isLoading: boolean }> = ({ isLoading }) => (
<button
className='normal-case
py-2 rounded-md font-semibold px-4 text-sm
border-primary-600 border
text-primary-600 bg-white
w-full
hover:bg-primary-600 hover:text-white
'
type='submit'
disabled={isLoading}
>
<button className='outlineButton w-full' type='submit' disabled={isLoading}>
{isLoading ? <CircularProgress size={20} color='inherit' /> : 'Search sequences'}
</button>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,73 @@ import { sentenceCase } from 'change-case';
import { routes } from '../../routes/routes';
import { type SequenceEntryHistory } from '../../types/lapis';
import { getAccessionVersionString } from '../../utils/extractAccessionVersion';
import { getVersionStatusColor } from '../../utils/getVersionStatusColor';
import IcBaselineDownload from '~icons/ic/baseline-download';
import IcBaselineHistory from '~icons/ic/baseline-history';
import Arrow from '~icons/ic/sharp-keyboard-arrow-down';
interface Props {
sequenceEntryHistory?: SequenceEntryHistory;
organism: string;
accessionVersion: string;
showFastaDownload: boolean;
}
const { sequenceEntryHistory, accessionVersion } = Astro.props;
const { sequenceEntryHistory, accessionVersion, showFastaDownload } = Astro.props;
---

<div class='flex justify-between flex-wrap'>
<div class='flex flex-row pb-6'>
<h1 class='title'>{accessionVersion}</h1>
</div>

{
sequenceEntryHistory !== undefined && sequenceEntryHistory.length > 1 && (
<div class='dropdown dropdown-hover'>
<label tabindex='0' class='btn btn-sm btn-outline py-1'>
<a href={routes.versionPage(accessionVersion)} class='text-sm'>
All versions
</a>
<Arrow />
</label>
<ul
tabindex='0'
class='dropdown-content z-[1] menu p-1 shadow bg-base-100 rounded-box absolute top-full left-0 text-sm'
>
{sequenceEntryHistory.map((version) => (
<li>
<a href={routes.sequencesDetailsPage(getAccessionVersionString({ ...version }))}>
{getAccessionVersionString({ ...version })}

<p class={`font-bold ${getVersionStatusColor(version.versionStatus)}`}>
({sentenceCase(version.versionStatus)})
</p>
<div class='pt-2'>
{
sequenceEntryHistory !== undefined && sequenceEntryHistory.length > 1 && (
<>
<div class='dropdown dropdown-hover hidden sm:inline-block'>
<label tabindex='0' class='btn btn-sm btn-outline py-1'>
<a href={routes.versionPage(accessionVersion)} class='text-sm'>
All versions
</a>
</li>
))}
</ul>
</div>
)
}
<Arrow />
</label>
<ul
tabindex='0'
class='dropdown-content z-[1] menu p-1 shadow bg-base-100 rounded-box absolute top-full left-0 text-sm'
>
{sequenceEntryHistory.map((version) => (
<li>
<a href={routes.sequencesDetailsPage(version.accessionVersion)}>
{version.accessionVersion}
<p class={`font-bold ${getVersionStatusColor(version.versionStatus)}`}>
({sentenceCase(version.versionStatus)})
</p>
</a>
</li>
))}
</ul>
</div>
<div class='sm:hidden inline-block'>
<a href={routes.versionPage(accessionVersion)} class='text-xl'>
<IcBaselineHistory />
</a>
</div>
</>
)
}
{
showFastaDownload && (
<a
class='sm:outlineButton inline-block'
href={routes.sequencesFastaPage(accessionVersion) + '?download'}
>
<span class='hidden sm:inline'>Download FASTA</span>
<span class='sm:hidden inline text-xl'>
<IcBaselineDownload />
</span>
</a>
)
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ const loadSequencesAutomatically = getSchema(organism).loadSequencesAutomaticall
)
}
<DataTable tableData={tableData} dataUseTermsHistory={dataUseTermsHistory} />
<div>
<a
class='mt-4 inline-block text-primary-700 hover:text-blue-800'
href={routes.sequencesFastaPage(accessionVersion) + '?download'}
>
Download FASTA
</a>
</div>
<div class='mt-10'>
<SequencesContainer
client:load
Expand Down
6 changes: 2 additions & 4 deletions website/src/components/common/BoxWithTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type BoxWithTabsTabProps = {
};

export const BoxWithTabsTab: FC<BoxWithTabsTabProps> = ({ isActive, label, onClick }) => (
<button className={`tab ${isActive ? 'tab-active' : ''}`} onClick={onClick}>
<button className={`tab ${isActive ? 'tab-active font-semibold' : ''}`} onClick={onClick}>
{label}
</button>
);
Expand All @@ -24,6 +24,4 @@ type BoxWithTabsBoxProps = {
children: ReactNode;
};

export const BoxWithTabsBox: FC<BoxWithTabsBoxProps> = ({ children }) => (
<div className='border p-4 max-w-[1000px]'>{children}</div>
);
export const BoxWithTabsBox: FC<BoxWithTabsBoxProps> = ({ children }) => <div className='border p-4'>{children}</div>;
6 changes: 5 additions & 1 deletion website/src/pages/seq/[accessionVersion]/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ if (
accessionVersion={accessionVersion}
organism={organism}
sequenceEntryHistory={
sequenceDetailsTableData.isOk() && result.type === SequenceDetailsTableResultType.TABLE_DATA
result.type === SequenceDetailsTableResultType.TABLE_DATA
? result.sequenceEntryHistory
: undefined
}
showFastaDownload={
result.type === SequenceDetailsTableResultType.TABLE_DATA &&
!isRevocationEntry(result.tableData)
}
/>
{result.type === SequenceDetailsTableResultType.TABLE_DATA &&
(isRevocationEntry(result.tableData) ? (
Expand Down
7 changes: 7 additions & 0 deletions website/src/styles/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ a {
font-weight: 400;
}

@layer utilities {
.outlineButton {
@apply normal-case py-2 rounded-md font-semibold px-4 text-sm border-primary-600 border text-primary-600 bg-white
hover:bg-primary-600 hover:text-white;
}
}

.loculusColor{
background: theme('colors.main');
&:hover {
Expand Down

0 comments on commit b47e13f

Please sign in to comment.