Class: IgnitionKit::Button
- Defined in:
- app/lib/ignition_kit/button.rb
Constant Summary collapse
- BASE =
[ [ "inline-flex items-center justify-center rounded-md border", "focus:outline-none focus:ring-[3px] focus:ring-ring" ] ].flatten.freeze
- VARIANTS =
{ default: ["bg-background text-foreground border-border border-b-zinc-300"], primary: ["bg-primary text-white border-primary"], destructive: ["bg-destructive text-white border-destructive"], ghost: ["bg-transparent text-foreground border-transparent"] }.freeze
- SIZES =
{ base: "px-4 py-1.5 font-medium" }
Instance Method Summary collapse
-
#initialize(text = nil, variant: :default, size: :base, href: nil, **options) ⇒ Button
constructor
A new instance of Button.
- #render ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(text = nil, variant: :default, size: :base, href: nil, **options) ⇒ Button
Returns a new instance of Button.
21 22 23 24 25 26 |
# File 'app/lib/ignition_kit/button.rb', line 21 def initialize(text = nil, variant: :default, size: :base, href: nil, **) super(**) @text = text || yield @href = href @classes = tw.merge([BASE, VARIANTS[variant], SIZES[size], [:class]]) end |
Instance Method Details
#render ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/lib/ignition_kit/button.rb', line 28 def render if @href tag.a(href: @href, class: @classes) do tag.span(@text) end else tag.(type: "button", class: @classes) do tag.span(@text) end end end |