├── .babelrc ├── .eslintrc.js ├── .gitignore ├── .idea ├── misc.xml └── vcs.xml ├── .prettierrc ├── README.md ├── dist ├── ChildButton.d.ts ├── FloatingMenu.d.ts ├── MainButton.d.ts ├── index.css ├── index.d.ts ├── index.js.map ├── index.modern.js ├── index.modern.js.map └── index.test.d.ts ├── example ├── README.md ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ └── manifest.json ├── src │ ├── App.test.tsx │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ └── setupTests.ts ├── tsconfig.json └── yarn.lock ├── package.json ├── src ├── .eslintrc ├── ChildButton.tsx ├── FloatingMenu.tsx ├── MainButton.tsx ├── index.test.tsx ├── index.tsx ├── styles.module.css └── typings.d.ts ├── tsconfig.json ├── tsconfig.test.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-react"], 3 | } 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', // Specifies the ESLint parser 3 | parserOptions: { 4 | ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features 5 | sourceType: 'module', // Allows for the use of imports 6 | ecmaFeatures: { 7 | jsx: true, // Allows for the parsing of JSX 8 | }, 9 | }, 10 | extends: [ 11 | 'plugin:@typescript-eslint/recommended', 12 | 'plugin:react/recommended', 13 | 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier 14 | 'plugin:prettier/recommended', 15 | ], 16 | plugins: ['react', 'jsx-a11y', 'import'], 17 | rules: { 18 | 'react/jsx-filename-extension': 'off', 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | 39 | /.idea 40 | 41 | build 42 | docs/dist 43 | es 44 | umd 45 | ChildButton.js 46 | MainButton.js 47 | FloatingMenu.js 48 | index.js -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 2, 4 | "semi": true, 5 | "singleQuote": true 6 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-floating-button-menu 2 | 3 | > A customizable floating action button menu 4 | 5 | [![NPM](https://img.shields.io/npm/v/react-floating-button-menu.svg)](https://www.npmjs.com/package/react-floating-button-menu) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 6 | 7 | Inspired by [react-material-floating-button](https://github.com/nobitagit/react-material-floating-button) 8 | 9 | ## Install 10 | 11 | ```bash 12 | npm install --save react-floating-button-menu 13 | ``` 14 | 15 | ## Demo 16 | 17 | See the [project page](https://ifndefdeadmau5.github.io/react-floating-button-menu/) 18 | 19 | ## Usage 20 | 21 | You can customize opening direction, speed, and styles of each button via props. Other options will be added soon 22 | 23 | ```javascript 24 | import { 25 | FloatingMenu, 26 | MainButton, 27 | ChildButton, 28 | Directions 29 | } from 'react-floating-button-menu'; 30 | import MdAdd from '@material-ui/icons/add'; 31 | import MdClose from '@material-ui/icons/clear'; 32 | import MdFavorite from '@material-ui/icons/favorite'; 33 | 34 | 35 | state = { 36 | isOpen: false, 37 | } 38 | ... 39 | 45 | } 47 | iconActive={} 48 | background="black" 49 | onClick={() => this.setState({ isOpen: !this.state.isOpen })} 50 | size={56} 51 | /> 52 | } 54 | background="white" 55 | size={40} 56 | onClick={() => console.log('First button clicked')} 57 | /> 58 | } 60 | background="white" 61 | size={40} 62 | /> 63 | } 65 | background="white" 66 | size={40} 67 | /> 68 | 69 | ... 70 | ``` 71 | 72 | ## License 73 | 74 | MIT © [ifndefdeadmau5](https://github.com/ifndefdeadmau5) 75 | -------------------------------------------------------------------------------- /dist/ChildButton.d.ts: -------------------------------------------------------------------------------- 1 | import { Directions } from './FloatingMenu'; 2 | export interface ChildButtonProps { 3 | icon?: any; 4 | direction?: Directions; 5 | index?: number; 6 | size?: number; 7 | spacing?: number; 8 | isOpen?: boolean; 9 | onClick?: any; 10 | background?: string; 11 | } 12 | declare const ChildButton: ({ direction, index, size, spacing, isOpen, onClick, icon, ...rest }: ChildButtonProps) => JSX.Element; 13 | export default ChildButton; 14 | -------------------------------------------------------------------------------- /dist/FloatingMenu.d.ts: -------------------------------------------------------------------------------- 1 | export declare const DIRECTIONS: { 2 | up: string; 3 | down: string; 4 | left: string; 5 | right: string; 6 | }; 7 | export declare enum Directions { 8 | Up = "up", 9 | Down = "down", 10 | Left = "left", 11 | Right = "right" 12 | } 13 | export interface FloatingMenuProps { 14 | children: JSX.Element[] | JSX.Element | string; 15 | spacing?: number; 16 | slideSpeed?: number; 17 | direction?: Directions; 18 | isOpen: boolean; 19 | } 20 | declare const FloatingMenu: ({ slideSpeed, direction, isOpen, spacing, children, ...rest }: FloatingMenuProps) => JSX.Element; 21 | export default FloatingMenu; 22 | -------------------------------------------------------------------------------- /dist/MainButton.d.ts: -------------------------------------------------------------------------------- 1 | export interface MainButtonProps { 2 | iconActive: any; 3 | iconResting: any; 4 | isOpen?: boolean; 5 | background: string; 6 | onClick: any; 7 | size: number; 8 | } 9 | declare const MainButton: ({ iconResting, iconActive, isOpen, ...rest }: MainButtonProps) => JSX.Element; 10 | export default MainButton; 11 | -------------------------------------------------------------------------------- /dist/index.css: -------------------------------------------------------------------------------- 1 | /* add css module styles here (optional) */ 2 | 3 | ._3ybTi { 4 | margin: 2em; 5 | padding: 0.5em; 6 | border: 2px solid #000; 7 | font-size: 2em; 8 | text-align: center; 9 | } 10 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import ChildButton, { ChildButtonProps } from './ChildButton'; 2 | import FloatingMenu, { Directions } from './FloatingMenu'; 3 | import MainButton, { MainButtonProps } from './MainButton'; 4 | export { ChildButton, FloatingMenu, MainButton, Directions, ChildButtonProps, MainButtonProps, }; 5 | -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sources":["../src/FloatingMenu.tsx","../src/ChildButton.tsx","../src/MainButton.tsx"],"sourcesContent":["import React from 'react'\nimport styled from 'styled-components'\n\nexport const DIRECTIONS = {\n up: 'column-reverse',\n down: 'column',\n left: 'row-reverse',\n right: 'row'\n}\n\n// @ts-ignore\nconst StyledUl = styled(({ direction, ...rest }) =>