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

noths-global-components

v1.35.0

Published

A set of global components for NOTHS.

Downloads

211

Readme

CircleCI npm version

NOTHS Global Components

Frontend global components used at www.notonthehighstreet.com

Components included

  • NOTHS Header
  • NOTHS Footer
  • NOTHS Copyright statement
  • NOTHS Navigation and Mega Dropdown

Background & context

Global components are components which will be on most pages of the site.

These components use mainly vanilla javascript and do not use any framework. This is to reduce the footprint on the consuming application.

The components are written in ES2015 and use Rollup for compilation and minification.

Component usage

Consuming

HTML

The NPM module includes pre bundled HTML files for Header, Navigation, Footer and Copyright components. To include these copy the file contents from node_modules/noths-global-components/compiled/dist/[header|navigation|footer|copyright].html and insert into your page where required.

React

import React from 'react';
import { Header, Navigation, Footer, Copyright } from 'noths-global-components';

export class App extends React.Component {
  render() {
    return (
      <div id="app">
        <Header />
        <Navigation />
          <h1>hello world</h1>
        <Footer />
        <Copyright />
      </div>
    );
  }
}

NOTE: These components are created using dangerouslySetInnerHTML of their counterpart HTML component. There is no JS logic in them, it's simply a wrapper to aid integrating components into React apps.

Triggering the Mobile Navigation

The Header components handles triggering the Mobile navigation when the burger menu is click by default. But if you need to toggle the Mobile navigation from another element you will need to fire a TOGGLE_NAVIGATION event.

Here is an example:

  const event = document.createEvent('Event');
  event.initEvent('TOGGLE_NAVIGATION', true, true):
  document.dispatchEvent(event);

Tracking / GTM / Analytics

A Google Tag Manager (GTM) container has been set up to track global component events (Global Components - GTM-WJKV2N3). To ensure that these events continue to track in your service, you will need to push a dataLayer variable with the environment your service is running on as soon as possible on the page. This allows us to know which Google Analytics account to send the tracked event to.

You will need something like the following in your service:

<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({ environment: '<development|staging|production>' });
</script>

Installation

Prerequisites

  • NodeJS 8

Setup & run

Install dependencies

npm install

Build and start

npm run build_and_start

Build and start for development which will watch your files and rebuild if there are any changes.

npm run watch

Testing

There are two different types of tests in the project.

Unit tests

Unit tests use Mocha and Chai.

To run unit tests:

npm run test:specs

End to end tests (e2e)

End to end tests use Nightwatch.

To run e2e tests:

npm run test:features

Mocks

There are a number of API's that get mocked as part of the e2e tests. Theses mocks are stored in server/dev-mocks.js and these are primed using Simulado.

Releases

The project is hosted on NPM with the name noths-global-components.

Releasing a new verson

When merging, add [release:(major|minor|patch)] to the bottom of your merge description.

Doing so will automatically release a new version once merged to master.

Example: Release a version

TODO

  • Still using styles-toolkit even though the repo has been deprecated and deleting
  • No support for static assets i.e. pushing images to a CDN