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

mns-core-ui-header

v8.3.21

Published

A NodeJS NPM module that contains the client code for the global header including level 1-3 navigation and enables sharing of common assets in this module between code bases. These code bases are currently:

Downloads

225

Readme

mns-core-ui-header

A NodeJS NPM module that contains the client code for the global header including level 1-3 navigation and enables sharing of common assets in this module between code bases. These code bases are currently:

This is a temporary step to extract original FEAR header code in to a self contained reusable module. Also to migrate from deprecated fear-core-ui to mns-core-ui. This module also has no dependency on a javascript framework.

UPDATE: The module no longer has dependency on fear-core-ui as a result of https://github.com/DigitalInnovation/mns-core-ui-header/pull/92.

For more info:

  • https://confluence.devops.mnscorp.net/display/FF/mns-core-ui-header
  • https://github.com/DigitalInnovation/mns-core-ui-header/wiki
  • Common header overview

Summary of steps to implement header on your page

Install the module in your application npm install mns-core-ui-header --save

The following steps would usually be performed as part of a build process:

  1. copy assets from src/mns-core-ui-header/templates/header/assets to desired location in your application.
  2. setup templates (see templates section below)
  3. define paths to assets used in styling (see SASS section below)
  4. import css bundle @import 'templates/header/bundle';
  5. include the javascript bundle:
    • If using es6 import Header from 'mns-core-ui-header/dist/templates/header/bundle';
    • If using es5 define([
'mns-core-ui-header'
], function (Header) {});
  6. The header needs to be instantiated:
new Header.Top();

new Header.Navigation();

  1. The level2 and level3 markup should be made available server side to the html templates as globalHeader.topNavLevel3 (A subsequent client side call is made in addition to this so that any recent content changes appear in the page navigation)

Templates:

The src folder contains the partials needed for the header and these partials have a .hbs (handlebars) extension for consumption in newer M&S codebases (e.g FESK projects). 

The partials are made available also in the dist folder with a .html extension for consumption in legacy codebases (e.g FEAR) that require templates to have this extension.

It is important to note is that currently the partials only use mustache syntax (i.e the engine used in FEAR) and hence are compatible with handlebars template engines as handlebars is a superset of mustache. Care should be taken if introducing handlebars functionality to the templates whilst they are being consumed by a FEAR page for this reason.


To use templates in your application (FESK)

  • the path path/to/node/modules + mns-core-ui-header/src/mns-core-ui-header/templates/header/partials needs to be added to your handlebars partialsDir config property (see docs path)
  • assign configuration data to the page handlebars handler.
const headerService = require('mns-fe-unicorn-platform/lib/services/getHeaderContent.js');
import configuration from 'path/to/fesk-configuration';
  • assign data to template
res.render('yourPage', {

    header: headerService.getConfig(header.config, configuration)

});
  • include the following in your page template {{> templates/header/partials/default/header header }}

Images

  • define $mns-core-ui-header-images-dir variable that contains path to where assets have been copied to in above steps
  • @import 'mns-core-ui-header/templates/header/sass/module_images';

Fonts

  • define $mns-london-font-path variable with path to font asset location e.g mns-core-ui/dist/fonts/mns-london
  • define $mns-london-font-name e.g mns-london
  • @import 'mns-core-ui/globals/typography/fonts/mns-london/module_mns-london';

Font-icons

  • define $mns-core-ui-header-icon-font-family variable e.g mns-icons
  • define $mns-core-ui-header-fonts-dir e.g ~mns-core-ui/dist/fonts/
  • @import 'mns-core-ui-header/templates/header/sass/module_font-icons';

Configuration



The module exposes a config object:

require('mns-core-ui-header).config



There is core configuration of the header (data) and the associated key (key). This is data that is deemed to not need business control.



* core configuration require('mns-core-ui-header).config.data - contains link data for flags and dropdowns.



A decorators object is also exposed, so this data can be optionally added the full config object. This is data that does/could need business control and could be replaced by an API when thats implemented. Current decorators are:



* labels - labels for dropdown menu items.



For detail on above see /index.js

Events

There are some events that can/should be fired from a client page/application that the header listens to.

  1. Update the header mini bag count. event name updateItemCount passing an integer of new page count in variable myBagCount i.e event.myBagCount

Development



The development environment is based on mns-fe-starter-kit and documentation for how that works can be found here

Mocking Routes



Mocked endpoints can be added to your express app by using the ExposeRoutes functionality. Add the following lines to your server.js file. Note that the "ExposeRoutes" line must be added above the current routes that your app defines.

const indexFile = require('../../index');

const ExposeRoutes = indexFile.ExposeRoutes;


server = new ExposeRoutes(server).attachToServer();



You must also make sure that your config file containing the api endpoints is setup with the following:


"loyaltyService": "http://127.0.0.1:3002/loyalty-service/"

"loyaltyServiceStub": "http://127.0.0.1:3002/loyalty-service/"

Testing

To run the UI tests locally:

  1. In terminal tab start the webapp npm start
  2. In another terminal tab npm run test:ui This will test against localhost
  3. Note that UI test spec files must have the the following pattern in order to be picked up ./test/specs/**/*test.spec.js

To run the UI tests in the cloud against a range of browsers and connect to your localhost:

  1. In terminal tab start the webapp npm start
  2. Add you sauce user credentials to the wdio.sauce.conf.js file, or set them as environment variables SAUCE_USER and SAUCE_KEY
  3. In another terminal tab npm run test:ui:sauce
  4. You can configure the required browsers in /test/wdio.sauce.conf.js

Visual Tests Admin Panel

  1. The visual tests are configured to use the 'Admin Panel' (http://webdrivercss-admin.dev.apps.mnscorp.net/)
  2. When the test starts it will first try to pull a baseline matching the id that you supplied
  3. When the test ends it will push the results to the admin panel so that you can view the results
  4. If this is the first time running the tests you must use the --capture (--c) flag to capture a baseline and push to the Admin panel

To run the Visual tests locally:

  1. In terminal tab start the webapp npm start
  2. In another terminal type: npm run test:visual -- --id myid (--c if first time)
  3. Note that visual test spec files must have the the following pattern in order to be picked up ./test/specs/**/*css.spec.js

To run the Visual tests against sauce labs:

  1. In terminal tab start the webapp npm start
  2. Add your sauce user credentials to the wdio.css.sauce.conf.js file, or set them as environment variables SAUCE_USER and SAUCE_KEY
  3. In another terminal type: npm run test:visual:sauce -- --id myid
  4. In another terminal tab npm run test:visual:sauce
  5. You can configure the required browsers in /test/wdio.sauce.css.conf.js

To run the Visual tests against another id:

  1. In terminal tab start the webapp npm start
  2. In another terminal type: npm run test:visual -- -i myid -l anotherid

This will pull the baseline from another id and push the results to your id

Publishing

Shrinkwrap the module

(https://github.com/DigitalInnovation/fesk-documentation/blob/master/how_tos/shrinkwrap_npm_dependencies.md)

Publish the module to NPM

(https://confluence.platform.mnscorp.net/display/FF/publishing+npm+modules)