Skip to content

Commit

Permalink
Make collapsed a dynamic prop in LayersControl
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam committed Jul 2, 2018
1 parent 5bc490c commit 111eb91
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 260 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.0.0-rc.3 (2018-07-02)

Added `collapsed` as dynamic property to `LayersControl`.

## v2.0.0-rc.2 (2018-06-28)

- Added `ControlledLayer` abstract class export.
Expand Down
219 changes: 108 additions & 111 deletions docs/components.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-leaflet",
"version": "2.0.0-rc.2",
"version": "2.0.0-rc.3",
"description": "React components for Leaflet maps",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down Expand Up @@ -82,7 +82,7 @@
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-react": "^7.10.0",
"flow-bin": "^0.75.0",
"flow-copy-source": "^2.0.0",
"flow-copy-source": "^2.0.1",
"flow-typed": "^2.4.0",
"jest": "^23.2.0",
"leaflet": "^1.3.1",
Expand All @@ -92,12 +92,12 @@
"react-dom": "^16.4.1",
"rimraf": "^2.6.2",
"rollup": "^0.62.0",
"rollup-plugin-babel": "^3.0.5",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^4.0.0",
"webpack": "^4.13.0",
"webpack": "^4.14.0",
"webpack-serve": "^1.0.4"
},
"jest": {
Expand Down
15 changes: 15 additions & 0 deletions src/LayersControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class Overlay extends ControlledLayer {
type LeafletElement = Control.Layers
type LayersControlProps = {
children: ChildrenArray<*>,
collapsed?: boolean,
} & MapControlProps

class LayersControl extends MapControl<LeafletElement, LayersControlProps> {
Expand Down Expand Up @@ -140,6 +141,20 @@ class LayersControl extends MapControl<LeafletElement, LayersControlProps> {
return new Control.Layers(undefined, undefined, options)
}

updateLeafletElement(
fromProps: LayersControlProps,
toProps: LayersControlProps,
) {
super.updateLeafletElement(fromProps, toProps)
if (toProps.collapsed !== fromProps.collapsed) {
if (toProps.collapsed === true) {
this.leafletElement.collapse()
} else {
this.leafletElement.expand()
}
}
}

componentWillUnmount() {
setTimeout(() => {
super.componentWillUnmount()
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"highlight.js": "^9.12.0"
},
"devDependencies": {
"docusaurus": "~1.3.0"
"docusaurus": "~1.3.1"
}
}
219 changes: 108 additions & 111 deletions website/versioned_docs/version-v2-rc/components.md

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions website/versioned_docs/version-v2-rc/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ original_id: examples

Different examples are available in the [example folder](https://github.com/PaulLeCam/react-leaflet/tree/master/example) to present various use cases:

* [A simple Marker with Popup](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/simple.js)
* [Event handling](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/events.js)
* [Viewport usage](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/viewport.js)
* [Vector layers (Rectangle, Circle, etc.)](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/vector-layers.js)
* [Other layers (LayerGroup, FeatureGroup)](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/other-layers.js)
* [Tooltips](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/tooltip.js)
* [Custom zoom control](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/zoom-control.js)
* [Layers control](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/layers-control.js)
* [Custom panes](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/pane.js)
* [Draggable marker toggle](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/draggable-marker.js)
* [Map with bounds](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/bounds.js)
* [Custom component: a list of markers](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/custom-component.js)
* [Animated map](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/animate.js)
* [WMS tile layer](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/wms-tile-layer.js)
* [Video overlay](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/video-overlay.js)
- [A simple Marker with Popup](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/simple.js)
- [Event handling](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/events.js)
- [Viewport usage](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/viewport.js)
- [Vector layers (Rectangle, Circle, etc.)](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/vector-layers.js)
- [Other layers (LayerGroup, FeatureGroup)](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/other-layers.js)
- [Tooltips](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/tooltip.js)
- [Custom zoom control](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/zoom-control.js)
- [Layers control](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/layers-control.js)
- [Custom panes](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/pane.js)
- [Draggable marker toggle](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/draggable-marker.js)
- [Map with bounds](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/bounds.js)
- [Custom component: a list of markers](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/custom-component.js)
- [Animated map](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/animate.js)
- [WMS tile layer](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/wms-tile-layer.js)
- [Video overlay](https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/video-overlay.js)

These examples can be run locally by cloning the repository, installing the dependencies and running `npm run examples` or `yarn run examples` if you're using Yarn.
4 changes: 2 additions & 2 deletions website/versioned_docs/version-v2-rc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ If you create [custom components](custom-components.md), make sure to learn abou

## Limitations

* Leaflet makes direct calls to the DOM when it is loaded, therefore this library is not compatible with server-side rendering.
* The components exposed are abstractions for Leaflet layers, not DOM elements. Some of them have properties that can be updated directly by calling the setters exposed by Leaflet while others should be completely replaced, by setting an unique value on their `key` property so that they are properly handled by React's algorithm.
- Leaflet makes direct calls to the DOM when it is loaded, therefore this library is not compatible with server-side rendering.
- The components exposed are abstractions for Leaflet layers, not DOM elements. Some of them have properties that can be updated directly by calling the setters exposed by Leaflet while others should be completely replaced, by setting an unique value on their `key` property so that they are properly handled by React's algorithm.
10 changes: 5 additions & 5 deletions website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1423,9 +1423,9 @@ diacritics-map@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/diacritics-map/-/diacritics-map-0.1.0.tgz#6dfc0ff9d01000a2edf2865371cac316e94977af"

docusaurus@~1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/docusaurus/-/docusaurus-1.3.0.tgz#a2a8a8f581390d53bffefc4b5e699699576970c9"
docusaurus@~1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/docusaurus/-/docusaurus-1.3.1.tgz#b9431ed45bff7899eeedc0ca55349df992f791cc"
dependencies:
babel-plugin-transform-class-properties "^6.24.1"
babel-plugin-transform-object-rest-spread "^6.26.0"
Expand Down Expand Up @@ -1465,7 +1465,7 @@ docusaurus@~1.3.0:
sitemap "^1.13.0"
tcp-port-used "^0.1.2"
tiny-lr "^1.1.1"
tree-node-cli "^1.2.2"
tree-node-cli "^1.2.5"

dom-serializer@0:
version "0.1.0"
Expand Down Expand Up @@ -4472,7 +4472,7 @@ tough-cookie@~2.3.3:
dependencies:
punycode "^1.4.1"

tree-node-cli@^1.2.2:
tree-node-cli@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/tree-node-cli/-/tree-node-cli-1.2.5.tgz#afd75437976bbf2cc0c52b9949798e7530e8fd8c"
dependencies:
Expand Down
84 changes: 73 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,12 @@ decamelize@^1.0.0, decamelize@^1.1.0, decamelize@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"

decamelize@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-2.0.0.tgz#656d7bbc8094c4c788ea53c5840908c9c7d063c7"
dependencies:
xregexp "4.0.0"

decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
Expand Down Expand Up @@ -2869,6 +2875,12 @@ find-up@^2.0.0, find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"

find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
dependencies:
locate-path "^3.0.0"

flat-cache@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"
Expand All @@ -2882,15 +2894,15 @@ flow-bin@^0.75.0:
version "0.75.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.75.0.tgz#b96d1ee99d3b446a3226be66b4013224ce9df260"

flow-copy-source@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/flow-copy-source/-/flow-copy-source-2.0.0.tgz#e0984a434fefb5995571d7a28cbff8c3cdda63fe"
flow-copy-source@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/flow-copy-source/-/flow-copy-source-2.0.1.tgz#249781585035ff8d9d35e5372b73af21996ee2af"
dependencies:
chokidar "^2.0.0"
fs-extra "^6.0.1"
glob "^7.0.0"
kefir "^3.7.3"
yargs "^11.0.0"
yargs "^12.0.1"

flow-typed@^2.4.0:
version "2.4.0"
Expand Down Expand Up @@ -4411,6 +4423,13 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
dependencies:
p-locate "^3.0.0"
path-exists "^3.0.0"

lodash-es@^4.0.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.10.tgz#62cd7104cdf5dd87f235a837f0ede0e8e5117e05"
Expand Down Expand Up @@ -5115,12 +5134,24 @@ p-limit@^1.1.0:
dependencies:
p-try "^1.0.0"

p-limit@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.0.0.tgz#e624ed54ee8c460a778b3c9f3670496ff8a57aec"
dependencies:
p-try "^2.0.0"

p-locate@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
dependencies:
p-limit "^1.1.0"

p-locate@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
dependencies:
p-limit "^2.0.0"

p-timeout@^1.1.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.1.tgz#5eb3b353b7fce99f101a1038880bb054ebbea386"
Expand All @@ -5131,6 +5162,10 @@ p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"

p-try@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.0.0.tgz#85080bb87c64688fa47996fe8f7dfbe8211760b1"

package-json@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed"
Expand Down Expand Up @@ -5837,9 +5872,9 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"

rollup-plugin-babel@^3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-3.0.5.tgz#9769a7977098da1dce5b5888fe38dfd8666bf08d"
rollup-plugin-babel@^3.0.7:
version "3.0.7"
resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-3.0.7.tgz#5b13611f1ab8922497e9d15197ae5d8a23fe3b1e"
dependencies:
rollup-pluginutils "^1.5.0"

Expand Down Expand Up @@ -6883,9 +6918,9 @@ webpack-sources@^1.0.1, webpack-sources@^1.1.0:
source-list-map "^2.0.0"
source-map "~0.6.1"

webpack@^4.13.0:
version "4.13.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.13.0.tgz#9a7bb953109a4079e4a32843610d2dc0184dfbe6"
webpack@^4.14.0:
version "4.14.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.14.0.tgz#bbcc40dbf9a34129491b431574189d3802972243"
dependencies:
"@webassemblyjs/ast" "1.5.12"
"@webassemblyjs/helper-module-context" "1.5.12"
Expand Down Expand Up @@ -7027,6 +7062,10 @@ xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"

[email protected]:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"

xtend@^4.0.0, xtend@~4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
Expand All @@ -7035,7 +7074,7 @@ y18n@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41"

y18n@^4.0.0:
"y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"

Expand All @@ -7053,6 +7092,12 @@ yargs-parser@^10.0.0:
dependencies:
camelcase "^4.1.0"

yargs-parser@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8"
dependencies:
camelcase "^4.1.0"

yargs-parser@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4"
Expand Down Expand Up @@ -7083,6 +7128,23 @@ yargs@^11.0.0:
y18n "^3.2.1"
yargs-parser "^9.0.2"

yargs@^12.0.1:
version "12.0.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.1.tgz#6432e56123bb4e7c3562115401e98374060261c2"
dependencies:
cliui "^4.0.0"
decamelize "^2.0.0"
find-up "^3.0.0"
get-caller-file "^1.0.1"
os-locale "^2.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1 || ^4.0.0"
yargs-parser "^10.1.0"

yargs@^4.2.0:
version "4.8.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0"
Expand Down

0 comments on commit 111eb91

Please sign in to comment.