Sha256: 51dccadfbc8d484a4927df142eb0224ada30040b50e927cfe650f428375d4628
Contents?: true
Size: 1.68 KB
Versions: 6
Compression:
Stored size: 1.68 KB
Contents
module Voom module Presenters module DSL module Components class Header < Base attr_accessor :title, :image, :placement VALID_PLACEMENTS = %i[static fixed].freeze def initialize(**attribs_, &block) super(type: :header, **attribs_, &block) self.title(attribs.delete(:title)) if attribs.key?(:title) @image = attribs.delete(:image) @placement = validate_placement(attribs.delete(:placement) { :static }) expand! end def button(icon=nil, **attributes, &block) return @button if locked? @button = Components::Button.new(icon: icon, parent: self, **attributes, &block) end def menu(**attribs, &block) return @menu if locked? @menu = Components::Menu.new(parent: self, **attribs, &block) end def nav(**attribs, &block) return @nav if locked? @nav = Components::Menu.new(parent: self, **attribs, &block) end def title(*text, **attribs, &block) return @title if locked? @title = Components::Typography.new(parent: self, type: :text, text: text, **attribs, &block) end private def validate_placement(value) return unless value placement = value.to_sym unless VALID_PLACEMENTS.include?(placement) raise Errors::ParameterValidation, "Invalid placement specified: #{placement}" end placement end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems