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
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Countdown
7
+ class ItemComponent < BaseComponent
8
+ erb_template <<-ERB
9
+ <%= tag.span(**set_options) %>
10
+ <%= @label %>
11
+ ERB
12
+
13
+ def initialize(
14
+ value:,
15
+ type: "second",
16
+ label: nil,
17
+ automatic:,
18
+ **args
19
+ )
20
+ @value = value.to_s
21
+ @type = type.to_s
22
+ @label = label.to_s
23
+ @automatic = automatic
24
+
25
+ super(**args)
26
+ end
27
+
28
+ private
29
+
30
+ def other_options
31
+ @options.merge!(style: style_string)
32
+ @options.merge!("aria-live": "polite")
33
+ @options.merge!("aria-label": @value)
34
+
35
+ return unless @automatic
36
+
37
+ @options.merge!("data-countdown-type": @type)
38
+ @options.merge!("data-countdown-target": "value")
39
+ end
40
+
41
+ def style_string
42
+ @css_style += "--value:#{@value};"
43
+ @css_style
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ class CountdownComponent < BaseComponent
7
+ CSS_CLASSES_DEFAULT = %w[countdown].freeze
8
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
9
+
10
+ erb_template <<-ERB
11
+ <%= tag.span(**set_options) do %>
12
+ <% items.each do |item| %>
13
+ <%= item %>
14
+ <% end %>
15
+ <% end %>
16
+ ERB
17
+
18
+ renders_many :items, ->(**args) { Countdown::ItemComponent.new(**args.merge(automatic: @automatic)) }
19
+
20
+ def initialize(
21
+ automatic: true,
22
+ **args
23
+ )
24
+ @automatic = automatic
25
+
26
+ super(**args)
27
+ end
28
+
29
+ private
30
+
31
+ def other_options
32
+ @options.merge!("data-controller": "countdown") if @automatic
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -3,9 +3,9 @@
3
3
  module UiComponents
4
4
  module DaisyUi
5
5
  module DataDisplay
6
- module Accordion
7
- class AnchorComponent < BaseComponent
8
- CSS_CLASSES_DEFAULT = %w[collapse-title].freeze
6
+ module Diff
7
+ class Item1Component < BaseComponent
8
+ CSS_CLASSES_DEFAULT = %w[diff-item-1].freeze
9
9
  CSS_CLASSES = CSS_CLASSES_DEFAULT
10
10
 
11
11
  erb_template <<-ERB
@@ -14,11 +14,8 @@ module UiComponents
14
14
 
15
15
  private
16
16
 
17
- def class_string
18
- TailwindMerge::Merger.new.merge([
19
- *CSS_CLASSES_DEFAULT,
20
- @css_class
21
- ])
17
+ def other_options
18
+ @options.merge!(role: "img")
22
19
  end
23
20
  end
24
21
  end
@@ -3,9 +3,9 @@
3
3
  module UiComponents
4
4
  module DaisyUi
5
5
  module DataDisplay
6
- module Accordion
7
- class BodyComponent < BaseComponent
8
- CSS_CLASSES_DEFAULT = %w[collapse-content].freeze
6
+ module Diff
7
+ class Item2Component < BaseComponent
8
+ CSS_CLASSES_DEFAULT = %w[diff-item-2].freeze
9
9
  CSS_CLASSES = CSS_CLASSES_DEFAULT
10
10
 
11
11
  erb_template <<-ERB
@@ -14,11 +14,9 @@ module UiComponents
14
14
 
15
15
  private
16
16
 
17
- def class_string
18
- TailwindMerge::Merger.new.merge([
19
- *CSS_CLASSES_DEFAULT,
20
- @css_class
21
- ])
17
+ def other_options
18
+ @options.merge!(role: "img")
19
+ @options.merge!(tabindex: "0")
22
20
  end
23
21
  end
24
22
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Diff
7
+ class ResizerComponent < BaseComponent
8
+ CSS_CLASSES_DEFAULT = %w[diff-resizer].freeze
9
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
10
+
11
+ erb_template <<-ERB
12
+ <%= tag.div(**set_options) %>
13
+ ERB
14
+
15
+ private
16
+
17
+ def other_options
18
+ @options.merge!(role: "img")
19
+ @options.merge!(tabindex: "0")
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ class DiffComponent < BaseComponent
7
+ CSS_CLASSES_DEFAULT = %w[diff].freeze
8
+ CSS_CLASSES = (
9
+ CSS_CLASSES_DEFAULT +
10
+ Diff::Item1Component::CSS_CLASSES +
11
+ Diff::Item2Component::CSS_CLASSES +
12
+ Diff::ResizerComponent::CSS_CLASSES
13
+ ).freeze
14
+
15
+ erb_template <<-ERB
16
+ <%= tag.figure(**set_options) do %>
17
+ <%= item1 %>
18
+ <%= item2 %>
19
+ <%= resizer %>
20
+ <% end %>
21
+ ERB
22
+
23
+ renders_one :item1, Diff::Item1Component
24
+ renders_one :item2, Diff::Item2Component
25
+ renders_one :resizer, Diff::ResizerComponent
26
+
27
+ private
28
+
29
+ def other_options
30
+ @options.merge!(tabindex: "0")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ class KbdComponent < BaseComponent
7
+ CSS_CLASSES_DEFAULT = %w[kbd].freeze
8
+ CSS_CLASSES_VARIANTS = (SIZES.map { |key| "kbd-#{key}" }).freeze
9
+ CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
10
+
11
+ erb_template <<-ERB
12
+ <%= tag.kbd(**set_options) { content } %>
13
+ ERB
14
+
15
+ def initialize(
16
+ size: nil,
17
+ **args
18
+ )
19
+ @size = size
20
+
21
+ super(**args)
22
+ end
23
+
24
+ private
25
+
26
+ def css_class_string
27
+ TailwindMerge::Merger.new.merge([
28
+ *CSS_CLASSES_DEFAULT,
29
+ size_css_class,
30
+ @css_class
31
+ ])
32
+ end
33
+
34
+ def size_css_class
35
+ "kbd-#{@size}" if SIZES.include?(@size)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module List
7
+ class ItemComponent < BaseComponent
8
+ CSS_CLASSES_DEFAULT = %w[list-row].freeze
9
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
10
+
11
+ erb_template <<-ERB
12
+ <%= tag.li(**set_options) { content } %>
13
+ ERB
14
+
15
+ def initialize(
16
+ row: true,
17
+ **args
18
+ )
19
+ @row = row
20
+
21
+ super(**args)
22
+ end
23
+
24
+ private
25
+
26
+ def css_class_string
27
+ TailwindMerge::Merger.new.merge([
28
+ *css_classes_default,
29
+ @css_class
30
+ ])
31
+ end
32
+
33
+ def css_classes_default
34
+ CSS_CLASSES_DEFAULT if @row
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ class ListComponent < BaseComponent
7
+ CSS_CLASSES_DEFAULT = %w[list bg-base-100 rounded-box shadow-md].freeze
8
+ CSS_CLASSES = (CSS_CLASSES_DEFAULT + List::ItemComponent::CSS_CLASSES).freeze
9
+
10
+ erb_template <<-ERB
11
+ <%= tag.ul(**set_options) do %>
12
+ <% items.each do |item| %>
13
+ <%= item %>
14
+ <% end %>
15
+ <% end %>
16
+ ERB
17
+
18
+ renders_many :items, List::ItemComponent
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Stat
7
+ module Item
8
+ class ActionComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[stat-actions].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 Stat
7
+ module Item
8
+ class DescriptionComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[stat-desc].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,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Stat
7
+ module Item
8
+ class FigureComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[stat-figure].freeze
10
+ CSS_CLASSES = CSS_CLASSES_DEFAULT
11
+
12
+ erb_template <<-ERB
13
+ <%= tag.div(**set_options) do %>
14
+ <%= avatar ? avatar : content %>
15
+ <% end %>
16
+ ERB
17
+
18
+ renders_one :avatar, Avatar::ItemComponent
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Stat
7
+ module Item
8
+ class TitleComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[stat-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 Stat
7
+ module Item
8
+ class ValueComponent < BaseComponent
9
+ CSS_CLASSES_DEFAULT = %w[stat-value].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,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Stat
7
+ class ItemComponent < BaseComponent
8
+ CSS_CLASSES_DEFAULT = %w[stat].freeze
9
+ CSS_CLASSES = (
10
+ CSS_CLASSES_DEFAULT +
11
+ Item::FigureComponent::CSS_CLASSES +
12
+ Item::TitleComponent::CSS_CLASSES +
13
+ Item::ValueComponent::CSS_CLASSES +
14
+ Item::DescriptionComponent::CSS_CLASSES +
15
+ Item::ActionComponent::CSS_CLASSES
16
+ ).freeze
17
+
18
+ erb_template <<-ERB
19
+ <%= tag.div(**set_options) do %>
20
+ <% content.present? %>
21
+
22
+ <% slot_order.each do |slot| %>
23
+ <%= send(slot) if send(slot).present? %>
24
+ <% end %>
25
+ <% end %>
26
+ ERB
27
+
28
+ renders_one :figure, Item::FigureComponent
29
+ renders_one :title, Item::TitleComponent
30
+ renders_one :value, Item::ValueComponent
31
+ renders_one :description, Item::DescriptionComponent
32
+ renders_one :action, Item::ActionComponent
33
+
34
+ tracks_slot_order registered_slots.keys
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ # froze_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ class StatComponent < BaseComponent
7
+ CSS_CLASSES_DEFAULT = %w[stats shadow].freeze
8
+ CSS_CLASSES_VARIANTS = %w[stats-horizontal stats-vertical].freeze
9
+ CSS_CLASSES = (
10
+ CSS_CLASSES_DEFAULT +
11
+ CSS_CLASSES_VARIANTS +
12
+ Stat::ItemComponent::CSS_CLASSES
13
+ ).freeze
14
+
15
+ erb_template <<-ERB
16
+ <%= tag.div(**set_options) do %>
17
+ <% items.each do |item| %>
18
+ <%= item %>
19
+ <% end %>
20
+ <% end %>
21
+ ERB
22
+
23
+ renders_many :items, Stat::ItemComponent
24
+
25
+ def initialize(
26
+ vertical: false,
27
+ **args
28
+ )
29
+ @vertical = vertical
30
+
31
+ super(**args)
32
+ end
33
+
34
+ private
35
+
36
+ def css_class_string
37
+ TailwindMerge::Merger.new.merge([
38
+ *CSS_CLASSES_DEFAULT,
39
+ vertical_css_class,
40
+ @css_class
41
+ ])
42
+ end
43
+
44
+ def vertical_css_class
45
+ "stats-vertical" if @vertical
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ class StatusComponent < BaseComponent
7
+ ANIMATIONS = %w[ping bounce].freeze
8
+
9
+ CSS_CLASSES_DEFAULT = %w[status].freeze
10
+ CSS_CLASSES_VARIANTS = (
11
+ SIZES.map { |key| "status-#{key}" } +
12
+ COLORS.map { |key| "status-#{key}" }
13
+ ).freeze
14
+ CSS_CLASSES = (CSS_CLASSES_DEFAULT + CSS_CLASSES_VARIANTS).freeze
15
+
16
+ erb_template <<-ERB
17
+ <%= tag.div(**set_options) %>
18
+ ERB
19
+
20
+ def initialize(
21
+ size: nil,
22
+ color: nil,
23
+ animate: nil,
24
+ **args
25
+ )
26
+ @size = size
27
+ @color = color
28
+ @animate = animate
29
+
30
+ super(**args)
31
+ end
32
+
33
+ private
34
+
35
+ def css_class_string
36
+ TailwindMerge::Merger.new.merge([
37
+ *CSS_CLASSES_DEFAULT,
38
+ size_css_class,
39
+ color_css_class,
40
+ animate_css_class,
41
+ @css_class
42
+ ])
43
+ end
44
+
45
+ def size_css_class
46
+ "status-#{@size}" if SIZES.include?(@size)
47
+ end
48
+
49
+ def color_css_class
50
+ "status-#{@color}" if COLORS.include?(@color)
51
+ end
52
+
53
+ def animate_css_class
54
+ "animate-#{@animate}" if ANIMATIONS.include?(@animate)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Table
7
+ module Item
8
+ class BodyComponent < BaseComponent
9
+ erb_template <<-ERB
10
+ <%= tag.tbody(**set_options) do %>
11
+ <% rows.each do |row| %>
12
+ <%= row %>
13
+ <% end %>
14
+ <% end %>
15
+ ERB
16
+
17
+ renders_many :rows, RowComponent
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Table
7
+ module Item
8
+ class FootComponent < BaseComponent
9
+ erb_template <<-ERB
10
+ <%= tag.tfoot(**set_options) do %>
11
+ <% rows.each do |row| %>
12
+ <%= row %>
13
+ <% end %>
14
+ <% end %>
15
+ ERB
16
+
17
+ renders_many :rows, RowComponent
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Table
7
+ module Item
8
+ class HeadComponent < BaseComponent
9
+ erb_template <<-ERB
10
+ <%= tag.thead(**set_options) do %>
11
+ <% rows.each do |row| %>
12
+ <%= row %>
13
+ <% end %>
14
+ <% end %>
15
+ ERB
16
+
17
+ renders_many :rows, RowComponent
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Table
7
+ module Item
8
+ module Row
9
+ class DataComponent < BaseComponent
10
+ erb_template <<-ERB
11
+ <%= tag.td(**set_options) { content } %>
12
+ ERB
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiComponents
4
+ module DaisyUi
5
+ module DataDisplay
6
+ module Table
7
+ module Item
8
+ module Row
9
+ class HeaderComponent < BaseComponent
10
+ erb_template <<-ERB
11
+ <%= tag.th(**set_options) { content } %>
12
+ ERB
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end