Class: Fluxbit::GravatarComponent
- Inherits:
-
AvatarComponent
- Object
- ViewComponent::Base
- Component
- AvatarComponent
- Fluxbit::GravatarComponent
- Includes:
- Config::AvatarComponent, Config::GravatarComponent
- Defined in:
- app/components/fluxbit/gravatar_component.rb
Overview
The ‘Fluxbit::GravatarComponent` is a component for rendering Gravatar avatars. It extends `Fluxbit::AvatarComponent` and provides options for configuring the Gravatar’s appearance and behavior. You can control the Gravatar’s rating, size, filetype, and other attributes.
The URL generation logic lives in ‘Fluxbit::Gravatar` and can be used standalone:
Fluxbit::Gravatar.url(email: "user@example.com")
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ GravatarComponent
constructor
Initializes the Gravatar component with the given properties.
Methods inherited from AvatarComponent
#avatar_itself, #declare_classes, #declare_color, #dot_indicator, #placeholder_icon, #placeholder_size
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?
Methods included from IconHelpers
#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon
Constructor Details
#initialize(**props) ⇒ GravatarComponent
Initializes the Gravatar component with the given properties.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/components/fluxbit/gravatar_component.rb', line 30 def initialize(**props) @props = props @email = @props.delete(:email) @url_only = @props.delete(:url_only) @gravatar_url_options = { rating: @props.delete(:rating), secure: @props.delete(:secure), filetype: @props.delete(:filetype), default: @props.delete(:default), size: @props[:size], name: @props.delete(:name), initials: @props.delete(:initials) }.compact add class: gravatar_styles[:base], to: @props src = Fluxbit::Gravatar.url(email: @email, **@gravatar_url_options) super(src: src, **@props) end |