1.0.6 • Published 2 years ago

vue3-floating-ball v1.0.6

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

vue3-floating-ball

A vue3 component for floating ball

Install

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

Usage

Codesandbox

// App.vue
<script setup>
import { ref } from 'vue';

const theme = ref('#42b883');
const position = ref('top left');
const column = ref(2);
const events = ref([
  { 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),
  }
])
</script>

<template>
  <floating-ball :theme="theme" :position="position" :events="events" :column="column" />
</template>

// main.js
import { createApp } from 'vue'
import FloatingBall from 'vue3-floating-ball';

createApp(App).use(FloatingBall).mount('#app')

DOCS

props

NameDescriptionTypedefault
themeset floating ball primary colorString#42b883
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 / v-slot:icon="{ item }"-
textevent nameString / v-slot:text="{ item }"-
handleevent(item: EventItem) => void-

useFBCore() and $fb

useFBCore() hook and $fb both return floating ball core instance, u can do anything of floating ball