Giter Site home page Giter Site logo

andcarpi / laravel-popper Goto Github PK

View Code? Open in Web Editor NEW
18.0 1.0 3.0 180 KB

A simple and easy to use package that generates tooltips in your Laravel views.

Home Page: https://andcarpi.github.io/laravel-popper/

License: MIT License

PHP 85.52% HTML 6.78% CSS 7.69%
laravel tooltip package popper tippy tooltips views laravel-popper blade php

laravel-popper's Introduction

Laravel Popper

This package provides an easy way to add tooltips in your Laravel blade views. Powered by Popper.js and Tippy.js. With this, you will not lose time getting them done. Install and use, out of the box.

Laravel Popper

Install

First things, first... Use composer to install the package:

composer require andcarpi/laravel-popper

Setup

When composer finish his job, add the Service Provider and the facade to your app.config in the config folder:

Skip this if you use Laravel 5.5 and above.

'providers' => [
    // ...
    // List of Service Providers...
    // ...
    andcarpi\Popper\PopperServiceProvider::class,
],

'aliases' => [
    // ...
    // List of Facades Aliases...
    // ...
    'Popper' => andcarpi\Popper\Facades\Popper::class,
],


Usage

To use Popper in your view, you need to inject the assets needed! Use @include('popper::assets') in the views you need tooltips, right before the body closing tag.

ps: If you have a Master View, add the assets on it :)

   @include('popper::assets')
</body>

Now, it's time to use it. To generate a simple tooltip, just use the Popper facade inside any html element.

<button {{ Popper::pop('Tooltip!') }}>Click Me!</button

Blade Directive

Another usage example is to use the @popper blade directive!

<span @popper(Span Tooltip!)> I'm a Span </span>

Configuration

Custom Tooltip Options

You can change the Tooltip default options publishing and editing the config file.

php artisan vendor:publish --provider="andcarpi\Popper\PopperServiceProvider" --tag=config

The file will be placed inside your config folder.

Each option is self-explanatory, and you can modify the default behavior of all the tooltips you generate.

Single Tooltip Options

Each tooltip can be customized using functions. They can also be chained!

  • Enable Arrows in the tooltip
{{ Popper::arrow()->pop('Tooltip with arrow!'); }}
{{ Popper::arrow('round')->pop('Tooltip with a rounded arrow!'); }}
  • Modify Tooltip Placement
{{ Popper::placement('bottom', 'start')->pop('Bottom Tooltip!'); //position, alignment }}
{{ Popper::position('left')->pop('Left Tooltip!'); // top, right, bottom, left }}
{{ Popper::alignment('end')->pop('Tooltip with end alignment!'); // start, center, end }}
  • Modify Tooltip distance from the element
//Use integers!
{{ Popper::distance(50)->pop('Tooltip far away!'); }}
  • Modify Tooltip size
{{ Popper::size('small')->pop('Small tooltip!'); // 'small', 'regular', 'large' }}
  • Modify Tooltip Triggers (What will make tooltip appear)
// 1st param is mouseenter, 2nd is focus, 3rd is click
{{ Popper::trigger(true, true, false)->pop('This tooltip appears onmouseover and onfocus!'); }} 
  • Modify Tooltip Show and Hide Delay
// Use integer values! 
{{ Popper::delay(500,0)->pop('500ms to appear, but vanishes instantly!');  }}
  • Modify Tooltip Theme
// 'light', 'lightborder', 'google', 'translucent', 'success', 'danger', 'warning', 'info'
// For the success, danger, warning, info, you can also use the Helpers (see next info)
// If you are using themes, enable themes at the config file! 
{{ Popper::theme('light')->pop('Light Theming!');  }}
  • Simple Success, Danger, Warning, Info Popup Helpers
{{ Popper::success('Success Message!") }}
{{ Popper::danger('Danger Message!") }}
{{ Popper::warning('Warning Message!") }}
{{ Popper::info('Info Message!") }}
  • Enable Tooltip Interactivity
{{ Popper::interactive()->pop('Select this text!');  }}
  • Options Chain!
{{ Popper::arrow()->size('large')->distance(50)->position('bottom')->pop('Arrow, Large, Far and at Bottom!'); }}

This package is powered by Pooper.js and Tippy.js

License

Laravel Popper is open-sourced software licensed under the MIT License (MIT). Please see License File for more information.

Todo

[x] Danger / Warning / Success , etc pops

[] Custom Theming

laravel-popper's People

Contributors

andcarpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

laravel-popper's Issues

Including Partials in Popper

I want to use laravel-popper to show a card with certain information. Due to the fact that my card information, which should be displayed when hovering, has many HTML tags. Is there a way to import Laravel blade files?

Something like this would be fine:

<span @popper(@include('partials.poppers.card'))>Hover Me!</span>

Repeated tooltips in <tr><td> does not show

I have a table with icons in a td.
I have wrapped an svg icon with the Popper tag.

The tooltip is only visible on the first row in the table.
The following rows does not show any tooltip.

This is in my blade file

<span {{ Popper::arrow('round')->pop($column->tooltip)  }}>
     @svg('light/exclamation-triangle', 'td-icon ')
</span>

This is the generated html

<span data-tippy="Size is missing" data-tippy-arrow="true" data-tippy-arrowtype="round">
    <svg class="svg-icon td-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M270.2 160h35.5c3.4 0 6.1 2.8 6 6.2l-7.5 196c-.1 3.2-2.8 5.8-6 5.8h-20.5c-3.2 0-5.9-2.5-6-5.8l-7.5-196c-.1-3.4 2.6-6.2 6-6.2zM288 388c-15.5 0-28 12.5-28 28s12.5 28 28 28 28-12.5 28-28-12.5-28-28-28zm281.5 52L329.6 24c-18.4-32-64.7-32-83.2 0L6.5 440c-18.4 31.9 4.6 72 41.6 72H528c36.8 0 60-40 41.5-72zM528 480H48c-12.3 0-20-13.3-13.9-24l240-416c6.1-10.6 21.6-10.7 27.7 0l240 416c6.2 10.6-1.5 24-13.8 24z"></path></svg>
</span>

Dynamic content inside a loop not working when data changes

Hello

I have a livewire page with filters and it loops items on the page.

Everything works fine but when I change filters and the items change, popper will not change the popper text even the content changes. The markup on html is correct and changes, but for somereason it displays the "old content"

Code to show popper:
<div @popper({{ $event['short_info'] }}) class="text-xs whitespace-nowrap">{{ $event['name'] }}</div>

Any ideas how to fix this?

plans to support popper 2 and tippy 6?

Config is currently based on:

        'cdn' => 'https://unpkg.com/popper.js@1',
        'cdn' => 'https://unpkg.com/tippy.js@4',

Available are:

        'cdn' => 'https://unpkg.com/@popperjs/core@2',
        'cdn' => 'https://unpkg.com/tippy.js@6',

But neither seem to work with laravel-popper.
When I enable either one or both I don't see a console error, but also no tooltip.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.