Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stepankuzmin committed Mar 11, 2019
0 parents commit 6a3414b
Show file tree
Hide file tree
Showing 27 changed files with 12,584 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"loose": true
}
],
"@babel/preset-react",
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-transform-spread",
"@babel/plugin-proposal-class-properties"
],
"env": {
"test": {
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-transform-spread",
"@babel/plugin-proposal-class-properties"
]
}
}
}
33 changes: 33 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Javascript Node CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-javascript/ for more details

version: 2

jobs:
build:
docker:
- image: circleci/node:8

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: yarn install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- run: yarn lint
- run: yarn flow
- run: yarn test
- run: yarn test:coverage
57 changes: 57 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"plugin:flowtype/recommended",
"prettier",
"prettier/flowtype"
],
"plugins": ["flowtype", "import", "react"],
"env": {
"browser": true,
"jest": true
},
"rules": {
"arrow-parens": [
"warn",
"as-needed",
{
"requireForBlockBody": true
}
],
"comma-dangle": ["error", "never"],
"max-len": [
"error",
{ "code": 80, "ignoreStrings": true, "ignoreUrls": true }
],
"no-return-assign": 0,
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"react/default-props-match-prop-types": [
"error",
{
"allowRequiredDefaults": true
}
],
"react/destructuring-assignment": 0,
"react/prop-types": [1, { "skipUndeclared": true }],
"react/sort-comp": [
1,
{
"order": [
"type-annotations",
"static-methods",
"lifecycle",
"everything-else",
"render"
]
}
],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
"react/require-default-props": 0,
"import/no-extraneous-dependencies": [
"error",
{ "devDependencies": true, "peerDependencies": true }
],
"quotes": ["error", "single"]
}
}
16 changes: 16 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[ignore]
.*/node_modules/findup/.*
.*/node_modules/@mapbox/jsonlint-lines-primitives/.*

[include]

[libs]
./flow-typed
./node_modules/mapbox-gl/flow-typed
./node_modules/mapbox-gl/dist/mapbox-gl.js.flow

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

[lints]
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# build
/dist

# dependencies
/node_modules

# docs
/styleguide

# testing
/coverage
/flow-coverage

# misc
.env
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.idea

npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 3 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eslint:
enabled: true
config_file: .eslintrc
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@urbica.co. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Urbica Design

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.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Urbica React Mapbox GL Cluster

[![Build Status](https://img.shields.io/circleci/project/github/urbica/react-map-gl-cluster.svg?style=popout)](https://circleci.com/gh/urbica/react-map-gl-cluster)
![npm](https://img.shields.io/npm/dt/@urbica/react-map-gl-cluster.svg)
![npm](https://img.shields.io/npm/v/@urbica/react-map-gl-cluster.svg?style=popout)

Cluster component for [Urbica React Components Library for Mapbox GL JS](https://github.com/urbica/react-map-gl).

## Installation

```shell
npm install mapbox-gl supercluster @urbica/react-map-gl @urbica/react-map-gl-cluster
```

...or if you are using yarn:

```shell
yarn add mapbox-gl supercluster @urbica/react-map-gl @urbica/react-map-gl-cluster
```

## Usage

```jsx
import { randomPoint } from '@turf/random';
import MapGL, { Marker } from '@urbica/react-map-gl';
import Cluster from '@urbica/react-map-gl-cluster';
import 'mapbox-gl/dist/mapbox-gl.css';

const bbox = [-160, -70, 160, 70];
const points = randomPoint(50, { bbox }).features;
points.forEach((point, index) => (point.id = index));

initialState = {
viewport: {
latitude: 0,
longitude: 0,
zoom: 0
}
};

const style = {
width: '20px',
height: '20px',
color: '#fff',
background: '#1978c8',
borderRadius: '20px',
textAlign: 'center'
};

<MapGL
style={{ width: '100%', height: '400px' }}
mapStyle='mapbox://styles/mapbox/light-v9'
accessToken={MAPBOX_ACCESS_TOKEN}
onViewportChange={viewport => setState({ viewport })}
{...state.viewport}
>
<Cluster
radius={40}
extent={512}
nodeSize={64}
component={({ longitude, latitude, pointCount }) => (
<Marker longitude={longitude} latitude={latitude}>
<div style={{ ...style, background: '#f28a25' }}>{pointCount}</div>
</Marker>
)}
>
{points.map(point => (
<Marker
key={point.id}
longitude={point.geometry.coordinates[0]}
latitude={point.geometry.coordinates[1]}
>
<div style={style} />
</Marker>
))}
</Cluster>
</MapGL>;
```
5 changes: 5 additions & 0 deletions flow-typed/npm/gl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

declare module 'gl' {
declare export default Function;
}
5 changes: 5 additions & 0 deletions flow-typed/npm/sinon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

declare module 'sinon' {
declare export default Function;
}
Loading

0 comments on commit 6a3414b

Please sign in to comment.