-
Notifications
You must be signed in to change notification settings - Fork 77
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
Rewrite as a Svelte/Express app #56
Conversation
I've deployed this even though there are tasks outstanding, as it's an improvement on the previous site, and it will hopefully mean feedback/bug reports. |
I was actually just taking a look at this locally. One thing I saw (besides the missing roadtrip dependency, which I see you fixed) was a weird routing bug on Firefox. Start from a particular anchor on the guide page, then click to the REPL or blog, then press back - the last back doesn't work, I'm staying on whatever the non-guide page was. This works fine on Chrome and works fine if you don't start from an anchor on the guide page. |
Huh, that is weird. What version of FF are you using? It seems to be okay for me on FF52 on OS X. Do you see any errors in the console when that happens? |
blocked = true; | ||
|
||
fn(); | ||
setTimeout( unblock, ms ); |
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.
I wonder whether this could lead to a memory leak if the timeouts aren't cleared.
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.
shouldn't do, why would it? The timeout is never meant to be cleared before it executes, and you obviously don't need to clear a timeout after it's been executed
padding: 2em 1em; | ||
/*background-color: #333; | ||
color: #f4f4f4;*/ | ||
background-color: white; |
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.
Usually you use hex values for colours.
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.
|
||
.learn-svelte { | ||
background-color: rgb(170,30,30); | ||
color: white; |
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.
Usually you use hex values for colours.
@media (min-width: 480px) { | ||
.left, .right { | ||
max-width: 32em; | ||
margin: 0 auto; |
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.
You need to make it a block element (or take care to not add those classes to inline elements as that won't have an effect).
bottom: 0; | ||
padding: 0.5em; | ||
background-color: rgb(255,220,220); | ||
border-top: 1px solid rgb(200,0,0); |
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.
You usually use hex values for colours.
// the component is actually in the DOM | ||
setTimeout( () => { | ||
this.editor.refresh(); | ||
}); |
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.
What happens with setTimeout
if you omit the second argument?
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 defaults to 0
toTeardown = component; | ||
component = null; | ||
|
||
setTimeout( () => { // necessary because `data` is not yet updated. TODO would be nice to fix this |
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.
Missing second argument?
<div class='controls'> | ||
<button class='{{showGenerated ? "" : "active"}}' on:click='set({ showGenerated: false })'>input</button> | ||
<button class='{{showGenerated ? "active" : ""}}' on:click='set({ showGenerated: true })'>output</button> | ||
<button class='{{saving ? "active" : ""}}' on:click='save()'>{{saving ? 'saving' : 'save'}}</button> |
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.
Semantically those <button>
s are of type „submit”.
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.
I associate submit
with forms, rather than event triggers. You could maybe argue the 'save' button is, but the others aren't, they're effectively tabs. With submit
you have to prevent the event default — is there any real advantage to submit
? If it's an a11y thing, maybe there's an aria
attribute that would be more appropriate?
margin: 0 0.5em 0 0; | ||
border-radius: 0.2em; | ||
color: rgb(170,30,30); | ||
border: 1px solid rgb(170,30,30); |
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.
Usually you use hex values for colours.
|
||
.controls button.active { | ||
background-color: rgb(170,30,30); | ||
color: white; |
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.
Usually you use hex values for colours.
I'm on Firefox 52 on Windows. I am getting a |
Huh, thought I'd fixed that in Rich-Harris/roadtrip@27778fa. Is this happening on the deployed site, or locally? Could it be that your dependencies are out of date? |
This is on the live deployed site. But taking a look at the minified code in https://svelte.technology/bundle.js I don't see that change. |
Curiouser and curiouser. I've redeployed, and it looks like bundle.js does now have that check, so hopefully that's the end of it... |
All right, I'm no longer getting that console error - but the navigation still isn't working. When I go back from /repl to /guide#some-anchor I'm assuming the new check is now returning early from the popstate handler, but there is still something that has to happen on that popstate. (Should this conversation move over to roadtrip? 😃) |
Ok, now I'm more freaked out that it is working for me! Now that you mention it does seem like something is missing from that code. Perils of trying to fix bugs at the end of the day.
Probably! And if you know of any alternative routers that use regular |
The |
Everything under the |
Yep, am just keeping it around so it's easier to copy and paste stuff if I need to... have updated the task list at the top of the page so we don't forget |
Edit for real this time - https://svelte.technology/repl works fine but https://svelte.technology/repl/ does not. |
Ah, right — that makes sense. We probably just need to add an entry here |
Some LESS snuck into the CSS here. |
Merging this, will open separate issues for the remaining tasks |
https://sveltetechnology-ukcvrplota.now.sh
Svelte is mature enough that it makes sense to use it rewrite https://svelte.technology. Apart from testing out the development workflow, this has some tangible benefits:
Still very work-in-progress, lots of outstanding tasks:
plus whatever I forgot.
A few notes on developer experience:
generate: 'ssr'
then callingapp.renderCss()
) is a bit clunky. It means you have to maintain thatApp.html
file as you add new routes, and you have to send all the CSS for the entire app (though maybe that's not a bad thing — dynamically adding CSS is often a CSP violation, and the CSS is tiny).npm run dev
taskAs we gather more of this sort of data on building these kinds of apps, maybe it'll become clearer what can be packaged up somehow in a way that improves the developer experience, in the way that Next.js improved the experience of building universal React apps.