0.4.7 โ€ข Published 2 years ago

react-float-menu v0.4.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
  • โšก Configurable and smart floating menu for react
  • โš™๏ธ Comes with a lot of options to customize the behavior of the menu
  • ๐Ÿ’ก Auto detects edges of the screen and places the menu accordingly
  • ๐ŸŽจ Customize colors with ease
  • ๐Ÿ“ฑ Seamless support for mobile and desktop
  • ๐Ÿ’ช Built with Typescript

๐Ÿ“ฆ Installation

Install the package with npm or yarn.

  npm install react-float-menu

or

  yarn add react-float-menu

๐Ÿš€ Getting started

Let's get started by creating a new floating menu with drag super power.

  <Menu
    dimension={40}
    items={[
      { name: "File" },
      {
        children: [
          { children: [{ name: "Cut 1" }, { name: "Cut 2" }], name: "Cut" },
          { name: "Select All" },
        ],
        name: "Edit",
      },
      { name: "Add" },
      {
        children: [
          { name: "Copy from clipboard" },
          { name: "Copy selection" },
        ],
        name: "Copy",
      },
      { name: "Save" },
      { name: "Logout" },
    ]}
    shape="square"
    startPosition="top left"
    width={250}
    onSelect={(val) => console.log(val)}
  >
    <PlusIcon />
  </Menu>

โš™๏ธ Properties

namedescriptiondefault
autoFlipMenuFlips the menu when the button is at the bottom of the screen and there is no space to display the menutrue
bringMenuToFocusAutomatically moves the menu and brings it to focus when the menu is activated from the left or right edge of the screen.true
closeOnClickOutsideCloses the menu if you touch or click outside the menu.true
dimensionSets the height and width of the button30
disableHeaderDisables the header section of the menu.false
iconSizeSize of the menu item icons"1rem"
itemsCollection of menu items. Please refer Menu item model[]
pinDisables dragging and pins the menu. The button's initial placement will be determined by startPosition30
shapeShape of the button. can be square or circlecircle
RTLRenders the menu items right to left. The submenu's will open to the left side.False
startPositionStarting position of the button. can be top left,top right,bottom left,bottom righttop left
themeWith the theme object, you can change the colors of different elements.
widthWidth of the menu30

items

items is an array of menu item objects. A menu item represents the individual menu item and its properties.

namedescription
nameLabel of the menu item
idUnique id of the menu item. This is optional as the ids are automatically generated by the library
childrenThe prop takes an array of Menu item objects and it will be rendered as the submenu for this menu item
iconUse this prop to display a icon for the menu item
selectedThis is an internal prop that is set to true when the menu item is selected

submenus are activated by clicking on the menu item or by hovering over the menu item.

๐ŸŽจ Theme

Use the theme object to customize the colors of the different elements of the menu.

namedescriptiondefault
menuBackgroundColorbackground color of the menu#FFFFFF
menuItemHoverColorbackground color of the menu item when its hovered#318CE7
menuItemHoverTextColorText color of the menu item when its hovered#fff
primaryPrimary color or the predominant color of the menu#318CE7
secondarySecondary color of the menu#FFFFFF
import {Menu} from 'react-float-menu';

<Menu
  startPosition="top right"
  theme={{
    menuBackgroundColor: "#FFFFFF",
    menuItemHoverColor: "#318CE7",
    menuItemHoverTextColor: "#fff",
    primary: "#318CE7",
    secondary: "#FFFFFF",
  }}
/>

๐Ÿงช Tests

We use cypress to test the library.

To run the tests, run the following command in the root directory of the project.

  pnpm install
  pnpm run cypress:open

๐Ÿซ CodeSandbox Examples

  1. Basic
  2. Pinned Menu
  3. Custom Colors
  4. RTL

๐Ÿค Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Add feature')
  4. Push to the branch (git push origin new-feature)
  5. Create a new Pull Request

Check out the contributing guide for more details.

๐Ÿ“ƒ Meta

Distributed under the MIT license. See LICENSE for more information.

Prabhu Murthy โ€“ @prabhumurthy2 โ€“ prabhu.m.murthy@gmail.com https://github.com/prabhuignoto

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago