File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -86,10 +86,11 @@ grammar CSS::Grammar:ver<0.3.10> {
86
86
rule end-decl { ' ;' | <?before ' }'> | $ }
87
87
88
88
rule color-range { <num>[$<percentage>=\%]? }
89
+ rule alpha-value { <num>[$<percentage>=\%]? }
89
90
90
91
proto rule color {*}
91
92
rule color:sym<rgb> {:i ' rgb ('
92
- [ <color-range> **3% ' ,' || <any-args> ]
93
+ [ <color-range> **3% ' ,' [ ' , ' <alpha-value> ]? || <any-args> ]
93
94
' )'
94
95
}
95
96
rule color:sym<hex> { <id> }
Original file line number Diff line number Diff line change @@ -192,6 +192,14 @@ class CSS::Grammar::Actions {
192
192
make $ . build . token( $ range . round , : type(CSSValue::NumberComponent));
193
193
}
194
194
195
+ method alpha-value ($/ ) {
196
+ my $ alpha = $ < num > . ast. value ;
197
+ $ alpha /= 100
198
+ if $ < percentage > ;
199
+ $ alpha = min ( max ($ alpha , 0 ), 1 );
200
+ make $ . build . token( $ alpha . round (.01 ), : type(CSSValue::NumberComponent));
201
+ }
202
+
195
203
proto method color {* }
196
204
method color :sym <rgb >($/ ) {
197
205
return $ . warning (' usage: rgb(c,c,c) where c is 0..255 or 0%-100%' )
You can’t perform that action at this time.
0 commit comments