Class: Satis::ApplicationComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Satis::ApplicationComponent
- Includes:
- ActionView::Helpers::TranslationHelper, Concerns::ContextualTranslations, Turbo::FramesHelper, ViewComponent::Slotable
- Defined in:
- app/components/satis/application_component.rb
Direct Known Subclasses
Satis::AppearanceSwitcher::Component, Satis::Avatar::Component, Breadcrumbs::Component, CalendarMonth::Component, Card::Component, ColorPicker::Component, DateTimePicker::Component, Dialog::Component, Editor::Component, FlashMessages::Component, FlashMessages::Message, Info::Component, InfoItem::Component, Input::Component, InputArray::Component, Map::Component, Menu::Component, MenuItem::Component, Page::Component, ProgressBar::Component, Sidebar::Component, SidebarMenu::Component, SidebarMenuItem::Component, Switch::Component, Tab::Component, Tabs::Component
Instance Attribute Summary collapse
-
#original_view_context ⇒ Object
Returns the value of attribute original_view_context.
Class Method Summary collapse
Instance Method Summary collapse
-
#component_name ⇒ Object
def original_view_context @template end.
Instance Attribute Details
#original_view_context ⇒ Object
Returns the value of attribute original_view_context.
11 12 13 |
# File 'app/components/satis/application_component.rb', line 11 def original_view_context @original_view_context end |
Class Method Details
.add_helper(name, component) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/satis/application_component.rb', line 24 def self.add_helper(name, component) if respond_to?(name) Satis.config.logger.warn("Helper #{name} already defined, skipping.") return end define_method(name) do |*args, **kwargs, &block| original_args = args.dup = args. instance = if .key? :variant variant_component = component.to_s.sub(/::Component$/, "::#{[:variant].to_s.camelize}::Component").safe_constantize (variant_component || component).new(*original_args, **kwargs) else kwargs[component_name.to_sym] = self component.new(*original_args, **kwargs) end original_view_context.render(instance, &block) end end |
Instance Method Details
#component_name ⇒ Object
def original_view_context
@template
end
20 21 22 |
# File 'app/components/satis/application_component.rb', line 20 def component_name self.class.name.sub(/::Component$/, "").sub(/^Satis::/, "").underscore end |