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-antd-sider-menus

v0.1.2

Published

Based on antd, menu props mode is inline. solve the problem of refreshing the route, jump routing, Layout.Sider collapsed from false to true, and when the collapsed is true, the dropdown is mistaken for the bug.

Downloads

5

Readme

react-antd-sider-menus

NPM Version Build Status Coverage Status

Based on antd, menu props mode is inline. solve the problem of refreshing the route, jump routing, Layout.Sider collapsed from false to true, and when the collapsed is true, the dropdown is mistaken for the bug.

Install

yarn

yarn add react-antd-sider-menus

npm

npm install --save react-antd-sider-menus

UMD

<script src="https://unpkg.com/[email protected]/dist/index.umd.js"></script>

OR

<script src="https://unpkg.com/[email protected]/dist/index.umd.min.js"></script>

Tips: You can find the library on window.ReactAntdSiderMenus.

Import

ES2015

import ReactAntdSiderMenus, {
  toggleCollapsed,
  childrenToFlat,
  findPathByLeafParam
} from 'react-antd-sider-menus'

CommonJS

const ReactAntdSiderMenus = require('react-antd-sider-menus')
const { toggleCollapsed, childrenToFlat, findPathByLeafParam } = require('react-antd-sider-menus')

Usage

import React, { useReducer } from 'react'
import ReactAntdSiderMenus, { toggleCollapsed } from 'react-antd-sider-menus'

const initial = {
  menus: [], // set self project menus
  collapsed: false,
  key: [],
  keyPath: [],
  cacheKeyPath: [],
  breadRouters: []
}

const reducer = (state, action) => {
  const payload = reap(action, 'payload', {})
  switch (action.type) {
    case 'update':
      return { ...state, ...payload }
    default:
      throw new Error()
  }
}

function Example() {
  const {} = props

  const [
    { menus = [], collapsed = false, key = [], keyPath = [], cacheKeyPath = [], breadRouters = [] },
    dispatch
  ] = useReducer(reducer, initial)

  const screenWidth = 1200 // listener screen resize. recommend: react-listen-resize
  const siderMenusWidth = '320px'
  const locationPathname = '' // listener browser router pathname change.

  const onChangeSiderMenus = value =>
    dispatch({
      type: 'update',
      payload: {
        ...value
      }
    })

  return (
    <React.Fragment>
      <div
        onClick={() =>
          toggleCollapsed({
            onChangeSiderMenus,
            collapsed,
            keyPath,
            cacheKeyPath,
            breadRouters
          })
        }
      >
        Expand/Close
      </div>
      <ReactAntdSiderMenus
        screenWidth={screenWidth}
        locationPathname={locationPathname}
        antdSider={{
          classNameSider: '',
          styleSider: { height: '100%', overflowX: 'hidden', overflowY: 'auto' },
          widthSider: siderMenusWidth,
          collapsedWidth: 64
        }}
        siderMenus={{
          menus,
          collapsed,
          key,
          keyPath,
          cacheKeyPath,
          breadRouters
        }}
        onChangeSiderMenus={onChangeSiderMenus}
        firstLevelSubMenuIconStyle={{ style: {} }}
        firstLevelMenuItemIconStyle={{ style: {} }}
      />
    </React.Fragment>
  )
}

Props

screenWidth

Type number, isRequired, Default 0. Screen resize listener change.

locationPathname

Type string, isRequired, Default ''. Browser location pathname.

antdSider

Antd Layout Sider props. Type object.

| Property | Description | Type | Default | isRequired | | -------------- | ------------------------------------------------------------------- | -------------- | ------- | ---------- | | classNameSider | React className property | string | '' | false | | styleSider | React style property | object | {} | false | | widthSider | Antd Sider component width, by the screenWidth change to set value. | string|number | '320px' | false | | collapsedWidth | Antd Sider component prop collapsed is true, sider's width. | number | 80 | false |

siderMenus

Menu operation data. Type object. isRequired. We can update using onChangeSiderMenus.

| Property | Description | Type | Default | isRequired | | ------------ | ------------------------------------------------------------------------ | ----- | ------- | ---------- | | menus | Data for rendering menu options. menus | array | [] | true | | collapsed | Whether to shrink the antd sider component. | bool | false | true | | key | Antd menu component prop selectedKeys, the currently selected menu item. | array | [] | true | | keyPath | Antd menu component prop openKeys, The current menu item expanded. | array | [] | true | | cacheKeyPath | Solve problems with caching keyPath. Type array. | array | [] | true | | breadRouters | Back to top selected all parents (contain: selected menu item). | array | [] | true |

menus

menus = [
  {
    name: '开始', // show real name OR umi-plugin-local key
    router: '/start', // Uniquely identifies. Also location pathname exact match.
    icon: Setting, // Unselected Svg Component. Only first level has icon
    selectIcon: SettingSelect // Selected Svg Component. Only first level has icon
  },
  {
    name: 'MANAGEMENT',
    router: '/management',
    icon: Setting,
    selectIcon: SettingSelect,
    children: [
      // submenu show router item
      {
        name: 'SETTING',
        router: '/management/setting', // Inheriting the previous layer of routing.
        children: [
          {
            name: 'SETTING',
            router: '/management/setting/rule'
          }
        ]
      }
    ]
  }
]

onChangeSiderMenus

Type function(siderMenusValues), isRequired. Update some of siderMenus object states.

firstLevelSubMenuIconStyle

Type object, Default {}. The first level has a submenu icon.

| Property | Description | Type | Default | isRequired | | --------- | ------------------------ | ------ | ------- | ---------- | | className | React className property | string | '' | false | | style | React style property | object | {} | false |

firstLevelMenuItemIconStyle

Type object, Default {}. The first level does not have a sub-menu icon.

| Property | Description | Type | Default | isRequired | | --------- | ------------------------ | ------ | ------- | ---------- | | className | React className property | string | '' | false | | style | React style property | object | {} | false |

LICENSE

MIT License