forked from zmoazeni/csscss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutline.rb
More file actions
45 lines (39 loc) · 1.31 KB
/
outline.rb
File metadata and controls
45 lines (39 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Csscss
module Parser
module Outline
extend Parser::Base
class Parser < Parslet::Parser
include Color
rule(:outline_width) { BorderWidth::Parser.new.border_width_side }
rule(:outline_style) { BorderStyle::Parser.new.border_style_side }
rule(:outline_color) { BorderColor::Parser.new.border_color_side }
rule(:outline) {
(
symbol("inherit") >> eof | (
outline_width.maybe.as(:outline_width) >>
outline_style.maybe.as(:outline_style) >>
outline_color.maybe.as(:outline_color)
)
).as(:outline)
}
root(:outline)
end
class Transformer < Parslet::Transform
extend Color::Transformer
extend Color::PlainColorValue
rule(outline: simple(:inherit)) {[]}
rule(outline: {
outline_width:simple(:width),
outline_style:simple(:style),
outline_color:simple(:color)
}) {
[].tap do |declarations|
declarations << Declaration.from_parser("outline-width", width) if width
declarations << Declaration.from_parser("outline-style", style) if style
declarations << Declaration.from_parser("outline-color", color) if color
end
}
end
end
end
end