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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yanqirenshi/menubook

v0.0.11

Published

See `src/index.html`

Readme

MenuBook

React 用のサイドメニュー(アカウントメニュー)コンポーネントです。

画面左上に固定表示されるアバターアイコンをクリック、またはホバーすると、複数の「ページ(タブ)」を持つサイドメニューが展開します。各ページにはアイテム(アイコン風の丸ボタン)が並び、選択中のアイテムはラベル付きの角丸ボックスに展開表示されます。

インストール

npm install @yanqirenshi/menubook

React 18 系がインストールされている必要があります(react / react-dom は peerDependencies)。

使い方

MenuBook は状態を内部に持たない controlled component です。表示状態(menu)と、状態を更新するためのコールバック(actions)を呼び出し側で管理し、props として渡します。

import * as React from 'react';
import MenuBook from '@yanqirenshi/menubook';

const initialMenu = {
    avater: { clicked: false, enterd: false },
    menu: { enterd: false },
    current_page: 'General',
    pages: [
        {
            label: 'General',
            items: [
                { code: 'home', url: '#/home', label: 'Home' },
                { code: 'profile', url: '#/profile', label: 'Profile' },
            ],
        },
        {
            label: 'Settings',
            items: [
                { code: 'account', url: '#/account', label: 'Account' },
            ],
        },
    ],
};

export default function App () {
    const [menu, setMenu] = React.useState(initialMenu);
    const [isOpend, setIsOpend] = React.useState(false);
    const [selectedItem, setSelectedItem] = React.useState('home');

    const actions = {
        menu: {
            change: setMenu,
            open: ()=> setIsOpend(true),
            close: ()=> setIsOpend(false),
            item: {
                click: (item)=> setSelectedItem(item.code),
            },
        },
    };

    return (
        <MenuBook menu={menu}
                  actions={actions}
                  is_opend={isOpend}
                  selected_item={selectedItem}
                  icon="/avatar.png"
                  theme_color={{ r: 63, g: 81, b: 181 }}/>
    );
}

動かせるサンプルは example ディレクトリにあります。

npm install
npm run dev --workspace example

Props

| Prop | 型 | 必須 | 説明 | | --- | --- | --- | --- | | menu | object | ○ | メニューの表示状態とページ/アイテム構成(menu オブジェクトの構造参照)。 | | actions | object | ○ | 状態更新用のコールバック群(actions オブジェクトの構造参照)。 | | is_opend | boolean | | ページ切り替え用ドロップダウンの開閉状態。 | | selected_item | string | | 選択中アイテムの code。 | | icon | string | | アバターアイコンの画像URL。未指定時はMUIのデフォルトアイコンが表示されます。 | | theme_color | { r, g, b } | | メニューの配色(RGB)。省略時は { r: 157, g: 91, b: 139 }。 |

menu オブジェクトの構造

{
    avater: { clicked: false, enterd: false }, // アバターアイコンのクリック/ホバー状態
    menu: { enterd: false },                   // メニュー本体へのホバー状態
    current_page: 'General',                   // 表示中のページの label
    pages: [
        {
            label: 'General',
            items: [
                { code: 'home', url: '#/home', label: 'Home' },
                // ...
            ],
        },
        // ...
    ],
}

actions オブジェクトの構造

{
    menu: {
        change: (new_menu) => void,   // menu を更新する(内部からイミュータブルな更新を通知される)
        open: () => void,             // is_opend を true にする
        close: () => void,            // is_opend を false にする
        item: {
            click: (item) => void,    // アイテムがクリックされたときに呼ばれる
        },
    },
}

依存ライブラリ

ライセンス

MIT