-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
total rewrite, rewritten in es6, added tests, improved decoupling
- Loading branch information
Stephan Meijer
committed
Dec 17, 2016
1 parent
d69c011
commit 4cc5e99
Showing
54 changed files
with
6,125 additions
and
642 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,22 @@ | ||
{ | ||
"presets": ["es2015", "stage-0", "power-assert"], | ||
"plugins": [ | ||
["transform-react-jsx", { "pragma": "preact.h"}], | ||
"transform-async-to-generator", | ||
["babel-plugin-espower", { | ||
"embedAst": true, | ||
"patterns": [ | ||
"t.truthy(value, [message])", | ||
"t.falsy(value, [message])", | ||
"t.true(value, [message])", | ||
"t.false(value, [message])", | ||
"t.is(value, expected, [message])", | ||
"t.not(value, expected, [message])", | ||
"t.deepEqual(value, expected, [message])", | ||
"t.notDeepEqual(value, expected, [message])", | ||
"t.regex(contents, regex, [message])", | ||
"t.notRegex(contents, regex, [message])" | ||
] | ||
}] | ||
] | ||
} |
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,13 @@ | ||
# @see http://editorconfig.org/ | ||
|
||
# This is the top-most .editorconfig file; do not search in parent directories. | ||
root = true | ||
|
||
# All files. | ||
[*] | ||
end_of_line = LF | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,2 @@ | ||
BING_API_KEY=AtUDjSVEBxo8BwgYUPdfnzHpznaYwDdjjS27jyFDj18nhTUDUjrhc0NwMndZvrXs | ||
GOOGLE_API_KEY=AIzaSyDigZ5WMPoTj_gnkUn3p1waYPDa5oE8WOw |
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,55 @@ | ||
extends: "airbnb" | ||
|
||
env: | ||
browser: true | ||
|
||
parser: "babel-eslint" | ||
parserOptions: | ||
ecmaVersion: 6 | ||
ecmaFeatures: | ||
experimentalObjectRestSpread: true | ||
jsx: true | ||
sourceType: "module" | ||
|
||
rules: | ||
# we need this to test leaflet private vars | ||
no-underscore-dangle: "off" | ||
|
||
# force else and catch to a new line | ||
brace-style: | ||
- "error" | ||
- "stroustrup" | ||
- allowSingleLine: true | ||
|
||
quote-props: | ||
- "error" | ||
- "consistent-as-needed" | ||
- keywords: true | ||
|
||
class-methods-use-this: "off" | ||
|
||
import/no-extraneous-dependencies: | ||
- "error" | ||
- devDependencies: | ||
- "**/*.spec.js" | ||
- "**/test_helpers/**/*.js" | ||
- "example/**/*.js" | ||
|
||
react/jsx-filename-extension: | ||
- "error" | ||
- extensions: | ||
- ".js" | ||
|
||
react/prop-types: "off" | ||
|
||
jsx-a11y/anchor-has-content: "off" | ||
|
||
globals: | ||
L: false | ||
fetch: false | ||
document: false | ||
location: false | ||
|
||
settings: | ||
react: | ||
pragma: "preact" |
This file was deleted.
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 |
---|---|---|
|
@@ -165,3 +165,6 @@ pip-log.txt | |
*.sublime-project | ||
*.sublime-workspace | ||
.idea | ||
dist/ | ||
lib/ | ||
node_modules/ |
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 @@ | ||
src/ |
Empty file.
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
File renamed without changes
File renamed without changes
File renamed without changes
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,54 @@ | ||
import preact, { Component } from 'preact'; | ||
import Search from './Search'; | ||
|
||
class Layout extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
hash: window.location.hash.slice(1), | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
window.addEventListener('hashchange', this.changePage, false); | ||
} | ||
|
||
componentWillUnmount() { | ||
window.removeEventListener('hashchange', this.changePage, false); | ||
} | ||
|
||
changePage = () => { | ||
this.setState({ | ||
hash: window.location.hash.slice(1), | ||
}); | ||
}; | ||
|
||
render() { | ||
const { pages } = this.props; | ||
const { hash } = this.state; | ||
const page = pages.find(p => p.slug === (hash || 'search')); | ||
|
||
return ( | ||
<div> | ||
<div className="header"> | ||
<h1>{`GeoSearch / ${page.title}`}</h1> | ||
|
||
<ul> | ||
{pages.map((p, idx) => ( | ||
<li key={idx} className={p.slug === hash ? 'active' : ''}> | ||
<a href={`#${p.slug}`}>{p.title}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
|
||
<div className={`content ${hash}`}> | ||
{page && page.view()} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Layout; |
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,55 @@ | ||
import preact, { Component } from 'preact'; | ||
import merge from 'lodash.merge'; | ||
import { GeoSearchControl, OpenStreetMapProvider, Provider as BaseProvider } from '../src'; | ||
|
||
const L = window.L; | ||
|
||
// eslint-disable-next-line no-confusing-arrow | ||
const ensureInstance = Provider => Provider instanceof BaseProvider ? Provider : new Provider(); | ||
|
||
const mapOptions = () => ({ | ||
layers: [ | ||
new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
maxZoom: 18, | ||
}), | ||
], | ||
center: new L.LatLng(53.2, 5.8), | ||
zoom: 12, | ||
}); | ||
|
||
class Map extends Component { | ||
componentDidMount() { | ||
const { options, Provider } = this.props; | ||
|
||
this.map = new L.Map(this.container, merge(mapOptions(), options)); | ||
|
||
const provider = (Provider) ? ensureInstance(Provider) : new OpenStreetMapProvider(); | ||
|
||
this.searchControl = new GeoSearchControl({ | ||
provider, | ||
}).addTo(this.map); | ||
} | ||
|
||
componentDidUpdate() { | ||
const Provider = this.props.Provider || OpenStreetMapProvider; | ||
this.searchControl.options.provider = ensureInstance(Provider); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.map.remove(); | ||
} | ||
|
||
bindContainer = (container) => { | ||
this.container = container; | ||
}; | ||
|
||
render() { | ||
const { style } = this.props; | ||
|
||
return ( | ||
<div className="leaflet-map" style={style} ref={this.bindContainer} /> | ||
); | ||
} | ||
} | ||
|
||
export default Map; |
Oops, something went wrong.