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

tbc-panda-mobile-header

v0.1.0

Published

Header for all TBC Panda React apps

Downloads

2

Readme

TBC Panda React App Header

Header for all TBC Panda React apps

Install

npm install --save tbc-panda-header

Styles

As of version 0.2.0, to use the component included in this module, the following style file will need to be imported/included into the main App.scss after the colors.scss import:

@import "tbc-panda-header/dist/Component/styles/header.scss";

Header Component:

import HeaderContainer from "tbc-panda-header/dist/Component/HeaderContainer";

Then, in the highest level presentational component, place the following where it should appear:

<HeaderContainer pagesObject={pagesObject} />

This should be above any routing tags.

pagesObject

The Header module requires a pagesObject which describes what items appear in the header.

It is recommended that a pagesConfig.js file be created which hosts this object.

The pagesObject is made up of:

| Key | Type | Default | Description | | ------------------- | ------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | pages | Array | [] | key containing an array of page objects (see below for details) | | utilsComponents | Array | [] | key contains an array of utility button components (items that appear in the far right of the header) | | default | Number | 0 | value (index) used to determine the default page index | | mobileThreshold | Number | 2 | value used to determine at which Bootstrap size does the header convert to "mobile"; defaults to 2 ("md") (options: 0 = "xs", 1 = "sm", 2 = "md", 3 = "lg", 4 = "xl") | | maxWidth | Boolean | false | if true, then header will be maximum width of screen for all sizes; else it will be limited to standard Bootstrap container size | | searchObject | Object | { enabled: false} | object controlling header search field (see below for details) |

The objects within the pages key contains:

| Key | Type | Required | Description | | --------------- | --------------- | -------- | -------------------------------------------------------------------- | | path | String | REQUIRED | used for key and local path (if local link) | | name | String | REQUIRED | short name (used in header and home tab) | | longName | String | OPTIONAL | long name (used in home tab) | | icon | String | REQUIRED | icon classes for links | | component | React.Component | OPTIONAL | the container component for internal pages | | link | String | OPTIONAL | external URL | | target | String | OPTIONAL | anchor target for external URLs (defaults to "_new") | | desktopOnly | Boolean | OPTIONAL | flag whether link appears in header only for desktop implementations | | mobileOnly | Boolean | OPTIONAL | flag whether link appears in header `only for mobile implementations |

The searchObject object is populated by the following keys:

| Key | Type | Default | Description | | ----------------------- | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | enabled | Boolean | false | flag determining if search field appears (and that the header is sized accordingly) NOTE: header height is 53px without search and 75px with | | initialValues | Object | {} | determines if/what initial values appear in the search fields; NOTE: search term form fieldName/value keyes are searchTerm and searchScope (Example: {searchTerm: "", searchScope: "ID"}) | | placeholder | String | "" | placeholder text within empty search field | | stickyValues | Boolean | false | by default, values clear upon search; setting this flag to true makes search values "sticky" (do not clear) | | submitSearch | Function | () => {} | function fired when search field is submitted | | prependScopeEnabled | Boolean | false | flag determining if a prepended drop down occurs before the search bar (usually for determining search scope); NOTE: drop down option form fieldName/value key is searchScope | | prependOptions | Array | [] | array of objects used for prepend drop down; objects include cd (value of selection) and nm (display name of option); example: [{cd: "ANY", nm: ""}, {cd: "NM", nm: "Name"}, {cd: "ID", nm: "ID"}]; NOTE: blank option will not be added automatically - the options provided in the option array are exactly what will be available | | enableEmptySearch | Boolean | false | flag determining if search icon is active when nothing is entered in field; allows for empty searches |

See below for sample pagesConfig.js file.

Required NPM Packages

npm install --save bootstrap reactstrap @material-ui/core lodash formik

Testing

For any unit test file that deep renders ("mounts") this imported component, add the following:

jest.mock("tbc-panda-header/dist/Component/HeaderContainer", () => "div");

Sample pagesConfig.js file

/** @module pagesConfig */

import React from "react";

import Tab1 from "./Tab1";
import Tab2 from "./Tab2";
import UtilButton from "./UtilButton";

const pagesObject = {
    default: 0,
    mobileThreshold: 1, // "sm"
    pages: [
        {
            path: "tab1",
            name: "Tab 1",
            icon: "far fa-dice-one",
            component: () => <Tab1 />
        },
        {
            path: "tab2",
            name: "Tab 2",
            icon: "far fa-dice-two",
            component: () => <Tab2 />
        },
        {
            path: "sdo",
            name: "SDO",
            longName: "Seed Dealer Orders",
            icon: "fas fa-store-alt",
            link: `http://seed-staging.trinidadbenham.com`
        }
    ],
    utilComponents: [<UtilButton />],
    maxWidth: false,
    searchObject: {
      enabled: true,
      initialValues: { searchTerm: "Test" },
      placeholder: "Search by ID or Name",
      stickyValues: true,
      submitSearch: values => console.log(values),
      prependScopeEnabled: true,
      prependOptions: [
        {cd: "ANY", nm: ""},
        {cd: "NM", nm: "Name"},
        {cd: "ID", nm: "ID"}
      ]
    }
};

export default pagesObject;