luc-github / ESP3D-WEBUI

A Web UI for ESP8266 or ESP32 based boards connected to 3D printers / CNC
GNU General Public License v3.0
747 stars 305 forks source link

Panel menu refactoring #232

Closed alxblog closed 2 years ago

alxblog commented 2 years ago

Panels menus extracted from panels components :

for better readability and smaller footprint.

Usage example :

// [...]
  const MyComp = () => {
    const menu = [
      {
        label: "My item N1",
        displayToggle: () => <span> {isActive ? "Yes" : "No"} </span>, // only for "toggleable" menu item
        onClick: actionOnClick,
      },
      {
        label: "My item N2",
        onClick: actionOnClick,
        icon: <span class="btn btn-clear" aria-label="Close" />
      },
      { divider: true },
      {
        label: T("S79"),
        onClick: (e) => { terminal.clear(); },
        icon: <span class="btn btn-clear" aria-label="Close" />
      }
    ]
    return <div>
      <Menu items={menu} />
    </div>
  }

Et voilà !

luc-github commented 2 years ago

I did commit to solve the conflict and integrate PR in easier way: https://github.com/luc-github/ESP3D-WEBUI/commit/c2aee4856f08a0ca7da6566c5f21501ae57f8a11