Class: Plutonium::UI::Breadcrumbs

Inherits:
Component::Base show all
Includes:
Phlex::Rails::Helpers::ActionName, Phlex::Rails::Helpers::LinkTo
Defined in:
lib/plutonium/ui/breadcrumbs.rb

Instance Method Summary collapse

Methods included from Component::Behaviour

#around_template

Methods included from Component::Tokens

#classes, #tokens

Methods included from Component::Kit

#BuildActionButton, #BuildActionsDropdown, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableSearchBar, #method_missing, #respond_to_missing?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit

Instance Method Details

#view_templateObject



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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/plutonium/ui/breadcrumbs.rb', line 7

def view_template
  nav(
    class: "flex py-3 mb-2",
    aria_label: "Breadcrumb"
  ) do
    ol(
      class: "inline-flex items-center gap-1 md:gap-2"
    ) do
      # Dashboard
      li(class: "inline-flex items-center") do
        a(
          href: root_path,
          class: "inline-flex items-center text-sm font-medium text-[var(--pu-text-muted)] hover:text-primary-600 transition-colors"
        ) do
          svg(
            class: "w-3 h-3 me-2.5",
            aria_hidden: "true",
            xmlns: "http://www.w3.org/2000/svg",
            fill: "currentColor",
            viewbox: "0 0 20 20"
          ) do |s|
            s.path(
              d:
                "m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"
            )
          end
          plain " Dashboard "
        end
      end

      # Parent
      if current_parent.present?
        # Parent Resource
        li(class: "flex items-center") do
          svg(
            class: "rtl:rotate-180 block w-3 h-3 mx-1 text-[var(--pu-text-subtle)]",
            aria_hidden: "true",
            xmlns: "http://www.w3.org/2000/svg",
            fill: "none",
            viewbox: "0 0 6 10"
          ) do |s|
            s.path(
              stroke: "currentColor",
              stroke_linecap: "round",
              stroke_linejoin: "round",
              stroke_width: "2",
              d: "m1 9 4-4-4-4"
            )
          end
          link_to resource_name_plural(current_parent.class),
            resource_url_for(current_parent.class, parent: nil),
            class: "ms-1 text-sm font-medium text-[var(--pu-text-muted)] hover:text-primary-600 md:ms-2 transition-colors"
        end

        # Parent Itself
        li(class: "flex items-center") do
          svg(
            class: "rtl:rotate-180 block w-3 h-3 mx-1 text-[var(--pu-text-subtle)]",
            aria_hidden: "true",
            xmlns: "http://www.w3.org/2000/svg",
            fill: "none",
            viewbox: "0 0 6 10"
          ) do |s|
            s.path(
              stroke: "currentColor",
              stroke_linecap: "round",
              stroke_linejoin: "round",
              stroke_width: "2",
              d: "m1 9 4-4-4-4"
            )
          end
          link_to display_name_of(current_parent),
            resource_url_for(current_parent, parent: nil),
            class: "ms-1 text-sm font-medium text-[var(--pu-text-muted)] hover:text-primary-600 md:ms-2 transition-colors"
        end
      end

      # Record
      if resource_record?
        unless current_engine.routes.resource_route_config_lookup[resource_class.model_name.plural][:route_type] == :resource
          # Record Resource
          li(class: "flex items-center") do
            svg(
              class: "rtl:rotate-180 block w-3 h-3 mx-1 text-[var(--pu-text-subtle)]",
              aria_hidden: "true",
              xmlns: "http://www.w3.org/2000/svg",
              fill: "none",
              viewbox: "0 0 6 10"
            ) do |s|
              s.path(
                stroke: "currentColor",
                stroke_linecap: "round",
                stroke_linejoin: "round",
                stroke_width: "2",
                d: "m1 9 4-4-4-4"
              )
            end
            link_to nestable_resource_name_plural(resource_class),
              resource_url_for(resource_class),
              class: "ms-1 text-sm font-medium text-[var(--pu-text-muted)] hover:text-primary-600 md:ms-2 transition-colors"
          end
        end

        # Record Itself
        if resource_record!.persisted? && action_name != "show"
          li(class: "flex items-center") do
            svg(
              class: "rtl:rotate-180 block w-3 h-3 mx-1 text-[var(--pu-text-subtle)]",
              aria_hidden: "true",
              xmlns: "http://www.w3.org/2000/svg",
              fill: "none",
              viewbox: "0 0 6 10"
            ) do |s|
              s.path(
                stroke: "currentColor",
                stroke_linecap: "round",
                stroke_linejoin: "round",
                stroke_width: "2",
                d: "m1 9 4-4-4-4"
              )
            end
            link_to display_name_of(resource_record!),
              resource_url_for(resource_record!),
              class: "ms-1 text-sm font-medium text-[var(--pu-text-muted)] hover:text-primary-600 md:ms-2 transition-colors"
          end
        end
      end

      # Trailing Caret
      li(class: "flex items-center") do
        svg(
          class: "rtl:rotate-180 block w-3 h-3 mx-1 text-[var(--pu-text-subtle)]",
          aria_hidden: "true",
          xmlns: "http://www.w3.org/2000/svg",
          fill: "none",
          viewbox: "0 0 6 10"
        ) do |s|
          s.path(
            stroke: "currentColor",
            stroke_linecap: "round",
            stroke_linejoin: "round",
            stroke_width: "2",
            d: "m1 9 4-4-4-4"
          )
        end
      end
    end
  end
end