Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert pathogens to app router [#1066] #1124

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

genehack
Copy link
Contributor

@genehack genehack commented Feb 26, 2025

Description of proposed changes

Preview

Converts /pathogens and components used on that page to App Router style.

Converted components:

  • ErrorBoundary
  • ExpandableTiles
  • ListResources (and included sub-components, ResourceGroup, IndividualResource, etc)
  • Spinner

Note that all of these were done in two stages: first a move or copy of the old Pages Router style code to the new App Router location — which sometimes, inevitably, leaves the code in a broken state — and then a subsequent commit to convert to the App Router style/code layout.

Please see individual commits for extra details around some porting decisions.

Related issue(s)

Closes #1066

Checklist

Note: this will leave the site in a broken state; doing this to ensure
better Git tracking of file renames.
Note: this is a copy, not a move, as `<ExpandableTiles>` is also used
in the `splash` and `Groups` components in addition to the
`ListResources` component that is consumed by the `/pathogens` page.
Note: this is a copy, not a move, as `<ErrorBoundary>` is used
elsewhere in the site, in addition to the `ListResources` component
that is consumed by the `/pathogens` page.
Note: this is a copy, not a move, as `<ListResources>` is used
elsewhere in the site, in addition to the `/pathogens` page.
@nextstrain-bot nextstrain-bot temporarily deployed to nextstrain-s-convert-pa-9ilhrn February 26, 2025 19:22 Inactive
Note: despite the placement of the component outside the
<ListResources> component, it is only used within that component.

I considered relocating it to
`static-site/components/list-resources/spinner.tsx` but elected to
maintain it outside of the <ListResources> component to better support
future re-use, which seems not unlikely.
@genehack genehack force-pushed the convert-pathogens-to-app-router-1066 branch from bfd05fb to 2c2d562 Compare February 26, 2025 21:46
@nextstrain-bot nextstrain-bot temporarily deployed to nextstrain-s-convert-pa-heatct February 26, 2025 21:46 Inactive
* add `use client` because of use of `useState`
* rename `Tile` type to `GenericTileBase`; rename `AnyTile` to `Tile`
* converted styled components to CSS module
* swap various prop-driven styled components bits to dynamic inline
  styles
* move `div.errorContainer` into global CSS file because it is
  used in multiple places
* segregate types and functions
* update formatting
* adjust leading/trailing whitespace
* move styling from styled components to CSS module
* refactor <ResourceModal> to `useContext` and `useCallback` to build
  `dismissModal()` function, rather than passing it in — this was
  necessary because all props of React Client Components need to be
  serializable (i.e., not functions), and <ResourceModal> needs to
  "use client" because it depends on `useState` and `useEffect`
* refactor the `_draw` function out into a distinct
  file (`modal_draw.js`) to reflect the lack of typing in that code (I
  briefly explored converting that file to Typescript and concluded
  the juice was not worth the squeeze)
  * note that this also means we don't need to add @types/d3 to
    devDependencies
* export component as a function
* convert to Typescript; light reformatting
* Refactor <Name>, <ResourceLinkWrapper>, and <ResourceLink> into
  <IndividualResourceLink>, and migrate into distinct file; in the
  future, <GroupLink> will also be refactored into that file, which is
  reflected in the `group-and-resource-links` file name
* Refactor <IconContainer> into distinct file, rework to avoid need to
  pass non-serializable prop
* Refactor <IndividualResource> and associated components from Styled
  to CSS Module
* Refactor <IndividualResource> component to be passed `gapWidth`
  prop, which supports cleaner separation of concerns with where that
  constant is defined and used
* Refactor <TooltipWrapper> into a distinct file, because it doesn't
  need to be a React Client component
* Refactored styles from structured component to CSS Module
* Refactored <GroupLink> and <IndividualQuickLink> components out into
  `group-and-resource-links.tsx`
* Refactored <ResourceGroup> and contained components
* convert `export const`` to `export default function`
* add "use client"
* refactor and update code
* convert to React Client Component
* refactor code lightly
* convert from styled comp to css module
* convert const fat-arrows to functions
* update imports, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert /pathogens to App Router
2 participants