feature(website): Allow the initially selected file to be specified #601
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #326
Why
When embedding a snack, the embedded view only shows the
App.{js,tsx)
file in the embedded view. To view other files, the user needs to open the snack on snack.expo.dev so that they can view the file browser.This limitation can cause issues when it's desired to show the contents of a file other than
App.{js,tsx)
in an embedded snack, such as when a snack is using@shopify/react-native-skia
and needs to be able to render usingreact-native-web
. In this scenario, the embedded snack ends up showing just the code needed to setup Skia for the web, rather than the code used to render the Skia component.With the ability to set the
initiallySelectedFile
param, the embedded snack can be set to show the most relevant file.When opening the full snack view using the icon, the param will be passed through and used to select the initial file when the file browser is visible.
If an invalid filename is specified, it will be ignored.
How
After investigating how other params like
sourceUrl
work, I was able to add theinitiallySelectedFile
param in a similar fashion.Test Plan
I've recorded the behaviour when used on the embedded client, when linking out to the full client, and when used on the full client.
Kapture.2024-08-15.at.15.34.23.mp4