Skip to content

jmezzacappa/spatial-web-demo

 
 

Repository files navigation

Crunchy Data PostGIS Day Demo - Web Client

This project was bootstrapped with Create React App.

Getting Started

Run npm install the first time to fetch and install dependencies.

Run npm start to run the app in development mode. More info in the Available Scripts section.

When ready to deploy, run npm run build to compile/bundle the app.

Project Info

Folder Structure

  • public/ - Contains a few static assets, including the index.html template. We may never need to touch this directory again, except maybe to add a favicon.ico. More info
  • src/ - Contains our app code
    • api/ - Modules to handle API requests
    • components/ - Components to be reused across multiple views
    • views/ - Our "views". These are the "page" components that render when the user selects a different page in the header nav.

State Management

There are no third-party state management libraries in use at this time. This project is small enough to use React's built-in state management.

UI Framework

This project uses PatternFly for UI components.

PatternFly an opinionated UI framework and design guidelines.
(This may seem somewhat familiar to anyone who has used Material-UI components with Google's Material Design guidelines.)

The PatternFly React library gives us components for nearly everything. For example, there is even a <Text> component just for placing text onto a page (which is required for "heading" elements [e.g. <h1>] to display properly). While working on this project, you may find it useful to reference the PatternFly documentation quite often at first.

CSS

Local component CSS goes in CSS Modules. This is a simple solution that gives us "locally-scoped" CSS, so there's no need for other methods, such as BEM.

This project has SASS installed, so feel free to use it when convenient.

A note about PatternFly and CSS

For this project (or any project that uses PatternFly), it is best to use PatternFly's global CSS variables whenever possible. This helps to maintain a cohesive and consistent UI (colors, fonts, spacing, transitions, etc.) and UX.

For example, you might add a background and border to a component like this:

/* MyComponent.module.css */

.myComponent {
  background-color: var(--pf-global--BackgroundColor--100);
  border-width: var(--pf-global--BorderWidth--md);
  border-style: solid;
  border-color: var(--pf-global--BorderColor--100);
}

Style Guide

We mostly follow the Airbnb JavaScript Style Guide, with some modifications.

The style is enforced using ESLint, so it is highly recommended to use an ESLint plugin with your editor.

ESLint rules can be found in .eslintrc.js.

Recommended Editor Plugins

ESLint helps maintain consistent styles and best practices. This plugin is recommended because it helps to enforce our styles and can prevent unsafe code.

Our ESLint configuration can be found in .eslintrc.js.

EditorConfig automatically applies formatting settings found in .editorconfig.

Although this project is not written in TypeScript, many third part libraries (including PatternFly) provide TypeScript type definitions.

Installing the TypeScript extension into your editor makes your editor "type-aware". This is great for things like autocompletion/IntelliSense and, depending on your settings, design-time safety checks.

You may notice some TypeScript syntax inside JSDoc annotations in this project.

Note: If using Visual Studio Code (open source, runs everywhere), the TypeScript extension is already included and enabled by default.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will automatically reload if you make edits.

You will also see some lint errors in the console. The lint errors in the console are from a minimal set of ESLint rules included with create-react-app. They do not include our custom configuration. It is recommended to use an ESLint plugin in your editor.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

Contributing

See CONTRIBUTING

Related Projects

Service layer: https://github.com/CrunchyData/spatial-suite-rest-demo

Deployment

http://spatialwebdemo-scfire.openshift-gis-apps.gce-containers.crunchydata.com/

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Demo

The current version of this demo is hosted in OpenShift 3.11. It is a fictious app designed to simulate a Fire Hazard Management UI. It uses publically avaialbe data from the Santa Cruz, CA County GIS website. It uses pg_tileserv to generate vector tiles from the parcel data and pg_featureserv to update the dataset and do a distance query.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 89.1%
  • CSS 4.8%
  • PLpgSQL 3.3%
  • HTML 2.8%