Class: Fluxbit::LinkComponent

Inherits:
Component
  • Object
show all
Includes:
Config::LinkComponent
Defined in:
app/components/fluxbit/link_component.rb

Overview

The ‘Fluxbit::LinkComponent` is a customizable link component that extends Component. It provides a straightforward way to generate anchor elements (`<a>`) with configurable colors and styling options. Additional HTML attributes can be passed to further control the component’s behavior and appearance.

Example usage:

= render Fluxbit::LinkComponent.new(size: 2, spacing: :wider, line_height: :relaxed) do
  "My Heading"

Constant Summary

Constants inherited from Component

Component::ComponentObj

Instance Method Summary collapse

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) ⇒ Fluxbit::LinkComponent

Initializes the link component with the provided options.

Examples:

= render Fluxbit::LinkComponent.new(color: :primary) do
  "My Heading"

Parameters:

  • color (Symbol)

    (:default) The color style for the heading. Must be one of the keys defined in styles[:colors].

  • props (Hash)

    Additional HTML attributes to be applied to the heading element, such as class, id, +data-*, etc.



29
30
31
32
33
34
35
36
37
# File 'app/components/fluxbit/link_component.rb', line 29

def initialize(**props)
  super
  @props = props
  @color = @props.delete(:color) || @@color

  add to: @props, class: [ styles[:colors][@color], styles[:base] ]
  @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class])
  @href = @props.delete(:href) || "#"
end

Instance Method Details

#callObject



39
40
41
# File 'app/components/fluxbit/link_component.rb', line 39

def call
  link_to content, @href, **@props
end