loco_motion-rails 0.0.6 → 0.0.8

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +139 -67
  3. data/app/components/daisy/actions/button_component.rb +112 -8
  4. data/app/components/daisy/actions/dropdown_component.html.haml +5 -5
  5. data/app/components/daisy/actions/dropdown_component.rb +95 -26
  6. data/app/components/daisy/actions/modal_component.html.haml +3 -2
  7. data/app/components/daisy/actions/modal_component.rb +111 -20
  8. data/app/components/daisy/actions/swap_component.rb +117 -6
  9. data/app/components/daisy/actions/theme_controller_component.html.haml +1 -1
  10. data/app/components/daisy/actions/theme_controller_component.rb +37 -2
  11. data/app/components/daisy/data_display/accordion_component.rb +81 -4
  12. data/app/components/daisy/data_display/avatar_component.rb +39 -17
  13. data/app/components/daisy/data_display/badge_component.rb +49 -5
  14. data/app/components/daisy/data_display/card_component.html.haml +5 -13
  15. data/app/components/daisy/data_display/card_component.rb +76 -40
  16. data/app/components/daisy/data_display/carousel_component.rb +39 -1
  17. data/app/components/daisy/data_display/chat_component.rb +42 -15
  18. data/app/components/daisy/data_display/collapse_component.rb +61 -2
  19. data/app/components/daisy/data_display/countdown_component.rb +51 -1
  20. data/app/components/daisy/data_display/diff_component.rb +38 -1
  21. data/app/components/daisy/data_display/figure_component.rb +49 -0
  22. data/app/components/daisy/data_display/kbd_component.rb +64 -3
  23. data/app/components/daisy/data_display/stat_component.rb +67 -7
  24. data/app/components/daisy/data_display/table_component.rb +100 -35
  25. data/app/components/daisy/data_display/timeline_component.rb +46 -1
  26. data/app/components/daisy/data_display/timeline_event_component.rb +40 -2
  27. data/app/components/daisy/feedback/alert_component.rb +47 -2
  28. data/app/components/daisy/feedback/loading_component.rb +50 -0
  29. data/app/components/daisy/feedback/progress_component.rb +58 -0
  30. data/app/components/daisy/feedback/radial_progress_component.rb +72 -0
  31. data/app/components/daisy/feedback/skeleton_component.rb +53 -0
  32. data/app/components/daisy/feedback/toast_component.rb +45 -0
  33. data/app/components/daisy/feedback/tooltip_component.rb +77 -0
  34. data/app/components/daisy/layout/artboard_component.rb +59 -0
  35. data/app/components/daisy/layout/divider_component.rb +72 -0
  36. data/app/components/daisy/layout/drawer_component.html.haml +9 -0
  37. data/app/components/daisy/layout/drawer_component.rb +155 -0
  38. data/app/components/daisy/layout/footer_component.rb +69 -0
  39. data/app/components/daisy/layout/hero_component.html.haml +5 -0
  40. data/app/components/daisy/layout/hero_component.rb +83 -0
  41. data/app/components/daisy/layout/indicator_component.rb +83 -0
  42. data/app/components/daisy/layout/join_component.rb +72 -1
  43. data/app/components/daisy/layout/stack_component.rb +68 -0
  44. data/app/components/daisy/mockup/browser_component.rb +78 -0
  45. data/app/components/daisy/mockup/code_component.rb +144 -0
  46. data/app/components/daisy/mockup/device_component.rb +81 -0
  47. data/app/components/daisy/mockup/frame_component.rb +62 -0
  48. data/app/components/daisy/navigation/bottom_nav_component.rb +83 -4
  49. data/app/components/daisy/navigation/breadcrumbs_component.rb +41 -4
  50. data/app/components/daisy/navigation/link_component.rb +66 -13
  51. data/app/components/daisy/navigation/menu_component.rb +83 -11
  52. data/app/components/daisy/navigation/navbar_component.html.haml +1 -1
  53. data/app/components/daisy/navigation/navbar_component.rb +64 -3
  54. data/app/components/daisy/navigation/steps_component.rb +78 -2
  55. data/app/components/daisy/navigation/tabs_component.rb +112 -9
  56. data/app/components/hero/icon_component.rb +50 -1
  57. data/lib/daisy.rb +18 -3
  58. data/lib/hero.rb +7 -0
  59. data/lib/loco_motion/basic_component.rb +1 -1
  60. data/lib/loco_motion/concerns/tippable_component.rb +26 -0
  61. data/lib/loco_motion/configuration.rb +35 -0
  62. data/lib/loco_motion/helpers.rb +96 -0
  63. data/lib/loco_motion/version.rb +5 -0
  64. data/lib/loco_motion.rb +6 -36
  65. metadata +58 -9
  66. data/app/components/daisy/data_display/badge_component.html.haml +0 -2
  67. data/app/components/daisy/data_display/kbd_component.html.haml +0 -2
  68. data/app/components/daisy/navigation/link_component.html.haml +0 -4
  69. data/lib/daisy/helpers.rb +0 -61
@@ -0,0 +1,77 @@
1
+ #
2
+ # The TooltipComponent displays informative text when users hover over an
3
+ # element. It can be used in two ways:
4
+ # 1. As a wrapper component around any HTML content.
5
+ # 2. Through the TippableComponent concern, which many components include.
6
+ #
7
+ # This component is also aliased as `daisy_tip` for convenience.
8
+ #
9
+ # @loco_example Basic Usage
10
+ # = daisy_tip "Helpful information" do
11
+ # %span Need help?
12
+ #
13
+ # = daisy_tip "Delete this item", css: "tooltip-error" do
14
+ # = hero_icon("trash", css: "size-5 text-error")
15
+ #
16
+ # @loco_example Positioned Tips
17
+ # = daisy_tip "Opens settings menu", css: "tooltip-left" do
18
+ # = daisy_button(title: "Settings", icon: "cog-6-tooth")
19
+ #
20
+ # = daisy_tip "View user profile", css: "tooltip-bottom tooltip-info" do
21
+ # = daisy_avatar(src: image_path("avatars/user.jpg"))
22
+ #
23
+ # @loco_example Component Integration
24
+ # = daisy_button(title: "Save Changes",
25
+ # css: "btn-primary",
26
+ # tip: "Save your current progress")
27
+ #
28
+ # = daisy_chat do |chat|
29
+ # - chat.with_avatar(css: "tooltip-left tooltip-info",
30
+ # tip: "Online",
31
+ # src: image_path("avatars/user.jpg"))
32
+ # - chat.with_bubble do
33
+ # Hello!
34
+ #
35
+ class Daisy::Feedback::TooltipComponent < LocoMotion::BaseComponent
36
+
37
+ #
38
+ # Creates a new Tooltip component.
39
+ #
40
+ # @param args [Array] If provided, the first argument is used as the `tip`
41
+ # text.
42
+ # @param kws [Hash] Keyword arguments for customizing the tooltip.
43
+ #
44
+ # @option kws tip [String] The text to display in the tooltip. Can be
45
+ # passed as the first positional argument or as a keyword argument.
46
+ #
47
+ # @option kws css [String] Additional CSS classes for styling. Common
48
+ # options include:
49
+ # - Position modifiers: `tooltip-top`, `tooltip-bottom`,
50
+ # `tooltip-left`, `tooltip-right`
51
+ # - Colors: `tooltip-primary`, `tooltip-secondary`, `tooltip-accent`,
52
+ # `tooltip-info`, `tooltip-success`, `tooltip-warning`, `tooltip-error`
53
+ # - Open state: `tooltip-open`
54
+ #
55
+ def initialize(*args, **kws, &block)
56
+ super
57
+
58
+ # Accept a `tip` keyword argument, or the first positional argument
59
+ @tip = config_option(:tip, args[0])
60
+ end
61
+
62
+ #
63
+ # Sets up the component's CSS and HTML attributes.
64
+ #
65
+ def before_render
66
+ add_css(:component, "tooltip")
67
+ add_html(:component, { data: { tip: @tip } }) if @tip
68
+ end
69
+
70
+ #
71
+ # Renders the component and its content (inline).
72
+ #
73
+ def call
74
+ part(:component) { content }
75
+ end
76
+
77
+ end
@@ -0,0 +1,59 @@
1
+ #
2
+ # The ArtboardComponent provides a fixed-size container that mimics mobile
3
+ # device screens. It's particularly useful for:
4
+ # - Prototyping mobile interfaces.
5
+ # - Displaying responsive design examples.
6
+ # - Creating device-specific mockups.
7
+ #
8
+ # The component includes preset sizes for common mobile devices and supports
9
+ # both portrait and landscape orientations.
10
+ #
11
+ # @loco_example Portrait Mode
12
+ # = daisy_artboard(css: "phone-4") do
13
+ # = daisy_hero do
14
+ # iPhone 13 (375×812)
15
+ #
16
+ # @loco_example Landscape Mode
17
+ # = daisy_artboard(css: "phone-4 artboard-horizontal") do
18
+ # = daisy_hero do
19
+ # iPhone 13 (812×375)
20
+ #
21
+ # @loco_example Custom Demo Style
22
+ # = daisy_artboard(css: "phone-1 artboard-demo") do
23
+ # iPhone SE (320×568)
24
+ #
25
+ class Daisy::Layout::ArtboardComponent < LocoMotion::BaseComponent
26
+
27
+ #
28
+ # Creates a new Artboard component.
29
+ #
30
+ # @param args [Array] Positional arguments passed to the parent class.
31
+ # @param kws [Hash] Keyword arguments for customizing the artboard.
32
+ #
33
+ # @option kws css [String] Additional CSS classes for styling. Common
34
+ # options include:
35
+ # - Device sizes: `phone-1` (320×568), `phone-2` (375×667),
36
+ # `phone-3` (414×736), `phone-4` (375×812), `phone-5` (414×896),
37
+ # `phone-6` (320×1024)
38
+ # - Orientation: `artboard-horizontal` for landscape mode
39
+ # - Demo style: `artboard-demo` for visible borders and background
40
+ #
41
+ def initialize(*args, **kws, &block)
42
+ super
43
+ end
44
+
45
+ #
46
+ # Sets up the component's CSS classes.
47
+ #
48
+ def before_render
49
+ add_css(:component, "artboard")
50
+ end
51
+
52
+ #
53
+ # Renders the component and its content.
54
+ #
55
+ def call
56
+ part(:component) { content }
57
+ end
58
+
59
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ # The DividerComponent creates a visual separator between content sections,
3
+ # either horizontally or vertically. It can include optional text or content
4
+ # in the center and supports various colors to match your theme.
5
+ #
6
+ # Common use cases include:
7
+ # - Separating sections of a page.
8
+ # - Creating visual breaks between cards or content blocks.
9
+ # - Providing alternative options with "OR" text.
10
+ # - Organizing form sections.
11
+ #
12
+ # @loco_example Basic Dividers
13
+ # = daisy_divider
14
+ #
15
+ # = daisy_divider do
16
+ # OR
17
+ #
18
+ # @loco_example Vertical Dividers
19
+ # .flex.grow
20
+ # = daisy_card(css: "h-48") do
21
+ # Left Content
22
+ #
23
+ # = daisy_divider(css: "divider-horizontal") do
24
+ # OR
25
+ #
26
+ # = daisy_card(css: "h-48") do
27
+ # Right Content
28
+ #
29
+ # @loco_example Colored Dividers
30
+ # = daisy_divider(css: "divider-primary") do
31
+ # Primary
32
+ #
33
+ # = daisy_divider(css: "divider-accent") do
34
+ # Accent
35
+ #
36
+ # = daisy_divider(css: "divider-success") do
37
+ # Success
38
+ #
39
+ class Daisy::Layout::DividerComponent < LocoMotion::BaseComponent
40
+
41
+ #
42
+ # Creates a new Divider component.
43
+ #
44
+ # @param args [Array] Positional arguments passed to the parent class.
45
+ # @param kws [Hash] Keyword arguments for customizing the divider.
46
+ #
47
+ # @option kws css [String] Additional CSS classes for styling. Common
48
+ # options include:
49
+ # - Orientation: `divider-horizontal` for vertical divider
50
+ # - Colors: `divider-neutral`, `divider-primary`, `divider-secondary`,
51
+ # `divider-accent`, `divider-info`, `divider-success`,
52
+ # `divider-warning`, `divider-error`
53
+ #
54
+ def initialize(*args, **kws, &block)
55
+ super
56
+ end
57
+
58
+ #
59
+ # Sets up the component's CSS classes.
60
+ #
61
+ def before_render
62
+ add_css(:component, "divider")
63
+ end
64
+
65
+ #
66
+ # Renders the component and its content.
67
+ #
68
+ def call
69
+ part(:component) { content }
70
+ end
71
+
72
+ end
@@ -0,0 +1,9 @@
1
+ = part(:component) do
2
+ = part(:input)
3
+
4
+ = part(:content_wrapper) do
5
+ = content
6
+
7
+ - if sidebar?
8
+ - sidebar.set_loco_parent(component_ref)
9
+ = sidebar
@@ -0,0 +1,155 @@
1
+ #
2
+ # The DrawerComponent provides a sliding sidebar panel that can be toggled
3
+ # open and closed. It's commonly used for:
4
+ # - Navigation menus
5
+ # - Filter panels
6
+ # - Additional information panels
7
+ # - Mobile-friendly navigation
8
+ #
9
+ # The drawer includes an overlay that covers the main content when open and
10
+ # can be configured to slide in from either the left or right side.
11
+ #
12
+ # @part input [LocoMotion::BaseComponent] The input checkbox that
13
+ # toggles the sidebar visibility.
14
+ #
15
+ # @part content_wrapper [LocoMotion::BaseComponent] The wrapper for the main
16
+ # page content that remains visible when the drawer is closed.
17
+ #
18
+ # @part overlay [LocoMotion::BaseComponent] The semi-transparent
19
+ # overlay that covers the main content when the drawer is open. Clicking it
20
+ # closes the drawer.
21
+ #
22
+ # @slot sidebar [Daisy::Layout::DrawerSidebarComponent] The sidebar
23
+ # panel that slides in when the drawer is opened. Contains the overlay
24
+ # within itself.
25
+ #
26
+ # @loco_example Basic Left Drawer
27
+ # = daisy_drawer do |drawer|
28
+ # - drawer.with_sidebar do
29
+ # .bg-base-100.p-4.w-40
30
+ # Menu Items
31
+ #
32
+ # = daisy_button(tag_name: "label",
33
+ # css: "btn btn-primary",
34
+ # title: "Open Menu",
35
+ # html: { for: drawer.id })
36
+ #
37
+ # @loco_example Right Drawer
38
+ # = daisy_drawer(css: "drawer-end") do |drawer|
39
+ # - drawer.with_sidebar do
40
+ # .bg-base-100.p-4.w-40
41
+ # Filter Options
42
+ #
43
+ # = daisy_button(tag_name: "label",
44
+ # css: "btn btn-secondary",
45
+ # title: "Show Filters",
46
+ # html: { for: drawer.id })
47
+ #
48
+ # @loco_example Styled Drawer
49
+ # = daisy_drawer do |drawer|
50
+ # - drawer.with_sidebar do
51
+ # .bg-base-200.p-4.w-80.h-full
52
+ # .flex.justify-between.items-center.mb-4
53
+ # %h2.text-xl Settings
54
+ # = daisy_button(tag_name: "label",
55
+ # css: "btn btn-ghost btn-circle",
56
+ # icon: "x-mark",
57
+ # html: { for: drawer.id })
58
+ #
59
+ class Daisy::Layout::DrawerComponent < LocoMotion::BaseComponent
60
+ #
61
+ # The DrawerSidebarComponent is a child of the {DrawerComponent} and renders
62
+ # the drawer sidebar and the overlay.
63
+ #
64
+ class Daisy::Layout::DrawerSidebarComponent < LocoMotion::BaseComponent
65
+ #
66
+ # Sets up the component's CSS classes.
67
+ #
68
+ def before_render
69
+ add_css(:component, "drawer-side")
70
+ end
71
+
72
+ #
73
+ # Renders the sidebar, the overlay, and its content.
74
+ #
75
+ def call
76
+ part(:component) do
77
+ # We need to render the parent component's overlay inside of the sidebar
78
+ concat(loco_parent.part(:overlay))
79
+ concat(content)
80
+ end
81
+ end
82
+ end
83
+
84
+ define_parts :input, :content_wrapper, :overlay
85
+
86
+ renders_one :sidebar, Daisy::Layout::DrawerSidebarComponent
87
+
88
+ #
89
+ # The ID of the drawer. Can be passed in as a configuration option, but
90
+ # defaults to a random UUID.
91
+ #
92
+ attr_reader :id
93
+
94
+ #
95
+ # Creates a new Drawer component.
96
+ #
97
+ # @param kws [Hash] Keyword arguments for customizing the drawer.
98
+ #
99
+ # @option kws id [String] The ID of the drawer. Defaults to a random UUID.
100
+ # This is used to connect the toggle button with the drawer.
101
+ #
102
+ # @option kws css [String] Additional CSS classes for styling. Common
103
+ # options include:
104
+ # - Position: `drawer-end` to slide from right instead of left
105
+ # - Responsive: `lg:drawer-open` to keep drawer open on large screens
106
+ # - Z-index: `z-[100]` to control stacking order
107
+ #
108
+ def initialize(**kws)
109
+ super
110
+
111
+ @id = config_option(:id, SecureRandom.uuid)
112
+ end
113
+
114
+ #
115
+ # Sets up the various parts of the component.
116
+ #
117
+ def before_render
118
+ setup_component
119
+ setup_input
120
+ setup_content_wrapper
121
+ setup_overlay
122
+ end
123
+
124
+ #
125
+ # Adds the `drawer` class to the component itself.
126
+ #
127
+ def setup_component
128
+ add_css(:component, "drawer")
129
+ end
130
+
131
+ #
132
+ # Sets up the input checkbox that toggles the sidebar.
133
+ #
134
+ def setup_input
135
+ set_tag_name(:input, :input)
136
+ add_css(:input, "drawer-toggle")
137
+ add_html(:input, { type: "checkbox", id: @id })
138
+ end
139
+
140
+ #
141
+ # Adds the `drawer-content` class to the content wrapper.
142
+ #
143
+ def setup_content_wrapper
144
+ add_css(:content_wrapper, "drawer-content")
145
+ end
146
+
147
+ #
148
+ # Sets up the overlay that covers the page when the sidebar is open.
149
+ #
150
+ def setup_overlay
151
+ set_tag_name(:overlay, :label)
152
+ add_css(:overlay, "drawer-overlay")
153
+ add_html(:overlay, { for: @id, "aria-label": "close sidebar" })
154
+ end
155
+ end
@@ -0,0 +1,69 @@
1
+ #
2
+ # The FooterComponent creates a responsive container for page footer content.
3
+ # Common use cases include:
4
+ # - Site navigation and sitemap links.
5
+ # - Copyright and legal information.
6
+ # - Contact details and social media links.
7
+ # - Newsletter signup forms.
8
+ #
9
+ # The component is responsive by default and will stack content on smaller
10
+ # screens.
11
+ #
12
+ # @loco_example Basic Navigation Footer
13
+ # = daisy_footer(css: "bg-neutral text-neutral-content p-10") do
14
+ # %nav
15
+ # %h6.footer-title Company
16
+ # = link_to "About", "/about", class: "link-hover"
17
+ # = link_to "Contact", "/contact", class: "link-hover"
18
+ # = link_to "Jobs", "/careers", class: "link-hover"
19
+ #
20
+ # @loco_example Multi-Column Footer
21
+ # = daisy_footer(css: "bg-base-200 text-base-content p-10") do
22
+ # %nav
23
+ # %h6.footer-title Products
24
+ # = link_to "Features", "#", class: "link-hover"
25
+ # = link_to "Pricing", "#", class: "link-hover"
26
+ #
27
+ # %nav
28
+ # %h6.footer-title Support
29
+ # = link_to "Documentation", "#", class: "link-hover"
30
+ # = link_to "Help Center", "#", class: "link-hover"
31
+ #
32
+ # @loco_example Copyright Footer
33
+ # = daisy_footer(css: "bg-neutral text-neutral-content p-4 text-center") do
34
+ # %small
35
+ # Copyright &copy; 2024 Company Name.
36
+ # All rights reserved.
37
+ #
38
+ class Daisy::Layout::FooterComponent < LocoMotion::BaseComponent
39
+ #
40
+ # Creates a new Footer component.
41
+ #
42
+ # @param kws [Hash] Keyword arguments for customizing the footer.
43
+ #
44
+ # @option kws css [String] Additional CSS classes for styling. Common
45
+ # options include:
46
+ # - Background: `bg-neutral`, `bg-base-200`
47
+ # - Text color: `text-neutral-content`, `text-base-content`
48
+ # - Spacing: `p-4`, `p-10`
49
+ # - Layout: `text-center`, `grid grid-cols-2 gap-4`
50
+ #
51
+ def initialize(**kws)
52
+ super
53
+ end
54
+
55
+ #
56
+ # Sets up the component's CSS classes and HTML tag.
57
+ #
58
+ def before_render
59
+ add_css(:component, "footer")
60
+ set_tag_name(:component, :footer)
61
+ end
62
+
63
+ #
64
+ # Renders the component and its content.
65
+ #
66
+ def call
67
+ part(:component) { content }
68
+ end
69
+ end
@@ -0,0 +1,5 @@
1
+ = part(:component) do
2
+ = overlay if overlay?
3
+
4
+ = part(:content_wrapper) do
5
+ = content
@@ -0,0 +1,83 @@
1
+ #
2
+ # The HeroComponent creates an eye-catching, full-width section typically used
3
+ # at the top of a page. Common use cases include:
4
+ # - Landing page introductions.
5
+ # - Feature showcases.
6
+ # - Call-to-action sections.
7
+ # - Image-rich banners.
8
+ #
9
+ # The component is responsive by default and provides flexible layout options
10
+ # for content positioning and image integration.
11
+ #
12
+ # @part content_wrapper [LocoMotion::BaseComponent] The wrapper for the hero
13
+ # content, providing flex-based layout control.
14
+ #
15
+ # @slot overlay [LocoMotion::BasicComponent] An optional `<div>` positioned
16
+ # behind the content for background effects like semi-transparency or blur.
17
+ #
18
+ # @loco_example Basic Hero
19
+ # = daisy_hero(css: "bg-base-200 text-center") do
20
+ # %div
21
+ # %h1.text-5xl.font-bold Welcome
22
+ # %p.my-6 Discover amazing features.
23
+ # = daisy_button(css: "btn btn-primary",
24
+ # title: "Get Started")
25
+ #
26
+ # @loco_example Hero with Image
27
+ # = daisy_hero(css: "bg-base-200",
28
+ # content_wrapper_css: "flex-col md:flex-row") do
29
+ # %img.h-40.rounded{
30
+ # src: image_path("hero-image.jpg"),
31
+ # alt: "Hero Image" }
32
+ # %div
33
+ # %h1.text-5xl.font-bold Features
34
+ # %p.my-6 Explore what we offer.
35
+ #
36
+ # @loco_example Hero with Background Overlay
37
+ # = daisy_hero(css: "min-h-96",
38
+ # html: { style: "background-image: url('bg.jpg')" }) do |hero|
39
+ # - hero.with_overlay(css: "bg-black/50 backdrop-blur")
40
+ # %div.text-white
41
+ # %h1.text-5xl.font-bold Discover
42
+ # %p.my-6 Start your journey today.
43
+ #
44
+ class Daisy::Layout::HeroComponent < LocoMotion::BaseComponent
45
+ define_part :content_wrapper
46
+
47
+ renders_one :overlay, LocoMotion::BasicComponent.build(css: "hero-overlay")
48
+
49
+ #
50
+ # Creates a new Hero component.
51
+ #
52
+ # @param kws [Hash] Keyword arguments for customizing the hero.
53
+ #
54
+ # @option kws css [String] Additional CSS classes for styling. Common
55
+ # options include:
56
+ # - Height: `min-h-screen`, `min-h-[50vh]`
57
+ # - Background: `bg-base-200`, `bg-primary`
58
+ # - Text: `text-center`, `text-primary-content`
59
+ #
60
+ # @option kws content_wrapper_css [String] CSS classes for the content
61
+ # wrapper. Common options include:
62
+ # - Layout: `flex-col`, `flex-col md:flex-row`
63
+ # - Spacing: `gap-4`, `space-y-4`
64
+ # - Alignment: `items-center`, `justify-between`
65
+ #
66
+ # @option kws html [Hash] HTML attributes for the hero container.
67
+ # Commonly used for background images:
68
+ # ```ruby
69
+ # html: { style: "background-image: url('image.jpg')" }
70
+ # ```
71
+ #
72
+ def initialize(**kws)
73
+ super
74
+ end
75
+
76
+ #
77
+ # Sets up the component's CSS classes.
78
+ #
79
+ def before_render
80
+ add_css(:component, "hero")
81
+ add_css(:content_wrapper, "hero-content")
82
+ end
83
+ end
@@ -0,0 +1,83 @@
1
+ #
2
+ # The IndicatorComponent positions notification elements around its content to
3
+ # draw attention to important information. Common use cases include:
4
+ # - Notification badges on avatars.
5
+ # - Cart item counters.
6
+ # - "New" badges on features.
7
+ # - Status indicators on elements.
8
+ #
9
+ # By default, indicators are positioned in the top-right corner, but they can
10
+ # be positioned anywhere around the content using CSS classes.
11
+ #
12
+ # @slot item+ [LocoMotion::BasicComponent] The items to be rendered around
13
+ # the content. Multiple items can be added and positioned independently.
14
+ #
15
+ # @loco_example Basic Badge Indicator
16
+ # = daisy_indicator do |indicator|
17
+ # - indicator.with_item do
18
+ # = daisy_badge(title: "8",
19
+ # css: "badge-secondary")
20
+ #
21
+ # = daisy_avatar(src: "avatar.jpg")
22
+ #
23
+ # @loco_example Multiple Indicators
24
+ # = daisy_indicator do |indicator|
25
+ # - indicator.with_item(css: "indicator-top indicator-start") do
26
+ # = daisy_badge(title: "New",
27
+ # css: "badge-accent")
28
+ #
29
+ # - indicator.with_item(css: "indicator-bottom indicator-end") do
30
+ # = daisy_badge(title: "Sale",
31
+ # css: "badge-secondary")
32
+ #
33
+ # = daisy_button(title: "View Item")
34
+ #
35
+ # @loco_example Custom Positioning
36
+ # = daisy_indicator do |indicator|
37
+ # - # Center of left edge
38
+ # - indicator.with_item(css: "indicator-middle indicator-start") do
39
+ # Online
40
+ #
41
+ # - # Center of right edge
42
+ # - indicator.with_item(css: "indicator-middle indicator-end") do
43
+ # Available
44
+ #
45
+ # .w-40.h-40.bg-base-200
46
+ #
47
+ class Daisy::Layout::IndicatorComponent < LocoMotion::BaseComponent
48
+ renders_many :items, LocoMotion::BasicComponent.build(css: "indicator-item")
49
+
50
+ #
51
+ # Creates a new Indicator component.
52
+ #
53
+ # @param kws [Hash] Keyword arguments for customizing the indicator.
54
+ #
55
+ # @option kws css [String] Additional CSS classes for styling. Common
56
+ # options include:
57
+ # - Spacing: `p-2`, `m-4`
58
+ # - Alignment: `inline-flex`, `inline-grid`
59
+ #
60
+ def initialize(**kws)
61
+ super
62
+ end
63
+
64
+ #
65
+ # Sets up the component's CSS classes.
66
+ #
67
+ def before_render
68
+ add_css(:component, "indicator")
69
+ end
70
+
71
+ #
72
+ # Renders the component, all indicator items, and the main content.
73
+ #
74
+ def call
75
+ part(:component) do
76
+ items.each do |item|
77
+ concat(item)
78
+ end
79
+
80
+ concat(content) if content?
81
+ end
82
+ end
83
+ end
@@ -1,10 +1,81 @@
1
- class Daisy::Layout::JoinComponent < LocoMotion.configuration.base_component_class
1
+ #
2
+ # The JoinComponent combines multiple elements into a cohesive group without
3
+ # gaps between them. Common use cases include:
4
+ # - Button groups for toolbars.
5
+ # - Input fields with prefix/suffix elements.
6
+ # - Segmented navigation controls.
7
+ # - Pagination controls.
8
+ #
9
+ # Note: Each joined item must include the `join-item` CSS class manually, as
10
+ # automatic application could cause rendering issues in complex scenarios.
11
+ #
12
+ # @slot item+ [LocoMotion::BaseComponent] The elements to be joined together.
13
+ # Each item should include the `join-item` CSS class.
14
+ #
15
+ # @loco_example Basic Button Group
16
+ # = daisy_join do |join|
17
+ # - join.with_item do
18
+ # = daisy_button(title: "Previous",
19
+ # css: "join-item")
20
+ # - join.with_item do
21
+ # = daisy_button(title: "Current",
22
+ # css: "join-item btn-active")
23
+ # - join.with_item do
24
+ # = daisy_button(title: "Next",
25
+ # css: "join-item")
26
+ #
27
+ # @loco_example Icon Button Group
28
+ # = daisy_join do |join|
29
+ # - join.with_item do
30
+ # = daisy_button(icon: "chevron-left",
31
+ # css: "join-item")
32
+ # - join.with_item do
33
+ # = daisy_button(icon: "home",
34
+ # css: "join-item")
35
+ # - join.with_item do
36
+ # = daisy_button(icon: "chevron-right",
37
+ # css: "join-item")
38
+ #
39
+ # @loco_example Vertical Join
40
+ # = daisy_join(css: "join-vertical") do |join|
41
+ # - join.with_item do
42
+ # = daisy_button(title: "Menu",
43
+ # css: "w-full join-item")
44
+ # - join.with_item do
45
+ # = daisy_button(title: "Settings",
46
+ # css: "w-full join-item")
47
+ # - join.with_item do
48
+ # = daisy_button(title: "Account",
49
+ # css: "w-full join-item")
50
+ #
51
+ class Daisy::Layout::JoinComponent < LocoMotion::BaseComponent
2
52
  renders_many :items
3
53
 
54
+ #
55
+ # Creates a new Join component.
56
+ #
57
+ # @param kws [Hash] Keyword arguments for customizing the join.
58
+ #
59
+ # @option kws css [String] Additional CSS classes for styling. Common
60
+ # options include:
61
+ # - Direction: `join-vertical` for vertical stacking
62
+ # - Size: `min-w-32`, `w-full`
63
+ # - Spacing: `gap-0`, `gap-px` (if gaps are needed)
64
+ #
65
+ def initialize(**kws)
66
+ super
67
+ end
68
+
69
+ #
70
+ # Sets up the component's CSS classes.
71
+ #
4
72
  def before_render
5
73
  add_css(:component, "join")
6
74
  end
7
75
 
76
+ #
77
+ # Renders all joined items in sequence.
78
+ #
8
79
  def call
9
80
  part(:component) do
10
81
  items.each do |item|