Repository: VictorCazanave/react-svg-map
Branch: master
Commit: a3a3b0e9e5d0
Files: 38
Total size: 453.6 KB
Directory structure:
gitextract_79rtgsnn/
├── .babelrc
├── .eslintignore
├── .eslintrc
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── __tests__/
│ ├── __mocks__/
│ │ └── styleMock.js
│ ├── __snapshots__/
│ │ ├── checkbox-svg-map.test.js.snap
│ │ ├── radio-svg-map.test.js.snap
│ │ └── svg-map.test.js.snap
│ ├── checkbox-svg-map.test.js
│ ├── fake-map.js
│ ├── radio-svg-map.test.js
│ └── svg-map.test.js
├── docs/
│ ├── index.html
│ └── index.js
├── examples/
│ └── src/
│ ├── components/
│ │ ├── checkbox-map.jsx
│ │ ├── examples-app.jsx
│ │ ├── examples-app.scss
│ │ ├── link-map.jsx
│ │ ├── radio-map.jsx
│ │ └── tooltip-heat-map.jsx
│ ├── index.html
│ ├── index.jsx
│ └── utils.js
├── jest-setup.js
├── jest.config.js
├── package.json
├── src/
│ ├── checkbox-svg-map.jsx
│ ├── index.js
│ ├── radio-svg-map.jsx
│ ├── svg-map.jsx
│ └── svg-map.scss
├── webpack.config.js
└── webpack.examples.config.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": ["env", "react"],
"plugins": ["transform-object-rest-spread"]
}
================================================
FILE: .eslintignore
================================================
README.md
jest.config.js
================================================
FILE: .eslintrc
================================================
{
"env": {
"browser": true,
"es6": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react",
"jest"
],
"rules": {
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
"semi": [
"error",
"always"
],
"react/no-find-dom-node": "off"
}
}
================================================
FILE: .gitignore
================================================
.DS_Store
.vscode
node_modules
lib
dist
coverage
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- "10"
script:
- npm test
- npm run build
after_success:
- bash <(curl -s https://codecov.io/bash)
================================================
FILE: CHANGELOG.md
================================================
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [2.2.0]
### Added
- Add `locationAriaLabel` prop to customize ARIA label of each location [#49](https://github.com/VictorCazanave/react-svg-map/pull/49)
### Fixed
- Add missing default values of `locationTabIndex` and locationRole` props
- Use MIT license instead of GPLv3
## [2.1.2]
### Fixed
- Add missing CSS file in production
## [2.1.1]
### Fixed
- Handle invalid ids in `selectedLocationIds`
## [2.1.0]
### Added
- Add `selectedLocationId` and `selectedLocationIds` props to handle initial selected locations
- Add `childrenBefore` and `childrenAfter` props to handle "slots"
## [2.0.2]
### Added
- Add files property in package.json to reduce size of package
-
### Changed
- Update dependencies to fix security issues
## [2.0.1]
### Fixed
- Fix tabindex of CheckboxSVGMap
## [2.0.0]
### Removed
- Externalize maps ([svg-maps](https://github.com/VictorCazanave/svg-maps/))
- Remove deprecated tabIndex and type properties
### Changed
- Update documentation
- Update tests using fake maps
## [1.3.1]
### Changed
- Use GitHub pages to host demo
## [1.3.0]
### Added
- Allow function locationClassName prop of SVGMap, CheckboxSVGMap and RadioSVGMap components
### Changed
- Update examples
- Externalize Jest config
- Update Jest config
## [1.2.0]
### Added
- Create CheckboxSVGMap and RadioSVGMap components
- Add unit tests
### Changed
- Update examples
- Deprecate tabIndex and type properties
- Improve snapshot tests
- Update dev dependencies
## [1.1.0]
### Added
- Create Utah map
### Removed
- Remove deprecated NSP badge
## [1.0.7] - 2018-08-25
### Added
- Add lint script
- Create CONTRIBUTING
- Create CHANGELOG
## [1.0.6] - 2018-07-11
### Added
- Add dev dependencies badge in README
### Changed
- Update prop-types dependency to v15.6.2
- Update dev dependencies
### Fixed
- Fix typo in README
## [1.0.5] - 2018-05-05
### Added
- Add onLocationMouseMove documentation
### Changed
- Update dev dependencies
### Fixed
- Fix indentation in README
- Fix gif URL in README
## [1.0.4] - 2018-04-22
### Added
- Add example gif in README
## [1.0.3] - 2018-04-22
### Added
- Add USA documentation
### Fixed
- Fix installation documentation
## [1.0.2] - 2018-04-22
### Added
- Create USA map
- Create onMouseMove event handler
- Create tooltip example
## [1.0.1] - 2018-04-03
### Added
- Add code coverage badge with [codecov](codecov.io)
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
If you want to contribute to this project, here's a quick guide:
1. Fork the repository
1. Develop your code changes
1. Ensure eslint is happy: `npm run lint`
1. Ensure the tests pass: `npm test`
1. Commit your changes
1. Push to your fork
1. Submit a pull request
## Creating a new map
### Map file
* Name the file `[country].js` in Kebab case. For example: `new-zealand.js`
* Use `Map of [Country]` as `label`
* Adjust the `viewBox` to have no empty space on each side (top, bottom, left, right)
* Use English `name`s by default in `[country].js`
* Create a specific `[country].[lang].js` file to use another language. For example: `taiwan.zh.js`, `france.fr.js`...
* Use semantic `id`s (shortnames or full names in Kebab case). For example: `ny` for New York, `taipei-city` for Taipei City...
* Add the map in `/src/maps/`
* Import and export the map in `/src/index.js`
### Tests
* Add a test in `/__tests__/svg-map.test.js` for this map: `displays map of [Country]` (in alphabetical order)
* Update the snapshots with `npm run build-tests`
* Run ESLint with `npm run lint`
* Run the tests with `npm test`
### Documentation
* Add the country with the list of locations alphabetically sorted in the [existing maps section](https://github.com/VictorCazanave/react-svg-map#existing-maps)
## Reporting a bug
[Open an issue](https://github.com/VictorCazanave/react-svg-map/issues/new).
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2018-present, Victor Cazanave
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# react-svg-map
[](https://www.npmjs.com/package/react-svg-map)
[](https://travis-ci.org/VictorCazanave/react-svg-map)
[](https://codecov.io/gh/VictorCazanave/react-svg-map)
[](https://david-dm.org/VictorCazanave/react-svg-map)
[](https://david-dm.org/VictorCazanave/react-svg-map?type=peer)
_A set of React.js components to display an interactive SVG map._

## Demo
[Take a look at the live demo!](https://victorcazanave.github.io/react-svg-map/)
## Installation
### npm
`npm install --save react-svg-map`
### yarn
`yarn add react-svg-map`
## Usage
### :warning: Breaking change from v1
**This package does not include maps anymore!**
You have to install the map you need from [svg-maps](https://github.com/VictorCazanave/svg-maps) or you can use your own map. See [maps section](#maps) for more details.
If you are still using the 1.x.x version, look at the [v1 documentation](https://github.com/VictorCazanave/react-svg-map/tree/v1.3.2#react-svg-map).
### :earth_africa: Simple SVG Map
This is the base component to display an SVG map.
- Import `SVGMap` component from `react-svg-map`
- Import the map you want
- Optionally, import `react-svg-map/lib/index.css` if you want to apply the default styles
```javascript
import React from "react";
import ReactDOM from "react-dom";
import Taiwan from "@svg-maps/taiwan";
import { SVGMap } from "react-svg-map";
import "react-svg-map/lib/index.css";
class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return ;
}
}
ReactDOM.render(, document.getElementById("app"));
```
#### API
| Prop | Type | Default | Description |
| ------------------- | ---------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------- |
| map | Object | **required** | Describe SVG map to display. See [maps section](#maps) for more details. |
| className | String | `'svg-map'` | CSS class of `