lib/slide_hero/slide.rb in slide_hero-0.0.4 vs lib/slide_hero/slide.rb in slide_hero-0.0.5

- old
+ new

@@ -1,12 +1,14 @@ module SlideHero class Slide - attr_reader :headline, :headline_size, :transition - def initialize(headline, headline_size: :large, transition: :default, &point_block) + attr_reader :headline, :headline_size, :transition, :background_color + def initialize(headline=nil, headline_size: :medium, transition: :default, background_color: nil, &point_block) @headline = headline @headline_size = headline_size @transition = transition + + @background_color = background_color instance_eval(&point_block) if block_given? end def compile Tilt::ERBTemplate.new(File.join(SlideHero.template_path, @@ -50,9 +52,13 @@ small: :h3 }[headline_size] end def data_attributes - "data-transition=\"#{transition}\"" + "data-transition=\"#{transition}\"".tap do |attr| + if background_color + attr << " data-background=\"#{background_color}\"" + end + end end end end