Class: Coco::Component
Direct Known Subclasses
Alert, Avatar, Badge, Button, ButtonGroup, ButtonTo, ColorPicker, ColorPickerButton, ConfirmPanel, Dropdown, Icon, Image, ImagePicker, ImagePickerButton, ImageUploader, LayoutPickerButton, Link, Menu, MenuButton, MenuItems::UserProfile, Modal, ModalCanvas, ModalDialog, ModalLightbox, Notice, OptionBar, Page, PagerButton, Panel, Placeholder, PollController, Popover, Prose, SeamlessTextarea, Snackbar, Spacer, Stack, Stamp, Svg, SystemBanner, Tabs, Toast, Toolbar, Tooltip, YoutubeEmbed
Constant Summary
Coco::Concerns::AcceptsTagAttributes::TAG_ATTRIBUTE_NAMES
Class Method Summary
collapse
Instance Method Summary
collapse
#x_attrs, #x_data
Methods included from TagHelper
#prefix_attr_keys, #random_id, #style_str
#coco_avatar, #coco_badge, #coco_button, #coco_button_group, #coco_button_to, #coco_color_picker_button, #coco_component, #coco_confirm_button, #coco_dropdown, #coco_embed, #coco_fields, #coco_form_for, #coco_form_with, #coco_icon, #coco_image, #coco_image_picker_button, #coco_layout_picker_button, #coco_link, #coco_link_to, #coco_menu, #coco_menu_button, #coco_menu_item, #coco_modal, #coco_modal_canvas, #coco_modal_dialog, #coco_modal_lightbox, #coco_notice, #coco_option_bar, #coco_page, #coco_pager_button, #coco_panel, #coco_placeholder, #coco_popover, #coco_prose, #coco_seamless_textarea, #coco_snackbar, #coco_spacer, #coco_stack, #coco_stamp, #coco_svg, #coco_system_banner, #coco_tabs, #coco_tag, #coco_toast, #coco_toolbar, #coco_tooltip, #resolve_component
#tt
#component_name
#tag_attrs
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)
kwargs = run_callbacks(:before_initialize, kwargs, reduce: true)
obj = super
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.accepts_options?
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 accepts_options?
self.class.respond_to?(:accepts_option)
end
|