loco_motion-rails 0.0.8 → 0.5.0

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -14
  3. data/app/components/daisy/actions/button_component.html.haml +2 -2
  4. data/app/components/daisy/actions/button_component.rb +98 -59
  5. data/app/components/daisy/actions/dropdown_component.html.haml +1 -2
  6. data/app/components/daisy/actions/dropdown_component.rb +7 -10
  7. data/app/components/daisy/actions/modal_component.html.haml +10 -8
  8. data/app/components/daisy/actions/modal_component.rb +6 -6
  9. data/app/components/daisy/actions/swap_component.rb +13 -9
  10. data/app/components/daisy/actions/theme_controller.js +113 -0
  11. data/app/components/daisy/actions/theme_controller_component.rb +58 -17
  12. data/app/components/daisy/actions/theme_preview_component.html.haml +5 -0
  13. data/app/components/daisy/actions/theme_preview_component.rb +68 -0
  14. data/app/components/daisy/data_display/accordion_component.html.haml +0 -1
  15. data/app/components/daisy/data_display/accordion_component.rb +10 -3
  16. data/app/components/daisy/data_display/avatar_component.html.haml +1 -1
  17. data/app/components/daisy/data_display/avatar_component.rb +17 -7
  18. data/app/components/daisy/data_display/badge_component.rb +122 -4
  19. data/app/components/daisy/data_display/card_component.html.haml +1 -1
  20. data/app/components/daisy/data_display/card_component.rb +20 -6
  21. data/app/components/daisy/data_display/chat_component.rb +2 -2
  22. data/app/components/daisy/data_display/collapse_component.rb +9 -5
  23. data/app/components/daisy/data_display/countdown_component.rb +15 -5
  24. data/app/components/daisy/data_display/figure_component.rb +8 -3
  25. data/app/components/daisy/data_display/kbd_component.rb +13 -4
  26. data/app/components/daisy/data_display/list_component.html.haml +5 -0
  27. data/app/components/daisy/data_display/list_component.rb +82 -0
  28. data/app/components/daisy/data_display/list_item_component.rb +39 -0
  29. data/app/components/daisy/data_display/stat_component.html.haml +5 -6
  30. data/app/components/daisy/data_display/stat_component.rb +21 -8
  31. data/app/components/daisy/data_display/status_component.rb +47 -0
  32. data/app/components/daisy/data_display/timeline_component.rb +1 -1
  33. data/app/components/daisy/data_input/cally_component.html.haml +14 -0
  34. data/app/components/daisy/data_input/cally_component.rb +182 -0
  35. data/app/components/daisy/data_input/cally_input_component.html.haml +5 -0
  36. data/app/components/daisy/data_input/cally_input_component.rb +165 -0
  37. data/app/components/daisy/data_input/cally_input_controller.js +235 -0
  38. data/app/components/daisy/data_input/checkbox_component.html.haml +20 -0
  39. data/app/components/daisy/data_input/checkbox_component.rb +106 -0
  40. data/app/components/daisy/data_input/fieldset_component.html.haml +8 -0
  41. data/app/components/daisy/data_input/fieldset_component.rb +57 -0
  42. data/app/components/daisy/data_input/file_input_component.rb +98 -0
  43. data/app/components/daisy/data_input/filter_component.html.haml +3 -0
  44. data/app/components/daisy/data_input/filter_component.rb +221 -0
  45. data/app/components/daisy/data_input/label_component.rb +84 -0
  46. data/app/components/daisy/data_input/radio_button_component.rb +87 -0
  47. data/app/components/daisy/data_input/range_component.rb +95 -0
  48. data/app/components/daisy/data_input/rating_component.html.haml +11 -0
  49. data/app/components/daisy/data_input/rating_component.rb +139 -0
  50. data/app/components/daisy/data_input/select_component.html.haml +27 -0
  51. data/app/components/daisy/data_input/select_component.rb +320 -0
  52. data/app/components/daisy/data_input/text_area_component.rb +127 -0
  53. data/app/components/daisy/data_input/text_input_component.html.haml +27 -0
  54. data/app/components/daisy/data_input/text_input_component.rb +142 -0
  55. data/app/components/daisy/data_input/toggle_component.rb +48 -0
  56. data/app/components/daisy/feedback/alert_component.html.haml +1 -1
  57. data/app/components/daisy/feedback/alert_component.rb +86 -2
  58. data/app/components/daisy/feedback/loading_component.rb +10 -3
  59. data/app/components/daisy/feedback/skeleton_component.rb +1 -1
  60. data/app/components/daisy/layout/divider_component.rb +4 -2
  61. data/app/components/daisy/layout/drawer_component.html.haml +0 -1
  62. data/app/components/daisy/layout/footer_component.rb +6 -6
  63. data/app/components/daisy/mockup/device_component.rb +15 -18
  64. data/app/components/daisy/navigation/breadcrumbs_component.html.haml +0 -1
  65. data/app/components/daisy/navigation/breadcrumbs_component.rb +84 -9
  66. data/app/components/daisy/navigation/dock_component.rb +146 -0
  67. data/app/components/daisy/navigation/link_component.rb +18 -9
  68. data/app/components/daisy/navigation/menu_component.rb +15 -9
  69. data/app/components/daisy/navigation/navbar_component.html.haml +1 -1
  70. data/app/components/daisy/navigation/navbar_component.rb +2 -13
  71. data/app/components/daisy/navigation/steps_component.rb +6 -6
  72. data/app/components/daisy/navigation/tabs_component.html.haml +0 -1
  73. data/app/components/daisy/navigation/tabs_component.rb +26 -16
  74. data/app/components/hero/icon_component.rb +15 -5
  75. data/app/helpers/daisy/form_builder_helper.rb +186 -0
  76. data/app/views/examples/daisy/data_input/filters.html.haml +62 -0
  77. data/lib/daisy.rb +5 -0
  78. data/lib/hero.rb +1 -1
  79. data/lib/loco_motion/base_component.rb +53 -3
  80. data/lib/loco_motion/component_config.rb +1 -0
  81. data/lib/loco_motion/concerns/iconable_component.rb +134 -0
  82. data/lib/loco_motion/concerns/labelable_component.rb +142 -0
  83. data/lib/loco_motion/concerns/linkable_component.rb +40 -0
  84. data/lib/loco_motion/concerns/tippable_component.rb +25 -10
  85. data/lib/loco_motion/engine.rb +6 -0
  86. data/lib/loco_motion/helpers.rb +38 -17
  87. data/lib/loco_motion/patches/view_component/slot_loco_parent_patch.rb +37 -0
  88. data/lib/loco_motion/patches/view_component/slotable_default_patch.rb +21 -0
  89. data/lib/loco_motion/version.rb +1 -1
  90. data/lib/loco_motion.rb +12 -2
  91. metadata +93 -21
  92. data/app/components/daisy/actions/theme_controller_component.html.haml +0 -5
  93. data/app/components/daisy/layout/artboard_component.rb +0 -59
  94. data/app/components/daisy/navigation/bottom_nav_component.rb +0 -138
@@ -9,6 +9,12 @@
9
9
  # @part content_wrapper [HTML] A wrapper for the main content of the alert.
10
10
  # This allows for proper spacing and alignment with the icon.
11
11
  #
12
+ # @option kws [String] :style (:default) The style of the alert.
13
+ # [:info, :success, :warning, :error, :default]
14
+ # @option kws [Boolean] :soft (false) Use the soft style variant.
15
+ # @option kws [Boolean] :outline (false) Use the outline style variant.
16
+ # @option kws [Boolean] :dash (false) Use the dash style variant.
17
+ #
12
18
  # @loco_example Basic Alert
13
19
  # = daisy_alert do
14
20
  # This is a standard alert message.
@@ -30,7 +36,77 @@
30
36
  # = daisy_alert(icon: "exclamation-circle", css: "alert-error", icon_html: { variant: :outline }) do
31
37
  # Error alert.
32
38
  #
39
+ # @loco_example Default
40
+ # = daisy_alert do
41
+ # This is an default alert.
42
+ #
43
+ # @loco_example Info
44
+ # = daisy_alert(css: "alert-info") do
45
+ # This is an info alert.
46
+ #
47
+ # @loco_example Success
48
+ # = daisy_alert(css: "alert-success") do
49
+ # This is a success alert.
50
+ #
51
+ # @loco_example Warning
52
+ # = daisy_alert(css: "alert-warning") do
53
+ # This is a warning alert.
54
+ #
55
+ # @loco_example Error
56
+ # = daisy_alert(css: "alert-error") do
57
+ # This is an error alert.
58
+ #
59
+ # @loco_example Soft Info
60
+ # = daisy_alert(css: "alert-info alert-soft") do
61
+ # This is a soft info alert.
62
+ #
63
+ # @loco_example Soft Success
64
+ # = daisy_alert(css: "alert-success alert-soft") do
65
+ # This is a soft success alert.
66
+ #
67
+ # @loco_example Soft Warning
68
+ # = daisy_alert(css: "alert-warning alert-soft") do
69
+ # This is a soft warning alert.
70
+ #
71
+ # @loco_example Soft Error
72
+ # = daisy_alert(css: "alert-error alert-soft") do
73
+ # This is a soft error alert.
74
+ #
75
+ # @loco_example Outline Info
76
+ # = daisy_alert(css: "alert-info alert-outline") do
77
+ # This is an outline info alert.
78
+ #
79
+ # @loco_example Outline Success
80
+ # = daisy_alert(css: "alert-success alert-outline") do
81
+ # This is an outline success alert.
82
+ #
83
+ # @loco_example Outline Warning
84
+ # = daisy_alert(css: "alert-warning alert-outline") do
85
+ # This is an outline warning alert.
86
+ #
87
+ # @loco_example Outline Error
88
+ # = daisy_alert(css: "alert-error alert-outline") do
89
+ # This is an outline error alert.
90
+ #
91
+ # @loco_example Dash Info
92
+ # = daisy_alert(css: "alert-info alert-dash") do
93
+ # This is a dash info alert.
94
+ #
95
+ # @loco_example Dash Success
96
+ # = daisy_alert(css: "alert-success alert-dash") do
97
+ # This is a dash success alert.
98
+ #
99
+ # @loco_example Dash Warning
100
+ # = daisy_alert(css: "alert-warning alert-dash") do
101
+ # This is a dash warning alert.
102
+ #
103
+ # @loco_example Dash Error
104
+ # = daisy_alert(css: "alert-error alert-dash") do
105
+ # This is a dash error alert.
106
+ #
33
107
  class Daisy::Feedback::AlertComponent < LocoMotion::BaseComponent
108
+ include LocoMotion::Concerns::IconableComponent
109
+
34
110
  define_parts :icon, :content_wrapper
35
111
 
36
112
  #
@@ -49,16 +125,24 @@ class Daisy::Feedback::AlertComponent < LocoMotion::BaseComponent
49
125
  # `alert-info`, `alert-success`, `alert-warning`, or `alert-error` for
50
126
  # different alert types.
51
127
  #
128
+ # @option kws style [String] The style of the alert.
129
+ # [:info, :success, :warning, :error, :default]
130
+ # @option kws soft [Boolean] Use the soft style variant.
131
+ # @option kws outline [Boolean] Use the outline style variant.
132
+ # @option kws dash [Boolean] Use the dash style variant.
133
+ #
52
134
  def initialize(*args, **kws, &block)
53
135
  super
54
136
 
55
137
  @icon = config_option(:icon)
56
138
  end
57
139
 
140
+ def default_icon_size
141
+ "where:size-6"
142
+ end
143
+
58
144
  def before_render
59
145
  add_css(:component, "alert")
60
146
  add_html(:component, { role: "alert" })
61
-
62
- add_css(:icon, "[:where(&)]:size-8")
63
147
  end
64
148
  end
@@ -20,7 +20,7 @@
20
20
  # readability, but CSS classes must still use the `loading-*` prefix.
21
21
  #
22
22
  class Daisy::Feedback::LoadingComponent < LocoMotion::BaseComponent
23
- prepend LocoMotion::Concerns::TippableComponent
23
+ include LocoMotion::Concerns::TippableComponent
24
24
 
25
25
  #
26
26
  # Creates a new Loading component.
@@ -41,10 +41,17 @@ class Daisy::Feedback::LoadingComponent < LocoMotion::BaseComponent
41
41
  end
42
42
 
43
43
  def before_render
44
- add_css(:component, "loading")
44
+ setup_component
45
+ super
45
46
  end
46
-
47
+
47
48
  def call
48
49
  part(:component)
49
50
  end
51
+
52
+ private
53
+
54
+ def setup_component
55
+ add_css(:component, "loading")
56
+ end
50
57
  end
@@ -10,7 +10,7 @@
10
10
  # loading states.
11
11
  #
12
12
  # @loco_example Basic Shapes
13
- # = daisy_skeleton(css: "w-24 h-24 rounded-full")
13
+ # = daisy_skeleton(css: "size-24 rounded-full")
14
14
  # = daisy_skeleton(css: "w-36 h-20")
15
15
  # = daisy_skeleton(css: "w-48 h-5")
16
16
  #
@@ -51,8 +51,10 @@ class Daisy::Layout::DividerComponent < LocoMotion::BaseComponent
51
51
  # `divider-accent`, `divider-info`, `divider-success`,
52
52
  # `divider-warning`, `divider-error`
53
53
  #
54
- def initialize(*args, **kws, &block)
54
+ def initialize(title = nil, **kws, &block)
55
55
  super
56
+
57
+ @simple_title = config_option(:title, title)
56
58
  end
57
59
 
58
60
  #
@@ -66,7 +68,7 @@ class Daisy::Layout::DividerComponent < LocoMotion::BaseComponent
66
68
  # Renders the component and its content.
67
69
  #
68
70
  def call
69
- part(:component) { content }
71
+ part(:component) { content || @simple_title }
70
72
  end
71
73
 
72
74
  end
@@ -5,5 +5,4 @@
5
5
  = content
6
6
 
7
7
  - if sidebar?
8
- - sidebar.set_loco_parent(component_ref)
9
8
  = sidebar
@@ -6,10 +6,10 @@
6
6
  # - Contact details and social media links.
7
7
  # - Newsletter signup forms.
8
8
  #
9
- # The component is responsive by default and will stack content on smaller
10
- # screens.
9
+ # @note Footers are vertical by default. Use `footer-horizontal` to make it
10
+ # horizontal at your desired screen size (e.g., `lg:footer-horizontal`).
11
11
  #
12
- # @loco_example Basic Navigation Footer
12
+ # @loco_example Basic Navigation Footer (Vertical)
13
13
  # = daisy_footer(css: "bg-neutral text-neutral-content p-10") do
14
14
  # %nav
15
15
  # %h6.footer-title Company
@@ -17,8 +17,8 @@
17
17
  # = link_to "Contact", "/contact", class: "link-hover"
18
18
  # = link_to "Jobs", "/careers", class: "link-hover"
19
19
  #
20
- # @loco_example Multi-Column Footer
21
- # = daisy_footer(css: "bg-base-200 text-base-content p-10") do
20
+ # @loco_example Horizontal Footer
21
+ # = daisy_footer(css: "bg-base-200 text-base-content p-10 lg:footer-horizontal") do
22
22
  # %nav
23
23
  # %h6.footer-title Products
24
24
  # = link_to "Features", "#", class: "link-hover"
@@ -46,7 +46,7 @@ class Daisy::Layout::FooterComponent < LocoMotion::BaseComponent
46
46
  # - Background: `bg-neutral`, `bg-base-200`
47
47
  # - Text color: `text-neutral-content`, `text-base-content`
48
48
  # - Spacing: `p-4`, `p-10`
49
- # - Layout: `text-center`, `grid grid-cols-2 gap-4`
49
+ # - Layout: `text-center`, `footer-horizontal` (or `lg:footer-horizontal` for large screens)
50
50
  #
51
51
  def initialize(**kws)
52
52
  super
@@ -7,33 +7,30 @@
7
7
  # - Building portfolio pieces.
8
8
  #
9
9
  # The component includes an optional camera element and a display area that
10
- # can contain any content, typically an ArtboardComponent for proper sizing.
10
+ # can contain any content with appropriate sizing classes.
11
11
  #
12
12
  # @part camera The device's camera element, shown at the top by default.
13
13
  # @part display The main display area of the device.
14
14
  #
15
15
  # @loco_example Phone with Camera
16
- # = daisy_device(css: "mockup-phone") do
17
- # = daisy_artboard(css: "phone-2") do
18
- # .flex.flex-col.p-4
19
- # .text-2xl.font-bold
20
- # My App
21
- # = image_tag("screenshot.jpg",
22
- # class: "rounded-lg")
16
+ # = daisy_device(css: "mockup-phone", display_css: "overflow-auto") do
17
+ # .flex.flex-col.gap-4.p-4.pt-12.pb-8.bg-white
18
+ # .text-2xl.font-bold
19
+ # My App
20
+ # = image_tag("screenshot.jpg",
21
+ # class: "rounded-lg")
23
22
  #
24
23
  # @loco_example Tablet without Camera
25
24
  # = daisy_device(css: "mockup-phone border-primary",
26
- # show_camera: false) do
27
- # = daisy_artboard(css: "artboard-horizontal phone-3") do
28
- # .bg-base-100.p-4
29
- # Tablet Content Here
25
+ # display_css: "overflow-auto w-[736px] h-[414px]", show_camera: false) do
26
+ # .flex.flex-col.gap-4.p-4.bg-white
27
+ # Tablet Content Here
30
28
  #
31
29
  # @loco_example Styled Device
32
30
  # = daisy_device(css: "mockup-phone border-4
33
- # border-accent shadow-xl") do
34
- # = daisy_artboard(css: "phone-1") do
35
- # .bg-gradient-to-br.from-primary.to-accent.p-4
36
- # Premium App Design
31
+ # border-accent shadow-xl", display_css: "w-[320px] h-[568px]") do
32
+ # .flex.flex-col.p-4.bg-gradient-to-br.from-primary.to-accent
33
+ # Premium App Design
37
34
  #
38
35
  class Daisy::Mockup::DeviceComponent < LocoMotion::BaseComponent
39
36
 
@@ -60,8 +57,8 @@ class Daisy::Mockup::DeviceComponent < LocoMotion::BaseComponent
60
57
  # Sets up the component's CSS classes.
61
58
  #
62
59
  def before_render
63
- add_css(:camera, "camera")
64
- add_css(:display, "display")
60
+ add_css(:camera, "mockup-phone-camera")
61
+ add_css(:display, "mockup-phone-display")
65
62
  add_css(:display, "!mt-0") if !@show_camera
66
63
  end
67
64
 
@@ -1,7 +1,6 @@
1
1
  = part(:component) do
2
2
  = part(:list_wrapper) do
3
3
  - items.each do |item|
4
- - item.set_loco_parent(component_ref)
5
4
  = item
6
5
 
7
6
  = content
@@ -7,16 +7,14 @@
7
7
  # @slot items+ {LocoMotion::BasicComponent} The individual breadcrumb items.
8
8
  # Each item is rendered as a list item (`<li>`) element.
9
9
  #
10
- # @example Basic breadcrumbs with text
10
+ # @loco_example Basic breadcrumbs with text
11
11
  # = daisy_breadcrumbs do |breadcrumbs|
12
- # - breadcrumbs.with_item do
13
- # = link_to "Home", "#"
14
- # - breadcrumbs.with_item do
15
- # = link_to "Docs", "#"
16
- # - breadcrumbs.with_item do
17
- # = link_to "Components", "#"
12
+ # - breadcrumbs.with_item(title: "Docs", href: "/")
13
+ # - breadcrumbs.with_item("Breadcrumbs", "/examples")
14
+ # - breadcrumbs.with_item(css: "italic") do
15
+ # This example
18
16
  #
19
- # @example Breadcrumbs with icons
17
+ # @loco_example Breadcrumbs with icons
20
18
  # = daisy_breadcrumbs do |breadcrumbs|
21
19
  # - breadcrumbs.with_item do
22
20
  # = link_to "#" do
@@ -28,9 +26,82 @@
28
26
  # Docs
29
27
  #
30
28
  class Daisy::Navigation::BreadcrumbsComponent < LocoMotion::BaseComponent
29
+
30
+
31
+ # Component for a single breadcrumb item in a breadcrumbs trail.
32
+ #
33
+ # @part link The link element wrapping the breadcrumb content when an href is
34
+ # provided.
35
+ #
36
+ # @loco_example Simple usage
37
+ # = render Daisy::Navigation::BreadcrumbItemComponent.new("Home", "/")
38
+ #
39
+ # @loco_example With icon
40
+ # = render Daisy::Navigation::BreadcrumbItemComponent.new("Home", "/", icon: :home)
41
+ #
42
+ # @see Daisy::Navigation::BreadcrumbsComponent
43
+ class Daisy::Navigation::BreadcrumbItemComponent < LocoMotion::BaseComponent
44
+ include LocoMotion::Concerns::IconableComponent
45
+ include LocoMotion::Concerns::TippableComponent
46
+
47
+ define_part :link
48
+
49
+ # Initialize a breadcrumb item component.
50
+ #
51
+ # @param title [String, nil] The display text for the breadcrumb.
52
+ #
53
+ # @param href [String, nil] The URL for the breadcrumb link.
54
+ #
55
+ # @param args [Array] Additional positional arguments passed to the
56
+ # component.
57
+ #
58
+ # @param kws [Hash] Additional keyword options.
59
+ #
60
+ # @option kws icon [Symbol] Icon name to display before the title.
61
+ #
62
+ # @option kws tip [String] Tooltip text shown on hover.
63
+ def initialize(title = nil, href = nil, *args, **kws)
64
+ super
65
+
66
+ @simple_title = config_option(:title, title)
67
+ @href = config_option(:href, href)
68
+ end
69
+
70
+ # Configure the component before rendering.
71
+ #
72
+ # Sets the component tag to be a list item and configures the link part with
73
+ # the href value.
74
+ def before_render
75
+ set_tag_name(:component, :li)
76
+
77
+ set_tag_name(:link, "a")
78
+ add_html(:link, { href: @href })
79
+ end
80
+
81
+ def call
82
+ part(:component) do
83
+ if @href
84
+ part(:link) do
85
+ render_icon_and_content
86
+ end
87
+ else
88
+ render_icon_and_content
89
+ end
90
+ end
91
+ end
92
+
93
+ # Render the icon (if provided) and content.
94
+ #
95
+ # @return [String] The rendered HTML for the icon and content.
96
+ def render_icon_and_content
97
+ concat(render_icon)
98
+ concat(content || @simple_title)
99
+ end
100
+ end
101
+
31
102
  define_parts :list_wrapper
32
103
 
33
- renders_many :items, LocoMotion::BasicComponent.build(tag_name: :li)
104
+ renders_many :items, Daisy::Navigation::BreadcrumbItemComponent
34
105
 
35
106
  # Create a new instance of the BreadcrumbsComponent.
36
107
  #
@@ -45,6 +116,10 @@ class Daisy::Navigation::BreadcrumbsComponent < LocoMotion::BaseComponent
45
116
  super(**kws)
46
117
  end
47
118
 
119
+ # Configure the component before rendering.
120
+ #
121
+ # Adds the breadcrumbs CSS class and sets the list wrapper to use an
122
+ # unordered list element.
48
123
  def before_render
49
124
  add_css(:component, "breadcrumbs")
50
125
  set_tag_name(:list_wrapper, :ul)
@@ -0,0 +1,146 @@
1
+ #
2
+ # Creates a dock navigation bar, typically used in mobile-friendly applications
3
+ # to provide quick access to important sections.
4
+ #
5
+ # @slot sections+ {Daisy::Navigation::DockSectionComponent} The sections to display in the dock.
6
+ #
7
+ # @loco_example Basic dock with icons
8
+ # = daisy_dock do |dock|
9
+ # - dock.with_section(icon: "home", href: "#")
10
+ # - dock.with_section(icon: "information-circle", href: "#", active: true)
11
+ # - dock.with_section(icon: "chart-bar", href: "#")
12
+ #
13
+ # @loco_example Dock with titles
14
+ # = daisy_dock do |dock|
15
+ # - dock.with_section(icon: "home", href: "#", title: "Home")
16
+ # - dock.with_section(icon: "information-circle", href: "#", title: "Info")
17
+ # - dock.with_section(icon: "chart-bar", href: "#", title: "Stats")
18
+ #
19
+ # @loco_example Colored dock
20
+ # = daisy_dock do |dock|
21
+ # - dock.with_section(icon: "home", href: "#", css: "text-primary")
22
+ # - dock.with_section(icon: "information-circle", href: "#", css: "text-secondary")
23
+ # - dock.with_section(icon: "chart-bar", href: "#", css: "text-accent")
24
+ #
25
+ class Daisy::Navigation::DockComponent < LocoMotion::BaseComponent
26
+
27
+ #
28
+ # A section within a Dock component.
29
+ #
30
+ # @part icon The icon element for the section.
31
+ # @part title The title element for the section.
32
+ #
33
+ # @loco_example Basic section with icon
34
+ # = daisy_dock do |dock|
35
+ # - dock.with_section(icon: "home", href: "#")
36
+ #
37
+ # @loco_example Active section with title
38
+ # = daisy_dock do |dock|
39
+ # - dock.with_section(icon: "information-circle", href: "#", active: true, title: "Info")
40
+ #
41
+ # @loco_example Custom title content
42
+ # = daisy_dock do |dock|
43
+ # - dock.with_section(icon: "chart-bar", href: "#") do
44
+ # .font-bold.text-xs
45
+ # Stats
46
+ #
47
+ class Daisy::Navigation::DockSectionComponent < LocoMotion::BaseComponent
48
+ include LocoMotion::Concerns::IconableComponent
49
+ include LocoMotion::Concerns::LinkableComponent
50
+
51
+ define_part :title
52
+
53
+ # Creates a new dock section.
54
+ #
55
+ # @param kws [Hash] The keyword arguments for the component.
56
+ #
57
+ # @option kws icon [String] The name of the icon to display.
58
+ #
59
+ # @option kws icon_variant [Symbol] The variant of the icon to use (default: :outline).
60
+ #
61
+ # @option kws icon_css [String] Additional CSS classes for the icon.
62
+ #
63
+ # @option kws title [String] Optional text to display below the icon.
64
+ #
65
+ # @option kws href [String] Optional URL to make the section a link.
66
+ #
67
+ # @option kws active [Boolean] Whether this section is currently active (default: false).
68
+ #
69
+ # @option kws css [String] Additional CSS classes for styling. Common
70
+ # options include:
71
+ # - Text color: `text-primary`, `text-secondary`, `text-accent`
72
+ # - Custom colors: `text-[#449944]`
73
+ #
74
+ def initialize(**kws)
75
+ super(**kws)
76
+
77
+ @icon_variant = config_option(:icon_variant, :outline)
78
+ @title = config_option(:title)
79
+ @active = config_option(:active, false)
80
+ end
81
+
82
+ # Configure the component before rendering.
83
+ #
84
+ # Adds the dock-active class if this section is active and configures the
85
+ # title with appropriate styling.
86
+ def before_render
87
+ super
88
+
89
+ set_tag_name(:component, "button") unless @href
90
+ add_css(:component, "dock-active") if @active
91
+
92
+ set_tag_name(:title, :span)
93
+ add_css(:title, "dock-label")
94
+ end
95
+
96
+ # Render the dock section component with icon, title, and content.
97
+ #
98
+ # @return [String] The rendered HTML for the dock section.
99
+ def call
100
+ part(:component) do
101
+ concat(render_icon)
102
+ concat(part(:title) { @title }) if @title
103
+ concat(content)
104
+ end
105
+ end
106
+
107
+ end
108
+
109
+ renders_many :sections, Daisy::Navigation::DockSectionComponent
110
+
111
+ # Creates a new dock component.
112
+ #
113
+ # @param kws [Hash] The keyword arguments for the component.
114
+ #
115
+ # @option kws css [String] Additional CSS classes for styling. Common
116
+ # options include:
117
+ # - Position: `relative`, `fixed bottom-0`
118
+ # - Width: `w-full`, `max-w-[400px]`
119
+ # - Border: `border`, `border-base-200`
120
+ # - Size: `dock-xs`, `dock-sm`, `dock-md`, `dock-lg`, `dock-xl`
121
+ #
122
+ def initialize(**kws)
123
+ super(**kws)
124
+ end
125
+
126
+ # Configure the component before rendering.
127
+ #
128
+ # Adds the dock CSS class to the component.
129
+ def before_render
130
+ add_css(:component, "dock")
131
+ end
132
+
133
+ # Render the dock component with all its sections and content.
134
+ #
135
+ # @return [String] The rendered HTML for the dock component.
136
+ def call
137
+ part(:component) do
138
+ sections.each do |section|
139
+ concat(section)
140
+ end
141
+
142
+ concat(content)
143
+ end
144
+ end
145
+
146
+ end
@@ -2,22 +2,23 @@
2
2
  # Creates a styled link component that can be used for navigation or inline text
3
3
  # links. This component is designed to work similarly to Rails' `link_to` helper.
4
4
  #
5
- # @example Link with custom styling
5
+ # @loco_example Link with custom styling
6
6
  # = daisy_link "Components", "#", css: "link-primary text-xl"
7
7
  #
8
- # @example Link with block content
8
+ # @loco_example Link with block content
9
9
  # = daisy_link "#", css: "link-hover" do
10
10
  # = hero_icon("home")
11
11
  # Home
12
12
  #
13
- # @example Link with positional arguments
13
+ # @loco_example Link with positional arguments
14
14
  # = daisy_link "Documentation", "#"
15
15
  #
16
- # @example Basic link with keyword arguments
16
+ # @loco_example Basic link with keyword arguments
17
17
  # = daisy_link(title: "Home", href: "#")
18
18
  #
19
19
  class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
20
- prepend LocoMotion::Concerns::TippableComponent
20
+ include LocoMotion::Concerns::TippableComponent
21
+ include LocoMotion::Concerns::LinkableComponent
21
22
 
22
23
  # Create a new instance of the LinkComponent.
23
24
  #
@@ -43,6 +44,9 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
43
44
  # - State: `link-hover`
44
45
  # - Text: `text-sm`, `text-xl`, `text-2xl`
45
46
  #
47
+ # @option kws tip [String] The tooltip text to display when hovering over
48
+ # the component.
49
+ #
46
50
  def initialize(*args, **kws)
47
51
  super
48
52
 
@@ -68,10 +72,9 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
68
72
  # if provided.
69
73
  #
70
74
  def before_render
71
- set_tag_name(:component, :a)
72
- add_css(:component, "link")
73
- add_html(:component, { href: @href }) if @href
74
- add_html(:component, { target: @target }) if @target
75
+ super
76
+
77
+ setup_component
75
78
  end
76
79
 
77
80
  #
@@ -84,4 +87,10 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
84
87
  def call
85
88
  part(:component) { content || @title }
86
89
  end
90
+
91
+ private
92
+
93
+ def setup_component
94
+ add_css(:component, "link")
95
+ end
87
96
  end