The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mo::utils::CSS - Mo CSS utilities.

SYNOPSIS

 use Mo::utils::CSS qw(check_css_color check_css_unit);

 check_css_color($self, $key);
 check_css_unit($self, $key);

DESCRIPTION

Mo utilities for checking of CSS style things.

SUBROUTINES

check_css_color

 check_css_color($self, $key);

Check parameter defined by $key if it's CSS color. Value could be undefined.

Returns undef.

check_css_unit

 check_css_unit($self, $key);

Check parameter defined by $key if it's CSS unit. Value could be undefined.

Returns undef.

ERRORS

 check_css_color():
         Parameter '%s' has bad color name.
                 Value: %s
         Parameter '%s' has bad rgb color (bad hex number).
                 Value: %s
         Parameter '%s' has bad rgb color (bad length).
                 Value: %s

 check_css_unit():
         Parameter '%s' doesn't contain number.
         Parameter '%s' doesn't contain unit.
         Parameter '%s' contain bad unit.
                 Value: %s

EXAMPLE1

 use strict;
 use warnings;

 use Mo::utils::CSS qw(check_css_color);

 my $self = {
         'key' => '#F00',
 };
 check_css_color($self, 'key');

 # Print out.
 print "ok\n";

 # Output:
 # ok

EXAMPLE2

 use strict;
 use warnings;

 use Error::Pure;
 use Mo::utils::CSS qw(check_css_color);

 $Error::Pure::TYPE = 'Error';

 my $self = {
         'key' => 'xxx',
 };
 check_css_color($self, 'key');

 # Print out.
 print "ok\n";

 # Output like:
 # #Error [...utils.pm:?] Parameter 'key' has bad color name.

EXAMPLE3

 use strict;
 use warnings;

 use Mo::utils::CSS qw(check_css_unit);

 my $self = {
         'key' => '123px',
 };
 check_css_unit($self, 'key');

 # Print out.
 print "ok\n";

 # Output:
 # ok

EXAMPLE4

 use strict;
 use warnings;

 use Error::Pure;
 use Mo::utils::CSS qw(check_css_unit);

 $Error::Pure::TYPE = 'Error';

 my $self = {
         'key' => '12',
 };
 check_css_unit($self, 'key');

 # Print out.
 print "ok\n";

 # Output like:
 # #Error [...utils.pm:?] Parameter 'key' doesn't contain unit.

DEPENDENCIES

Error::Pure, Exporter, Graphics::ColorNames::CSS, List::Util, Readonly.

SEE ALSO

Mo

Micro Objects. Mo is less.

Mo::utils

Mo utilities.

Mo::utils::Language

Mo language utilities.

Wikibase::Datatype::Utils

Wikibase datatype utilities.

REPOSITORY

https://github.com/michal-josef-spacek/Mo-utils-CSS

AUTHOR

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

http://skim.cz

LICENSE AND COPYRIGHT

© 2023-2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.01