docs: Migrate to tanstack router#2895
Conversation
Runs but still a lot to fix / improve
…ermining which iframe to use. Update the tabs to reset when the component changes
Deploying atlantis with
|
| Latest commit: |
2a8795f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f5f05ebd.atlantis.pages.dev |
| Branch Preview URL: | https://mike-migrate-to-tanstack-rou.atlantis.pages.dev |
|
|
||
| useEffect(() => { | ||
| if (code) { | ||
| console.log("updating code"); |
… a mdx file for the sidebar navigation
…ate-to-tanstack-router
…ate-to-tanstack-router
…ate-to-tanstack-router
…ate-to-tanstack-router
scotttjob
left a comment
There was a problem hiding this comment.
Smoke tested locally. Can't find any major issues.
This is overall a low-risk PR because it shouldn't affect the build output of the product. Michael if you can run a diff output and confirm the build is identical, then I saw we just ship it (I'll come back and approve).
Overall there's some chunky code in places, just in terms of length, but we're doing a fair amount of complex functionality in here. We can continue to iterate once react-router is out properly.
| label: string; | ||
| } | ||
|
|
||
| export type RecmaVFile = VFile & { |
There was a problem hiding this comment.
It is a JS processor for markdown files for writing plugins with mdx files
https://github.com/mdx-js/recma
| import { Box, Content, Typography } from "@jobber/components"; | ||
| import { MouseEvent, useEffect, useState } from "react"; | ||
| import { Link, useMatches, useParams } from "@tanstack/react-router"; | ||
| import omit from "lodash/omit"; |
There was a problem hiding this comment.
I have a polite, module bundler friendly related request. Is there any way we can avoid lodash usage moving forward?
| * Recma plugin: injects `export const toc = [...]` from file.data.toc so the | ||
| * compiled MDX module exports a TOC for the sidebar. | ||
| */ | ||
| export function recmaInjectToc() { |
There was a problem hiding this comment.
I'd love some more detailed JS Doc comments in here explaining what some of this code is up, and why. May help future us/LLMs.
There was a problem hiding this comment.
Added a few more comments in 190e05c I totally lost my initial references for this
| }, 100); | ||
| } | ||
| }; | ||
| const newParams = omit(params, "tab"); |
There was a problem hiding this comment.
Just so I'm not all "no way lodash" without any support as how to work without lodash omit, In this case, I know it's a little clunky but it doesn't require any libraries:
const newParams = { ...params };
delete newParams.tab;
The other solution {tab:_tab, ...newParams} = params doesn't work for us because we lint away unused variables, so the delete is the backup.
There was a problem hiding this comment.
I can nuke lodash. I tried doing the import of lodash to help with tree shaking but I can nuke it. I used import omit from "lodash/omit" instead of the heavier import { omit } from "lodash"
| * This isn't really a Layout component, but it's not really a component component either. We could make a "Views" directory maybe, or a "Template" directory? | ||
| * @returns ReactNode | ||
| */ | ||
| // eslint-disable-next-line max-statements |
There was a problem hiding this comment.
:that-thing-you-do-with-your-fingers-that-sounds-like-a-snap-rainbow:
| [PageMeta, currentPlatform], | ||
| ); | ||
|
|
||
| // Set initial type based on what's available for this component |
There was a problem hiding this comment.
:that-thing-you-do-with-your-fingers-that-sounds-like-a-snap-rainbow:
| } | ||
| }, [code, type, updateCode]); | ||
|
|
||
| const handleTabChange = (tabIn: number) => { |
There was a problem hiding this comment.
:that-thing-you-do-with-your-fingers-that-sounds-like-a-snap-rainbow:
| import UseResizeObserverDocs from "../content/hooks/useResizeObserver.stories.mdx"; | ||
| import UseStepperDocs from "../content/hooks/useStepper.stories.mdx"; | ||
| import UseWindowDimensionsDocs from "../content/hooks/useWindowDimensions.stories.mdx"; | ||
| import UseBoolDocs, { |
There was a problem hiding this comment.
All this extra boilerplate...I really want to find a better solve for this long-term. It's not the worst, but it's not great either.
There was a problem hiding this comment.
Yeah, I do want to remove the boiler plate on this. I was original going to migrate to file based routing in TSR but that made things chunky and I figured getting to TSR was a good first step
| { | ||
| path: "/guides", | ||
| handle: "Guides", | ||
| exact: true, |
| "react-element-to-jsx-string": "^15.0.0", | ||
| "react-markdown": "^10.1.0", | ||
| "react-native-svg-web": "^1.0.9", | ||
| "react-router": "5.3.4", |
|
@scotttjob I just pushed a fix in 2a8795f which solves a problem I just found where if you clicked on a mobile usage or props link on the sidebar it wouldn't actually go to the mobile tab and would instead stay on web (or whatever platform you were currently on) |
|
I am QA-ing 👀 |
taylorvnoj
left a comment
There was a problem hiding this comment.
big improvement! sooo excited about the linking! All the QA items you listed work as described.
I see Scott reviewed also and dug deeper into the code than I did. I'm approving but want to make sure Scott is 👍🏻 also!
Motivations
There are some improvements we want to make to the doc site such as linking directly to tabs and using hashes to link directly to headings. While react-router-dom supports this type of stuff we are currently using a super old version (react router dom v5 which was last updated 2 years ago). Since it was such an old version finding resources for this version would be difficult.
In theory I could have updated react-router-dom on the docs site, however I decided to migrate to tanstack router for the following reasons:
Future work
Adding support for copying and going to headings in other tabs (for example the implement tab)
Changes
Added
Changed
Deprecated
Removed
Fixed
Security
Testing
Buttoncomponent in the implement tab when you click "variants" it takes you to the design tab and scrolls to that headingChanges can be
tested via Pre-release
In Atlantis we use Github's built in pull request reviews.