Skip to content

An easy and customizable tool for pop-up, tooltip, dropdown and more

Notifications You must be signed in to change notification settings

pharos-lab/blink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blink

An easy and customizable tool for pop-up, tooltip, dropdown and more

· Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Blink is a tool for quickly add tooltip, pop-up and more in your project within few lines of code.

(back to top)

Getting Started

All you need is installing the Blink package and add few lines of code.

Prerequisites

You just need npm installed to get Blink.

  • npm
    npm install npm@latest -g

Installation

Install NPM package

npm install @pharos-lab/blink

(back to top)

Usage

All you need to create a pop-up or else is two element at least:

  • A trigger, like a button or any element you wish
  • A popper, the element you want to appear based on the event you choose (hover or click)

Then, in your js file, you can import the Blink class and use the create method to create your pop-up, tooltip or whatever element you want to make appearance.

Here is a exemple:

In html file

<!DOCTYPE html>
<title>Popper example</title>

<button id="button" >I'm a button</button>
<div id="tooltip">I'm a tooltip</div>

In Js file

import { Blink } from '@pharos-lab/blink'

const button = document.getElementById('button')
const tooltip = document.getElementById('tooltip')

Blink.create(button, tooltip)

Use it with VUE

<template>
<title>Popper example</title>

<button id="button" ref="trigger">I'm a button</button>
<div id="tooltip" ref="popper">I'm a tooltip</div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { Blink } from '@pharos-lab/blink'

const button = ref()
const tooltip = ref()

onMounted(() => {
  Blink.create(button.value, tooltip.value)
})

</script>

Use it with REACT

import { Blink } from 'pharos-lab/blink'
import { React } from 'react'

class MyComponent extends React.Component {
   constructor(props) {
    super(props);
    this.trigger = React.createRef();
    this.popper = React.createRef();
  }

  componentDidMount() {
    Blink.create(this.trigger.current, this.popper.current);
  }

  render() {
    return (
      <div>
        <!-- your component JSX -->

        <p>Lorem ipsum dolor sit amet <span ref={this.trigger}>adipiscing</span> elit, sed do</p>

        <div className="popper" ref={this.popper}>
          I'm a tooltip
        </div>
      </div>
    );
  }
}

Customization

placement

The Blink create method will place your pop-up automatically based on the place available in the viewport.

By default, it will try at top of the trigger, then bottom, right and finally left. But you can choose by adding an option object as 3rd argument to create method.

Example
const options = {
  placement: 'top'
}

Blink.create(trigger, tooltip, options)

You may choose the placement among these values: top, bottom, right, left, auto.

auto is the default option

Event

In addition to the placement option, you can choose what kind of event will trigger the pop-up with the event option

Example
const options = {
  event: 'click'
}

Blink.create(trigger, tooltip, options)

You may choose the event among these values: click, hover.

hover is the default option

Arrow

Finally, you can add an arrow to the pop-up for UI/UX appreciation with the arrow option

Example
const options = {
  arrow: true
}

Blink.create(trigger, tooltip, options)

You may choose the arrow option among these values: true, false.

false is the default option

Dropdown

If you want to create a dropdown that is right or left aligned with your trigger, you can use the dropdown option.

Example
const options = {
  dropdown: 'right'
}

Blink.create(trigger, tooltip, options)

You may choose the dropdown option among these values: right, left, none.

none is the default option

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License.

(back to top)

Contact

pharos-lab - @pharOsLab - 1i6h7h0u53.lighthouse@gmail.com

Project Link: https://github.com/pharos-lab/blink

(back to top)

About

An easy and customizable tool for pop-up, tooltip, dropdown and more

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published