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

Upgrade React-Native website to Docusaurus v3 #3780

Merged
merged 34 commits into from
Sep 14, 2023

Conversation

slorber
Copy link
Contributor

@slorber slorber commented Jun 30, 2023

WIP PR to upgrade to Docusaurus v3 canary

I will let you know when it's ready to review


Deploy preview: https://deploy-preview-3780--react-native.netlify.app/

Argos visual tests


Note to myself: we can revert usage of in favor of \|, see change made in #3807 (comment)


Follow-up of:

@slorber slorber marked this pull request as draft June 30, 2023 18:00
@netlify
Copy link

netlify bot commented Jun 30, 2023

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit a5143f8
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/6502e8446954e10008b987ab
😎 Deploy Preview https://deploy-preview-3780--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@slorber

This comment was marked as outdated.

@slorber slorber changed the title WIP - Upgrade to Docusaurus v3 Upgrade React-Native website to Docusaurus v3 Sep 1, 2023
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @slorber, thank you so much for this PR. I left a few comments, mainly for clarification.
The only significant piece I am not confident to review are the Snack updates: at first glance, they looks good to me, but let's wait for another pair of eyes to double check them.

plugins/remark-snackplayer/package.json Outdated Show resolved Hide resolved
plugins/remark-snackplayer/package.json Show resolved Hide resolved
website/docusaurus.config.js Outdated Show resolved Hide resolved
website/package.json Show resolved Hide resolved
Comment on lines -12 to +13
if (!ExecutionEnvironment.canUseDOM) {
const isBrowser = useIsBrowser();
if (!isBrowser) {
Copy link
Contributor Author

@slorber slorber Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a little React hydration issue. The issue was already there, and is not a blocker, but is now logged thanks to React 18 new hydration callback onRecoverableError(error) (https://react.dev/blog/2022/03/29/react-v18)

The SSR/SSG render and the first CSR render outputs should match, so things such as typeof window !== "undefined" etc should be avoided.

@slorber
Copy link
Contributor Author

slorber commented Sep 12, 2023

Hi @slorber, thank you so much for this PR. I left a few comments, mainly for clarification. The only significant piece I am not confident to review are the Snack updates: at first glance, they looks good to me, but let's wait for another pair of eyes to double check them.

Thanks @cipolleschi

Regarding the SnackPlayer, unless you know well the differences between MDX v1/v2 it would be hard to review technically. IMHO you'd rather focus on the outcome: is the snack player still working on all the pages in the deploy preview, or do you see any regression?

@cipolleschi
Copy link
Contributor

Regarding the SnackPlayer, unless you know well the differences between MDX v1/v2 it would be hard to review technically. IMHO you'd rather focus on the outcome: is the snack player still working on all the pages in the deploy preview, or do you see any regression?

Not really, I was just mentioning it in case someone among @cortinico @TheSavior or @Simek wants to double-check that code! :D

Copy link
Member

@elicwhite elicwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snack changes seem fine, and the snack player seems to work in the preview

*/
figcaption > p:last-child {
margin-bottom: 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a new line at the end of the file it seems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new line but not sure why it's needed? CI is passing. Is there linter I don't see?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned it because GitHub showed this icon presumably because there wasn't an extra new line, whereas all other files have that extra new line.
CleanShot 2023-09-15 at 17 48 25

And yeah, it's normally enforced with a linter. See react-native's main eslint config: https://github.com/facebook/react-native/blob/2be409ff55b50563a5f123f7823fa7cdb72dbef9/packages/eslint-config-react-native/index.js#L264

@@ -94,7 +94,7 @@ return <S3Album track/>

AWS Amplify favors a convention over configuration style of development, with a global initialization routine or initialization at the category level. The quickest way to get started is with an [aws-exports file](https://aws.amazon.com/blogs/mobile/enhanced-javascript-development-with-aws-mobile-hub/). However, developers can also use the library independently with existing resources.

For a deep dive into the philosophy and to see a full demo, check out the video from [AWS re:Invent](https://www.youtube.com/watch?v=vAjf3lyjf8c).
For a deep dive into the philosophy and to see a full demo, check out the video from [AWS re\:Invent](https://www.youtube.com/watch?v=vAjf3lyjf8c).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be escaped?

Copy link
Contributor Author

@slorber slorber Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docusaurus v3 now uses https://github.com/remarkjs/remark-directive to provide support for admonitions, and other things using syntax such as :textDirective, ::leafDirective and :::containerDirective.

Re:invent is parsed as Re + :invent text directive.

This is what happens in the MDX playground if you turn the remark-directive option on:

CleanShot 2023-09-14 at 13 06 03@2x

This regression was captured by the visual regression tests:

https://app.argos-ci.com/slorber/rnw-visual-tests/builds/32/56012838

CleanShot 2023-09-14 at 12 51 24@2x


Technically it should probably be possible to add some code in Docusaurus v3 so that this escaping becomes un-necessary, and the unhandled AST directive nodes get serialized back as raw text. For now it's not implemented, and not even sure who should implement that 😅. Will think about it. I hope in the meantime it's not a blocker for you to merge this PR.

className="btn">
Read more
</a>
className="btn">Read more</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change made by a formatter or manually?

Copy link
Contributor Author

@slorber slorber Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are manual and intentional.

With MDX v2, using new lines now create extra paragraphs, cf the MDX playground:

CleanShot 2023-09-14 at 12 53 26@2x

And RN website adds padding-bottom to all paragraphs of the website, so this extra <p> tag visually changes the way this is rendered.

I'm not sure the intent is to create a <a><p>Read more</p></a> here so refactored to avoid that and keep <a>Read more</a> as the final output.

There are only 4 similar cases and they are only found in very old blog posts, so I thought it was better to adjust those 4 blog posts rather than fixing it with CSS.


Somehow it's the exact same case as the <figcaption> case that you commented here: #3780 (comment)

But there are much more recent multiline usage cases of <figcaption> on the RNW site, like this one:

<figure>
  <img src="/docs/assets/d_pressable_anatomy.svg" width="1000" alt="Diagram of HitRect and PressRect and how they work." />
  <figcaption>
    You can set <code>HitRect</code> with <code>hitSlop</code> and set <code>PressRect</code> with <code>pressRetentionOffset</code>.
  </figcaption>
</figure>

That's the reason I decided to use CSS for <figcaption> instead of refactoring many MDX docs:

/*
Prevent useless bottom margin for multiline <figcaption> tags in MDX:
<figcaption>
  some paragraph text
</figcaption>
 */
figcaption > p:last-child {
  margin-bottom: 0;
}

@slorber
Copy link
Contributor Author

slorber commented Sep 14, 2023

Thanks for the review @cipolleschi @TheSavior

Let me know if I can do anything else ;)

@cipolleschi cipolleschi merged commit add2db0 into facebook:main Sep 14, 2023
1 check passed
@slorber
Copy link
Contributor Author

slorber commented Sep 14, 2023

🎊 thanks 🎉 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants