ui_components 0.1.1 → 0.1.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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ui_components/controllers/countdown_controller.js +55 -0
  3. data/app/components/documentation/body/example_preview_component.rb +1 -1
  4. data/app/components/documentation/body_component.html.erb +1 -1
  5. data/app/components/documentation/body_component.rb +4 -4
  6. data/app/components/ui_components/daisy_ui/action/button_component.rb +13 -13
  7. data/app/components/ui_components/daisy_ui/action/dropdown/anchor_component.rb +1 -11
  8. data/app/components/ui_components/daisy_ui/action/dropdown/card/item_component.rb +20 -0
  9. data/app/components/ui_components/daisy_ui/action/dropdown/card_component.rb +4 -14
  10. data/app/components/ui_components/daisy_ui/action/dropdown/menu/item_component.rb +32 -0
  11. data/app/components/ui_components/daisy_ui/action/dropdown/menu_component.rb +2 -12
  12. data/app/components/ui_components/daisy_ui/action/dropdown_component.rb +12 -12
  13. data/app/components/ui_components/daisy_ui/action/modal/anchor_component.rb +1 -11
  14. data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action/item_component.rb +0 -9
  15. data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action_component.rb +0 -9
  16. data/app/components/ui_components/daisy_ui/action/modal/dialog/box/body_component.rb +0 -9
  17. data/app/components/ui_components/daisy_ui/action/modal/dialog/box/close_component.rb +0 -9
  18. data/app/components/ui_components/daisy_ui/action/modal/dialog/box/title_component.rb +0 -9
  19. data/app/components/ui_components/daisy_ui/action/modal/dialog/box_component.rb +0 -9
  20. data/app/components/ui_components/daisy_ui/action/modal/dialog_component.rb +2 -12
  21. data/app/components/ui_components/daisy_ui/action/swap/off_component.rb +0 -9
  22. data/app/components/ui_components/daisy_ui/action/swap/on_component.rb +0 -9
  23. data/app/components/ui_components/daisy_ui/action/swap_component.rb +6 -6
  24. data/app/components/ui_components/daisy_ui/base_component.rb +24 -3
  25. data/app/components/ui_components/daisy_ui/data_display/accordion/item/anchor_component.rb +20 -0
  26. data/app/components/ui_components/daisy_ui/data_display/accordion/item/body_component.rb +20 -0
  27. data/app/components/ui_components/daisy_ui/data_display/accordion/item_component.rb +15 -15
  28. data/app/components/ui_components/daisy_ui/data_display/avatar/item/box_component.rb +63 -0
  29. data/app/components/ui_components/daisy_ui/data_display/avatar/item_component.rb +8 -8
  30. data/app/components/ui_components/daisy_ui/data_display/badge_component.rb +7 -7
  31. data/app/components/ui_components/daisy_ui/data_display/card/body/action_component.rb +20 -0
  32. data/app/components/ui_components/daisy_ui/data_display/card/body/context_component.rb +17 -0
  33. data/app/components/ui_components/daisy_ui/data_display/card/body/title_component.rb +20 -0
  34. data/app/components/ui_components/daisy_ui/data_display/card/body_component.rb +34 -0
  35. data/app/components/ui_components/daisy_ui/data_display/card/figure_component.rb +15 -0
  36. data/app/components/ui_components/daisy_ui/data_display/card_component.rb +83 -0
  37. data/app/components/ui_components/daisy_ui/data_display/carousel/indicator_component.rb +18 -0
  38. data/app/components/ui_components/daisy_ui/data_display/carousel/item/passer_component.rb +20 -0
  39. data/app/components/ui_components/daisy_ui/data_display/carousel/item_component.rb +26 -0
  40. data/app/components/ui_components/daisy_ui/data_display/carousel_component.rb +63 -0
  41. data/app/components/ui_components/daisy_ui/data_display/chat/bubble_component.rb +42 -0
  42. data/app/components/ui_components/daisy_ui/data_display/chat/footer_component.rb +18 -0
  43. data/app/components/ui_components/daisy_ui/data_display/chat/header_component.rb +18 -0
  44. data/app/components/ui_components/daisy_ui/data_display/chat_component.rb +58 -0
  45. data/app/components/ui_components/daisy_ui/data_display/countdown/item_component.rb +49 -0
  46. data/app/components/ui_components/daisy_ui/data_display/countdown_component.rb +37 -0
  47. data/app/components/ui_components/daisy_ui/data_display/{accordion/anchor_component.rb → diff/item1_component.rb} +5 -8
  48. data/app/components/ui_components/daisy_ui/data_display/{accordion/body_component.rb → diff/item2_component.rb} +6 -8
  49. data/app/components/ui_components/daisy_ui/data_display/diff/resizer_component.rb +25 -0
  50. data/app/components/ui_components/daisy_ui/data_display/diff_component.rb +35 -0
  51. data/app/components/ui_components/daisy_ui/data_display/kbd_component.rb +40 -0
  52. data/app/components/ui_components/daisy_ui/data_display/list/item_component.rb +40 -0
  53. data/app/components/ui_components/daisy_ui/data_display/list_component.rb +22 -0
  54. data/app/components/ui_components/daisy_ui/data_display/stat/item/action_component.rb +20 -0
  55. data/app/components/ui_components/daisy_ui/data_display/stat/item/description_component.rb +20 -0
  56. data/app/components/ui_components/daisy_ui/data_display/stat/item/figure_component.rb +24 -0
  57. data/app/components/ui_components/daisy_ui/data_display/stat/item/title_component.rb +20 -0
  58. data/app/components/ui_components/daisy_ui/data_display/stat/item/value_component.rb +20 -0
  59. data/app/components/ui_components/daisy_ui/data_display/stat/item_component.rb +39 -0
  60. data/app/components/ui_components/daisy_ui/data_display/stat_component.rb +50 -0
  61. data/app/components/ui_components/daisy_ui/data_display/status_component.rb +59 -0
  62. data/app/components/ui_components/daisy_ui/data_display/table/item/body_component.rb +23 -0
  63. data/app/components/ui_components/daisy_ui/data_display/table/item/foot_component.rb +23 -0
  64. data/app/components/ui_components/daisy_ui/data_display/table/item/head_component.rb +23 -0
  65. data/app/components/ui_components/daisy_ui/data_display/table/item/row/data_component.rb +19 -0
  66. data/app/components/ui_components/daisy_ui/data_display/table/item/row/header_component.rb +19 -0
  67. data/app/components/ui_components/daisy_ui/data_display/table/item/row_component.rb +32 -0
  68. data/app/components/ui_components/daisy_ui/data_display/table/item_component.rb +29 -0
  69. data/app/components/ui_components/daisy_ui/data_display/table_component.rb +72 -0
  70. data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_end_component.rb +44 -0
  71. data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_middle_component.rb +20 -0
  72. data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_start_component.rb +44 -0
  73. data/app/components/ui_components/daisy_ui/data_display/timeline/item/line_component.rb +17 -0
  74. data/app/components/ui_components/daisy_ui/data_display/timeline/item_component.rb +40 -0
  75. data/app/components/ui_components/daisy_ui/data_display/timeline_component.rb +50 -0
  76. data/app/controllers/ui_components/daisy_ui/data_display_components_controller.rb +22 -0
  77. data/app/helpers/data_display/carousel_helper.rb +13 -0
  78. data/app/views/ui_components/daisy_ui/action_components/button.html.erb +35 -33
  79. data/app/views/ui_components/daisy_ui/action_components/dropdown.html.erb +38 -25
  80. data/app/views/ui_components/daisy_ui/action_components/modal.html.erb +31 -18
  81. data/app/views/ui_components/daisy_ui/action_components/swap.html.erb +31 -17
  82. data/app/views/ui_components/daisy_ui/data_display_components/accordion.html.erb +59 -105
  83. data/app/views/ui_components/daisy_ui/data_display_components/avatar.html.erb +40 -27
  84. data/app/views/ui_components/daisy_ui/data_display_components/badge.html.erb +45 -42
  85. data/app/views/ui_components/daisy_ui/data_display_components/card.html.erb +302 -0
  86. data/app/views/ui_components/daisy_ui/data_display_components/carousel.html.erb +303 -0
  87. data/app/views/ui_components/daisy_ui/data_display_components/chat.html.erb +190 -0
  88. data/app/views/ui_components/daisy_ui/data_display_components/countdown.html.erb +211 -0
  89. data/app/views/ui_components/daisy_ui/data_display_components/diff.html.erb +69 -0
  90. data/app/views/ui_components/daisy_ui/data_display_components/kbd.html.erb +157 -0
  91. data/app/views/ui_components/daisy_ui/data_display_components/list.html.erb +247 -0
  92. data/app/views/ui_components/daisy_ui/data_display_components/stat.html.erb +208 -0
  93. data/app/views/ui_components/daisy_ui/data_display_components/status.html.erb +93 -0
  94. data/app/views/ui_components/daisy_ui/data_display_components/table.html.erb +358 -0
  95. data/app/views/ui_components/daisy_ui/data_display_components/timeline.html.erb +431 -0
  96. data/app/views/ui_components/daisy_ui/home/index.html.erb +11 -0
  97. data/config/routes.rb +13 -2
  98. data/lib/tasks/ui_components_tasks.rake +0 -3
  99. data/lib/ui_components/config/daisy_ui_class_names.rb +3 -2
  100. data/lib/ui_components/config/tailwind_class_names.rb +27 -4
  101. data/lib/ui_components/version.rb +1 -1
  102. metadata +65 -7
  103. data/app/components/ui_components/daisy_ui/action/dropdown/card_item_component.rb +0 -29
  104. data/app/components/ui_components/daisy_ui/action/dropdown/list_item_component.rb +0 -30
  105. data/app/components/ui_components/daisy_ui/data_display/avatar/box_component.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e31ad6fe648a34de7a80d53704daf454b21fffd519709908acd89bc79ad36110
4
- data.tar.gz: d9a518ee3ee2920ada5690a5408920762e826ac19df74937be18b261c3369a1b
3
+ metadata.gz: 120dc503191b4b508b4ef7ce75702960054a54e35da8d23e885ee76c5374f28f
4
+ data.tar.gz: af4df82c998db4bf226f4225292514daa11863522d8bc7dbbd14fe1acd5aac41
5
5
  SHA512:
6
- metadata.gz: f84a0496d5eb96e925965eee822a7a5b6ab62c411f58d9e47903a898874c1b8caacaa7319cf47e4c0f4b8f626b8552c5f1b82705f1318a4333cae79238f8120c
7
- data.tar.gz: 52682d5b85b9b114d06f62572dbe0cc9a657cb1a2f6473082e8b71ec50852141c6c4a4c02deb4a09e98c4090fb3920ea6cf6a33f465ce423f4735a13bdb83613
6
+ metadata.gz: 368bde69e7761b242bcd58f27976e5d43ccba197739c7f44c559bb66f2df0cfade5a542ae8768a5e8431f054ab6b53675978957d5f7ed094ecd4d80215658e32
7
+ data.tar.gz: 64e902a2adab8a39438705b81c94db0c9e63031f4894eb6ff9a4b1c765353296bbe40f76585b45abf13c6ed483084f0989d230935a4119fe5eaaa9f60d661b6b
@@ -0,0 +1,55 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = ["value"]
5
+
6
+ connect() {
7
+ this.timers = []
8
+ this.targetsData = []
9
+
10
+ this.valueTargets.forEach(target => {
11
+ const type = target.dataset.countdownType || "second"
12
+ const initialStr = target.style.getPropertyValue('--value').trim()
13
+ const initial = parseInt(initialStr) || 0
14
+ const dataObj = { target, type, original: initial, current: initial }
15
+
16
+ this.targetsData.push(dataObj)
17
+
18
+ let timer = this.startCountdown(dataObj)
19
+
20
+ this.timers.push(timer)
21
+ })
22
+ }
23
+
24
+ startCountdown(dataObj) {
25
+ let intervalDuration
26
+
27
+ switch (dataObj.type.toLowerCase()) {
28
+ case "minute":
29
+ intervalDuration = 60 * 1000
30
+ break
31
+ case "hour":
32
+ intervalDuration = 3600 * 1000
33
+ break
34
+ case "day":
35
+ intervalDuration = 86400 * 1000
36
+ break
37
+ default:
38
+ intervalDuration = 1000
39
+ }
40
+
41
+ return setInterval(() => {
42
+ if (dataObj.current > 0) {
43
+ dataObj.current--
44
+ } else {
45
+ dataObj.current = dataObj.original
46
+ }
47
+ dataObj.target.textContent = dataObj.current
48
+ dataObj.target.style.setProperty('--value', dataObj.current)
49
+ }, intervalDuration)
50
+ }
51
+
52
+ disconnect() {
53
+ this.timers.forEach(timer => clearInterval(timer))
54
+ }
55
+ }
@@ -7,7 +7,7 @@ class Documentation::Body::ExamplePreviewComponent < ViewComponent::Base
7
7
  def initialize(
8
8
  source:
9
9
  )
10
- @source = source.gsub("$", "%")
10
+ @source = source.gsub("<$", "<%").gsub("$>", "%>")
11
11
  end
12
12
 
13
13
  def call; end
@@ -15,7 +15,7 @@
15
15
  </svg>
16
16
  <% end %>
17
17
 
18
- <div data-clipboard-target="code" class="m-3">
18
+ <div data-clipboard-target="code" class="m-3 max-h-98">
19
19
  <% preview_examples.each do |example| %>
20
20
  <%= example.code_preview %>
21
21
  <% end %>
@@ -22,19 +22,19 @@ module Documentation
22
22
  private
23
23
 
24
24
  def set_preview_options
25
- @preview_options.merge!(class: preview_class_string)
25
+ @preview_options.merge!(class: preview_css_class_string)
26
26
  @preview_options.compact_blank!
27
27
  end
28
28
 
29
- def preview_class_string
29
+ def preview_css_class_string
30
30
  TailwindMerge::Merger.new.merge([
31
31
  *CSS_CLASSES_DEFAULT,
32
- @preview_options[:css_class]
32
+ @preview_options.delete(:css_class)
33
33
  ])
34
34
  end
35
35
 
36
36
  def set_code_options
37
- @code_options.merge!(class: @code_options[:css_class])
37
+ @code_options.merge!(class: @code_options.delete(:css_class))
38
38
  @code_options.compact_blank!
39
39
  end
40
40
  end
@@ -4,8 +4,8 @@ module UiComponents
4
4
  module DaisyUi
5
5
  module Action
6
6
  class ButtonComponent < BaseComponent
7
- SHAPES = %w[square circle]
8
- WIDE_SIZES = %w[wide block]
7
+ SHAPES = %w[square circle].freeze
8
+ WIDE_SIZES = %w[wide block].freeze
9
9
 
10
10
  CSS_CLASSES_DEFAULT = %w[btn].freeze
11
11
  CSS_CLASSES_VARIANTS = (
@@ -42,14 +42,14 @@ module UiComponents
42
42
 
43
43
  private
44
44
 
45
- def class_string
45
+ def css_class_string
46
46
  TailwindMerge::Merger.new.merge([
47
47
  *css_classes_default,
48
- size_class,
49
- color_class,
50
- kind_class,
51
- shape_class,
52
- wide_size_class,
48
+ size_css_class,
49
+ color_css_class,
50
+ kind_css_class,
51
+ shape_css_class,
52
+ wide_size_css_class,
53
53
  @css_class
54
54
  ])
55
55
  end
@@ -58,23 +58,23 @@ module UiComponents
58
58
  CSS_CLASSES_DEFAULT unless @no_btn
59
59
  end
60
60
 
61
- def size_class
61
+ def size_css_class
62
62
  "btn-#{@size}" if SIZES.include?(@size)
63
63
  end
64
64
 
65
- def color_class
65
+ def color_css_class
66
66
  "btn-#{@color}" if COLORS.include?(@color)
67
67
  end
68
68
 
69
- def kind_class
69
+ def kind_css_class
70
70
  "btn-#{@kind}" if KINDS.include?(@kind)
71
71
  end
72
72
 
73
- def shape_class
73
+ def shape_css_class
74
74
  "btn-#{@shape}" if SHAPES.include?(@shape)
75
75
  end
76
76
 
77
- def wide_size_class
77
+ def wide_size_css_class
78
78
  "btn-#{@wide_size}" if WIDE_SIZES.include?(@wide_size)
79
79
  end
80
80
  end
@@ -14,19 +14,9 @@ module UiComponents
14
14
 
15
15
  private
16
16
 
17
- def set_options
18
- @options.merge!(class: class_string)
19
- @options.merge!(style: @css_style)
17
+ def other_options
20
18
  @options.merge!(role: "button")
21
19
  @options.merge!(tabindex: "0")
22
- @options.compact_blank!
23
- end
24
-
25
- def class_string
26
- TailwindMerge::Merger.new.merge([
27
- *CSS_CLASSES_DEFAULT,
28
- @css_class
29
- ])
30
20
  end
31
21
  end
32
22
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module Action
6
+ module Dropdown
7
+ module Card
8
+ class ItemComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[card-body].freeze
10
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
11
+
12
+ erb_template <<-ERB
13
+ <%= tag.div(**set_options) { content } %>
14
+ ERB
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -5,10 +5,10 @@ module UiComponents
5
5
  module Action
6
6
  module Dropdown
7
7
  class CardComponent < BaseComponent
8
- CSS_CLASSES_DEFAULT = %w[dropdown-content card card-sm bg-base-100 z-1 w-64 shadow-md]
8
+ CSS_CLASSES_DEFAULT = %w[dropdown-content card card-sm bg-base-100 z-1 w-64 shadow-md].freeze
9
9
  CSS_CLASSES = (
10
10
  CSS_CLASSES_DEFAULT +
11
- CardItemComponent::CSS_CLASSES
11
+ Card::ItemComponent::CSS_CLASSES
12
12
  ).freeze
13
13
 
14
14
  erb_template <<-ERB
@@ -17,22 +17,12 @@ module UiComponents
17
17
  <% end %>
18
18
  ERB
19
19
 
20
- renders_one :item, CardItemComponent
20
+ renders_one :item, Card::ItemComponent
21
21
 
22
22
  private
23
23
 
24
- def set_options
25
- @options.merge!(class: class_string)
26
- @options.merge!(style: @css_style)
24
+ def other_options
27
25
  @options.merge!(tabindex: "0")
28
- @options.compact_blank!
29
- end
30
-
31
- def class_string
32
- TailwindMerge::Merger.new.merge([
33
- *CSS_CLASSES_DEFAULT,
34
- @css_class
35
- ])
36
26
  end
37
27
  end
38
28
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module Action
6
+ module Dropdown
7
+ module Menu
8
+ class ItemComponent < BaseComponent
9
+ erb_template <<-ERB
10
+ <%= tag.li(**set_options) do %>
11
+ <% if @with_tag_a %>
12
+ <a><%= content %></a>
13
+ <% else %>
14
+ <%= content %>
15
+ <% end %>
16
+ <% end %>
17
+ ERB
18
+
19
+ def initialize(
20
+ with_tag_a: true,
21
+ **args
22
+ )
23
+ @with_tag_a = with_tag_a
24
+
25
+ super(**args)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -16,22 +16,12 @@ module UiComponents
16
16
  <% end %>
17
17
  ERB
18
18
 
19
- renders_many :items, ListItemComponent
19
+ renders_many :items, Menu::ItemComponent
20
20
 
21
21
  private
22
22
 
23
- def set_options
24
- @options.merge!(class: class_string)
25
- @options.merge!(style: @css_style)
23
+ def other_options
26
24
  @options.merge!(tabindex: "0")
27
- @options.compact_blank!
28
- end
29
-
30
- def class_string
31
- TailwindMerge::Merger.new.merge([
32
- *CSS_CLASSES_DEFAULT,
33
- @css_class
34
- ])
35
25
  end
36
26
  end
37
27
  end
@@ -4,11 +4,11 @@ module UiComponents
4
4
  module DaisyUi
5
5
  module Action
6
6
  class DropdownComponent < BaseComponent
7
- CSS_CLASSES_DEFAULT = %w[dropdown]
7
+ CSS_CLASSES_DEFAULT = %w[dropdown].freeze
8
8
  CSS_CLASSES_VARIANTS = (
9
9
  %w[dropdown-hover dropdown-open] +
10
- ALIGNS.map { |color| "dropdown-#{color}" } +
11
- AXES.map { |size| "dropdown-#{size}" }
10
+ ALIGNS.map { |key| "dropdown-#{key}" } +
11
+ AXES.map { |key| "dropdown-#{key}" }
12
12
  ).freeze
13
13
 
14
14
  CSS_CLASSES = (
@@ -47,30 +47,30 @@ module UiComponents
47
47
 
48
48
  private
49
49
 
50
- def class_string
50
+ def css_class_string
51
51
  TailwindMerge::Merger.new.merge([
52
52
  *CSS_CLASSES_DEFAULT,
53
- align_class,
54
- axis_class,
55
- hover_class,
56
- opened_class,
53
+ align_css_class,
54
+ axis_css_class,
55
+ hover_css_class,
56
+ opened_css_class,
57
57
  @css_class
58
58
  ])
59
59
  end
60
60
 
61
- def align_class
61
+ def align_css_class
62
62
  "dropdown-#{@align}" if ALIGNS.include?(@align)
63
63
  end
64
64
 
65
- def axis_class
65
+ def axis_css_class
66
66
  "dropdown-#{@axis}" if AXES.include?(@axis)
67
67
  end
68
68
 
69
- def hover_class
69
+ def hover_css_class
70
70
  "dropdown-hover" if @hover
71
71
  end
72
72
 
73
- def opened_class
73
+ def opened_css_class
74
74
  "dropdown-open" if @opened
75
75
  end
76
76
  end
@@ -23,18 +23,8 @@ module UiComponents
23
23
 
24
24
  private
25
25
 
26
- def set_options
27
- @options.merge!(class: class_string)
28
- @options.merge!(style: @css_style) if @css_style.present?
26
+ def other_options
29
27
  @options.merge!(onclick: "#{@opener}.showModal()")
30
- @options.compact_blank!
31
- end
32
-
33
- def class_string
34
- TailwindMerge::Merger.new.merge([
35
- *CSS_CLASSES_DEFAULT,
36
- @css_class
37
- ])
38
28
  end
39
29
  end
40
30
  end
@@ -14,15 +14,6 @@ module UiComponents
14
14
  erb_template <<-ERB
15
15
  <%= tag.button(**set_options) { content } %>
16
16
  ERB
17
-
18
- private
19
-
20
- def class_string
21
- TailwindMerge::Merger.new.merge([
22
- *CSS_CLASSES_DEFAULT,
23
- @css_class
24
- ])
25
- end
26
17
  end
27
18
  end
28
19
  end
@@ -24,15 +24,6 @@ module UiComponents
24
24
  ERB
25
25
 
26
26
  renders_many :items, Action::ItemComponent
27
-
28
- private
29
-
30
- def class_string
31
- TailwindMerge::Merger.new.merge([
32
- *CSS_CLASSES_DEFAULT,
33
- @css_class
34
- ])
35
- end
36
27
  end
37
28
  end
38
29
  end
@@ -13,15 +13,6 @@ module UiComponents
13
13
  erb_template <<-ERB
14
14
  <%= tag.div(**set_options) { content } %>
15
15
  ERB
16
-
17
- private
18
-
19
- def class_string
20
- TailwindMerge::Merger.new.merge([
21
- *CSS_CLASSES_DEFAULT,
22
- @css_class
23
- ])
24
- end
25
16
  end
26
17
  end
27
18
  end
@@ -15,15 +15,6 @@ module UiComponents
15
15
  <%= tag.button(**set_options) { content } %>
16
16
  </form>
17
17
  ERB
18
-
19
- private
20
-
21
- def class_string
22
- TailwindMerge::Merger.new.merge([
23
- *CSS_CLASSES_DEFAULT,
24
- @css_class
25
- ])
26
- end
27
18
  end
28
19
  end
29
20
  end
@@ -13,15 +13,6 @@ module UiComponents
13
13
  erb_template <<-ERB
14
14
  <%= tag.h3(**set_options) { content } %>
15
15
  ERB
16
-
17
- private
18
-
19
- def class_string
20
- TailwindMerge::Merger.new.merge([
21
- *CSS_CLASSES_DEFAULT,
22
- @css_class
23
- ])
24
- end
25
16
  end
26
17
  end
27
18
  end
@@ -37,15 +37,6 @@ module UiComponents
37
37
 
38
38
  super(**args)
39
39
  end
40
-
41
- private
42
-
43
- def class_string
44
- TailwindMerge::Merger.new.merge([
45
- *CSS_CLASSES_DEFAULT,
46
- @css_class
47
- ])
48
- end
49
40
  end
50
41
  end
51
42
  end
@@ -36,20 +36,10 @@ module UiComponents
36
36
  super(**args)
37
37
  end
38
38
 
39
- def set_options
40
- @options.merge!(class: class_string)
41
- @options.merge!(style: @css_style) if @css_style.present?
42
- @options.merge!(id: @opener)
43
- @options.compact_blank!
44
- end
45
-
46
39
  private
47
40
 
48
- def class_string
49
- TailwindMerge::Merger.new.merge([
50
- *CSS_CLASSES_DEFAULT,
51
- @css_class
52
- ])
41
+ def other_options
42
+ @options.merge!(id: @opener)
53
43
  end
54
44
  end
55
45
  end
@@ -11,15 +11,6 @@ module UiComponents
11
11
  erb_template <<-ERB
12
12
  <%= tag.div(**set_options) { content } %>
13
13
  ERB
14
-
15
- private
16
-
17
- def class_string
18
- TailwindMerge::Merger.new.merge([
19
- *CSS_CLASSES_DEFAULT,
20
- @css_class
21
- ])
22
- end
23
14
  end
24
15
  end
25
16
  end
@@ -11,15 +11,6 @@ module UiComponents
11
11
  erb_template <<-ERB
12
12
  <%= tag.div(**set_options) { content } %>
13
13
  ERB
14
-
15
- private
16
-
17
- def class_string
18
- TailwindMerge::Merger.new.merge([
19
- *CSS_CLASSES_DEFAULT,
20
- @css_class
21
- ])
22
- end
23
14
  end
24
15
  end
25
16
  end
@@ -4,7 +4,7 @@ module UiComponents
4
4
  module DaisyUi
5
5
  module Action
6
6
  class SwapComponent < BaseComponent
7
- EFFECTS = %w[rotate flip]
7
+ EFFECTS = %w[rotate flip].freeze
8
8
 
9
9
  CSS_CLASSES_DEFAULT = %w[swap].freeze
10
10
  CSS_CLASSES_VARIANTS = (
@@ -37,20 +37,20 @@ module UiComponents
37
37
 
38
38
  private
39
39
 
40
- def class_string
40
+ def css_class_string
41
41
  TailwindMerge::Merger.new.merge([
42
42
  *CSS_CLASSES_DEFAULT,
43
- effect_class,
44
- active_class,
43
+ effect_css_class,
44
+ active_css_class,
45
45
  @css_class
46
46
  ])
47
47
  end
48
48
 
49
- def effect_class
49
+ def effect_css_class
50
50
  "swap-#{@effect}" if EFFECTS.include?(@effect)
51
51
  end
52
52
 
53
- def active_class
53
+ def active_css_class
54
54
  "swap-active" if @active
55
55
  end
56
56
  end
@@ -15,6 +15,8 @@ module UiComponents
15
15
  CSS_CLASSES_VARIANTS = %w[].freeze
16
16
  CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
17
17
 
18
+ attr_accessor :slot_order
19
+
18
20
  def initialize(
19
21
  css_class: nil,
20
22
  css_style: nil,
@@ -23,18 +25,37 @@ module UiComponents
23
25
  @css_class = css_class.to_s
24
26
  @css_style = css_style.to_s
25
27
  @options = options
28
+
29
+ @slot_order = []
30
+ end
31
+
32
+ def self.tracks_slot_order(slots)
33
+ slots.each do |slot|
34
+ singularized = slot.to_s.singularize
35
+ alias_method "original_with_#{singularized}", "with_#{singularized}"
36
+
37
+ define_method "with_#{singularized}" do |*args, **kwargs, &block|
38
+ @slot_order << slot unless @slot_order.include?(slot)
39
+
40
+ send("original_with_#{singularized}", *args, **kwargs, &block)
41
+ end
42
+ end
26
43
  end
27
44
 
28
45
  private
29
46
 
30
47
  def set_options
31
- @options.merge!(class: class_string)
48
+ @options.merge!(class: css_class_string)
32
49
  @options.merge!(style: @css_style) if @css_style.present?
50
+ other_options if respond_to?(:other_options, true)
33
51
  @options.compact_blank!
34
52
  end
35
53
 
36
- def class_string
37
- @css_class
54
+ def css_class_string
55
+ TailwindMerge::Merger.new.merge([
56
+ *self.class::CSS_CLASSES_DEFAULT,
57
+ @css_class
58
+ ])
38
59
  end
39
60
  end
40
61
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Accordion
7
+ module Item
8
+ class AnchorComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[collapse-title].freeze
10
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
11
+
12
+ erb_template <<-ERB
13
+ <%= tag.div(**set_options) { content } %>
14
+ ERB
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Accordion
7
+ module Item
8
+ class BodyComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[collapse-content].freeze
10
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
11
+
12
+ erb_template <<-ERB
13
+ <%= tag.div(**set_options) { content } %>
14
+ ERB
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end