-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink.rb
More file actions
34 lines (30 loc) · 1003 Bytes
/
link.rb
File metadata and controls
34 lines (30 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true
module Flowbite
# The link component can be used to set hyperlinks from one page to another or
# to an external website when clicking on an inline text item, button, or card
#
# Use this component to add default styles to an inline link element.
class Link < ViewComponent::Base
attr_reader :href, :options
class << self
def classes
["font-medium", "text-blue-600", "dark:text-blue-500", "hover:underline"].join(" ")
end
end
# Initialize the Link component.
#
# @param href What to link to. This can be a String or anything else that
# `link_to` supports. See `ActionView::Helpers::UrlHelper#link_to` for more
# details.
#
# @param options [Hash] Additional HTML options for the link element
def initialize(href:, **options)
super()
@href = href
@options = options
end
def call
link_to(content, href, {class: self.class.classes}.merge(options))
end
end
end