-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] Stable version & Project framework migrated from Idea-React
- Loading branch information
0 parents
commit 1cae423
Showing
18 changed files
with
6,584 additions
and
0 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,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 |
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,5 @@ | ||
node_modules/ | ||
.parcel-cache/ | ||
dist/ | ||
docs/ | ||
.vscode/settings.json |
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,5 @@ | ||
#!/bin/sh | ||
|
||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm test |
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,5 @@ | ||
#!/bin/sh | ||
|
||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run build |
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,6 @@ | ||
.parcel-cache/ | ||
docs/ | ||
preview/ | ||
.vscode/ | ||
.husky/ | ||
.github/ |
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,101 @@ | ||
# Open 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/OpenMap.svg)][4] | ||
[![CI & CD](https://github.com/idea2app/OpenMap/actions/workflows/main.yml/badge.svg)][5] | ||
|
||
[![NPM](https://nodei.co/npm/open-map.png?downloads=true&downloadRank=true&stars=true)][6] | ||
|
||
## Usage | ||
|
||
Preview site: https://idea2app.github.io/OpenMap/preview/ | ||
|
||
### Installation | ||
|
||
#### Command | ||
|
||
```shell | ||
npm i open-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 { OpenMap, OpenMapProps } from 'open-map'; | ||
|
||
function ChinaTileLayer() { | ||
const map = useMap(); | ||
|
||
useEffect(() => { | ||
// @ts-ignore | ||
tileLayer.chinaProvider('GaoDe.Normal.Map').addTo(map); | ||
}, [map]); | ||
|
||
return <></>; | ||
} | ||
|
||
const ChinaMap: FC<OpenMapProps> = props => ( | ||
<OpenMap {...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-map | ||
[5]: https://github.com/idea2app/OpenMap/actions/workflows/main.yml | ||
[6]: https://nodei.co/npm/open-map/ | ||
[7]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/ba8e396aa190896aaa8a3dee0f9eac654dfce5b3/components/ChinaMap.tsx |
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,93 @@ | ||
{ | ||
"name": "open-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/OpenMap/", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/idea2app/OpenMap.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/idea2app/OpenMap/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.20", | ||
"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" | ||
} | ||
} |
Oops, something went wrong.