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

ssw.megamenu

v4.8.0

Published

### Current Library Usage

Downloads

1,475

Readme

How to use the Mega Menu

Current Library Usage

We are currently using this library for the following projects:

  • SSW.Website
  • SSW.People
  • SSW.Rules

The data for these projects is hosted on GitHub at: https://github.com/SSWConsulting/SSW.Website/blob/main/content/megamenu/menu.json.

Editing Process

To make any edits, you need to use TinaCMS mode to update the content.

MEGAMENU

Figure: TinaCMS mode to edit the megamenu data

Installation

  1. Install package
npm install ssw.megamenu
yarn add ssw.megamenu
pnpm add ssw.megamenu
  1. Import the generated styles
import "ssw.megamenu/dist/style.css";

NOTE: If you have TailwindCSS installed in your project, you can instead list the ssw.megamenu package in your tailwind.config.js content array and add the SSW colors like so:

// tailwind.config.js

// ...

module.exports = {
  // ...
  content: [
    // ...
    "node_modules/ssw.megamenu/**/*.js",
  ],
  // ...
  theme: {
    extend: {
      colors: {
        ssw: {
          red: "#cc4141",
          light: {
            red: "#d26e6e",
          },
          gray: "#797979",
          black: "#333333",
        },
      },
    }
  }
};
  1. You can then use the components in your React app like so:
// CommonJS
const { Menu, MobileMenu, MenuBar } = require('ssw.megamenu');

// ESM
import { MegaMenuLayout } from 'ssw.megamenu';

Basic Usage

The ssw.megamenu NPM package provides you with the <MegaMenuLayout /> component, which can be used in both client-side and server-side rendered React apps.

Example:

import { MegaMenuLayout } from 'ssw.megamenu';

function App() {
  return (
    <MegaMenuLayout />
    /* {{ CONTENT_HERE }} */
  );
}

Usage with SSR

The <MegaMenuLayout /> component can be used with SSG (Static Site Generation) and SSR (Server Side Rendering) frameworks like Next.js and Gatsby. This is achieved by providing an optional prop in the <MegaMenuLayout /> component called menuBarItems, which is an array of objects that represent the menu bar items.

Example usage with SSR (Next.js):

import { MegaMenuLayout } from 'ssw.megamenu';

function App(props) {
  return (
    <MegaMenuLayout menuBarItems={props.menuBarItems} />
    /* {{ CONTENT_HERE }} */
  );
}

export function getStaticProps() {
  const menuItems = await getMenuItems();

  return {
    props: {
      menuItems,
    },
  };
}

Available Props

| Prop Name | Type | Description | Required | | --- | --- | --- | --- | | menuBarItems | MenuBarItem[] | An array of objects that represent the menu bar items provided by SSR or other data fetching mechanisms. If this prop isn't supplied, the component will fetch the data from the Next.js API route. | No | | title | string | The title text displayed next to the SSW logo. | Yes (If there is no tagline provided) | | subtitle | string | The text displayed underneath the SSW logo | No | | tagline | string | The text displayed next the SSW Logo. | No | | url | string | The URL of the menu bar item. | No | | searchUrl | string | The absolute URL the search takes you to. If not provided, will default to the host address. i.e. for SSW <www.ssw.com.au> | No | | rightSideActionsOverride | () => JSX.Element | The component to replace the "Call Us" and search buttons that are displayed by default on the right side of the menu. | No | | linkComponent | React.FC<{ href: string; className?: string; title?: string; onClick?: () => void; children?: React.ReactNode;}> | The component to use for the links in the menu. i.e. <Link> from next/link or gatsby | No | | callback | (seachTerm: string) => void | Callback run on search. If provided, the search will not open a google tab. | No |

Testing

When using pnpm link on the SSW.Website project, we encountered some issues with using ssw.megamenu, so instead use file: in the package.json file to link the package like so:

{
  "dependencies": {
    "ssw.megamenu": "file:../SSW.MegaMenu"
  }
}

Replace ../SSW.MegaMenu with the path to the SSW.MegaMenu project on your local machine.

How to contribute?

In the project directory, you can run:

pnpm dev

Runs the app in the development mode.

Open http://localhost:5173 to view it in the browser.

The page will reload if you make edits.

pnpm build

Builds the lib for production to the dist folder.

How to publish?

  1. Important: Before to push your changes, you need to increment the version number in the file package.json using semver
  2. Make a pull request to add your code into the main branch.
  3. Get the pull request approved
  4. Merge your code into the main branch
  5. Publish a GitHub release with the same version number as the one you incremented in the file package.json at https://github.com/SSWConsulting/SSW.MegaMenu/releases