maquina-components 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28216906695fc33245706bd71b7496d3d7508fb3317ac7c0ba6524a3fd899ec2
4
- data.tar.gz: a2f18961cdbe2a57604d14af2ef810655d89f9a3f0473af1880a4cbad65bcaf5
3
+ metadata.gz: 55a2ec2879afb8976c7b668873da307a50d2a2798e003399dbc8c2d4d9779471
4
+ data.tar.gz: 2db272ca8f735467c06d2f37b133fb7da4156d9662b85cb19ec93ac9d84078f7
5
5
  SHA512:
6
- metadata.gz: 0deefadda8d4c8c049f20ade8f1112325fb2ca58fdadc41006efb1343812158e943d01399e2fe2fa23f418610865e7c08894c70344ce8cfc433e6d07bf05c83f
7
- data.tar.gz: fada4a588f3cfa1629eebc28a11f3e8400be69d1c00bbda71cec643b94ab7f4687b5131499051d2f6a33ccf41cd008664f15899456ceedc2b025871baf69f04c
6
+ metadata.gz: 719870f407619f1f4fe5714db8e77af06db45ae3272a58784f647c4280b8ef78d0c1e805e95b58ccdd2f439392652f1483f054c421b093621472bac8cfc34de9
7
+ data.tar.gz: 4bc447930b1e71135ef1012455d82a78de7be2483ba17fae25185239a459185b0ed29278ac49bc40c086ade7a8ed2bbc0bd248f4cce8505a26897c273e96246f
@@ -3,11 +3,31 @@ module MaquinaComponents
3
3
  def icon_for(name, options = {})
4
4
  return nil unless name
5
5
 
6
- svg = icon_svg_for(name.to_sym) || main_icon_svg_for(name.to_sym)
6
+ svg = main_icon_svg_for(name.to_sym) || icon_svg_for(name.to_sym)
7
7
  return nil unless svg
8
8
 
9
+ apply_icon_options(svg, options)
10
+ end
11
+
12
+ # Internal icon helper for engine components. Always uses built-in SVGs
13
+ # so components work reliably regardless of the app's icon configuration.
14
+ def builtin_icon_for(name, options = {})
15
+ return nil unless name
16
+
17
+ svg = icon_svg_for(name.to_sym)
18
+ return nil unless svg
19
+
20
+ apply_icon_options(svg, options)
21
+ end
22
+
23
+ def main_icon_svg_for(name)
24
+ end
25
+
26
+ private
27
+
28
+ def apply_icon_options(svg, options)
9
29
  css_classes = options[:class]
10
- svg = svg.gsub('class="', "class=\"#{css_classes} ")
30
+ svg = svg.gsub('class="', "class=\"#{css_classes} ") if css_classes
11
31
 
12
32
  if options[:stroke_width]
13
33
  svg = svg.gsub('stroke-width="2"', "stroke-width=\"#{options[:stroke_width]}\"")
@@ -16,9 +36,6 @@ module MaquinaComponents
16
36
  svg.html_safe
17
37
  end
18
38
 
19
- def main_icon_svg_for(name)
20
- end
21
-
22
39
  def icon_svg_for(name)
23
40
  case name
24
41
  when :dollar
@@ -68,7 +68,7 @@
68
68
  <%= "disabled" if disabled %>
69
69
  aria-haspopup="dialog"
70
70
  aria-expanded="false">
71
- <%= icon_for :calendar, class: "size-4" %>
71
+ <%= builtin_icon_for :calendar, class: "size-4" %>
72
72
  <span data-date-picker-target="display">
73
73
  <%= display_value || placeholder || default_placeholder %>
74
74
  </span>
@@ -36,7 +36,7 @@
36
36
  <span class="truncate text-xs"><%= subtitle %></span>
37
37
  <% end %>
38
38
  </div>
39
- <%= icon_for(:chevron_up_down, class: "ml-auto") if submenu %>
39
+ <%= builtin_icon_for(:chevron_up_down, class: "ml-auto") if submenu %>
40
40
  </button>
41
41
 
42
42
  <%= yield %>
@@ -26,7 +26,7 @@
26
26
  **html_options do %>
27
27
  <% if toast_icon %>
28
28
  <div data-toast-part="icon">
29
- <%= icon_for toast_icon, class: "size-5" %>
29
+ <%= builtin_icon_for toast_icon, class: "size-5" %>
30
30
  </div>
31
31
  <% end %>
32
32
 
@@ -47,7 +47,7 @@
47
47
  data-toast-part="close"
48
48
  data-action="toast#dismiss"
49
49
  aria-label="Dismiss notification">
50
- <%= icon_for :x, class: "size-4" %>
50
+ <%= builtin_icon_for :x, class: "size-4" %>
51
51
  </button>
52
52
  <% end %>
53
53
  <% end %>
@@ -4,6 +4,6 @@
4
4
  ) %>
5
5
 
6
6
  <%= content_tag :span, role: "presentation", class: css_classes, data: merged_data, **html_options do %>
7
- <%= icon_for(:ellipsis) %>
7
+ <%= builtin_icon_for(:ellipsis) %>
8
8
  <span class="sr-only">More</span>
9
9
  <% end %>
@@ -6,7 +6,7 @@
6
6
  data-action="click->calendar#previousMonth"
7
7
  data-calendar-target="prevButton"
8
8
  aria-label="Previous month">
9
- <%= icon_for :chevron_left, class: "size-4" %>
9
+ <%= builtin_icon_for :chevron_left, class: "size-4" %>
10
10
  </button>
11
11
 
12
12
  <div data-calendar-part="caption">
@@ -17,6 +17,6 @@
17
17
  data-action="click->calendar#nextMonth"
18
18
  data-calendar-target="nextButton"
19
19
  aria-label="Next month">
20
- <%= icon_for :chevron_right, class: "size-4" %>
20
+ <%= builtin_icon_for :chevron_right, class: "size-4" %>
21
21
  </button>
22
22
  <% end %>
@@ -6,7 +6,7 @@
6
6
  ) %>
7
7
 
8
8
  <div data-combobox-part="input-wrapper">
9
- <%= icon_for :search, class: "size-4 shrink-0 opacity-50" %>
9
+ <%= builtin_icon_for :search, class: "size-4 shrink-0 opacity-50" %>
10
10
  <%= tag.input type: "text",
11
11
  placeholder: placeholder,
12
12
  autocomplete: "off",
@@ -18,7 +18,7 @@
18
18
  data: merged_data,
19
19
  **html_options do %>
20
20
  <span data-combobox-part="check" class="<%= 'invisible' unless selected %>">
21
- <%= icon_for :check, class: "size-4" %>
21
+ <%= builtin_icon_for :check, class: "size-4" %>
22
22
  </span>
23
23
  <%= yield %>
24
24
  <% end %>
@@ -18,5 +18,5 @@
18
18
  data: merged_data,
19
19
  **html_options do %>
20
20
  <span data-combobox-target="label"><%= placeholder %></span>
21
- <%= icon_for :chevrons_up_down, class: "size-4 shrink-0 opacity-50" %>
21
+ <%= builtin_icon_for :chevrons_up_down, class: "size-4 shrink-0 opacity-50" %>
22
22
  <% end %>
@@ -19,6 +19,6 @@
19
19
  aria: { haspopup: "menu", expanded: "false" },
20
20
  **html_options do %>
21
21
  <%= yield %>
22
- <%= icon_for :chevron_down, data: { "dropdown-menu-target": "chevron" } %>
22
+ <%= builtin_icon_for :chevron_down, data: { "dropdown-menu-target": "chevron" } %>
23
23
  <% end %>
24
24
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module MaquinaComponents
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maquina-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez