Class: Coco::App::Elements::SystemBanner
- Includes:
- Concerns::AcceptsOptions, Concerns::WrapsComponent
- Defined in:
- app/components/coco/app/elements/system_banner/system_banner.rb
Constant Summary
Constants included from Concerns::AcceptsTagAttributes
Concerns::AcceptsTagAttributes::TAG_ATTRIBUTE_NAMES
Instance Attribute Summary collapse
-
#dismiss_for ⇒ Object
readonly
Returns the value of attribute dismiss_for.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #alpine_data ⇒ Object
- #dismiss_cookie_name ⇒ Object
- #dismissable? ⇒ Boolean
-
#initialize(id: nil, dismiss_for: nil) ⇒ SystemBanner
constructor
A new instance of SystemBanner.
- #render? ⇒ Boolean
Methods included from Concerns::AcceptsOptions
#accepted_options, #get_option_group
Methods inherited from Component
#accepts_options?, after_initialize, before_initialize, before_render, new
Methods included from Coco::AlpineHelper
Methods included from TagHelper
#prefix_attr_keys, #random_id, #style_str
Methods included from ComponentHelper
#coco_component, #resolve_component
Methods included from Coco::AppHelper
#coco_app_header, #coco_button, #coco_button_group, #coco_color_picker_button, #coco_confirm_button, #coco_dropdown_button, #coco_fields, #coco_form_for, #coco_form_with, #coco_image_picker_button, #coco_layout, #coco_layout_picker_button, #coco_link, #coco_menu_button, #coco_menu_item, #coco_notice, #coco_seamless_textarea, #coco_sidebar_nav, #coco_snackbar, #coco_system_banner, #coco_toast, #coco_toolbar
Methods included from BookHelper
#coco_editable_slide, #coco_media_slide
Methods included from BaseHelper
#coco_avatar, #coco_embed, #coco_icon, #coco_image, #coco_link_to_modal, #coco_modal, #coco_modal_data_attributes, #coco_modal_dialog, #coco_modal_frame_id, #coco_modal_lightbox, #coco_placeholder, #coco_svg, #coco_tag
Methods included from Concerns::Translatable
Methods included from Concerns::HasName
Methods included from Concerns::AcceptsTagAttributes
Constructor Details
#initialize(id: nil, dismiss_for: nil) ⇒ SystemBanner
Returns a new instance of SystemBanner.
45 46 47 48 49 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 45 def initialize(id: nil, dismiss_for: nil, **) @id = id @dismiss_for = dismiss_for set_tag_attr(:id, id) end |
Instance Attribute Details
#dismiss_for ⇒ Object (readonly)
Returns the value of attribute dismiss_for.
43 44 45 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 43 def dismiss_for @dismiss_for end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
43 44 45 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 43 def id @id end |
Instance Method Details
#alpine_data ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 63 def alpine_data dismissable? ? { cookie_name: , cookie_expiry: dismiss_for&.in_days&.to_i, cookie_value: "true" } : {} end |
#dismiss_cookie_name ⇒ Object
59 60 61 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 59 def "cb_system_banner_#{tag_attr(:id)&.underscore}_dismissed".to_sym end |
#dismissable? ⇒ Boolean
51 52 53 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 51 def dismissable? get_option_value(:dismissable) == true end |
#render? ⇒ Boolean
55 56 57 |
# File 'app/components/coco/app/elements/system_banner/system_banner.rb', line 55 def render? helpers.[] != "true" end |