Class: RUI::Links::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/rui/links/base.rb

Direct Known Subclasses

Destructive, Ghost, Outline, Primary, Secondary

Instance Method Summary collapse

Constructor Details

#initialize(href: "#", icon: nil, **attrs) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
# File 'lib/rui/links/base.rb', line 4

def initialize(href: "#", icon: nil, **attrs)
  @href = href
  @icon = icon
  @attrs = attrs
end

Instance Method Details

#view_templateObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rui/links/base.rb', line 10

def view_template
  div do
    a(href: @href, class: classes, **@attrs) do
      div(class: "flex flex-row items-center gap-2") do
        if @icon
          div(class: "size-4 my-1") do
            render RUI::Icon.new(@icon)
          end
        end
        span { yield } if block_given?
      end
    end
  end
end