Class: Fluxbit::HeadingComponent
- Includes:
- Config::HeadingComponent
- Defined in:
- app/components/fluxbit/heading_component.rb
Overview
The ‘Fluxbit::HeadingComponent` is a customizable heading component that extends Component. It provides a straightforward way to generate heading elements (`<h1>` through `<h6>`) with configurable sizes, letter spacing, and line heights. Additional HTML attributes can be passed to further control the component’s behavior and styling.
Example usage:
= render Fluxbit::HeadingComponent.new(size: 2, spacing: :wider, line_height: :relaxed) do
"My Heading"
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(size: nil, spacing: nil, line_height: nil, **props) ⇒ Fluxbit::HeadingComponent
constructor
Initializes the heading component with the provided options.
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #options, #random_id, #remove_class, #render_popover_or_tooltip, #target
Constructor Details
#initialize(size: nil, spacing: nil, line_height: nil, **props) ⇒ Fluxbit::HeadingComponent
Initializes the heading component with the provided options.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/fluxbit/heading_component.rb', line 30 def initialize(size: nil, spacing: nil, line_height: nil, **props) super @props = props @base_component = "h#{size || @@size}".to_sym add to: @props, class: [ styles[:base], styles[:sizes][@base_component], styles[:spacings][spacing || @@spacing], styles[:line_heights][line_height || @@line_height] ] @props[:class] = remove_class(@props.delete(:remove_class) || "", @props[:class]) end |
Instance Method Details
#call ⇒ Object
44 45 46 |
# File 'app/components/fluxbit/heading_component.rb', line 44 def call content_tag @base_component, content, **@props end |