Skip to content

Commit 3833c35

Browse files
authored
feat: Adds support for React projects. (#802)
* feat: Adds support for React projects. Change-Id: I35cf5f483892ee84c11c8f79bf1524ff9849cc97 * Update comment tags for place details example * Update placeSearchRef type to allow null values * Update placeSearchRef type to allow null It now passes checks, but looks like I might've broken your UI (zoom does not behave normally upon selecting a result, it stays zoomed all the way out).
1 parent d0f1f35 commit 3833c35

File tree

15 files changed

+82
-46
lines changed

15 files changed

+82
-46
lines changed

samples/react-docs.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Copy/generate files for doc snippets.
4+
5+
echo ">>>Running react-docs.sh"
6+
7+
# Copy static documentation files as part of the build process.
8+
NAME=$1 # The name of the folder, taken from package.json "build" line.
9+
10+
# /Users/[USERNAME]/git/js-api-samples/samples
11+
12+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # Script directory (/samples)
13+
PROJECT_ROOT=$(dirname "$SCRIPT_DIR") # Get the parent directory (js-api-samples)
14+
DIST_DIR="${PROJECT_ROOT}/dist"
15+
SAMPLE_DIR="${PROJECT_ROOT}/dist/samples/${NAME}"
16+
17+
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
18+
19+
DOCS_DIR="${PROJECT_ROOT}/dist/samples/${NAME}/docs"
20+
21+
# Create two new folders.
22+
mkdir -p ${DOCS_DIR}/src
23+
24+
# Copy files
25+
cp "${SCRIPT_DIR}/${NAME}/src/app.js" "${DOCS_DIR}/src/app.js"
26+
cp "${SCRIPT_DIR}/${NAME}/src/app.tsx" "${DOCS_DIR}/src/app.tsx"
27+
cp "${SCRIPT_DIR}/${NAME}/src/styles.css" "${DOCS_DIR}/src/styles.css"
28+
cp "${SCRIPT_DIR}/${NAME}/index.html" "${DOCS_DIR}/index.html"
29+
30+
# Copy the data folder if one is found.
31+
if [ -d "public" ] && [ "$(ls -A public)" ]; then
32+
cp -r public/* "${DOCS_DIR}/"
33+
fi

samples/react-ui-kit-place-details-compact/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"version": "1.0.0",
44
"type": "module",
55
"scripts": {
6-
"start": "vite",
7-
"build": "tsc && vite build",
8-
"test": "tsc",
6+
"build": "tsc && bash ../react-docs.sh react-ui-kit-place-details-compact && npm run build:vite --workspace=. && bash ../dist.sh react-ui-kit-place-details-compact",
7+
"test": "tsc && npm run build:vite --workspace=.",
8+
"start": "tsc && vite build --base './' && vite",
9+
"build:vite": "vite build --base './'",
910
"preview": "vite preview"
1011
},
1112
"dependencies": {

samples/react-ui-kit-place-details-compact/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright 2025 Google LLC. All Rights Reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
// [START maps_react_ui_kit_place_details_compact]
6+
{/* [START maps_react_ui_kit_place_details_compact] */}
77
import React, {useEffect, useRef} from 'react';
88
import {createRoot} from 'react-dom/client';
99
import {APIProvider, useMapsLibrary} from '@vis.gl/react-google-maps';
@@ -84,5 +84,5 @@ export function renderToDom(container: HTMLElement) {
8484
</React.StrictMode>
8585
);
8686
}
87-
// [END maps_react_ui_kit_place_details_compact]
87+
{/* [END maps_react_ui_kit_place_details_compact] */}
8888

samples/react-ui-kit-place-details-latlng-compact/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2-
"name": "@js-api-samples/react-ui-kit-place-details-by-latlng-compact",
2+
"name": "@js-api-samples/react-ui-kit-place-details-latlng-compact",
33
"version": "1.0.0",
44
"type": "module",
5+
56
"scripts": {
6-
"start": "vite",
7-
"build": "tsc && vite build",
8-
"test": "tsc",
7+
"build": "tsc && bash ../react-docs.sh react-ui-kit-place-details-latlng-compact && npm run build:vite --workspace=. && bash ../dist.sh react-ui-kit-place-details-latlng-compact",
8+
"test": "tsc && npm run build:vite --workspace=.",
9+
"start": "tsc && vite build --base './' && vite",
10+
"build:vite": "vite build --base './'",
911
"preview": "vite preview"
1012
},
1113
"dependencies": {

samples/react-ui-kit-place-details-latlng-compact/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright 2025 Google LLC. All Rights Reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
// [START maps_react_ui_kit_place_details_by_latlng_compact]
6+
{/* [START maps_react_ui_kit_place_details_latlng_compact] */}
77
import React, {useEffect, useRef} from 'react';
88
import {createRoot} from 'react-dom/client';
99
import {APIProvider, useMapsLibrary} from '@vis.gl/react-google-maps';
@@ -85,4 +85,4 @@ export function renderToDom(container: HTMLElement) {
8585
</React.StrictMode>
8686
);
8787
}
88-
// [END maps_react_ui_kit_place_details_by_latlng_compact]
88+
{/* [END maps_react_ui_kit_place_details_latlng_compact] */}

samples/react-ui-kit-place-details-latlng/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2-
"name": "@js-api-samples/react-ui-kit-place-details-by-latlng",
2+
"name": "@js-api-samples/react-ui-kit-place-details-latlng",
33
"version": "1.0.0",
44
"type": "module",
5+
56
"scripts": {
6-
"start": "vite",
7-
"build": "tsc && vite build",
8-
"test": "tsc",
7+
"build": "tsc && bash ../react-docs.sh react-ui-kit-place-details-latlng && npm run build:vite --workspace=. && bash ../dist.sh react-ui-kit-place-details-latlng",
8+
"test": "tsc && npm run build:vite --workspace=.",
9+
"start": "tsc && vite build --base './' && vite",
10+
"build:vite": "vite build --base './'",
911
"preview": "vite preview"
1012
},
1113
"dependencies": {

samples/react-ui-kit-place-details-latlng/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright 2025 Google LLC. All Rights Reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
// [START maps_react_ui_kit_place_details_by_latlng]
6+
{/* [START maps_react_ui_kit_place_details_by_latlng] */}
77
import React from 'react';
88
import {createRoot} from 'react-dom/client';
99
import {APIProvider, useMapsLibrary} from '@vis.gl/react-google-maps';
@@ -91,4 +91,4 @@ export function renderToDom(container: HTMLElement) {
9191
</React.StrictMode>
9292
);
9393
}
94-
// [END maps_react_ui_kit_place_details_by_latlng]
94+
{/* [END maps_react_ui_kit_place_details_by_latlng] */}

samples/react-ui-kit-place-details/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"version": "1.0.0",
44
"type": "module",
55
"scripts": {
6-
"start": "vite",
7-
"build": "tsc && vite build",
8-
"test": "tsc",
6+
"build": "tsc && bash ../react-docs.sh react-ui-kit-place-details && npm run build:vite --workspace=. && bash ../dist.sh react-ui-kit-place-details",
7+
"test": "tsc && npm run build:vite --workspace=.",
8+
"start": "tsc && vite build --base './' && vite",
9+
"build:vite": "vite build --base './'",
910
"preview": "vite preview"
1011
},
1112
"dependencies": {

samples/react-ui-kit-place-details/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright 2025 Google LLC. All Rights Reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
// [START maps_react_ui_kit_place_details]
6+
{/* [START maps_react_ui_kit_place_details] */}
77
import React from 'react';
88
import {createRoot} from 'react-dom/client';
99
import {APIProvider, useMapsLibrary} from '@vis.gl/react-google-maps';
@@ -90,5 +90,5 @@ export function renderToDom(container: HTMLElement) {
9090
</React.StrictMode>
9191
);
9292
}
93-
// [END maps_react_ui_kit_place_details]
9493

94+
{/* [END maps_react_ui_kit_place_details] */}

samples/react-ui-kit-place-details/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"types": [
1818
"vite/client",
1919
"node"
20-
]
20+
],
21+
"removeComments": false,
2122
}
2223
}

0 commit comments

Comments
 (0)