Class: RUI::Buttons::Base

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

Direct Known Subclasses

Destructive, Ghost, Outline, Primary, Secondary

Constant Summary collapse

STYLE =

Style string public for use in forms

"inline-block px-2 py-1 hover:cursor-pointer rounded-md transition duration-200 ease-in-out".freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Base.



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

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

Instance Method Details

#view_templateObject



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

def view_template
  button(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(class: "text-nowrap") { yield } if block_given?
    end
  end
end