Class: BulmaPhlex::Title
- Inherits:
-
Base
- Object
- Base
- BulmaPhlex::Title
- Defined in:
- lib/bulma_phlex/title.rb
Overview
Renders a Bulma title element with an optional subtitle.
Supports size (1–6) for both the title and subtitle, an optional subtitle string, and a spaced layout option to increase the gap between the title and subtitle.
Example
render BulmaPhlex::Title.new("Hello World")
render BulmaPhlex::Title.new("Dr. Strangelove", size: 2, subtitle: "Or: How I Learned to Stop Worrying and
Love the Bomb")
Class Method Summary collapse
-
.new(text, size: nil, subtitle: nil, subtitle_size: nil, spaced: false) ⇒ Object
Parameters -
text— The main title text to display -size— An integer from 1 to 6 indicating the title size; corresponds to Bulma'sis-<size>classes -subtitle— The subtitle text to display below the main title -subtitle_size— An integer from 1 to 6 indicating the subtitle size; defaults tosize + 2ifsizeis set -spaced— Iftrue, adds theis-spacedclass to the title.
Instance Method Summary collapse
-
#initialize(text, size: nil, subtitle: nil, subtitle_size: nil, spaced: false) ⇒ Title
constructor
A new instance of Title.
- #view_template ⇒ Object
Constructor Details
#initialize(text, size: nil, subtitle: nil, subtitle_size: nil, spaced: false) ⇒ Title
Returns a new instance of Title.
25 26 27 28 29 30 31 |
# File 'lib/bulma_phlex/title.rb', line 25 def initialize(text, size: nil, subtitle: nil, subtitle_size: nil, spaced: false) @text = text @size = size @subtitle = subtitle @subtitle_size = subtitle_size @spaced = spaced end |
Class Method Details
.new(text, size: nil, subtitle: nil, subtitle_size: nil, spaced: false) ⇒ Object
Parameters
text— The main title text to displaysize— An integer from 1 to 6 indicating the title size; corresponds to Bulma'sis-<size>classessubtitle— The subtitle text to display below the main titlesubtitle_size— An integer from 1 to 6 indicating the subtitle size; defaults tosize + 2ifsizeis setspaced— Iftrue, adds theis-spacedclass to the title
21 22 23 |
# File 'lib/bulma_phlex/title.rb', line 21 def self.new(text, size: nil, subtitle: nil, subtitle_size: nil, spaced: false) super end |
Instance Method Details
#view_template ⇒ Object
33 34 35 36 |
# File 'lib/bulma_phlex/title.rb', line 33 def view_template h1(class: title_classes) { @text } h2(class: subtitle_classes) { @subtitle } if @subtitle end |