CSS-Prepare

 view release on metacpan or  search on metacpan

lib/CSS/Prepare/Plugin/BorderRadius.pm  view on Meta::CPAN

package CSS::Prepare::Plugin::BorderRadius;

use Modern::Perl;
use CSS::Prepare::Property::Expansions;
use CSS::Prepare::Property::Values;

my $get_border_radius_value = qr{ 
        (?'h1' $individual_border_radius_value )
        (?: \s+ (?'h2' $individual_border_radius_value ) )?
        (?: \s+ (?'h3' $individual_border_radius_value ) )?
        (?: \s+ (?'h4' $individual_border_radius_value ) )?
        (?:
            \s* / \s*
            (?'v1' $individual_border_radius_value )
            (?: \s+ (?'v2' $individual_border_radius_value ) )?
            (?: \s+ (?'v3' $individual_border_radius_value ) )?
            (?: \s+ (?'v4' $individual_border_radius_value ) )?
        )?
    }x;



sub expand {
    my $self     = shift;
    my $property = shift;
    my $value    = shift;
    
    # individual directions
    foreach my $corner ( @standard_corners ) {
        if ( "-cp-border-${corner}-radius" eq $property ) {
            return expand_vendor_properties( $corner, $value );
        }
    }
    if ( '-cp-border-radius' eq $property ) {
        if ( $value =~ m{^ $get_border_radius_value $}x ) {
            my %match = %+;
            
            my @matches;
            map { push @matches, $match{$_} if defined $match{$_} }
                qw( h1 h2 h3 h4 );
            my @horizontal = expand_corner_values( @matches );
            
            undef @matches;
            map { push @matches, $match{$_} if defined $match{$_} }
                qw( v1 v2 v3 v4 );
            my @vertical = expand_corner_values( @matches );
            
            my @return;
            foreach my $corner ( @standard_corners ) {
                my $value = shift( @horizontal )
                            . ( defined $vertical[0]
                                    ? ' ' . shift( @vertical )
                                    : ''
                              );
                
                my $values = expand_vendor_properties( $corner, $value );
                push @return, @$values;
            }
            
            return \@return;
        }
    }
    

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.451 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )