1.0.11 • Published 2 years ago

react-floating-ball v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-floating-ball

A react component for floating ball

Install

// npm
npm i --save react-floating-ball
// yarn
yarn add -D react-floating-ball
// pnpm
pnpm add -D react-floating-ball

Usage

Codesandbox

// cjs
const FloatingBall = require('react-floating-ball');
// esm
import FloatingBall from 'react-floating-ball';
import React from 'react'
import ReactDOM from 'react-dom'

function App() {
  return (
    <FloatingBall
      theme='#61dafb'
      position='top left'
      column={2}
      events={[
        { icon: 'H', text: 'home', handle: (e) => console.log(e) },
        {
          icon: 'O',
          text: 'home2',
          handle: (e) => console.log(e),
        },
        {
          icon: 'M',
          text: 'home3',
          handle: (e) => console.log(e),
        }
      ]}
    />
  );
}

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
)

DOCS

props

NameDescriptionTypedefault
themeset floating ball primary colorString#61dafb
positionset floating ball init position.(top/bottom/left/right)Stringtop left
columnset floating ball column of popover.(max: 4)Number2
canMovecontrol the floating ball can move by mouseBooleantrue
eventsevents will be displayed on the floating ball popoverArray[]

EventItem props

NameDescriptionTypedefault
iconevent iconString / React.ReactNode-
textevent nameString / React.ReactNode-
handleevent(item: EventItem) => void-

Provider and useFBCore()

useFBCore() hook return floating ball core instance, u can do anything of floating ball, but u must Provider wrap your component