Class: Flowbite::Alert::Icon

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/flowbite/alert/icon.rb

Overview

Renders the info icon shown inside an alert.

Flowbite uses the same outlined info icon for all alert styles; the icon inherits its color from the alert via currentColor.

Constant Summary collapse

SVG_PATH =
"M10 11h2v5m-2 0h4m-2.592-8.5h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class: nil) ⇒ Icon

Returns a new instance of Icon.



23
24
25
# File 'app/components/flowbite/alert/icon.rb', line 23

def initialize(class: nil)
  @class = Array.wrap(binding.local_variable_get(:class))
end

Class Method Details

.classes ⇒ Object



18
19
20
# File 'app/components/flowbite/alert/icon.rb', line 18

def classes
  ["w-4", "h-4", "shrink-0"]
end

Instance Method Details

#call ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/flowbite/alert/icon.rb', line 27

def call
  tag.svg(
    tag.path(
      d: svg_path,
      stroke: "currentColor",
      "stroke-linecap": "round",
      "stroke-linejoin": "round",
      "stroke-width": "2"
    ),
    "aria-hidden": "true",
    class: svg_classes,
    fill: "none",
    viewBox: "0 0 24 24",
    xmlns: "http://www.w3.org/2000/svg"
  )
end

#svg_classes ⇒ Object



44
45
46
# File 'app/components/flowbite/alert/icon.rb', line 44

def svg_classes
  self.class.classes + @class
end

#svg_path ⇒ Object



48
49
50
# File 'app/components/flowbite/alert/icon.rb', line 48

def svg_path
  SVG_PATH
end