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
Squiggle value menu additions #2564
Conversation
🦋 Changeset detectedLatest commit: e00fd23 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Apply Sweep Rules to your PR?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great changes. window
suggestion should be fixed before merge, and I don't care much about the second one, can be improved later.
//Set the output to the window so that it can be accessed by users/developers there | ||
//This is useful for debugging | ||
if (window) { | ||
window[WINDOW_VARIABLE_NAME] = output; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be multiple Squiggle components on any page, so maybe this shouldn't be enabled by default?
Two alternatives:
- set this in
onOutputChange
prop that's passed toLeftPlaygroundPanel
inSquigglePlayground
(multiple playgrounds on a single page are rare) - pass it to
SquigglePlayground
inonOutputChange
prop (we don't haveonOutputChange
prop in the playground yet because we merged your version withonExportsChange
before I implementedVersionedSquiggleChart
, but I think we agreed to change it later); then log it in docs playground and in Squiggle Hub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
We do (1), and also, we set each playground to have it's own ID, that we use for it.
Like, window.squiggleOutput.[Playground_ID]
We can generate the ID with https://react.dev/reference/react/useId.
If we do that, we could also save the project
, sourceId
, code
, and anything else, if we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's also an option.
OTOH, I've started to have doubts about the usefulness of this feature, compared to using built-in React dev tools:
I just tried it and it works; it's slightly hard to locate SquiggleViewer component because it doesn't have a name (I'm not sure why; we do forwardRef(function SquiggleViewer(...) {})
instead of forwardRef(() => ...)
, which should be enough), but other than that, it's quite convenient.
There's also right click -> "Store as global variable" action on individual props (hard to screenshot).
IIRC, until recently, Next.js obfuscated component names in production builds, but recently they changed it to look the same as in dev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might not be very useful, but it seems pretty cheap. And the React dev tools are a browser extention - a fair bit more hacky.
This we could give to users for use.
Co-authored-by: Vyacheslav Matyukhin <me@berekuk.ru>
window.squiggleOutput
, for further debugging.