CSS::Object::Builder - CSS Object Oriented Builder
use CSS::Object; my $css = CSS::Object->new( debug => 3 ) || die( CSS::Object->error ); my $b = $css->builder; $b->select( ['#main_section > .article', 'section .article'] ) ->display( 'none' ) ->font_size( '+0.2rem' ) ->comment( ['Some multiline comment', 'that are made possible with array reference'] ) ->text_align( 'center' ) ->comment( 'Making it look pretty' ) ->padding( 5 ); $b->charset( 'UTF-8' ); $b->at( _webkit_keyframes => 'error' ) ->frame( 0, { _webkit_transform => 'translateX( 0px )' }) ->frame( 25, { _webkit_transform => 'translateX( 30px )' }) ->frame( 45, { _webkit_transform => 'translateX( -30px )' }) ->frame( 65, { _webkit_transform => 'translateX( 30px )' }) ->frame( 82, { _webkit_transform => 'translateX( -30px )' }) ->frame( 94, { _webkit_transform => 'translateX( 30px )' }) ->frame( [qw( 35 55 75 87 97 100 )], { _webkit_transform => 'translateX( 0px )' } );
v0.1.1
CSS::Object::Builder is a dynamic object oriented CSS builder
To instantiate a new CSS::Object::Builder object you need to pass it a CSS::Object object and that's it.
Optional argument are:
This is an integer. The bigger it is and the more verbose is the output.
This is a shorthand for calling "as_string" in CSS::Object using our "css" method.
This takes an at-mark type parameter as first argument, and the name of the at-mark rule. It returns an object from the proper class. For example, a @keyframes rule would return a CSS::Object::Rule::Keyframes.
@keyframes
This takes an encoding as unique argument, and no matter when it is called in the chain of method calls, this will always be placed at the top of the stylesheet.
Provided with a string or an array reference of comment lines, and this will return an CSS::Object::Comment object.
This sets or gets the required CSS::Object for this parser. The parser uses this method and the underlying object to access CSS::Object methods and store css rules using "add_element" in CSS::Object
Returns the last added rule from CSS::Object list of rules by calling "last" in Module::Generic::Array on "elements" in CSS::Object which returns a Module::Generic::Array object.
Sets or gets the list of css elements. This is a Module::Generic::Array, but is not used. I should remove it.
This creates and returns a new CSS::Object::Builder::AtRule object. This should be moved under CSS::Object
This creates and returns a new CSS::Object::Builder::KeyframesRule- object. This should be moved under CSS::Object
This creates and returns a new CSS::Object::Builder::Rule object. CSS::Object::Builder::Rule class allos for dynamic method call to create and add css properties inside a css rule.
This takes either a css selector as a string or an array reference of css selectors. It then returns a CSS::Object::Builder::Rule, which is a special class with dynamic method using AUTOLOAD. This makes it possible to call the hundred of css property as method.
Since those css properties are called as perl method, dashes have to be expressed as underline, such as:
$b->select( '.my-class' )->_moz_transition( 'all .25s ease' );
This would be interpreted as:
.my-class { -moz-transition: all .25s ease; }
Jacques Deguest <jack@deguest.jp>
CSS::Object
Copyright (c) 2020 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
To install CSS::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CSS::Object
CPAN shell
perl -MCPAN -e shell install CSS::Object
For more information on module installation, please visit the detailed CPAN module installation guide.