Class: Coco::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Coco::Component
- Includes:
- AlpineHelper, ComponentHelper, Coco::Concerns::AcceptsTagAttributes, Coco::Concerns::HasName, Coco::Concerns::Translatable
- Defined in:
- app/components/coco/component.rb
Direct Known Subclasses
App::Blocks::Banner, App::Blocks::NavBar, App::Blocks::NavDrawer, App::Blocks::Slat, App::Blocks::SlideEditor, App::Elements::Alert, App::Elements::ButtonGroup, App::Elements::ColorPicker, App::Elements::ColorPickerButton, App::Elements::ConfirmPanel, App::Elements::FormButton, App::Elements::ImagePicker, App::Elements::ImagePickerButton, App::Elements::LayoutPickerButton, App::Elements::Menu, App::Elements::MenuButton, App::Elements::Notice, App::Elements::SeamlessTextarea, App::Elements::Snackbar, App::Elements::SystemBanner, App::Elements::Toast, App::Elements::Toolbar, App::Layouts::Application, Book::Blocks::Slides::EditableSlide, Book::Blocks::Slides::MediaSlide, Button, Dropdown, Embeds::Youtube, Icon, Image, ImageUploader, Link, Placeholder, Svg
Constant Summary
Constants included from Coco::Concerns::AcceptsTagAttributes
Coco::Concerns::AcceptsTagAttributes::TAG_ATTRIBUTE_NAMES
Class Method Summary collapse
- .after_initialize(method_name = nil, &callback) ⇒ Object
- .before_initialize(method_name = nil, &callback) ⇒ Object
- .before_render(method_name = nil, &callback) ⇒ Object
- .new(**kwargs) ⇒ Object
Instance Method Summary collapse
Methods included from AlpineHelper
Methods included from TagHelper
#prefix_attr_keys, #random_id, #style_str
Methods included from ComponentHelper
#coco_component, #resolve_component
Methods included from AppHelper
#coco_button, #coco_button_group, #coco_color_picker_button, #coco_confirm_button, #coco_dropdown_button, #coco_fields, #coco_form_button, #coco_form_for, #coco_form_with, #coco_image_picker_button, #coco_layout_picker_button, #coco_link, #coco_menu_button, #coco_notice, #coco_seamless_textarea, #coco_snackbar, #coco_system_banner, #coco_toast, #coco_toolbar
Methods included from BookHelper
#coco_editable_slide, #coco_media_slide
Methods included from BaseHelper
#coco_embed, #coco_icon, #coco_image, #coco_placeholder, #coco_svg, #coco_tag
Methods included from Coco::Concerns::Translatable
Methods included from Coco::Concerns::HasName
Methods included from Coco::Concerns::AcceptsTagAttributes
Class Method Details
.after_initialize(method_name = nil, &callback) ⇒ Object
84 85 86 |
# File 'app/components/coco/component.rb', line 84 def after_initialize(method_name = nil, &callback) callbacks[:after_initialize].push(method_name || callback) end |
.before_initialize(method_name = nil, &callback) ⇒ Object
88 89 90 |
# File 'app/components/coco/component.rb', line 88 def before_initialize(method_name = nil, &callback) callbacks[:before_initialize].push(method_name || callback) end |
.before_render(method_name = nil, &callback) ⇒ Object
80 81 82 |
# File 'app/components/coco/component.rb', line 80 def before_render(method_name = nil, &callback) callbacks[:before_render].push(method_name || callback) end |
.new(**kwargs) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/components/coco/component.rb', line 62 def new(**kwargs) # If a `before_initialize` callback returns a hash then # that is used as the new kwargs value which will eventually # be used to initialize the component. kwargs = run_callbacks(:before_initialize, kwargs, reduce: true) obj = super(**kwargs) if obj.instance_of?(Coco::Component) raise "`Coco::Component` must be subclassed before use" end obj.instance_variable_set(:@_args, kwargs) obj.send(:process_tag_attrs, kwargs) obj.send(:merge_option_values, kwargs) if obj. obj.class.send(:run_callbacks, :after_initialize, {}, context: obj) && obj end |
Instance Method Details
#accepts_options? ⇒ Boolean
9 10 11 |
# File 'app/components/coco/component.rb', line 9 def self.class.respond_to?(:accepts_option) end |