2017 © Pedro PelĂĄez
 

library bootstrap

Helper to use Bootstrap's HTML elements

image

polyfony-inc/bootstrap

Helper to use Bootstrap's HTML elements

  • Wednesday, February 21, 2018
  • by AnnoyingTechnology
  • Repository
  • 4 Watchers
  • 2 Stars
  • 62 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 82 % Grown

The README.md

Introduction

This class helps in building Bootstrap Modals, Dropdowns and Alerts. It currently support Bootstrap 5, other branches may support bootstrap5-alpha or bootstrap 4., (*1)

Alert

  • You can use from different types of bootstrap alerts (previously called Notice) to suit your needs
Bootstrap\Alert([
    'class'         =>null,
    'message'       =>null,
    'title'         =>null,
    'footer'        =>null,
    'dismissible'   =>true
])

All will be converted to HTML automatically using bootstrap 4 friendly classes., (*2)

Typical example using the "flashbag"

// set an alert depending on the presence of errors
$foobar->doSomething() ? 
    new Bootstrap\Alert([
        'class'=>'danger',
        'message'=>'Cache directory has not been emptied'
    )->save() :
    new Bootstrap\Alert([
        'class'=>'success',
        'message'=>'cache directory has been empties'
    ])->save();

// maybe you want to redirect somewhere
Response::setRedirect('/admin/');

Or using shortcuts

These will build alerts of class success or danger. With the Locale Operation succeeded or Operation failed., (*3)


use Bootstrap\Alert\{ Success as OK, Failure as KO }; // [...] // set an alert depending on the presence of errors $foobar->doSomething() ? (new OK) : (new KO); // [...] // maybe you want to redirect somewhere Response::setRedirect('/admin/');

Then in a shared view, available everywhere, (*4)

<?= Bootstrap\Alert::flash(); ?>

You can ask the Logger engine to log your alert by applying ->log() to the alert object. * Alert of class danger will map to a Polyfony/Log event of type critical * Alert of class warning will map to a Polyfony/Log event of type warning * Any other class will map to a Polyfony/Log event of type info, (*5)

 Manually getting back notice text

$alert->getMessage()
$alert->getTitle()
$alert->getFooter()
  • generate a modal element


echo (new Bootstrap\Modal) ->setTitle( ['text'=>'Hey!'], 'fa fa-car' ) ->setBody([ 'text'=>'Here is the content' ]) ->setTrigger( [ 'text'=>'Open the modal', 'class'=>'btn btn-link' ], 'fa fa-send' ) ->addOption( [ 'text'=>'To this', 'class'=>'btn btn-success' ], 'fa fa-car' ) ->addOption( [ 'text'=>'To that', 'class'=>'btn btn-warning' ], 'fa fa-car' );
  • generate a dropdown element

echo (new Bootstrap\Dropdown) ->setTrigger( [ 'text'=>'Click this nice looking modal', 'class'=>'btn btn-primary' ], 'fa fa-send' ) ->addItem([ 'text'=>'To this', //'class'=>'some-cool-class' //'html'=>'Non protected text' ]) ->addDivider() ->addHeader([ 'text'=>'Pretty Header' ]);

The Versions

21/02 2018

dev-master

9999999-dev

Helper to use Bootstrap's HTML elements

  Sources   Download

GPL-3.0

The Requires

 

by Avatar AnnoyingTechnology

php helper progress modal alert bootrap

08/02 2018

0.1.0-alpha

0.1.0.0-alpha

Helper to use Bootstrap's HTML elements

  Sources   Download

GPL-3.0

The Requires

  • php >=7.1.0
  • sib-retail/polyfony *

 

by Avatar AnnoyingTechnology

php helper progress modal alert bootrap

08/02 2018

1.0.0

1.0.0.0

Helper to use Bootstrap's HTML elements

  Sources   Download

GPL-3.0

The Requires

  • php >=7.1.0
  • sib-retail/polyfony *

 

by Avatar AnnoyingTechnology

php helper progress modal alert bootrap