Class: PhlexUI::Accordion::Icon

Inherits:
Base
  • Object
show all
Defined in:
lib/phlex_ui/accordion/icon.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#before_template, #initialize

Constructor Details

This class inherits a constructor from PhlexUI::Base

Instance Method Details

#default_attrsObject



31
32
33
34
35
36
# File 'lib/phlex_ui/accordion/icon.rb', line 31

def default_attrs
  {
    class: "opacity-50",
    data: {accordion_target: "icon"}
  }
end

#iconObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/phlex_ui/accordion/icon.rb', line 15

def icon
  svg(
    xmlns: "http://www.w3.org/2000/svg",
    viewbox: "0 0 20 20",
    fill: "currentColor",
    class: "w-4 h-4"
  ) do |s|
    s.path(
      fill_rule: "evenodd",
      d:
        "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",
      clip_rule: "evenodd"
    )
  end
end

#view_template(&block) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/phlex_ui/accordion/icon.rb', line 5

def view_template(&block)
  span(**attrs) do
    if block
      block.call
    else
      icon
    end
  end
end