Skip to content

Commit f37532c

Browse files
author
Cédric Delpoux
committed
v4.0.0
1 parent 4423567 commit f37532c

20 files changed

+8744
-288
lines changed

.babelrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

.eslintrc

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,18 @@
11
{
22
"parser": "babel-eslint",
3-
4-
"plugins": [
5-
"react"
6-
],
7-
83
"env": {
4+
"amd": true,
95
"es6": true,
10-
"browser": true,
11-
"node": true,
12-
"mocha": true
13-
},
14-
15-
"ecmaFeatures": {
16-
"jsx": true,
17-
"modules": true
6+
"jest/globals": true
187
},
19-
20-
"rules": {
21-
"block-scoped-var": 0,
22-
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
23-
"camelcase": 0,
24-
"comma-dangle": [1, "always-multiline"],
25-
"comma-style": [1, "last"],
26-
"consistent-this": [2, "self"],
27-
"curly": 0,
28-
"indent": [1, 2],
29-
"no-multiple-empty-lines": [1, {"max": 1}],
30-
"no-self-compare": 2,
31-
"no-underscore-dangle": 0,
32-
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
33-
"no-use-before-define": 0,
34-
"no-var": 2,
35-
"semi": [2, "never"],
36-
"space-before-blocks": [1, "always"],
37-
"space-before-function-paren": [1, "never"],
38-
"space-in-parens": [1, "never"],
39-
"spaced-comment": [1, "always"],
40-
"strict": [2, "never"],
41-
"react/jsx-boolean-value": [1, "never"],
42-
"react/jsx-uses-react": 2,
43-
"react/jsx-uses-vars": 2,
44-
"react/jsx-wrap-multilines": 1,
45-
"react/no-did-mount-set-state": 2,
46-
"react/no-did-update-set-state": 2,
47-
"react/react-in-jsx-scope": 2,
48-
"react/self-closing-comp": 1,
49-
"quotes": [1, "double", "avoid-escape"]
8+
"plugins": ["jest", "prettier", "react"],
9+
"extends": [
10+
"eslint:recommended",
11+
"plugin:jest/recommended",
12+
"plugin:react/recommended",
13+
"prettier"
14+
],
15+
"globals": {
16+
"window": true
5017
}
5118
}

.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
lib
2-
node_modules
3-
npm-debug.log
4-
.DS_Store
1+
/coverage
2+
/demo/dist
3+
/es
4+
/lib
5+
/node_modules
6+
/umd
7+
npm-debug.log*

.lintstagedrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"*.js": [
3+
"prettier --no-bracket-spacing --no-semi --trailing-comma=es5 --write",
4+
"git add"
5+
]
6+
}

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sudo: false
2+
3+
language: node_js
4+
node_js: 8
5+
6+
before_install:
7+
- npm install codecov
8+
9+
after_success:
10+
- cat ./coverage/lcov.info | ./node_modules/.bin/codecov
11+
12+
branches:
13+
only:
14+
- master

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 4.0.0 - 2017-10-25
2+
* Update : Tranform Hight Order Component to React Component using a render prop
3+
* Add : CommonJS build
4+
* Add : ES6 build
5+
* Add : UMD build
6+
* Add : Demo page
7+
18
# 3.0.1 - 2017-07-03
29
* Update : Documentation
310

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing
2+
3+
## Prerequisites
4+
5+
[Node.js](http://nodejs.org/) >= v4 must be installed.
6+
7+
## Installation
8+
9+
- Running `yarn install` in the components's root directory will install everything you need for development.
10+
11+
## Demo Development Server
12+
13+
- `yarn start` will run a development server with the component's demo app at [http://localhost:3000](http://localhost:3000) with hot module reloading.
14+
15+
## Linting
16+
17+
- `yarn run lint` will lint the `src` and `demo/src` folders
18+
19+
## Running Tests
20+
21+
- `yarn test` will run the tests once and produce a coverage report in `coverage/`.
22+
23+
- `yarn run test:watch` will run the tests on every change.
24+
25+
## Building
26+
27+
- `yarn run build` will build the component for publishing to npm and also bundle the demo app.
28+
29+
- `yarn run clean` will delete built resources.
30+
31+
> **Builds:**
32+
> * CommonJS build => `/lib`,
33+
> * ES6 modules build => `/es`
34+
> * UMD build => `/umd`
35+
> * Demo build => `/demo/dist`

LICENCE renamed to LICENCE.md

File renamed without changes.

README.md

Lines changed: 54 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,78 @@
1-
# react-google-maps-loader ![npm](https://img.shields.io/npm/v/react-google-maps-loader.svg) ![license](https://img.shields.io/npm/l/react-google-maps-loader.svg) ![github-issues](https://img.shields.io/github/issues/xuopled/react-google-maps-loader.svg)
1+
# react-google-maps-loader
22

3-
React HOC to use google maps services into your react applications
3+
[![npm package][npm-badge]][npm]
4+
[![Travis][build-badge]][build]
5+
[![Codecov][codecov-badge]][codecov]
6+
![Module formats][module-formats]
47

5-
## Install
8+
React Component to use google maps services into your react applications using a render prop.
69

7-
```sh
8-
npm install --save react-google-maps-loader
10+
## Getting started
911

10-
// OR
12+
[![react-google-maps-loader](https://nodei.co/npm/react-google-maps-loader.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/react-google-maps-loader/)
1113

14+
You can download `react-google-maps-loader` from the NPM registry via the `npm` or `yarn` commands
15+
16+
```shell
1217
yarn add react-google-maps-loader
18+
npm install react-google-maps-loader --save
1319
```
1420

15-
## Changelog
21+
If you don't use package manager and you want to include `react-google-maps-loader` directly in your html, you could get it from the UNPKG CDN
1622

17-
See [changelog](./CHANGELOG.md)
23+
```html
24+
https://unpkg.com/react-google-maps-loader/dist/react-google-maps-loader.min.js.
25+
```
1826

1927
## Usage
2028

21-
The `googleMapsLoader` HOC take an options object in parameter.
22-
You can specify any parameters Google let you use to load Google Maps API.
23-
Checkout [Google Maps Javascript API documentation](https://developers.google.com/maps/documentation/javascript/libraries) to specify librairies or others parameters.
24-
25-
```js
26-
import React, {Component} from "react"
27-
import googleMapsLoader from "react-google-maps-loader"
28-
29-
CONST = GOOGLE_MAPS_API_KEY = "myapikey" // Change your api key
30-
31-
class MyComponent extends Component {
32-
constructor() {
33-
super()
34-
this.state = {
35-
map: null,
36-
}
37-
}
38-
39-
componentDidMount() {
40-
if (this.props.googleMaps)
41-
this.initMap()
42-
}
43-
}
44-
45-
componentDidUpdate(prevProps) {
46-
if (!prevProps.googleMaps && this.props.googleMaps)
47-
this.initMap()
48-
}
49-
}
50-
51-
initMap() {
52-
const map = new googleMaps.Map(this.ref_map)
53-
this.setState({map})
54-
}
55-
56-
render() {
57-
const {googleMaps} = this.props
58-
59-
// You should handle the case when Google Maps is not loaded yet
60-
return googleMaps
61-
? <div ref={ref => this.ref_map = ref} />
62-
: <Spinner /> // You should use a custom loader here
63-
}
64-
}
65-
66-
export default googleMapsLoader(MyComponent, {
67-
libraries: ["places", "geometry"],
68-
key: GOOGLE_MAPS_API_KEY,
69-
})
29+
```javascript
30+
import React from "react"
31+
import BankCard from "react-google-maps-loader"
32+
33+
const App = () =>
34+
<ReactGoogleMapLoader
35+
params={{
36+
key: YOUR_API_KEY, // Define your api key here
37+
libraries: "places,geometry", // To request multiple libraries, separate them with a comma
38+
}}
39+
render={googleMaps =>
40+
googleMaps && (
41+
<div>Google Maps is loaded !</div>
42+
)}
43+
/>
7044
```
7145

72-
## Development
46+
## Demo
7347

74-
### Clean `lib` folder
48+
See [Demo page][github-page]
7549

76-
```js
77-
npm run clean
78-
```
50+
## Contributing
7951

80-
### Build `lib` folder
52+
* ⇄ Pull/Merge requests and ★ Stars are always welcome.
53+
* For bugs and feature requests, please [create an issue][github-issue].
54+
* Pull requests must be accompanied by passing automated tests (`npm test`).
8155

82-
```js
83-
npm run build
84-
```
56+
See [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines
8557

86-
### Watch `src` folder
58+
## Changelog
8759

88-
```js
89-
npm run watch
90-
```
60+
See [changelog](./CHANGELOG.md)
9161

92-
### Lint `src` folder
62+
## License
9363

94-
```js
95-
npm run lint
96-
```
64+
This project is licensed under the MIT License - see the [LICENCE.md](./LICENCE.md) file for details
9765

98-
## License
66+
[npm-badge]: https://img.shields.io/npm/v/react-google-maps-loader.svg?style=flat-square
67+
[npm]: https://www.npmjs.org/package/react-google-maps-loader
68+
69+
[build-badge]: https://img.shields.io/travis/xuopled/react-google-maps-loader/master.svg?style=flat-square
70+
[build]: https://travis-ci.org/xuopled/react-google-maps-loader
71+
72+
[codecov-badge]: https://img.shields.io/codecov/c/github/xuopled/react-google-maps-loader.svg?style=flat-square
73+
[codecov]: https://codecov.io/gh/xuopled/react-google-maps-loader
74+
75+
[module-formats]: https://img.shields.io/badge/module%20formats-umd%2C%20cjs%2C%20esm-green.svg?style=flat-square
9976

100-
See [MIT](./LICENCE)
77+
[github-page]: https://xuopled.github.io/react-google-maps-loader
78+
[github-issue]: https://github.com/xuopled/react-google-maps-loader/issues/new

demo/src/demo.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Code
2+
3+
```javascript
4+
import ReactGoogleMapLoader from "react-google-maps-loader"
5+
import ReactGoogleMap from "react-google-map"
6+
7+
const YourComponent = () =>
8+
<ReactGoogleMapLoader
9+
params={{
10+
key: "AIzaSyCI3cDduwloUnVSfREo-6wuRYTMjOHcQjc",
11+
libraries: "places,geometry",
12+
}}
13+
render={googleMaps =>
14+
googleMaps && (
15+
<div style={{height: "300px"}}>
16+
<ReactGoogleMap
17+
googleMaps={googleMaps}
18+
center={{lat: 43.604363, lng: 1.443363}}
19+
zoom={8}
20+
/>
21+
</div>
22+
)}
23+
/>
24+
```
25+
26+
## Demo

demo/src/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from "react"
2+
import {render} from "react-dom"
3+
4+
import ReactDemoPage from "react-demo-page"
5+
import routes from "./routes"
6+
import pkg from "../../package.json"
7+
8+
const header = {
9+
title: pkg.name,
10+
buttons: [
11+
{label: "Github", url: pkg.homepage},
12+
{label: "Npm", url: `https://www.npmjs.com/package/${pkg.name}`},
13+
{label: "Download", url: `${pkg.homepage}/archive/master.zip`},
14+
],
15+
}
16+
17+
const footer = {
18+
author: pkg.author,
19+
}
20+
21+
const Demo = () => (
22+
<ReactDemoPage
23+
basename={pkg.name}
24+
header={header}
25+
footer={footer}
26+
pages={routes}
27+
color="#44B39D"
28+
/>
29+
)
30+
31+
// eslint-disable-next-line
32+
render(<Demo />, document.querySelector("#demo"))

0 commit comments

Comments
 (0)