-
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): organism selector on mobile navigation #543
- Loading branch information
1 parent
5a573be
commit 1851d8d
Showing
10 changed files
with
94 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,17 @@ | ||
--- | ||
import { SandwichMenu } from './SandwichMenu.tsx'; | ||
import { getConfiguredOrganisms } from '../../config'; | ||
import { navigationItems, routes } from '../../routes'; | ||
import { cleanOrganism } from './cleanOrganism'; | ||
import { navigationItems } from '../../routes'; | ||
let organism = Astro.params.organism; | ||
const organisms = getConfiguredOrganisms(); | ||
if (organism !== undefined && !organisms.includes(organism)) { | ||
organism = undefined; | ||
} | ||
const label = organism === undefined ? 'Choose Organism' : `Organism ${organism}`; | ||
const { organism, knownOrganisms } = cleanOrganism(Astro.params.organism); | ||
--- | ||
|
||
<div class='flex justify-end'> | ||
<div class='dropdown dropdown-hover'> | ||
<label tabindex='0' class='btn m-1'>{label}</label> | ||
<ul tabindex='0' class='dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52'> | ||
{ | ||
organisms.map((organism) => ( | ||
<li> | ||
<a href={routes.organismStartPage(organism)}>{organism}</a> | ||
</li> | ||
)) | ||
} | ||
</ul> | ||
</div> | ||
<div class='subtitle hidden sm:flex sm:z-6 gap-4'> | ||
{navigationItems.top(organism).map(({ text, path }) => <a href={path}>{text}</a>)} | ||
{navigationItems.top(organism?.key).map(({ text, path }) => <a href={path}>{text}</a>)} | ||
</div> | ||
|
||
<div class='sm:hidden fixed z-0'> | ||
<SandwichMenu top={16} right={28} organism={organism} client:load /> | ||
<SandwichMenu top={16} right={28} organism={organism} knownOrganisms={knownOrganisms} client:load /> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
import { cleanOrganism } from './cleanOrganism'; | ||
import { routes } from '../../routes'; | ||
import Arrow from '~icons/ic/sharp-keyboard-arrow-down'; | ||
const { knownOrganisms, organism } = cleanOrganism(Astro.params.organism); | ||
const label = organism === undefined ? 'Choose Organism' : organism.displayName; | ||
--- | ||
|
||
<div class='dropdown dropdown-hover'> | ||
<label tabindex='0' class='btn btn-sm m-1 py-2'> | ||
{label} | ||
<Arrow /> | ||
</label> | ||
<ul tabindex='0' class='dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52'> | ||
{ | ||
knownOrganisms.map((knownOrganism) => ( | ||
<li> | ||
<a href={routes.organismStartPage(knownOrganism.key)}>{knownOrganism.displayName}</a> | ||
</li> | ||
)) | ||
} | ||
</ul> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { getConfiguredOrganisms } from '../../config.ts'; | ||
|
||
export function cleanOrganism(organism: string | undefined) { | ||
const knownOrganisms = getConfiguredOrganisms(); | ||
|
||
return { | ||
knownOrganisms, | ||
organism: knownOrganisms.find((it) => it.key === organism), | ||
}; | ||
} |
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
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
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
--- | ||
import { BackButton } from '../../components/Navigation/BackButton'; | ||
import BaseLayout from '../../layouts/BaseLayout.astro'; | ||
const organism = Astro.params.organism; | ||
--- | ||
|
||
<BaseLayout title={organism}> | ||
Hello {organism} | ||
<div class='flex items-center'> | ||
<BackButton marginRight={2} client:load /> | ||
<h1 class='title'>Organism {organism}</h1> | ||
</div> | ||
</BaseLayout> |
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
dynamic classes don't work with tailwind, see #1107
@fengelniederhammer for the future ;)