module Coco module Concerns module WithTooltip extend ActiveSupport::Concern include AcceptsOptions included do accepts_option :tooltip, alias: "tippy", shorthand: :content do |tt| tt.accepts_option :content tt.accepts_option :disabled, from: [true, false] tt.accepts_option :placement, from: %w[top top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-end auto auto-start auto-end] end renders_one :tooltip, ->(content = nil, **kwargs, &block) do content = capture(&block) if block kwargs[:content] = content if content merge_option_values(:tooltip, kwargs) end end end end end