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

react-custom-sidebar

v1.0.6

Published

React Custom Sidebar is a fully customizable sidebar component for React. - Can be used a docked or over content. - Docked version has open and close state. - Fully customizabe light and dark theme option. - User profile section. - Dedicated logout b

Downloads

12

Readme

React Custom Sidebar

React Custom Sidebar is a fully customizable sidebar component for React.

  • Can be used a docked or over content.
  • Docked version has open and close state.
  • Fully customizabe light and dark theme option.
  • User profile section.
  • Dedicated logout button
  • Auto adjusted on mobile devices to 'Over content' mode
  • Custom styles supported

Screenshots

desktop view

screen 1

desktop view menu closed

screen 2

mobile view menu opened

screen 3

light theme

screen 5

Installation

npm install react-custom-sidebar

Getting started

import { Sidebar } from "react-custom-sidebar";

const themeColors = {
  light: {
    bgColor: "#e4e4e6",
    textColor: "#0f0f1f",
    highlights: "#cfcfcf",
  },
  dark: {
    bgColor: "#0f0f1f",
    textColor: "#ffffff",
    highlights: "#21213d",
  },
};

function App() {
  // sidebar toggle status
  const [isMenuOpen, setIsMenuOpened] = useState(false);

  // menu list
  const menuItems = [
    {
      title: "Home",
      link: "/",
      icon: <FontAwesomeIcon icon={faHome} />,
    },
    {
      title: "Mails",
      link: "/mails",
      icon: <FontAwesomeIcon icon={faEnvelope} />,
    },
    {
      title: "Services",
      link: "/services",
      icon: <FontAwesomeIcon icon={faList} />,
    },
    {
      title: "Contacts",
      link: "/contacts",
      icon: <FontAwesomeIcon icon={faContactCard} />,
    },
  ];

  // logout click handler
  const handleLogout = () => {
    console.log("logout clicked");
  };

  return (
    <div className="App">
      <BrowserRouter>
        <Sidebar
          menuItems={menuItems}
          theme="light"
          logoUrl="add logo url here"
          logoSmallUrl="add small logo url here which will be visible in closed state"
          themeColors={defaultThemeColors}
          showLogout={true}
          handleLogout={handleLogout}
          userDetails={{
            name: "User name",
            description: "designation",
            avatar: "add user avatart url here",
          }}
          closeOnLinkClick={false}
          closeOnOutsideClick={false}
          isSidebarOpened={isMenuOpen}
          handleSidebarToggle={setIsMenuOpened}
          showToggleButton={true}
        >
          // main content here
          <Routes>
            <Route path="/" element={<Home />} />
            <Route path="mails" element={<Mails />} />
            <Route path="contacts" element={<Contacts />} />
            <Route path="services" element={<Services />} />
          </Routes>
        </Sidebar>
      </BrowserRouter>
    </div>
  );
}

export default App;

Supported props

| Property name | Type | Default | Description | | ------------------ | ------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | docked | boolean | true for desktop/tablet and false for mobiles | If the sidebar is docked with main content or float over it
| menuItems | array of objects | Empty array | The list of menu items to be rendered | | logoUrl | string | NULL | Logo url
| logoSmallUrl | string | NULL | Small Logo for closed state, only visible if showToggleButton is false url | | theme | string | dark | light/dark | | themeColors | object | default colors | Theme colors | | showLogout | boolean | false | To show/hide logout button | | handleLogout | function | NULL | Logout button click listener | | userDetails | object | NULL | User details to be shown in sidebar. | | closeOnLinkClick | boolean | false | To close the sidebar on menu item click | | closeOnOutsideClick | boolean | false | To close the sidebar on outside click on docked state or mobile view | | isSidebarOpened | boolean | true | If the sidebar should be open | | showToggleButton | boolean | true | If hamburger menu icon visible | | handleSidebarToggle | function | n/a | Callback called when the sidebar status changed from hamburger menu icon | | showTooltipOnClose | boolean | true | If tooltip visible in closed state. | | styles | object | empty object | Custom styles. |

Default theme colors

{
  light: {
    bgColor: "#e4e4e6", // sidebar background color
    textColor: "#0f0f1f", // text color
    highlights: "#cfcfcf", // bg color of active/hover link item
  },
  dark: {
    bgColor: "#0f0f1f",
    textColor: "#ffffff",
    highlights: "#21213d",
  },
}

Menu items

[
    {
        title: "Home",
        link: "/home",
        icon: "" //  component or img,
    },
    ...
]

userDetails

{
    name: "",
    description: "",
    avatar: ""
}

Styles

Custom styles can be passed as an object with these keys:

{
    sidebar : { /* for main container */},
    logoContainer: {/* for logo container */},
    logo: { /* for logo icon */},
    logoSmall: { /* for small logo icon */},
    toggleIcon: { /* for hamburger menu icon */},
    menuItem: { /* for menu logo and text container */},
    menuItemIcon: { /* for menu item logo */},
    menuItemText: { /* for menu item text */},
    userContainer: { /* for  user details container */},
    username: { /* for username text */},
    avatar: { /* for user avatar */},
    userDescription: { /* for user description text */},
    logout: { /* for logout icon */},
    mainContentContainer: { /* for main content outside the sidebar */}
}