File Coverage

blib/lib/Moonshine/Bootstrap/Component/PageHeader.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 20 21 95.2


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::PageHeader;
2              
3 5     5   168153 use Moonshine::Magic;
  5         158101  
  5         46  
4 5     5   3364 use Params::Validate qw/HASHREF/;
  5         15  
  5         581  
5              
6             lazy_components qw/h1 small div/;
7              
8             extends 'Moonshine::Bootstrap::Component';
9              
10             has(
11             page_header_spec => sub {
12             {
13             tag => { default => 'div' },
14             class_base => { default => 'page-header' },
15             header_tag => { default => 'h1' },
16             header => { type => HASHREF },
17             small => { type => HASHREF, optional => 1 },
18             };
19             }
20             );
21              
22             sub page_header {
23 5     5   32443 my ($self) = shift;
24              
25 5   50     78 my ( $base_args, $build_args ) = $self->validate_build(
26             {
27             params => $_[0] // {},
28             spec => $self->page_header_spec,
29             }
30             );
31              
32 5         83 my $base_element = Moonshine::Element->new($base_args);
33              
34 5         14405 my $tag = $build_args->{header_tag};
35 5         43 my $header = $base_element->add_child( $self->$tag( $build_args->{header} ) );
36              
37 5 100       13056 if ( $build_args->{small} ) {
38 3         21 $header->add_child( $self->small($build_args->{small}) );
39             }
40              
41 5         7864 return $base_element;
42             }
43              
44             1;
45              
46             __END__