Sha256: 725a010e2ece776f7ad8d7969791faf6acf639f4fb187c412651fa37db4465d3
Contents?: true
Size: 1.88 KB
Versions: 8
Compression:
Stored size: 1.88 KB
Contents
require_relative 'mixins/event' require_relative 'mixins/tooltips' module Voom module Presenters module DSL module Components class Menu < Base attr_accessor :items, :title, :position, :color, :open def initialize(title=nil, **attribs_, &block) super(type: :menu, **attribs_, &block) @title = title @items = [] @position = attribs.delete(:position) || :left @color = attribs.delete(:color) @open = attributes.delete(:open){false} expand! end def item(first_text = nil, text: nil, **attribs, &block) the_text = first_text || text @items << Item.new(parent: self, text: the_text, context: context, **attribs, &block) end def divider(**attribs, &block) @items << Divider.new(parent: self, context: context, **attribs, &block) end private class Item < EventBase include Mixins::Tooltips attr_accessor :text, :disabled def initialize(**attribs_, &block) super(type: :item, **attribs_, &block) @text = attribs.delete(:text) @disabled = attribs.delete(:disabled) expand! end def icon(icon=nil, **attribs, &block) return @icon if locked? @icon = Icon.new(parent: self, icon: icon, context: context, **attribs, &block) end end class Divider < Base def initialize(**attribs, &block) super(type: :divider, **attribs, &block) end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems