Skip to content

Commit

Permalink
[add] Stable version & Project framework migrated from Idea-React
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Aug 28, 2023
0 parents commit ca0bc71
Show file tree
Hide file tree
Showing 18 changed files with 6,186 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI & CD
on:
push:
tags:
- v*
jobs:
Build-and-Publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org
cache: pnpm
- name: Install Dependencies
run: pnpm i --frozen-lockfile

- name: Build & Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Update document
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: ./docs
personal_token: ${{ secrets.GITHUB_TOKEN }}
force_orphan: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.parcel-cache/
dist/
docs/
.vscode/settings.json
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

npm test
5 changes: 5 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

npm run build
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.parcel-cache/
docs/
preview/
.vscode/
.husky/
.github/
101 changes: 101 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Open React Map

Compatible Map component supports Geo services with **Freedom** or **Open API**, based on [TypeScript][1], [MobX][2] & [React][3].

[![MobX compatibility](https://img.shields.io/badge/Compatible-1?logo=mobx&label=MobX%204%2F5%2F6)][2]
[![NPM Dependency](https://img.shields.io/librariesio/github/idea2app/OpenReactMap.svg)][4]
[![CI & CD](https://github.com/idea2app/OpenReactMap/actions/workflows/main.yml/badge.svg)][5]

[![NPM](https://nodei.co/npm/open-react-map.png?downloads=true&downloadRank=true&stars=true)][6]

## Usage

Preview site: https://idea2app.github.io/OpenReactMap/preview/

### Installation

#### Command

```shell
npm i open-react-map mobx mobx-react react@17 react-dom@17
```

#### `index.html`

```html
<html>
<head>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
/>
</head>
</html>
```

### Third-party Tile provider

[China map in China Open-source Map project][7]

#### Install Extra packages

```shell
npm i leaflet react-leaflet leaflet.chinatmsproviders
```

#### Write Wrapper component

```tsx
// eslint-disable-next-line simple-import-sort/imports
import { FC, useEffect } from 'react';
import { tileLayer } from 'leaflet';
import 'leaflet.chinatmsproviders';
import { useMap } from 'react-leaflet';
import { OpenReactMap, OpenReactMapProps } from 'open-react-map';

function ChinaTileLayer() {
const map = useMap();

useEffect(() => {
// @ts-ignore
tileLayer.chinaProvider('GaoDe.Normal.Map').addTo(map);
}, [map]);

return <></>;
}

const ChinaMap: FC<OpenReactMapProps> = props => (
<OpenReactMap {...props} renderTileLayer={() => <ChinaTileLayer />} />
);
export default ChinaMap;
```

### Use in Next.js

```tsx
import dynamic from 'next/dynamic';

const ChinaMap = dynamic(() => import('./ChinaMap'), { ssr: false });

export default function ExampleMap() {
return (
<ChinaMap
markers={[
{
position: [34.32, 108.55],
tooltip: 'Geo Center of China'
}
]}
onMarkerClick={console.log}
/>
);
}
```

[1]: https://www.typescriptlang.org/
[2]: https://mobx.js.org/
[3]: https://react.dev/
[4]: https://libraries.io/npm/open-react-map
[5]: https://github.com/idea2app/OpenReactMap/actions/workflows/main.yml
[6]: https://nodei.co/npm/open-react-map/
[7]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/ba8e396aa190896aaa8a3dee0f9eac654dfce5b3/components/ChinaMap.tsx
93 changes: 93 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"name": "open-react-map",
"version": "0.5.0",
"license": "LGPL-3.0-or-later",
"author": "shiy2008@gmail.com",
"description": "Compatible Map component supports Geo services with Freedom or Open API, based on TypeScript, MobX & React.",
"keywords": [
"map",
"geo",
"lbs",
"compatibility",
"free",
"open",
"typescript",
"mobx",
"react"
],
"homepage": "https://idea2app.github.io/OpenReactMap/",
"repository": {
"type": "git",
"url": "git+https://github.com/idea2app/OpenReactMap.git"
},
"bugs": {
"url": "https://github.com/idea2app/OpenReactMap/issues"
},
"source": "source/index.ts",
"types": "dist/index.d.ts",
"module": "dist/index.esm.js",
"main": "dist/index.js",
"dependencies": {
"@swc/helpers": "^0.5.1",
"@types/leaflet": "^1.9.3",
"koajax": "^0.8.6",
"leaflet": "^1.9.4",
"mobx-react-helper": "^0.2.3",
"react-leaflet": "^3.2.5",
"web-utility": "^4.1.0"
},
"peerDependencies": {
"mobx": ">=4",
"mobx-react": ">=6",
"react": ">=16 <18",
"react-dom": ">=16 <18"
},
"devDependencies": {
"@parcel/packager-ts": "~2.9.3",
"@parcel/transformer-typescript-types": "~2.9.3",
"@types/react": "^17.0.65",
"@types/react-dom": "^17.0.20",
"husky": "^8.0.3",
"idea-react": "^1.0.0-rc.21",
"koapache": "^2.2.2",
"lint-staged": "^14.0.1",
"mobx": "^6.10.0",
"mobx-react": "^9.0.0",
"parcel": "^2.9.3",
"prettier": "^3.0.2",
"prismjs": "^1.29.0",
"process": "^0.11.10",
"react": "^17.0.2",
"react-bootstrap": "^2.8.0",
"react-dom": "^17.0.2",
"typedoc": "^0.25.0",
"typedoc-plugin-mdn-links": "^3.1.0",
"typescript": "^5.2.2"
},
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"tabWidth": 4
},
"lint-staged": {
"*.{md,json,yml,ts,tsx}": "prettier --write"
},
"browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
"targets": {
"main": {
"optimize": true
}
},
"scripts": {
"prepare": "husky install",
"test": "lint-staged",
"preview": "cd preview/ && rm -rf ../.parcel-cache dist/ && parcel --open",
"pack-preview": "cd preview/ && rm -rf ../.parcel-cache dist/ && parcel build --public-url=. --dist-dir=../docs/preview/",
"pack-docs": "rm -rf docs/ && typedoc source/",
"pack-dist": "rm -rf .parcel-cache/ dist/ && parcel build",
"start": "npm run pack-docs && npm run pack-preview && web-server docs/ -p 8080 -o",
"build": "npm run pack-docs && npm run pack-preview && npm run pack-dist",
"prepublishOnly": "npm test && npm run build"
}
}

0 comments on commit ca0bc71

Please sign in to comment.