Tags-HTML-Pager

Tags helper for pager.


License
BSD-3-Clause

Documentation

NAME
    Tags::HTML::Pager - Tags helper for pager.

SYNOPSIS
     use Tags::HTML::Pager;

     my $obj = Tags::HTML::Pager->new(%params);
     $obj->process($pager_hr);
     $obj->process_css;

METHODS
  "new"
     my $obj = Tags::HTML::Pager->new(%params);

    Constructor.

    *       "css"

            'CSS::Struct::Output' object for process_css processing.

            Default value is undef.

    *       "css_colors"

            Colors for CSS style.

            Default value is: { 'actual_background' => 'black',
            'actual_color' => 'white', 'border' => 'black',
            'hover_background' => 'black', 'hover_color' => 'white',
            'other_background' => undef, 'other_color' => 'black', }

    *       "css_pager"

            Main CSS class of this block.

            It's required.

            Default value is 'pager'.

    *       "flag_prev_next"

            Flag, which mean print of prev_next buttons.

            Default value is 0.

    *       "flag_paginator"

            Flag, which mean print of paginator buttons.

            Default value is 1.

    *       "url_page_cb"

            Callback for creating of url for view page.

            Input argument is page variable with number of page.

            It's required parameter.

    *       "tags"

            'Tags::Output' object.

            Default value is undef.

  "process"
     $obj->process($pager_hr);

    Process Tags structure for output with pager.

    Returns undef.

  "process_css"
     $obj->process_css;

    Process CSS::Struct structure for output.

    Returns undef.

ERRORS
     new():
             Both paginator styles disabled.
             Missing 'url_page_cb' parameter.
             Parameter 'css_pager' is required.
             From Class::Utils::set_params():
                     Unknown parameter '%s'.
             From Tags::HTML::new():
                     Parameter 'tags' must be a 'Tags::Output::*' class.

     process():
             Missing 'pages_num' parameter in pages data structure.
             Missing 'actual_page' parameter in pages data structure.
             Pages data structure is missing.
             Parameter 'actual_page' is greater than parameter 'pages_num'.
                     actual_page: %s
                     pages_num: %s
             From Tags::HTML::process():
                     Parameter 'tags' isn't defined.

EXAMPLE
     use strict;
     use warnings;

     use CSS::Struct::Output::Indent;
     use Tags::HTML::Pager;
     use Tags::Output::Indent;

     # Object.
     my $css = CSS::Struct::Output::Indent->new;
     my $tags = Tags::Output::Indent->new;
     my $obj = Tags::HTML::Pager->new(
             'css' => $css,
             'tags' => $tags,
             'url_page_cb' => sub {
                     my $page = shift;
                     return 'https://example.com/?page='.$page;
             }
     );

     # Process pager.
     $obj->process({
             'actual_page' => 1,
             'pages_num' => 1,
     });
     $obj->process_css;

     # Print out.
     print $tags->flush;
     print "\n\n";
     print $css->flush;

     # Output:
     # <div class="pager">
     #   <p class="pager-paginator">
     #     <strong class="pager-paginator-selected">
     #      1
     #     </strong>
     #   </p>
     # </div>
     #
     # .pager a {
     #         text-decoration: none;
     # }
     # .pager-paginator {
     #         display: flex;
     #         flex-wrap: wrap;
     #         justify-content: center;
     #         padding-left: 130px;
     #         padding-right: 130px;
     #         float: both;
     # }
     # .pager-prev_next {
     #         display: flex;
     # }
     # .pager-paginator a, .pager-paginator strong, .pager-paginator span, .pager-next,
     # .pager-next-disabled, .pager-prev, .pager-prev-disabled {
     #         display: flex;
     #         height: 55px;
     #         width: 55px;
     #         justify-content: center;
     #         align-items: center;
     #         border: 1px solid black;
     #         margin-left: -1px;
     # }
     # .pager-prev, .pager-next {
     #         display: inline-flex;
     #         align-items: center;
     #         justify-content: center;
     # }
     # .pager-paginator a:hover, .pager-prev_next a:hover {
     #         color: white;
     #         background-color: black;
     # }
     # .pager-paginator a {
     #         color: black;
     # }
     # .pager-paginator-selected {
     #         background-color: black;
     #         color: white;
     # }

DEPENDENCIES
    Class::Utils, Error::Pure, Readonly, Tags::HTML, Unicode::UTF8.

REPOSITORY
    <https://github.com/michal-josef-spacek/Tags-HTML-Pager>

AUTHOR
    Michal Josef Špaček <mailto:skim@cpan.org>

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2022 Michal Josef Špaček

    BSD 2-Clause License

VERSION
    0.04