2017 © Pedro Peláez
 

symfony-bundle ui-bundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

image

grizzlylab/ui-bundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  • Thursday, June 7, 2018
  • by grizzlylab
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2,645 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 25 Versions
  • 14 % Grown

The README.md

GrizzlylabUIBundle

UI Twig helpers (alert, modal,...) for Twitter Bootstrap 3 and others. Easy way to generate redundant HTML (HTML only, not JS or CSS)., (*1)

1. Installation

  • composer require 'grizzlylab/ui-bundle@dev-master'
  • in AppKernel.php: new Grizzlylab\Bundle\UIBundle\GrizzlylabUIBundle()
  • optionnal : Install Boostrap 3 if you will use the default configuration, (*2)

      <!-- include Bootstrap 3 CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
      <!-- include Boostrap 3 JS -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    

2. Configuration

Basic configuration (to use defaults)

#app/config/config.yml
grizzlylab_ui:
    alert: ~ #enable "alert" helper
    modal: ~ #enable "modal" helper
    modal_trigger: ~ #enable "modal_trigger" helper
    truncate: ~ #enabled "trigger" helper (only available as a filter, not a function)

Complete default configuration

# Default configuration for "GrizzlylabUIBundle"
grizzlylab_ui:
    alert:
        template:             'GrizzlylabUIBundle::alert.html.twig'
        translation_domain:   messages
        translation_parameters:  
            %%strong_start%%: '<strong>'
            %%strong_end%%:   '</strong>'
        translate:            true
        escape_message:       true
        escape_prefix:        false
        dismissible:          false
        dismiss_button:       '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'
        display_prefix:       true
        context:              info # One of "info"; "success"; "warning"; "danger"
        prefixes:
            info:                 '<span class="glyphicon glyphicon-info-sign"></span> '
            success:              '<span class="glyphicon glyphicon-ok"></span> '
            warning:              '<span class="glyphicon glyphicon-warning-sign"></span> '
            danger:               '<span class="glyphicon glyphicon-warning-sign"></span> '
    modal:
        template:             'GrizzlylabUIBundle::modal.html.twig'
        backdrop:             'true' # One of "true"; "false"; "static"
        keyboard:             'true' # One of "true"; "false";
        id:                   modal
        fade:                 true
        size:                 medium # One of "small"; "medium"; "large"
        escape_title:         true
        escape_body:          true
        translate_title:      true
        translate_body:       true
        title_markup:         h1
        title_translation_domain:  messages
        title_translation_parameters:
            %%strong_start%%: '<strong>'
            %%strong_end%%:   '</strong>'
        body_translation_domain:  messages
        body_translation_parameters:  
            %%strong_start%%: '<strong>'
            %%strong_end%%:   '</strong>'
        dismiss_button:       '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>'
        keep_default_footer_buttons: true
        footer_raw_prepend: ''
        footer_raw_append: ''
        footer_buttons:
            -   #there is a close button in the footer by default
                link:                false
                escape:              true
                translate:           true
                dismiss:             true
                context:             default
                label:               grizzlylab_ui.modal.close
    modal_trigger:
        template:             'GrizzlylabUIBundle::modal_trigger.html.twig'
        context:              info # One of "info"; "success"; "warning"; "danger"
        escape:               true
        translate:            true
        translation_domain:   messages
        translation_parameters:  
            %%strong_start%%: '<strong>'
            %%strong_end%%:   '</strong>'
        size:                 medium # One of "small"; "medium"; "large"
        is_link:              false
    truncate_to_tooltip: 
        template:             'GrizzlylabUIBundle::truncate.html.twig'
        length:               30
        preserve:             false
        separator:            '...'  
        tooltip_placement:    'top'  #use one of these: top, right, bottom, left  

3. Use (in Twig)

Tips:, (*3)

  • Almost each option defined in grizzlylab_ui (config.yml) can be overridden.
  • For all available options, please check UIComponentExtension.php (functions "alert", "modalTrigger" and "modal")

a) "Alert" Helper:

Examples:, (*4)

Function:, (*5)

{{ alert('Your form is not valid', {'context': 'danger'} }) }}
{{ alert('Your form is not valid', {'context': 'danger', 'display_prefix': false} }) }}
{{ alert('Your form is not valid', {'context': 'danger', 'prefix': '<span class="glyphicon glyphicon-info-sign"></span> '} }) }}
#You can even override default attributes:
{{ alert('Your form is not valid', {'attr': {'id': 'my-id', class': 'my-class'} }) }}

Filter:, (*6)

{{ 'your form is not valid'|alert }}

b) "Modal" and "Modal Trigger" helpers:

Examples:, (*7)

Function:, (*8)

#trigger
{{ modal_trigger('my trigger label') }}
#modal
{{ modal('my modal body', {'title': my modal title'}) }}

Filter:, (*9)

#trigger
{{ 'my trigger label'|modal_trigger }}
#modal
{{ 'my modal body'|modal({'title': my modal title'}) }}

c) "truncate_to_tooltip" filter

This filter depends on the "truncate" filter from the Twig "Text" extension (http://twig.sensiolabs.org/doc/extensions/text.html) For performance reasons, you must enable Bootstrap tooltips (http://getbootstrap.com/javascript/#tooltips) Then, you can simply use the filter like this:, (*10)

#will truncate the text and show the entire text in a tooltip (when mouse is over the truncated text)
{{ 'my very long text'|truncate_to_tooltip }}
{{ 'my very long text'|truncate_to_tooltip(length, options) }}

If you use Bootstrap 3 (default), compliant HTML will be generated (alert,modal)., (*11)

License

This bundle is under the MIT license., (*12)

The Versions

07/06 2018

dev-master

9999999-dev https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2018

1.3.1

1.3.1.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2018

1.3

1.3.0.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2018

1.2.7

1.2.7.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2018

1.2.6

1.2.6.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

09/10 2017

1.2.5

1.2.5.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

27/09 2017

1.2.4

1.2.4.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

27/09 2017

1.2.3

1.2.3.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

21/09 2017

1.2.2

1.2.2.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

21/09 2017

1.2.1

1.2.1.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

20/09 2017

1.2.0

1.2.0.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

24/01 2017

1.1.1

1.1.1.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/12 2016

1.1.0

1.1.0.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

09/04 2016

1.0.5

1.0.5.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

18/02 2016

1.0.4.6

1.0.4.6 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2016

1.0.4.5

1.0.4.5 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2016

1.0.4.4

1.0.4.4 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2016

1.0.4.3

1.0.4.3 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2016

1.0.4.2

1.0.4.2 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2016

1.0.4.1

1.0.4.1 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

06/02 2016

1.0.4

1.0.4.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

04/02 2016

1.0.3

1.0.3.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

05/12 2015

1.0.2

1.0.2.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

05/12 2015

1.0.1

1.0.1.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface

19/11 2015

1.0.0

1.0.0.0 https://github.com/grizzlylab/UIBundle

UI Twig helpers (alert, modal) for Twitter Bootstrap and Co

  Sources   Download

MIT

The Requires

 

by Jean-Louis Pirson

bootstrap ui user interface