Class: Essence::Link

Inherits:
Essence
  • Object
show all
Defined in:
lib/essence/components/link.rb

Constant Summary collapse

CLASS =
"inline-flex items-center gap-1 font-medium text-gray-900 border-b-2 hover:border-gray-900 transition-colors"
KINDS =
{
  regular: "border-transparent",
  underline: "border-gray-200"
}

Constants inherited from Essence

Essence::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind: :regular, **attributes) ⇒ Link

Returns a new instance of Link.



12
13
14
15
# File 'lib/essence/components/link.rb', line 12

def initialize(kind: :regular, **attributes)
  @attributes = attributes
  @attributes[:class] = @attributes[:class] ? TAILWIND_MERGER.merge([ CLASS, @attributes[:class] ]) : CLASS
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/essence/components/link.rb', line 10

def attributes
  @attributes
end

Instance Method Details

#view_templateObject



17
18
19
# File 'lib/essence/components/link.rb', line 17

def view_template(&)
  a(**attributes, &)
end