Skip to content

rewrite snackplayer with remark plugin #4

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

Closed
wants to merge 13 commits into from
Closed

Conversation

darshkpatel
Copy link
Member

@darshkpatel darshkpatel commented Aug 29, 2020

Note: Merge #3 before this PR ( Branched from #3 )
I've re-written the snackpayer because v2 supports remark plugin instead of remarkable plugin

@darshkpatel darshkpatel requested review from slorber and teikjun August 29, 2020 12:37
@darshkpatel darshkpatel changed the base branch from minimal-site to main August 29, 2020 12:37
@darshkpatel
Copy link
Member Author

hey where did the deploy previews disappear : /

@teikjun
Copy link
Member

teikjun commented Aug 29, 2020

I'm not sure either 🤔

@slorber slorber changed the base branch from main to dev September 2, 2020 15:30
@darshkpatel
Copy link
Member Author

Do note the showcase, versions, and landing page won't work in this branch as of now.
Will be fixed in a separate PR upgrading these pages

data-snack-description="${description}"
data-snack-code="${encodedSampleCode}"
data-snack-platform="${platform}"
data-snack-supported-platforms=${supportedPlatforms}
Copy link

Choose a reason for hiding this comment

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

should we add quotes there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, basically the plugin injects HTML in place of the SnackPlayer code blocks so
data-snack-description="${description}" will be data-snack-description="Description of the snackplayer" in the page

Copy link

Choose a reason for hiding this comment

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

I mean data-snack-supported-platforms specifically does not have quotes will the others have, is it normal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added them in 574838e

@darshkpatel
Copy link
Member Author

Screenshot 2020-09-03 at 10 37 36 AM

SnackPlayers work only after a refresh due to other scripts not being migrated ( eg. tabs.js ), and the page disappears on refresh when on prod, use the dev server to view it. I'm looking into fixes

@teikjun
Copy link
Member

teikjun commented Sep 3, 2020

Possibly related issue: SnackPlayers within Docusaurus tabs disappear after switching tabs:
e.g. https://deploy-preview-4--react-native-website-migration.netlify.app/docs/next/
I'm looking into this as well

@slorber
Copy link

slorber commented Sep 3, 2020

Thanks,

There should be a call like windon.ExpoSnack.initialize(); or windon.ExpoSnack.append(domNode,options); to put somewhere :)

https://snack.expo.io/embed.js

Docusaurus v2 is more "lazy", I think only the first tab is in the DOM on first render, and on navigation the dom ready events don't wire again.

@darshkpatel
Copy link
Member Author

darshkpatel commented Sep 3, 2020

There should be a call like windon.ExpoSnack.initialize(); or windon.ExpoSnack.append(domNode,options); to put somewhere :)

It's present in codeblock.js

@darshkpatel
Copy link
Member Author

darshkpatel commented Sep 3, 2020

Docusaurus v2 is more "lazy", I think only the first tab is in the DOM on first render, and on navigation the dom ready events don't wire again.

Might be the reason why snackplayer load on reload, any suggestions on where to put the ExpoSnack initialize call?

@slorber
Copy link

slorber commented Sep 3, 2020

I'm not sure, this must be called on navigation + on tab switch :)

Maybe it's the remark plugin that should add an inline <script> just after the snack player div?

I've seen this PR but not sure if it has ever been used nor documented: facebook/docusaurus#1591
(It would solve the nav problem but not the tab switch problem anyway)

@yangshun do you think it's a good usecase for the onRouteUpdate?

@slorber
Copy link

slorber commented Sep 3, 2020

Look at the google analytics plugin to see an example usage of onRouteUpdate

@Simek
Copy link

Simek commented Sep 11, 2020

One more thing that need to be implemented is SnackPlayer theme sync with Docusaurus theme. I have asked Expo related person about the tip or guidance how this can be achieved.

@Simek
Copy link

Simek commented Sep 14, 2020

@darshkpatel Can you extract the tabs changes to the separate PR? It would be nice to have them on dev branch. 🙂

@darshkpatel
Copy link
Member Author

darshkpatel commented Sep 14, 2020

@darshkpatel Can you extract the tabs changes to the separate PR? It would be nice to have them on dev branch. 🙂

If I'm not mistaken, you're referring to
8c661bb, 137276f and e5db801
I believe @teikjun just pushed them as a PoC and the changes are made only to a couple of files

@Simek
Copy link

Simek commented Sep 14, 2020

@darshkpatel Yup, you're right. I don't know why this coded ended here but I have created very simple issue about the tabs #20.

Also on the SnackPlayer topic - it should not be available on mobile platforms (code block with the correct highlight should be rendered instead of it):

@darshkpatel
Copy link
Member Author

Just a head's up, I'm currently working on a general Remark Plugin for SnackPlayer as discussed.

@darshkpatel
Copy link
Member Author

Closing in favor of #31

@darshkpatel darshkpatel closed this Oct 8, 2020
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.

4 participants