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

refactor: Clean up a bit post #1155 & #1150 #1157

Merged
merged 3 commits into from
Jun 30, 2024

Conversation

rschristian
Copy link
Member

Few things I ran into in #1148 that can be extracted a bit.

@@ -20,6 +20,7 @@
"rules": {
"react/sort-comp": 0,
"react/no-danger": 0,
"react/jsx-no-bind": 0,
Copy link
Member Author

Choose a reason for hiding this comment

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

Is anyone against this getting silence? Granted, many of them are my fault, but we have dozens of warnings that I don't think are important to anyone these days?

Comment on lines -143 to -147
// TODO: CodeMirror v5 cannot load in Node, and loading only the runner
// causes some bad jumping/pop-in. For the moment, this is the best option
typeof window === 'undefined'
? null
: <Splitter
Copy link
Member Author

@rschristian rschristian Jun 30, 2024

Choose a reason for hiding this comment

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

There is already a if (typeof window === 'undefined') return null above, this does nothing. Was a relic from when I was trying to see if I could prerender the content portion of the tutorial but skip the editor & runner (I could not, at least not well enough to ship).

Evidently I forgot to clean it up.

Comment on lines -41 to +39
function initialCode(query) {
let code, slug;
async function getInitialCode(query) {
const { route } = useLocation();
Copy link
Member Author

@rschristian rschristian Jun 30, 2024

Choose a reason for hiding this comment

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

Admittedly this block was a bit of a mess that I should have given a better look over.

Fixes an issue with ?code being cleared from the URL on mount (though the code would still populate correctly) and drops history.replaceState in a few places in favor of route().

This still isn't great, preact-iso has a rather fundamental issue at the moment (IMO) in that it updates the location context as soon as it matches a route. This leads to really awful control flow w/ suspense as you cannot rely on the content being updated alongside a path change -- content will update in a subsequent render. It's workable, just... fiddly. I was trying to avoid some of the woes by using history.replaceState but this refactor should work well while getting us in a position to take advantage of a fix to iso in the future (though I think it'll need a major).

const [editorCode, setEditorCode] = useStoredValue('preact-www-repl-code', code);
const [exampleSlug, setExampleSlug] = useState(slug || '');
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the slug changes here are, again, due to me trying to run around iso when I wrote this due to the awkward update order.

@rschristian rschristian force-pushed the chore/clean-after-tutorial-and-repl branch from 6a5b3b1 to eb67ebd Compare June 30, 2024 07:12
Comment on lines -27 to -29
footer {
display: none !important;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

No footer on the REPL of course -- I had just copy/pasted this CSS, it's not relevant anymore.

@rschristian rschristian marked this pull request as ready for review June 30, 2024 07:17
@rschristian rschristian merged commit fa8a917 into master Jun 30, 2024
5 checks passed
@rschristian rschristian deleted the chore/clean-after-tutorial-and-repl branch June 30, 2024 19:30
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.

2 participants