search spec components factored out of T365
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Image.pm
1 package Reaction::UI::Widget::Image;
2
3 use Reaction::UI::WidgetClass;
4 use namespace::clean -except => [ qw(meta) ];
5
6 before fragment widget {
7   my $vp = $_{viewport};
8   my $attrs = {
9     src => $vp->uri,
10     ($vp->has_width ? (width => $vp->width) : ()),
11     ($vp->has_height ? (height => $vp->height) : ()),
12   };
13   arg img_attrs => attrs( $attrs );
14 };
15
16 __PACKAGE__->meta->make_immutable;
17
18 1;
19
20 __END__;
21
22 =head1 NAME
23
24 Reaction::UI::Widget::Image - An image with optional height and width properties
25
26 =head1 DESCRIPTION
27
28 =head1 FRAGMENTS
29
30 =head2 widget
31
32 The widget layout will be provided with an additional C<img_attrs> argument containing
33 a rendered string of the image's attributes containing:
34
35 =over 4
36
37 =item src
38
39 The return value of the viewports C<uri> method.
40
41 =item width
42
43 The value of the viewports C<width> attribute if one was found.
44
45 =item height
46
47 The value of the viewports C<height> attribute if one was found.
48
49 =back
50
51 =head1 LAYOUT SETS
52
53   share/skin/base/layout/image.tt
54
55 =head1 AUTHORS
56
57 See L<Reaction::Class> for authors.
58
59 =head1 LICENSE
60
61 See L<Reaction::Class> for the license.
62
63 =cut