Class: NitroKit::Tooltip
- Defined in:
- app/components/nitro_kit/tooltip.rb
Instance Attribute Summary collapse
-
#placement ⇒ Object
readonly
Returns the value of attribute placement.
-
#string_content ⇒ Object
readonly
Returns the value of attribute string_content.
Attributes inherited from Component
Instance Method Summary collapse
- #content(text = nil, **attrs, &block) ⇒ Object
-
#initialize(content: nil, placement: nil, **attrs) ⇒ Tooltip
constructor
A new instance of Tooltip.
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(content: nil, placement: nil, **attrs) ⇒ Tooltip
Returns a new instance of Tooltip.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/components/nitro_kit/tooltip.rb', line 5 def initialize(content: nil, placement: nil, **attrs) @string_content = content @placement = placement super( attrs, data: { action: "mouseover->nk--tooltip#open mouseout->nk--tooltip#close", controller: "nk--tooltip", nk__tooltip_placement_value: placement } ) end |
Instance Attribute Details
#placement ⇒ Object (readonly)
Returns the value of attribute placement.
19 20 21 |
# File 'app/components/nitro_kit/tooltip.rb', line 19 def placement @placement end |
#string_content ⇒ Object (readonly)
Returns the value of attribute string_content.
19 20 21 |
# File 'app/components/nitro_kit/tooltip.rb', line 19 def string_content @string_content end |
Instance Method Details
#content(text = nil, **attrs, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/nitro_kit/tooltip.rb', line 28 def content(text = nil, **attrs, &block) builder do div( **mattr( attrs, class: tooltip_class, data: { state: "closed", nk__tooltip_target: "content" } ) ) do text_or_block(text, &block) end end end |
#view_template ⇒ Object
21 22 23 24 25 26 |
# File 'app/components/nitro_kit/tooltip.rb', line 21 def view_template span(**attrs) do content(string_content) if string_content yield end end |