Sha256: f36d950ce263ff04e1ee70e41298f7329eaa612162b46d4153447bea6b663ae4

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

module Csscss
  module Parser
    module Border
      extend Parser::Base

      class Parser < Parslet::Parser
        include Color

        rule(:border_side) { BorderSide::Parser.new(:top).border_side_anonymous }

        rule(:border) {
          (
           symbol("inherit") >> eof |
           border_side.maybe.as(:side)
          ).as(:border)
        }

        root(:border)
      end

      class Transformer < Parslet::Transform
        extend Color::Transformer
        extend Color::PlainColorValue
        extend BorderSide::Transformer::Helpers

        rule(border: simple(:inherit)) {[]}
        rule(border: {
          side: {
            width:simple(:width),
            style:simple(:style),
            color:simple(:color)
          }
        }) {|context|
          [].tap do |declarations|
            [:top, :right, :bottom, :left].each do |side|
              declarations << transform_side(side, context)
            end

            declarations.flatten!
          end
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
csscss-1.3.3 lib/csscss/parser/border.rb
csscss-1.3.2 lib/csscss/parser/border.rb
csscss-1.3.1 lib/csscss/parser/border.rb
csscss-1.3.0 lib/csscss/parser/border.rb
csscss-1.2.0 lib/csscss/parser/border.rb
csscss-1.1.0 lib/csscss/parser/border.rb
csscss-1.0.0 lib/csscss/parser/border.rb
csscss-0.2.1 lib/csscss/parser/border.rb
csscss-0.2.0 lib/csscss/parser/border.rb
csscss-0.1.0 lib/csscss/parser/border.rb