npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@smartcitiesdata/react-discovery-ui

v2.1.41

Published

React component for dataset discovery UI

Downloads

213

Readme

Master Master

React Discovery UI

React (also known as React.js or ReactJS) is an open-source, front end, JavaScript library for building user interfaces or UI components.

react_discovery_ui is a UI component for consuming the Discovery API of the SmartCitiesData platform. It is exported as a React Component, <ReactDiscoveryUI>, and can be imported into another site such as seen in SmartColumbusOS/Discovery_UI.

What to Install

To run the commands below you will need to install node. For directions on installing both of these tools depending on your system see the NodeJS website.

How to Use

Install Dependencies

Npm is a package manger that comes with node. This command creates a nodes_modules folder and installs your dependencies in there and also installs your devDependencies.

npm install

Run All Tests

"test:all" is a script in the package.json file that when run with npm runs all unit and functional tests.

npm run test:all

Run Unit Tests

"test" is a script in the package.json file that when run with npm run all the unit tests. It uses a JavaScript testing framework called Jest

npm run test

Run Functional Tests

"cypress:run" is a script in the package.json file that when run with npm runs all the functional tests. It uses a JavaScript End to End Testing Framework called Cypress

npm run cypress:run

Run Unit Tests in Watch Mode

npm run test-watch

Unit tests will output warnings related to accessibility. Configurations are found in test-start-point.js

Lint the Code

npm run lint

Configuration

Runtime configuration for running the test app locally is stored in config/config.js. The component expects configuration to be on the window object i.e: window.DISC_UI_URL = 'https://www.example.com'

  • DISC_API_URL This application is designed to be used with discovery-api as the backend. Set this value to the URL of the local discovery-api endpoint. (Note: this can also be set to a known public discovery api endpoint, though certain features, such as user logins, are not guaranteed to work properly.)

  • GTM_ID Set this value to the Google Tag Manager ID to enable analytics.

  • DISC_UI_URL The domain that the site will be hosted on

  • DISC_STREAMS_URL This application is designed to be used with discovery-streams for providing live updates for streaming datasets. Set this value to the URL of the local discovery-streams endpoint. (Note: this can also be set to a known public discovery streams endpoint, though certain features, such as user logins, are not guaranteed to work properly.)

  • STREETS_TILE_LAYER_URL This is the url source of the mapbox tiles used in Leaflet. Example: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png

  • LOGO_URL The url of an image to be used as the site logo within the react components.

Start the UI Locally

npm run start

This starts a simple React site with the main Discovery UI component as the sole content. You can view the UI in your web browser at http://localhost:9001

Stop All Node processes

npm run stop

Using the Package Locally

  • Run npm run build:library in the component root directory.
  • Run npm link in the component root directory.
    • This registers your component as a valid npm package local to your machine.
    • npm unlink will unregister it on your machine if needed.
  • Run npm pack in the component root directory.
    • This will pack whatever was in the lib build output. Generated by the mentioned "npm run build:library`
    • The result of the pack is a tar file
  • Run npm install $COMPONENT_ROOT/$COMPONENT_PACKAGE.tgz in the consuming application.
    • This will utilize that local tar file instead of any remotely published package.

Note that any changes to the component will require the package to be rebuilt with npm run build:library

To consume this component in your react app place the component into your app or other sub-components such as in the below example:

import ReactDiscoveryUI from '@smartcitiesdata/react-discovery-ui'


export default class App extends Component {
  render() {
    return (
      <div>
        <Header />
        <ReactDiscoveryUI />
        <Footer />
      </div >
    )
  }
}