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
@@ -1,25 +1,80 @@
1
- class Daisy::Navigation::MenuComponent < LocoMotion.configuration.base_component_class
1
+ #
2
+ # Creates a menu component for displaying a list of items, optionally with group titles.
3
+ #
4
+ # @slot items+ {Daisy::Navigation::MenuItemComponent} The menu items to display.
5
+ #
6
+ # @example Basic menu with items
7
+ # = daisy_menu do |menu|
8
+ # - menu.with_item do
9
+ # = link_to "Item 1", "#"
10
+ # - menu.with_item do
11
+ # = link_to "Item 2", "#"
12
+ #
13
+ # @example Menu with group titles
14
+ # = daisy_menu do |menu|
15
+ # - menu.with_item(title: "Group 1") do
16
+ # = link_to "Item 1-1", "#"
17
+ # = link_to "Item 1-2", "#"
18
+ # - menu.with_item("Group 2") do
19
+ # = link_to "Item 2-1", "#"
20
+ # = link_to "Item 2-2", "#"
21
+ #
22
+ # @example Menu with disabled items
23
+ # = daisy_menu do |menu|
24
+ # - menu.with_item do
25
+ # = link_to "Active Item", "#"
26
+ # - menu.with_item(disabled: true) do
27
+ # Disabled Item
28
+ #
29
+ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
2
30
 
3
31
  #
4
- # The items for the MenuComponent.
32
+ # A menu item component that can optionally have a title and be disabled.
5
33
  #
34
+ # @part title The title element for the menu item.
6
35
  #
7
- class Daisy::Navigation::MenuItemComponent < LocoMotion.configuration.base_component_class
36
+ # @example Basic menu item
37
+ # = menu.with_item do
38
+ # = link_to "Item", "#"
39
+ #
40
+ # @example Menu item with title
41
+ # = menu.with_item(title: "Group") do
42
+ # = link_to "Item", "#"
43
+ #
44
+ # @example Disabled menu item
45
+ # = menu.with_item(disabled: true) do
46
+ # = link_to "Item", "#"
47
+ #
48
+ class Daisy::Navigation::MenuItemComponent < LocoMotion::BaseComponent
8
49
  define_part :title
9
50
 
10
- #
11
51
  # Create a new instance of the MenuItemComponent.
12
52
  #
13
- # @param title [String] (Optional) Shows an additional title above the item.
14
- # @param disabled [Boolean] (Optional) Sets the item in a disabled state.
53
+ # @param args [Array] If provided, the first argument is considered the
54
+ # `title`.
55
+ #
56
+ # @param kws [Hash] The keyword arguments for the component.
15
57
  #
16
- def initialize(*args, **kws, &block)
17
- super
58
+ # @option kws title [String] Shows an additional title above the item.
59
+ #
60
+ # @option kws disabled [Boolean] Sets the item in a disabled state.
61
+ #
62
+ # @option kws css [String] Additional CSS classes for styling. Common
63
+ # options include:
64
+ # - Text: `text-sm`, `text-base-content`
65
+ # - Spacing: `mt-4`, `mb-2`
66
+ #
67
+ def initialize(*args, **kws)
68
+ super(**kws)
18
69
 
19
- @simple_title = config_option(:title)
70
+ @simple_title = config_option(:title, args[0])
20
71
  @disabled = config_option(:disabled)
21
72
  end
22
73
 
74
+ #
75
+ # Adds the relevant Daisy classes and applies the disabled state if
76
+ # provided (utilizes Tailwind pointer-events-none).
77
+ #
23
78
  def before_render
24
79
  set_tag_name(:component, :li)
25
80
  add_css(:component, "disabled pointer-events-none") if @disabled
@@ -28,6 +83,9 @@ class Daisy::Navigation::MenuComponent < LocoMotion.configuration.base_component
28
83
  add_css(:title, "menu-title")
29
84
  end
30
85
 
86
+ #
87
+ # Renders the menu item component including a title if present.
88
+ #
31
89
  def call
32
90
  part(:component) do
33
91
  concat(part(:title) { @simple_title }) if @simple_title
@@ -38,10 +96,24 @@ class Daisy::Navigation::MenuComponent < LocoMotion.configuration.base_component
38
96
 
39
97
  renders_many :items, Daisy::Navigation::MenuItemComponent
40
98
 
41
- def initialize(*args, **kws, &block)
42
- super
99
+ # Create a new instance of the MenuComponent.
100
+ #
101
+ # @param kws [Hash] The keyword arguments for the component.
102
+ #
103
+ # @option kws css [String] Additional CSS classes for styling. Common
104
+ # options include:
105
+ # - Size: `w-56`, `max-w-xs`
106
+ # - Background: `bg-base-100`, `bg-neutral`
107
+ # - Border: `border`, `rounded-box`
108
+ # - Shadow: `shadow`, `shadow-lg`
109
+ #
110
+ def initialize(**kws)
111
+ super(**kws)
43
112
  end
44
113
 
114
+ #
115
+ # Sets the tag name to `<ul>` and adds the relevant Daisy classes.
116
+ #
45
117
  def before_render
46
118
  set_tag_name(:component, :ul)
47
119
  add_css(:component, "menu")
@@ -1,4 +1,4 @@
1
1
  = part(:component) do
2
2
  = start if start?
3
3
  = center if center?
4
- = tail if tail?
4
+ = end_content if end?
@@ -1,12 +1,73 @@
1
- class Daisy::Navigation::NavbarComponent < LocoMotion.configuration.base_component_class
1
+ #
2
+ # Creates a navigation bar component typically used at the top of a page to
3
+ # organize navigation links and branding elements.
4
+ #
5
+ # @slot start {LocoMotion::BasicComponent} The left section of the navbar.
6
+ # Automatically gets the `navbar-start` CSS class.
7
+ #
8
+ # @slot center {LocoMotion::BasicComponent} The center section of the navbar.
9
+ # Automatically gets the `navbar-center` CSS class.
10
+ #
11
+ # @slot end {LocoMotion::BasicComponent} The right section of the navbar.
12
+ # Automatically gets the `navbar-end` CSS class.
13
+ #
14
+ # @example Basic navbar with logo and GitHub link
15
+ # = daisy_navbar(css: "bg-base-100") do |navbar|
16
+ # - navbar.with_start do
17
+ # = image_tag("logo.png", class: "h-8")
18
+ # %span.font-bold Company Name
19
+ #
20
+ # - navbar.with_end do
21
+ # = link_to "GitHub", "https://github.com", target: "_blank"
22
+ #
23
+ # @example Navbar with all sections and dropdown
24
+ # = daisy_navbar(css: "bg-base-100") do |navbar|
25
+ # - navbar.with_start do
26
+ # %span.text-lg.italic Brand
27
+ #
28
+ # - navbar.with_center do
29
+ # = hero_icon("code-bracket", css: "size-14")
30
+ #
31
+ # - navbar.with_end do
32
+ # = daisy_dropdown do |dropdown|
33
+ # - dropdown.with_button(title: "Menu")
34
+ # - dropdown.with_item do
35
+ # = link_to "Item 1", "#"
36
+ #
37
+ class Daisy::Navigation::NavbarComponent < LocoMotion::BaseComponent
2
38
  renders_one :start, LocoMotion::BasicComponent.build(css: "navbar-start")
3
39
 
4
40
  renders_one :center, LocoMotion::BasicComponent.build(css: "navbar-center")
5
41
 
6
- # End is a reserved word in Ruby
7
- renders_one :tail, LocoMotion::BasicComponent.build(css: "navbar-end")
42
+ renders_one :end, LocoMotion::BasicComponent.build(css: "navbar-end")
43
+
44
+ # Create a new instance of the NavbarComponent.
45
+ #
46
+ # @param kws [Hash] The keyword arguments for the component.
47
+ #
48
+ # @option kws css [String] Additional CSS classes for styling. Common
49
+ # options include:
50
+ # - Background: `bg-base-100`, `bg-neutral`
51
+ # - Border: `border`, `border-base-200`, `rounded-lg`
52
+ # - Shadow: `shadow`, `shadow-lg`
53
+ # - Min Height: `min-h-8`, `min-h-16`
54
+ #
55
+ def initialize(**kws)
56
+ super(**kws)
57
+ end
8
58
 
9
59
  def before_render
10
60
  add_css(:component, "navbar")
11
61
  end
62
+
63
+ private
64
+
65
+ # Returns the end section content.
66
+ #
67
+ # Since `end` is a reserved word in Ruby, we need to use a different method
68
+ # name in the template.
69
+ #
70
+ def end_content
71
+ self.end
72
+ end
12
73
  end
@@ -1,7 +1,69 @@
1
- class Daisy::Navigation::StepsComponent < LocoMotion.configuration.base_component_class
1
+ #
2
+ # Creates a component for displaying a series of steps that users can follow to
3
+ # complete a task. Useful for onboarding, form completion, and progress tracking.
4
+ #
5
+ # @note Steps are automatically numbered and connected with lines. You can use
6
+ # colors to indicate progress through the steps.
7
+ #
8
+ # @slot steps+ {Daisy::Navigation::StepsComponent::StepComponent} The individual
9
+ # steps to display.
10
+ #
11
+ # @example Basic steps with progress
12
+ # = daisy_steps do |steps|
13
+ # - steps.with_step(title: "Write Code", css: "step-primary")
14
+ # - steps.with_step(title: "Release Code", css: "step-primary")
15
+ # - steps.with_step(title: "Profit", css: "step-secondary")
16
+ # - steps.with_step(title: "Rule the World")
17
+ #
18
+ # @example Vertical steps
19
+ # = daisy_steps(css: "steps-vertical") do |steps|
20
+ # - steps.with_step(title: "Write Code", css: "step-primary")
21
+ # - steps.with_step(title: "Release Code", css: "step-primary")
22
+ # - steps.with_step(title: "Profit", css: "step-secondary")
23
+ # - steps.with_step(title: "Rule the World")
24
+ #
25
+ # @example Custom step content
26
+ # = daisy_steps do |steps|
27
+ # - steps.with_step(number: "AB")
28
+ # - steps.with_step(number: "★")
29
+ # - steps.with_step(number: "✓", css: "after:!text-green-500")
30
+ #
31
+ class Daisy::Navigation::StepsComponent < LocoMotion::BaseComponent
2
32
 
3
- class Daisy::Navigation::StepComponent < LocoMotion.configuration.base_component_class
33
+ #
34
+ # A step within a StepsComponent.
35
+ #
36
+ # @example Basic step with title
37
+ # = steps.with_step(title: "Step 1")
38
+ #
39
+ # @example Step with custom number
40
+ # = steps.with_step(number: "★", title: "Special Step")
41
+ #
42
+ # @example Step with custom content
43
+ # = steps.with_step(number: "1") do
44
+ # .flex.gap-2
45
+ # = hero_icon("check")
46
+ # Complete
47
+ #
48
+ class Daisy::Navigation::StepComponent < LocoMotion::BaseComponent
4
49
  attr_reader :simple
50
+
51
+ # Create a new instance of the StepComponent.
52
+ #
53
+ # @param args [Array] Not used.
54
+ #
55
+ # @param kws [Hash] The keyword arguments for the component.
56
+ #
57
+ # @option kws title [String] The text to display in the step.
58
+ #
59
+ # @option kws number [String] Custom content to display in the step's
60
+ # circle. Can be text, numbers, or emoji.
61
+ #
62
+ # @option kws css [String] Additional CSS classes for styling. Common
63
+ # options include:
64
+ # - Progress: `step-primary`, `step-secondary`, `step-accent`
65
+ # - Circle Content: `after:!text-green-500`, `after:!bg-black`
66
+ #
5
67
  def initialize(*args, **kws, &block)
6
68
  super
7
69
 
@@ -25,6 +87,20 @@ class Daisy::Navigation::StepsComponent < LocoMotion.configuration.base_componen
25
87
 
26
88
  renders_many :steps, Daisy::Navigation::StepComponent
27
89
 
90
+ # Create a new instance of the StepsComponent.
91
+ #
92
+ # @param kws [Hash] The keyword arguments for the component.
93
+ #
94
+ # @option kws css [String] Additional CSS classes for styling. Common
95
+ # options include:
96
+ # - Direction: `steps-vertical`
97
+ # - Size: `steps-mini`, `steps-sm`, `steps-md`, `steps-lg`
98
+ # - Width: `w-full`, `max-w-xs`
99
+ #
100
+ def initialize(**kws)
101
+ super(**kws)
102
+ end
103
+
28
104
  def before_render
29
105
  set_tag_name(:component, :ul)
30
106
  add_css(:component, "steps")
@@ -1,18 +1,103 @@
1
- # This is the Tabs component.
2
- class Daisy::Navigation::TabsComponent < LocoMotion.configuration.base_component_class
3
-
1
+ #
2
+ # Creates a tabbed navigation component that can be used either as links or radio
3
+ # buttons with associated content.
4
+ #
5
+ # @note When using radio button tabs, the titles must be simple strings and cannot
6
+ # contain HTML elements or icons.
7
+ #
8
+ # @slot tabs+ {Daisy::Navigation::TabsComponent::TabComponent} The individual
9
+ # tabs to display.
10
+ #
11
+ # @example Basic tabs with links
12
+ # = daisy_tabs(css: "tabs-bordered") do |tabs|
13
+ # - tabs.with_tab(title: "Home", active: true)
14
+ # - tabs.with_tab(title: "Click Me", html: { onclick: "alert('Clicked!')" })
15
+ # - tabs.with_tab(title: "Google", href: "https://google.com", target: "_blank")
16
+ #
17
+ # @example Radio button tabs with content
18
+ # = daisy_tabs(css: "tabs-lifted", radio: true) do |tabs|
19
+ # - tabs.with_tab(title: "Tab 1", checked: true) do
20
+ # %p Tab 1 content
21
+ # - tabs.with_tab(title: "Tab 2") do
22
+ # %p Tab 2 content
23
+ #
24
+ # @example Tabs with custom titles and content
25
+ # = daisy_tabs(css: "tabs-lifted") do |tabs|
26
+ # - tabs.with_tab do |tab|
27
+ # - tab.with_title do
28
+ # .flex.gap-2
29
+ # = hero_icon("home")
30
+ # Home
31
+ # - tab.with_custom_content(css: "tab-content p-4") do
32
+ # %p Welcome home!
33
+ #
34
+ class Daisy::Navigation::TabsComponent < LocoMotion::BaseComponent
35
+
36
+ #
37
+ # A tab within a TabsComponent that can be either a link or a radio button.
38
+ #
39
+ # @part content_wrapper The wrapper for the tab's content when not using
40
+ # custom content.
41
+ #
42
+ # @slot title The title content for the tab. Only used if no `title` option
43
+ # is provided.
44
+ #
45
+ # @slot custom_content Custom content to be rendered after the tab. Use this
46
+ # instead of the block content for complete control over the content's HTML.
47
+ #
48
+ # @example Basic tab with title
49
+ # = tabs.with_tab(title: "Home")
50
+ #
51
+ # @example Tab with custom title
52
+ # = tabs.with_tab do |tab|
53
+ # - tab.with_title do
54
+ # .flex.gap-2
55
+ # = hero_icon("home")
56
+ # Home
57
+ #
58
+ # @example Tab with content
59
+ # = tabs.with_tab(title: "Content") do
60
+ # %p This is the tab's content
61
+ #
62
+ # @example Tab with custom content
63
+ # = tabs.with_tab do |tab|
64
+ # - tab.with_custom_content(css: "tab-content p-4") do
65
+ # %p Custom content with custom wrapper
66
+ #
4
67
  class TabComponent < LocoMotion::BasicComponent
5
68
  define_parts :content_wrapper
6
69
 
7
70
  renders_one :title
8
71
  renders_one :custom_content
9
72
 
10
- attr_reader :active
11
-
12
- # @return [String] Accessor for the `title` string passed via the component
13
- # config.
14
- attr_reader :simple_title
15
-
73
+ attr_reader :active, :simple_title
74
+
75
+ # Create a new instance of the TabComponent.
76
+ #
77
+ # @param args [Array] Not used.
78
+ #
79
+ # @param kws [Hash] The keyword arguments for the component.
80
+ #
81
+ # @option kws title [String] The text to display in the tab.
82
+ #
83
+ # @option kws active [Boolean] Whether this tab is active (default: false).
84
+ #
85
+ # @option kws checked [Boolean] Whether this tab is checked (default: false).
86
+ #
87
+ # @option kws disabled [Boolean] Whether this tab is disabled (default: false).
88
+ #
89
+ # @option kws href [String] The URL to visit when the tab is clicked.
90
+ #
91
+ # @option kws target [String] The target attribute for the tab (e.g., "_blank").
92
+ #
93
+ # @option kws value [String] The value attribute when using radio buttons.
94
+ #
95
+ # @option kws css [String] Additional CSS classes for styling. Common
96
+ # options include:
97
+ # - Size: `tab-lg`, `tab-md`, `tab-sm`, `tab-xs`
98
+ # - Width: `w-full`, `!w-14`
99
+ # - Cursor: `cursor-pointer`, `!cursor-auto`
100
+ #
16
101
  def initialize(*args, **kws, &block)
17
102
  super
18
103
 
@@ -88,6 +173,24 @@ class Daisy::Navigation::TabsComponent < LocoMotion.configuration.base_component
88
173
 
89
174
  attr_reader :name, :radio
90
175
 
176
+ # Create a new instance of the TabsComponent.
177
+ #
178
+ # @param args [Array] Not used.
179
+ #
180
+ # @param kws [Hash] The keyword arguments for the component.
181
+ #
182
+ # @option kws name [String] The name attribute for radio button tabs
183
+ # (default: auto-generated UUID).
184
+ #
185
+ # @option kws radio [Boolean] Whether to use radio buttons instead of links
186
+ # (default: false).
187
+ #
188
+ # @option kws css [String] Additional CSS classes for styling. Common
189
+ # options include:
190
+ # - Style: `tabs-bordered`, `tabs-lifted`
191
+ # - Size: `tabs-lg`, `tabs-md`, `tabs-sm`, `tabs-xs`
192
+ # - Width: `w-full`, `w-[500px]`
193
+ #
91
194
  def initialize(*args, **kws, &block)
92
195
  super
93
196
 
@@ -1,4 +1,46 @@
1
- class Hero::IconComponent < LocoMotion.configuration.base_component_class
1
+ #
2
+ # Creates an icon component using Heroicons, a set of free, MIT-licensed
3
+ # high-quality SVG icons. For a complete list of available icons, visit
4
+ # https://heroicons.com.
5
+ #
6
+ # @note By default, icons are displayed with the `size-5` Tailwind class. This
7
+ # can be overridden without using the `!` modifier because we utilize the
8
+ # `:where()` pseudo-class to ensure our default classes have the lowest CSS
9
+ # specificity.
10
+ #
11
+ # @example Basic icon usage
12
+ # = hero_icon("academic-cap")
13
+ # = hero_icon(icon: "adjustments-horizontal")
14
+ # %span.text-blue-500
15
+ # = hero_icon("archive-box")
16
+ #
17
+ # @example Customized icons
18
+ # = hero_icon("no-symbol", css: "size-4 text-red-600")
19
+ # = hero_icon("arrow-trending-up", css: "size-10 text-green-600")
20
+ # = hero_icon("exclamation-triangle", css: "size-14 text-yellow-400 animate-pulse")
21
+ #
22
+ class Hero::IconComponent < LocoMotion::BaseComponent
23
+ prepend LocoMotion::Concerns::TippableComponent
24
+
25
+ # Create a new instance of the IconComponent.
26
+ #
27
+ # @param args [Array] If provided, the first argument is considered the
28
+ # `icon` name.
29
+ #
30
+ # @param kws [Hash] The keyword arguments for the component.
31
+ #
32
+ # @option kws icon [String] The name of the icon to display. See
33
+ # https://heroicons.com for available icons.
34
+ #
35
+ # @option kws variant [Symbol] The variant of the icon to use
36
+ # (default: :outline).
37
+ #
38
+ # @option kws css [String] Additional CSS classes for styling. Common
39
+ # options include:
40
+ # - Size: `size-4`, `size-10`, `size-14`
41
+ # - Color: `text-red-600`, `text-green-600`, `text-yellow-400`
42
+ # - Animation: `animate-pulse`, `animate-spin`
43
+ #
2
44
  def initialize(*args, **kws, &block)
3
45
  super
4
46
 
@@ -12,6 +54,13 @@ class Hero::IconComponent < LocoMotion.configuration.base_component_class
12
54
  add_css(:component, "[:where(&)]:size-5")
13
55
  end
14
56
 
57
+ #
58
+ # Renders the icon component.
59
+ #
60
+ # Because this is an inline component which might be utlized alongside text,
61
+ # we utilize the `call` method instead of a template to ensure that no
62
+ # additional whitespace gets added to the output.
63
+ #
15
64
  def call
16
65
  heroicon_tag(@icon, **rendered_html(:component))
17
66
  end
data/lib/daisy.rb CHANGED
@@ -1,6 +1,6 @@
1
- require "daisy/helpers"
2
- require "heroicons-rails"
3
-
1
+ #
2
+ # Parent module for all Daisy components.
3
+ #
4
4
  module Daisy
5
5
  #
6
6
  # Holds all Action-type components.
@@ -16,4 +16,19 @@ module Daisy
16
16
  # Holds all Navigation-type components.
17
17
  #
18
18
  module Navigation; end
19
+
20
+ #
21
+ # Holds all Feedback-type components.
22
+ #
23
+ module Feedback; end
24
+
25
+ #
26
+ # Holds all Layout-type components.
27
+ #
28
+ module Layout; end
29
+
30
+ #
31
+ # Holds all Mockup-type components.
32
+ #
33
+ module Mockup; end
19
34
  end
data/lib/hero.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "heroicons-rails"
2
+
3
+ #
4
+ # Parent module for all Hero components.
5
+ #
6
+ module Hero
7
+ end
@@ -3,7 +3,7 @@
3
3
  # so that users can pass in all of the same CSS and HTML options that a standard
4
4
  # component would have.
5
5
  #
6
- class LocoMotion::BasicComponent < LocoMotion.configuration.base_component_class
6
+ class LocoMotion::BasicComponent < LocoMotion::BaseComponent
7
7
 
8
8
  def call
9
9
  part(:component) do
@@ -0,0 +1,26 @@
1
+ module LocoMotion
2
+ module Concerns
3
+ #
4
+ # Can be included in relevant components to allow a new `tip` attibute that
5
+ # automatically adds the `tooltip` CSS class and the `data-tip` attribute
6
+ # to the component.
7
+ #
8
+ module TippableComponent
9
+ #
10
+ # Calls the parent `before_render`. Then adds the `tooltip` CSS class and
11
+ # the `data-tip` attribute to the component if the `tip` attribute is
12
+ # present.
13
+ #
14
+ def before_render
15
+ super
16
+
17
+ tip = config_option(:tip)
18
+
19
+ if tip
20
+ add_css(:component, "tooltip")
21
+ add_html(:component, { data: { tip: tip } })
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,35 @@
1
+ module LocoMotion
2
+
3
+ class << self
4
+ def configure
5
+ yield(configuration)
6
+ end
7
+
8
+ #
9
+ # Return the current instance of the LocoMotion::Configuration or create a
10
+ # new one.
11
+ #
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ #
17
+ # Mostly used for internal testing; not needed in Rails
18
+ #
19
+ def require_components
20
+ comp_files = Dir.glob(File.dirname(__FILE__) + '/../../app/components/**/*.rb')
21
+
22
+ comp_files.each do |file|
23
+ require file
24
+ end
25
+ end
26
+ end
27
+
28
+ #
29
+ # Unused for now. Was previously using to setup a base class for all
30
+ # LocoMotion components to inherit from.
31
+ #
32
+ class Configuration
33
+ end
34
+
35
+ end