Class: Irelia::Component
- Inherits:
-
ViewComponentContrib::Base
- Object
- ViewComponentContrib::Base
- Irelia::Component
show all
- Extended by:
- Dry::Initializer
- Defined in:
- app/components/irelia/component.rb
Direct Known Subclasses
AppShell::Component, Avatar::Component, Breadcrumbs::Component, Button::Component, Irelia::Card::Component, Irelia::Container::Component, Div::Component, Divider::Component, Dropdown::Component, Dropdown::Component::CustomDropdownTrigger, EmptyCollection::Component, Flex::Component, Form::Base::Component, Html::Component, Icon::Component, Modal::Component, Navbar::Brand::Component, Navbar::Component, Navbar::Navigation::Link::Component, Navbar::Section::Component, Navbar::Separator::Component, Navigation::Component, Notification::Component, PageHeader::Component, Sidebar::Brand::Component, Sidebar::Component, Sidebar::Navigation::Link::Component, Sidebar::Section::Component, SplitScreen::Component, Stack::Component, Table::Component, Table::Component::ColumnComponent, Table::Row::Component, Table::Row::Component::CellComponent
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**options) ⇒ Component
Returns a new instance of Component.
8
9
10
11
12
13
14
|
# File 'app/components/irelia/component.rb', line 8
def initialize(**options)
super
@component_classes = +""
add_css_classes(variants)
self.class.run_after_initialize_hooks(self)
end
|
Class Method Details
.after_initialize(method_name = nil, &block) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/components/irelia/component.rb', line 29
def after_initialize(method_name = nil, &block)
@after_initialize_hooks ||= []
if method_name
@after_initialize_hooks << method_name
elsif block_given?
@after_initialize_hooks << block
end
end
|
.inherited(subclass) ⇒ Object
49
50
51
52
|
# File 'app/components/irelia/component.rb', line 49
def inherited(subclass)
super
subclass.instance_variable_set(:@after_initialize_hooks, @after_initialize_hooks.dup)
end
|
.run_after_initialize_hooks(instance) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'app/components/irelia/component.rb', line 38
def run_after_initialize_hooks(instance)
return unless @after_initialize_hooks
@after_initialize_hooks.each do |hook|
if hook.is_a?(Symbol)
instance.send(hook)
elsif hook.is_a?(Proc)
instance.instance_eval(&hook)
end
end
end
|
Instance Method Details
#add_css_classes(css_class) ⇒ Object
21
22
23
|
# File 'app/components/irelia/component.rb', line 21
def add_css_classes(css_class)
@component_classes += " #{css_class}"
end
|
#html_options ⇒ Object
16
17
18
19
|
# File 'app/components/irelia/component.rb', line 16
def html_options
@html_options.merge({ class: "#{@component_classes} #{@html_options[:class]}".strip })
end
|
#variants ⇒ Object
25
26
|
# File 'app/components/irelia/component.rb', line 25
def variants
end
|