Class: DocsKit::LandingConfig::Cta
- Inherits:
-
Data
- Object
- Data
- DocsKit::LandingConfig::Cta
- Defined in:
- lib/docs_kit/landing_config.rb
Overview
One hero call-to-action button. style maps to a daisyUI btn variant
(:primary → btn-primary, anything else → btn-ghost). icon is an optional
brand/lucide token rendered before the label (DocsUI::BrandMark resolves it).
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Class Method Summary collapse
Instance Method Summary collapse
-
#btn_class ⇒ Object
The daisyUI button class for this CTA's style.
-
#external? ⇒ Boolean
Whether the href points off-site (absolute http/https) — the component adds target=_blank + rel=noopener only for external links.
-
#initialize(label:, href:, style: :ghost, icon: nil) ⇒ Cta
constructor
A new instance of Cta.
Constructor Details
#initialize(label:, href:, style: :ghost, icon: nil) ⇒ Cta
Returns a new instance of Cta.
104 105 106 |
# File 'lib/docs_kit/landing_config.rb', line 104 def initialize(label:, href:, style: :ghost, icon: nil) super(label:, href:, style: style&.to_sym, icon: icon) end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href
103 104 105 |
# File 'lib/docs_kit/landing_config.rb', line 103 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon
103 104 105 |
# File 'lib/docs_kit/landing_config.rb', line 103 def icon @icon end |
#label ⇒ Object (readonly)
Returns the value of attribute label
103 104 105 |
# File 'lib/docs_kit/landing_config.rb', line 103 def label @label end |
#style ⇒ Object (readonly)
Returns the value of attribute style
103 104 105 |
# File 'lib/docs_kit/landing_config.rb', line 103 def style @style end |
Class Method Details
.from(cta) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/docs_kit/landing_config.rb', line 108 def self.from(cta) return cta if cta.is_a?(self) attrs = cta.to_h.transform_keys(&:to_sym) new(label: attrs[:label], href: attrs[:href], style: attrs[:style] || :ghost, icon: attrs[:icon]) end |
Instance Method Details
#btn_class ⇒ Object
The daisyUI button class for this CTA's style.
116 |
# File 'lib/docs_kit/landing_config.rb', line 116 def btn_class = style == :primary ? "btn btn-primary" : "btn btn-ghost" |
#external? ⇒ Boolean
Whether the href points off-site (absolute http/https) — the component adds target=_blank + rel=noopener only for external links.
120 |
# File 'lib/docs_kit/landing_config.rb', line 120 def external? = href.to_s.match?(%r{\Ahttps?://}i) |