-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add basic react app in examples/apps
- Loading branch information
1 parent
fd97855
commit ea8e280
Showing
9 changed files
with
8,972 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["@babel/preset-env", "@babel/preset-react"], | ||
"plugins": ["transform-class-properties"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
A previous link is required to test current status | ||
|
||
- `npm link` in the parent project | ||
- `npm link @carto/web-sdk` in this app | ||
|
||
Then, to run the project `npm install` and `npm run start` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "react-basic", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "webpack-dev-server --open --mode development", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@carto/web-sdk": "^1.0.0-alpha.2", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.5", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/preset-react": "^7.10.4", | ||
"babel-loader": "^8.1.0", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"html-loader": "^1.3.0", | ||
"html-webpack-plugin": "^4.4.1", | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<style> | ||
body, | ||
#app, | ||
#map { | ||
width: 100vw; | ||
height: 100vh; | ||
box-sizing: border-box; | ||
margin: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { auth, viz } from '@carto/web-sdk'; | ||
|
||
class Map extends React.Component { | ||
map = null; | ||
|
||
componentDidMount() { | ||
auth.setDefaultCredentials({ username: 'public' }); | ||
// this.map = viz.createMap(); | ||
this.map = viz.createMap({ | ||
basemap: 'darkmatter', | ||
view: { zoom: 4, longitude: 3, latitude: 40, pitch: 0, bearing: 0 }, | ||
container: 'map' | ||
}); | ||
|
||
const ports = new viz.Layer('world_ports'); | ||
ports.addTo(this.map); | ||
} | ||
|
||
render() { | ||
return <div id="map">Map</div>; | ||
} | ||
} | ||
|
||
export default Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Map from './Map'; | ||
|
||
ReactDOM.render(<Map />, document.getElementById('app')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const path = require('path'); | ||
const HtmlWebPackPlugin = require('html-webpack-plugin'); | ||
|
||
module.exports = { | ||
entry: './src/index.js', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'bundle.js' | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx'] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js|jsx)$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader' | ||
} | ||
}, | ||
{ | ||
test: /\.html$/, | ||
use: [ | ||
{ | ||
loader: 'html-loader' | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new HtmlWebPackPlugin({ | ||
template: './public/index.html', | ||
filename: './index.html' | ||
}) | ||
] | ||
}; |
Oops, something went wrong.