NAME

Mojolicious::Plugin::MoreHTMLHelpers - Some general helpers

VERSION

version 0.02

SYNOPSIS

In your startup:

  sub startup {
      my $self = shift;

      # do some Mojolicious stuff
      $self->plugin( 'MoreHTMLHelpers' );

      # more Mojolicious stuff
  }

In your template:

<span style="color: <% textcolor('#135713') %>">Any text</span>

HELPERS

This plugin adds a helper method to your web application:

textcolor

This method requires at least one parameter: The color the text color is based on. The text color should have a contrast to the background color. In web apps where the user can define its own color set, it's necessary to calculate the textcolor on the fly. This is what this helper is for.

<span style="background-color: #135713; color: <% textcolor('#135713') %>">Any text</span>

gradient

This creates the CSS directives for a gradient

<style>
    .black-gradient { <%= gradient('#000000') %> }
</style>

will be

<style>
    .black-gradient {
        background: #000000 !important;
        background: -moz-linear-gradient(top,  #000000 0%,#000000 100%) !important;
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%,#000000)) !important;
        background: -webkit-linear-gradient(top,  #000000 0%,#000000 100%) !important;
        background: -o-linear-gradient(top,  #000000 0%,#000000 100%) !important;
        background: -ms-linear-gradient(top,  #000000 0%,#000000 100%) !important;
        background: linear-gradient(to bottom,#000000 0%,#000000 100%) !important;
}
</style>

METHODS

register

Called when registering the plugin. On creation, the plugin accepts a hashref to configure the plugin.

# load plugin, alerts are dismissable by default
$self->plugin( 'MoreHTMLHelpers' );

AUTHOR

Renee Baecker <reneeb@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)