lostintangent / codeswing

VS Code extension for building web applications ("swings") using a interactive and editor-integrated coding environment
https://aka.ms/codeswing
MIT License
977 stars 46 forks source link

Use --vscode theme variables in default template #46

Closed Sheraff closed 3 years ago

lostintangent commented 3 years ago

My only concern with this is that it's a very noticeable change, after CodeSwing has been out for a while. Additionally, if you open a CodePen that was exported to a gist, that was almost definitely authored with the assumption that the default background is white. So this change could also impact interop with other services.

Sheraff commented 3 years ago

@lostintangent I was actually looking to add a boolean option for this in the settings but I've never authored a vscode extension and i haven't found out how to do that yet.

lostintangent commented 3 years ago

That sounds good! We could add a new setting, that would leave the current behavior as-is, but let users opt-into the new theming.

Here's an example of how to add a new Boolean setting. Maybe we could call it something like codeswing.themePreview? And have it default to false?

Here's the code that reads the config settings, so you'd just need to add a new overload for themePreview, and then update your PR the check if that setting is true, and conditionally apply the background/foreground color.

Sheraff commented 3 years ago

@lostintangent I guess I was tired yesterday when I looked at it because it took me 5 minutes this morning to add it! Thanks for the pointers BTW.

Sheraff commented 3 years ago

I made a more exhaustive stylesheet that would go a little beyond just background and color

While it's more extensive than my initial proposal, it still just overrides browser defaults with theme variables so it feels reasonable to me, but I didn't want to include it in my PR without checking whether you think it's okay to go this far.

And here's a preview:

Screen Shot 2021-07-01 at 10 55 56
lostintangent commented 3 years ago

@Sheraff That sounds great to me! Now that it's an opt-in behavior, I think we can be much more opinionated with the styling 👍🏼

Another thought is that it might be worth adding this "themePreview" setting to the codeswing.json file schema as well. That way, if a swing was authored in a way that depended on these styles, then the user could indicate that in the swing itself, so that when another user opened it, they've get the right styling, regardless what their VS Code setting was.

Sheraff commented 3 years ago

@lostintangent alright, everything should be in order as far as I can tell.

Tell me if I'm missing anything!

Sheraff commented 3 years ago

@lostintangent all done ;-)

lostintangent commented 3 years ago

Awesome! Thanks so much for this contribution. Merging right now, and I'll try to release an update this afternoon :D

Sheraff commented 3 years ago

@lostintangent What does the release timeline look like from here? As in: what are the steps / delays before I can see this in VSCode for real?

lostintangent commented 3 years ago

I'm going to test out your changes right now and if everything goes well, then I'll ship an update in the next hour. That will also include support for importing JSX and TSX files.

lostintangent commented 3 years ago

This change how now been shipped! Thanks 🚀

Sheraff commented 3 years ago

Thank you for your help with this!