Class: PhlexKit::Link
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Link
- Defined in:
- app/components/phlex_kit/link/link.rb
Overview
Link, ported from ruby_ui's RubyUI::Link — an that wears PhlexKit::Button's
look. Same variant/size vocabulary as Button, so it reuses the .pk-button*
classes from button.css (link.css only adds the inline :link treatment).
Default variant is :link (an inline underline-on-hover link); the button-style
variants turn it into a button-styled anchor (ruby_ui's "Link" concept — what
we already do ad-hoc with a(class: "pk-button outline sm")).
Presentational; mix passes **@attrs (incl. data-*) straight through.
VARIANTS.fetch/SIZES.fetch fail loud.
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
-
#initialize(href: "#", variant: :link, size: :md, icon: false, **attrs) ⇒ Link
constructor
A new instance of Link.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
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 |