Skip to content

Commit 31566f5

Browse files
authored
Urban/create library (#238)
Build standalone application with parcel Build library with parcel Bundle all static assets in buildtime
2 parents 440c244 + 8852df4 commit 31566f5

File tree

35 files changed

+1737
-44037
lines changed

35 files changed

+1737
-44037
lines changed

urban-dashboard/.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

urban-dashboard/.env.local-sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
REACT_APP_MAPBOX_TOKEN='xxxxxxxxxx'
22
REACT_APP_MAPBOX_STYLE_URL='mapbox://styles/xxxxxxxxx'
3-
REACT_APP_FEATURES_API_URL='xxxxxxxxxx'
43
PUBLIC_URL='xxxxxxx'
4+
REACT_APP_BASEMAP_STYLES_MAPBOX_ID='xxxxxxx'
5+
REACT_APP_DATA_URL='xxxxxxx'

urban-dashboard/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# production
1010
/build
1111

12+
1213
# misc
1314
.DS_Store
1415
.env.local
@@ -19,5 +20,9 @@
1920
npm-debug.log*
2021
yarn-debug.log*
2122
yarn-error.log*
23+
dist/
24+
.parcel-*
25+
.env
26+
yarn.lock
2227

2328
# environment variables

urban-dashboard/README.md

Lines changed: 180 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,187 @@
1-
## Pre requisities
1+
# Urban Dashboard
22

3-
- Install node
4-
- use latest node version
5-
- if using nvm, run `nvm use`
3+
A React-based application for visualizing Urban Dashboard
64

7-
## Install dependency
5+
---
86

9-
run `yarn`
7+
## Local Setup
108

11-
## Run application in Local
9+
To get Urban interface up and running on your local machine, follow these steps:
1210

13-
- create `.env.local` a replica of `.env.local-sample` with the appropriate tokens
14-
- run `yarn start`
11+
### Prerequisites
1512

16-
## Bundle using webpack
13+
You'll need the following tools installed:
1714

18-
run `yarn build`
15+
- **nvm** (Node Version Manager): For managing Node.js versions. You can find installation instructions on the [nvm GitHub page](https://github.com/nvm-sh/nvm).
16+
- **Yarn**: A fast, reliable, and secure dependency manager. Install it by following the instructions on the [Yarn website](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable).
17+
18+
### Environment Variables
19+
20+
Create a copy of the `.env.local-sample` file and name it `.env`. Populate it with your specific environment variables:
21+
22+
```
23+
REACT_APP_MAPBOX_TOKEN='xxxxxxxxxx'
24+
REACT_APP_MAPBOX_STYLE_URL='mapbox://styles/xxxxxxxxx'
25+
REACT_APP_FEATURES_API_URL='xxxxxxxxxx'
26+
PUBLIC_URL='xxxxxxx'
27+
REACT_APP_BASEMAP_STYLES_MAPBOX_ID='xxxxxxx'
28+
REACT_APP_DATA_URL='xxxxxxx'
29+
30+
```
31+
32+
### Installation and Running
33+
34+
Once your environment variables are set, use the following commands:
35+
36+
1. **Select Node.js Version**:
37+
38+
```bash
39+
nvm use
40+
```
41+
42+
This command ensures you're using the appropriate Node.js version specified for the project.
43+
44+
2. **Install Dependencies**:
45+
46+
```bash
47+
yarn
48+
```
49+
50+
This will install all the necessary project dependencies.
51+
52+
3. **Start Development Server**:
53+
```bash
54+
yarn serve
55+
```
56+
This command will launch the development server, and you can access Urban Dashboard App in your browser.
57+
58+
---
59+
60+
## Bundling as a Library
61+
62+
You can package `custom-interface-urban` as a reusable library for distribution via the [npm registry](https://www.npmjs.com/).
63+
64+
### 1. Build the Library
65+
66+
Use the provided build command to generate the library bundle:
67+
68+
This will create a production-ready build in the `dist` (or equivalent) directory.
69+
70+
```bash
71+
yarn build-lib
72+
```
73+
74+
### 2. Prepare for Publishing
75+
76+
Ensure the `name` and `version` fields in your [`package.json`](https://docs.npmjs.com/cli/v10/configuring-npm/package-json) are correctly set.
77+
These two fields together uniquely identify your package in the npm registry.
78+
79+
### 3. Authenticate with npm
80+
81+
If you haven't already, log in to your npm account.
82+
If you don’t have one, you can [sign up here](https://www.npmjs.com/signup).
83+
84+
```bash
85+
npm login
86+
```
87+
88+
### 4. Publish the Package
89+
90+
Once authenticated, publish your library to npm:
91+
92+
```bash
93+
npm publish
94+
```
95+
96+
**Note:**
97+
98+
> - Make sure your package name is unique if it's public.
99+
> - Consider using [scoped packages](https://docs.npmjs.com/cli/v10/using-npm/scope) (e.g., `@your-org/custom-interface-urban`) for organization or private packages.
100+
> - For more details, see the [npm publishing guide](https://docs.npmjs.com/cli/v10/commands/npm-publish).
101+
102+
---
103+
104+
After publishing, your library can be installed in any project via:
105+
106+
## Usage as a Library
107+
108+
Urban interface can also be used as a library within other React applications.
109+
110+
### Installation
111+
112+
Install the library via npm or yarn:
113+
114+
```bash
115+
npm install custom-interface-urban
116+
# or
117+
yarn add custom-interface-urban
118+
```
119+
120+
## Usage
121+
122+
### Import Urban Dashboard :
123+
124+
```JavaScript
125+
import { UrbanDashboard } from 'custom-interface-urban';
126+
```
127+
128+
### Create a Configuration Variable:
129+
130+
```JavaScript
131+
132+
const urbanConfig = {
133+
// API Endpoints
134+
mapboxToken:"xxxxxxx",
135+
mapboxStyle: "xxxxxxx",
136+
basemapStyle: "xxxxxxx",
137+
featuresApiUrl: "xxxxxxx",
138+
dataUrl: "xxxxxxx",
139+
140+
};
141+
142+
```
143+
144+
### Add some default map configuration to start with
145+
146+
```Javascript
147+
const defaultZoomLocation:[number,number] = [-98.771556, 32.967243];
148+
const defaultZoomLevel: number = 4;
149+
const defaultDataset: string = 'vulcan'
150+
```
151+
152+
### Use the CloudBrowse Component:
153+
154+
```JavaScript
155+
<UrbanDashboard
156+
config={urbanConfig}
157+
defaultZoomLevel={defaultZoomLevel}
158+
defaultZoomLocation={defaultZoomLocation}
159+
defaultDataset={defaultDataset}
160+
/>
161+
```
162+
163+
#### Note: Configuration settings can also be provided directly in the host React application's .env file. For example:
164+
165+
```
166+
REACT_APP_MAPBOX_TOKEN='xxxxxxxxxx'
167+
REACT_APP_MAPBOX_STYLE_URL='mapbox://styles/xxxxxxxxx'
168+
REACT_APP_FEATURES_API_URL='xxxxxxxxxx'
169+
PUBLIC_URL='xxxxxxx'
170+
REACT_APP_BASEMAP_STYLES_MAPBOX_ID='xxxxxxx'
171+
REACT_APP_DATA_URL='xxxxxxx'
172+
173+
```
174+
175+
## Peer Dependencies
176+
177+
This component has the following peer dependencies that you will need to install in your host application:
178+
179+
```JSON
180+
"peerDependencies": {
181+
"react": "^18.2.0 || ^19.0.0",
182+
"react-dom": "^18.2.0 || ^19.0.0",
183+
"@mui/material": "^5.14.2 || ^6.0.0 || ^7.0.0"
184+
}
185+
```
186+
187+
Make sure these versions (or compatible ones) are installed in your project to avoid issues.

0 commit comments

Comments
 (0)