Sha256: 757bfc42ee94d7200c7604d28c41b80a3e24036b3464f37de69e8dadf4ab92df

Contents?: true

Size: 1019 Bytes

Versions: 7

Compression:

Stored size: 1019 Bytes

Contents

require 'browser/css/declaration'
require 'browser/css/style_sheet'
require 'browser/css/rule'
require 'browser/css/rule/style'

module Kernel
  # @overload CSS(document = $document, &block)
  #
  #   Create a `<style>` element from a {Paggio::CSS} DSL.
  #
  #   @param document [Browser::DOM::Document] the document instance
  #     we intend to use
  #
  #   @return [Browser::DOM::Element] the created `<style>` element
  #
  # @overload CSS(string, document = $document)
  #
  #   Create a `<style>` element from a string.
  #
  #   @param document [Browser::DOM::Document] the document instance
  #     we intend to use
  #
  #   @return [Browser::DOM::Element] the created `<style>` element
  def CSS(*args, &block)
    document = if args.length > 1 || block_given?
      args.pop
    end || $document

    style = document.create_element(:style)
    style[:type] = 'text/css'

    if block
      style.inner_text = Paggio.css(&block)
    else
      style.inner_text = args.join("")
    end

    style
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
opal-browser-0.3.5 opal/browser/css.rb
opal-browser-0.3.4 opal/browser/css.rb
atome-opal-browser-0.3.9.5 opal/browser/css.rb
opal-browser-0.3.3 opal/browser/css.rb
opal-browser-0.3.2 opal/browser/css.rb
opal-browser-0.3.1 opal/browser/css.rb
opal-browser-0.3.0 opal/browser/css.rb