Method: Teacup::Stylesheet#style

Defined in:
lib/teacup/stylesheet.rb

#style(*queries) ⇒ Object

Add a set of properties for a given stylename or multiple stylenames.

Examples:

Teacup::Stylesheet.new(:ipadbase) do
  style :pretty_button,
    backgroundImage: UIImage.imageNamed("big_red_shiny_button")

  style :continue_button, extends: :pretty_button,
    title: "Continue!",
    top: 50
end

Parameters:

  • Symbol,

    *stylename

  • Hash (Symbol, Object)

    , properties



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/teacup/stylesheet.rb', line 248

def style(*queries)
  if queries[-1].is_a? Hash
    properties = queries.pop
  else
    # empty style declarations are allowed, but accomplish nothing.
    return
  end

  queries.each do |stylename|

    # reset the stylesheet_cache for this stylename
    @stylesheet_cache.delete(stylename) if @stylesheet_cache

    # merge into styles[stylename] (an instance of Teacup::Style). new
    # properties "win" over existing properties.
    Teacup::merge_defaults(properties, styles[stylename], styles[stylename])
  end
end