-
Notifications
You must be signed in to change notification settings - Fork 122
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
Changes from 13 commits
3774d57
68b4f33
f1c58d1
aed82c3
9e45d78
fe1b65b
e4d8f0b
1dc45d0
f937364
bfa8316
ec40e11
980eb17
c406f07
fc2ef7c
451618c
bf2d58b
cfd1d55
cc98827
bf106e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.control-panel { | ||
font-size: 14px; | ||
line-height: 18px; | ||
width: 284px; | ||
background: #fff; | ||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.15); | ||
margin: 24px; | ||
padding: 12px 24px; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
outline: none; | ||
cursor: auto; | ||
box-sizing: border-box; | ||
|
||
& h3 { | ||
font-size: 1.2em; | ||
font-weight: 500; | ||
margin: 8px 0; | ||
} | ||
|
||
& p { | ||
margin-bottom: 16px; | ||
} | ||
|
||
.links { | ||
margin-top: 8px; | ||
display: flex; | ||
justify-content: space-between; | ||
|
||
& a { | ||
font-weight: bold; | ||
color: #486865; | ||
font-size: 11px; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
import {defineConfig, loadEnv} from 'vite'; | ||
import {resolve} from 'node:path'; | ||
|
||
export default defineConfig(({mode}) => { | ||
const {GOOGLE_MAPS_API_KEY} = loadEnv(mode, process.cwd(), ''); | ||
|
||
return { | ||
define: { | ||
'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify(GOOGLE_MAPS_API_KEY) | ||
}, | ||
resolve: { | ||
alias: { | ||
'@vis.gl/react-google-maps': resolve('../../src/index.ts') | ||
} | ||
} | ||
}; | ||
}); | ||
export default { | ||
define: { | ||
'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify( | ||
process.env.GOOGLE_MAPS_API_KEY | ||
) | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,19 @@ import * as React from 'react'; | |
|
||
function ControlPanel() { | ||
return ( | ||
<div className="control-panel"> | ||
<div className="control-panel-basic-map"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
<h3>Basic Map</h3> | ||
<p> | ||
The simplest example possible, just rendering a google map with some | ||
settings adjusted. | ||
</p> | ||
<div className="source-link"> | ||
<div className="links"> | ||
<a | ||
href="https://codesandbox.io/s/github/visgl/react-google-maps/tree/main/examples/basic-map" | ||
target="_new"> | ||
Try on CodeSandbox ↗ | ||
</a> | ||
|
||
<a | ||
href="https://github.com/visgl/react-google-maps/tree/main/examples/basic-map" | ||
target="_new"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.control-panel-basic-map { | ||
font-size: 14px; | ||
line-height: 18px; | ||
width: 284px; | ||
background: #fff; | ||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.15); | ||
margin: 24px; | ||
padding: 12px 24px; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
outline: none; | ||
cursor: auto; | ||
box-sizing: border-box; | ||
} | ||
|
||
.control-panel-basic-map h3 { | ||
font-size: 1.2em; | ||
font-weight: 500; | ||
margin: 8px 0; | ||
} | ||
|
||
.control-panel-basic-map p { | ||
margin-bottom: 16px; | ||
} | ||
|
||
.control-panel-basic-map .links { | ||
margin-top: 8px; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.control-panel-basic-map .links a { | ||
font-weight: bold; | ||
color: #486865; | ||
font-size: 11px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
import {defineConfig, loadEnv} from 'vite'; | ||
import {resolve} from 'node:path'; | ||
|
||
export default defineConfig(({mode}) => { | ||
const {GOOGLE_MAPS_API_KEY} = loadEnv(mode, process.cwd(), ''); | ||
|
||
return { | ||
define: { | ||
'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify(GOOGLE_MAPS_API_KEY) | ||
}, | ||
resolve: { | ||
alias: { | ||
'@vis.gl/react-google-maps': resolve('../../src/index.ts') | ||
} | ||
} | ||
}; | ||
}); | ||
export default { | ||
define: { | ||
'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify( | ||
process.env.GOOGLE_MAPS_API_KEY | ||
) | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ function ControlPanel({ | |
onMapConfigIdChange | ||
}: ControlPanelProps) { | ||
return ( | ||
<div className="control-panel"> | ||
<div className="control-panel-change-map-id"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above |
||
<h3>Change MapIds</h3> | ||
<p> | ||
The react-component can switch between multiple mapIds without having to | ||
|
@@ -38,7 +38,13 @@ function ControlPanel({ | |
</select> | ||
</div> | ||
|
||
<div className="source-link"> | ||
<div className="links"> | ||
<a | ||
href="https://codesandbox.io/s/github/visgl/react-google-maps/tree/main/examples/change-map-id" | ||
target="_new"> | ||
Try on CodeSandbox ↗ | ||
</a> | ||
|
||
<a | ||
href="https://github.com/visgl/react-google-maps/tree/main/examples/change-map-id" | ||
target="_new"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function getApiKey() { | ||
const url = new URL(location.href); | ||
const apiKey = | ||
url.searchParams.get('apiKey') || | ||
(process.env.GOOGLE_MAPS_API_KEY as string); | ||
|
||
if (!apiKey) { | ||
const key = prompt( | ||
'Please provide your Google Maps API key in the URL\n' + | ||
'(using the parameter `?apiKey=YOUR_API_KEY_HERE`) or enter it here:' | ||
); | ||
|
||
if (key) { | ||
url.searchParams.set('apiKey', key); | ||
location.replace(url.toString()); | ||
} | ||
} | ||
|
||
return apiKey; | ||
} |
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 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