Class: PhlexKit::Link

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/link/link.rb

Overview

Constant Summary collapse

VARIANTS =

Mirrors PhlexKit::Button's vocabulary 1:1 so the shared .pk-button* CSS applies.

{
  link: "link",
  primary: "primary",
  secondary: "secondary",
  destructive: "destructive",
  outline: "outline",
  ghost: "ghost"
}.freeze
SIZES =
{
  sm: "sm",
  md: nil,
  lg: "lg",
  xl: "xl"
}.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(href: "#", variant: :link, size: :md, icon: false, **attrs) ⇒ Link

Returns a new instance of Link.



29
30
31
32
33
34
35
# File 'app/components/phlex_kit/link/link.rb', line 29

def initialize(href: "#", variant: :link, size: :md, icon: false, **attrs)
  @href = href
  @variant = variant.to_sym
  @size = size.to_sym
  @icon = icon
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



37
38
39
# File 'app/components/phlex_kit/link/link.rb', line 37

def view_template(&block)
  a(**mix({ href: @href, class: classes }, @attrs), &block)
end