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

feat: standalone examples (CodeSandbox) #48

Merged
merged 19 commits into from
Nov 7, 2023

Conversation

mrMetalWood
Copy link
Collaborator

  • restructure examples to be able to run the standalone on a service like CodeSandbox so that users can play with the examples right away

@@ -2,13 +2,19 @@ import * as React from 'react';

function ControlPanel() {
return (
<div className="control-panel">
<div className="control-panel-basic-map">
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this will interfere with the embedded rendering in the website. Would probably be better to keep it at just control-panel or add another class if needed.

@@ -13,7 +13,7 @@ function ControlPanel({
onMapConfigIdChange
}: ControlPanelProps) {
return (
<div className="control-panel">
<div className="control-panel-change-map-id">
Copy link
Collaborator

Choose a reason for hiding this comment

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

see above

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think adding a lib directory just for this one file is a bit much and it could just be in the src folder, but its fine by me either way

import App from 'website-examples/basic-map/src/app';

<App />
<BrowserOnly>{() => <App />}</BrowserOnly>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the fix to get the build process to work again? I remember that at some point I thought I needed the BrowserOnly wrapper, but it turned out the reason for the problem was something completely different. Let's have a look if we find another way to solve this.

@usefulthink
Copy link
Collaborator

usefulthink commented Nov 2, 2023

First of all, I'm very excited about this feature and I think this will make the examples on our site so much more user-friendly.

About the styles for standalone examples, how about we just load a special stylesheet for the examples (or maybe even the full stylesheet) from something like https://visgl.github.io/react-google-maps/styles/examples.css. Then we wouldn't need the duplicated styles for all examples and they would still work standalone.

We'd only have to figure out how to build/deploy the file during the website-build and we would be fine. I would maybe even consider doing the same for other shared code like the getApiKey() function. We could just have that as a plain JS module on our site and load it from there.

@usefulthink usefulthink merged commit 959c6e3 into visgl:main Nov 7, 2023
2 checks passed
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