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

dna-responsive-nav

v1.1.0

Published

React component for a responsive navigation bar with search box

Downloads

37

Readme

dna-responsive-nav

React component for a responsive navigation bar with a search box using Semantic-UI theme.

NPM JavaScript Style Guide

Demo

https://deniapps.com/playground/dna-rn

About

I created this tiny package to solve the issue that neither Semantic UI nor Semantic UI React offers a responsive navbar. They provide an example about how to create one using sidebar, but it's just way too complicated, and not easy to use in my opinion.

You can customize the style by creating a new css file based one the default one at dna-responsive-nav/dist/dna-rn.css to match your site.

NOTE: It uses semantic-ui for icon and input, so you have to import 'semantic-ui-css/semantic.min.css' if you site is not yet using it. (I am looking for a better solution to fix this drawback.)

Features

  • With a responsive search box
  • Be able to disable the search box
  • Simple & Slick (Only three options)
  • Scrollable navigation links in the desktop mode in case you have many links
  • Fading effect when navigation links overflows at the left and right edges (i.e. x-overflow)

Screenshots

Blog-DeNiApps-mobile Blog-DeNiApps-search

Install

npm install --save dna-responsive-nav

Options

| option | required? | type | explain | | ------------ | --------- | -------- | ------------------------------------------------------------ | | siteName | yes | string | site name | | links | yes | node | site navigation links | | logo | no | string | image path of the site logo, if no set, then logo is hidden. | | handleSearch | no | function | if not set, the search box is hidden. |

By default both siteName and logo show when the page width is >= 780px, and only logo shows when the page width is < 780px. But you can overwrite this by using css style sheet. Make a new one from the default one at dna-responsive-nav/dist/dna-rn.css, and change the following lines:

/** when page width >=780px **/
.dnarn nav .logo img {
  display: inline-block; /** to show/hide logo image **/
  vertical-align: middle;
  padding-right: 5px; /** editable **/
  height: 36px; /** editable **/
}
.dnarn nav .logo span {
  display: none; /** to hide/show sitename **/
}

/** when page width < 780px **/
@media (max-width: 779px) {
  .dnarn nav .logo img {
    padding-right: 0;
    display: none; /** to hide/show the logo image **/
  }

  .dnarn nav .logo span {
    display: inline-block; /** to show/hide sitename **/
  }
}

Usage

import React from 'react'
import { useRouter } from 'next/router'

import ResponsiveHeader from 'dna-responsive-nav'
import 'semantic-ui-css/semantic.min.css'
import 'dna-responsive-nav/dist/dna-rn.css'

// we use next/router as example to get the pathname, by which we set "is-active" class to <a>
const router = useRouter()

const links = (
  <ul>
    <li key='blog-menu'>
      <a
        className={router.pathname === '/blog' ? 'is-active' : ''}
        href='/blog'
      >
        Blog
      </a>
    </li>
    <li key='about-menu'>
      <a
        className={router.pathname === '/about' ? 'is-active' : ''}
        href='/about'
      >
        About Us
      </a>
    </li>
    <li key='playground-menu'>
      <a
        className={router.pathname === '/playground' ? 'is-active' : ''}
        href='/playground'
      >
        Playground
      </a>
    </li>
    <li key='mistakes'>
      <a
        className={router.pathname === '/mistakes' ? 'is-active' : ''}
        href='/mistakes'
      >
        Mistakes
      </a>
    </li>
  </ul>
)

const handleSearch = (kw) => {
  if (kw) {
    const url = 'https://deniapps.com/search?kw=' + encodeURIComponent(kw)
    window.open(url, '_blank')
  }
}

const App = () => {
  return (
    <ResponsiveHeader
      siteName='DeNiApps'
      links={links}
      logo='/image/YOUR-LOGO-PATH.png'
      handleSearch={handleSearch}
    />
  )
}

export default App

License

MIT © deniapps