Module: Klods::Components::Tooltip
- Included in:
- Builders
- Defined in:
- lib/klods/components/tooltip.rb
Instance Method Summary collapse
-
#tooltip(props, children) ⇒ Object
tooltip(props, children) — renders the static HTML structure.
Instance Method Details
#tooltip(props, children) ⇒ Object
tooltip(props, children) — renders the static HTML structure. Visibility is toggled by data-open via client JS; event wiring is omitted here.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/klods/components/tooltip.rb', line 6 def tooltip(props, children) props = props.transform_keys(&:to_s) tip = props.delete("tip") position = props.delete("position") || "above" extra_class = props.delete("class") id = _next_tooltip_id tip_node = Core.el( "span", {"id" => id, "role" => "tooltip", "class" => "klods-tooltip__tip klods-tooltip__tip--#{position}"}, tip ) cls = Core.class_names("klods-tooltip", Core.resolve_class(extra_class)) attrs = props.merge( "class" => cls.empty? ? nil : cls, "aria-describedby" => id ).compact Core.el("span", attrs, [children, tip_node]) end |