Class: NfgUi::Components::Elements::Avatar
- Inherits:
-
Base
- Object
- Bootstrap::Components::Base
- Base
- NfgUi::Components::Elements::Avatar
- Includes:
- Bootstrap::Utilities::Sizable, Bootstrap::Utilities::Tooltipable, Bootstrap::Utilities::Wrappable, Traits::Size
- Defined in:
- lib/nfg_ui/components/elements/avatar.rb
Overview
Activity doc coming soon
Constant Summary
Constants included from Traits::Size
Constants included from Traits
Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES
Instance Attribute Summary
Attributes included from Bootstrap::Utilities::Wrappable
Attributes included from Bootstrap::Utilities::Disableable
Attributes inherited from Bootstrap::Components::Base
#body, #options, #view_context
Instance Method Summary collapse
- #alt ⇒ Object
- #image ⇒ Object
- #render ⇒ Object
-
#size ⇒ Object
Set the default size if no size is set.
Methods included from Traits::Size
#lg_trait, #md_trait, #sm_trait, #xl_trait
Methods included from Bootstrap::Utilities::Wrappable
Methods included from Bootstrap::Utilities::Tooltipable
#data, #disabled_component_tooltip_wrapper_html_options, #html_options, #tooltip
Methods included from Bootstrap::Utilities::Disableable
Methods included from Utilities::Traitable
Methods included from Utilities::Renderable
Methods included from Utilities::Describable
Methods inherited from Bootstrap::Components::Base
#component_family, #data, #href, #html_options, #id, #initialize, #style
Constructor Details
This class inherits a constructor from NfgUi::Bootstrap::Components::Base
Instance Method Details
#alt ⇒ Object
13 14 15 |
# File 'lib/nfg_ui/components/elements/avatar.rb', line 13 def alt .fetch(:alt, nil) end |
#image ⇒ Object
17 18 19 |
# File 'lib/nfg_ui/components/elements/avatar.rb', line 17 def image .fetch(:image, nil) end |
#render ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/nfg_ui/components/elements/avatar.rb', line 21 def render content_tag(as, ) do if image.present? image_tag view_context.image_path(image), alt: alt.presence elsif body.present? content_tag(:span, (block_given? ? yield : body), class: body_css_class) end end end |
#size ⇒ Object
Set the default size if no size is set. Avatars, unlike other components, always have a size provided to them. This also rejects nil from fetching as a fallback
35 36 37 |
# File 'lib/nfg_ui/components/elements/avatar.rb', line 35 def size [:size] || default_size end |