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

@substrate-system/hamburger

v0.0.8

Published

A hamburger menu, implemented as a web component

Downloads

8

Readme

hamburger

tests types module semantic versioning dependencies license

A hamburger menu, implemented as a web component.

Hamburger button closed Hamburger button open

install

npm i -S @substrate-system/hamburger

use

This is a web component. Just import the JS and CSS, then you can use the tag in your HTML.

example

bundler

With a bundler such as vite,

// just import, then we can use the tag in HTML
import '@sustrate-system/hamburger'
import '@sustrate-system/hamburger/style.css'

// import the application CSS, because we are defining some CSS variables
import './index.css'

HTML only

You can use the files in this module directly by linking in your HTML.

First, copy the files to a location accessible to your web server. This package includes minified files.

JS

cp ./node_modules/@sustrate-system/hamburger/dist/index.min.js ./public/hamburger.js

CSS

cp ./node_modules/@sustrate-system/hamburger/dist/style.min.css ./public/hamburger.css

Then link to them in HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- the style -->
    <link rel="stylesheet" href="/hamburger.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example</title>
</head>
<body>
    <!-- use the element -->
    <hamburger-menu transition=800>
      <a href="#example">example link</a>
      <a href="#example">example two</a>
    </hamburger-menu>

    <!-- the JS -->
    <script type="module" src="/hamburger.js"></script>
  </body>
</html>

API

events

Two custom events, open and close.

const burger = document.querySelector('hamburger-menu')

burger?.addEventListener('open', ev => {
  debug('open')
})

burger?.addEventListener('close', ev => {
  debug('close')
})

attributes

transition

Take an attribute transition to set the time, in milliseconds that it takes for the menu to transition in and out of the viewport.

Default is 200ms.

This corresponds to a CSS variable, --hamburger-transition, which is the transition time as a CSS property. Eg, in CSS,

hamburger-menu {
  --hamburger-transition: .8s
}

corresponds with this HTML:

<hamburger-menu transition=800>
  <a href="#example">example link</a>
  <a href="#example">example two</a>
</hamburger-menu>

[!NOTE]
800 milliseconds is 0.8 seconds.

CSS variables

Define several CSS variables to customize the appearance.

:root {
  --hamburger-bgc: var(--white);  /* hamburger background color */
  --hamburger-color: var(--purple); /* hamburger text color */
  --hamburger-hover-color: var(--bright-white); /* hover state text color */
  --menu-bgc: var(--white);  /* background color for the expanded menu */
  --menu-color: var(--purple);  /* text color for expanded menu */
  --menu-hover-bgc: var(--purple); /* hover background color inside menu */
  --menu-hover-color: var(--white); /* hover text color inside menu */
  --menu-width: 200px;
  --hamburger-transition: .2s;  /* default is .2s */
}

credits

Based on this codepen page.