loco_motion-rails 0.0.7 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +101 -14
- data/app/components/daisy/actions/button_component.rb +109 -8
- data/app/components/daisy/actions/dropdown_component.html.haml +5 -5
- data/app/components/daisy/actions/dropdown_component.rb +94 -25
- data/app/components/daisy/actions/modal_component.html.haml +3 -2
- data/app/components/daisy/actions/modal_component.rb +94 -45
- data/app/components/daisy/actions/swap_component.rb +114 -5
- data/app/components/daisy/actions/theme_controller_component.html.haml +1 -1
- data/app/components/daisy/actions/theme_controller_component.rb +36 -1
- data/app/components/daisy/data_display/accordion_component.rb +79 -3
- data/app/components/daisy/data_display/avatar_component.rb +36 -16
- data/app/components/daisy/data_display/badge_component.rb +35 -5
- data/app/components/daisy/data_display/card_component.html.haml +5 -13
- data/app/components/daisy/data_display/card_component.rb +74 -39
- data/app/components/daisy/data_display/carousel_component.rb +38 -0
- data/app/components/daisy/data_display/chat_component.rb +40 -10
- data/app/components/daisy/data_display/collapse_component.rb +58 -1
- data/app/components/daisy/data_display/countdown_component.rb +49 -0
- data/app/components/daisy/data_display/diff_component.rb +37 -0
- data/app/components/daisy/data_display/figure_component.rb +49 -0
- data/app/components/daisy/data_display/kbd_component.rb +50 -2
- data/app/components/daisy/data_display/stat_component.rb +64 -6
- data/app/components/daisy/data_display/table_component.rb +99 -34
- data/app/components/daisy/data_display/timeline_component.rb +45 -0
- data/app/components/daisy/data_display/timeline_event_component.rb +39 -1
- data/app/components/daisy/data_input/checkbox_component.rb +92 -0
- data/app/components/daisy/data_input/file_input_component.rb +92 -0
- data/app/components/daisy/data_input/label_component.rb +84 -0
- data/app/components/daisy/data_input/radio_button_component.rb +87 -0
- data/app/components/daisy/data_input/range_component.rb +95 -0
- data/app/components/daisy/data_input/rating_component.html.haml +13 -0
- data/app/components/daisy/data_input/rating_component.rb +138 -0
- data/app/components/daisy/data_input/select_component.html.haml +15 -0
- data/app/components/daisy/data_input/select_component.rb +178 -0
- data/app/components/daisy/data_input/text_area_component.rb +124 -0
- data/app/components/daisy/data_input/text_input_component.html.haml +6 -0
- data/app/components/daisy/data_input/text_input_component.rb +140 -0
- data/app/components/daisy/data_input/toggle_component.rb +36 -0
- data/app/components/daisy/feedback/alert_component.rb +46 -1
- data/app/components/daisy/feedback/loading_component.rb +39 -0
- data/app/components/daisy/feedback/progress_component.rb +39 -1
- data/app/components/daisy/feedback/radial_progress_component.rb +44 -1
- data/app/components/daisy/feedback/skeleton_component.rb +44 -0
- data/app/components/daisy/feedback/toast_component.rb +36 -0
- data/app/components/daisy/feedback/tooltip_component.rb +46 -10
- data/app/components/daisy/layout/artboard_component.rb +48 -0
- data/app/components/daisy/layout/divider_component.rb +50 -10
- data/app/components/daisy/layout/drawer_component.rb +62 -17
- data/app/components/daisy/layout/footer_component.rb +51 -11
- data/app/components/daisy/layout/hero_component.rb +67 -5
- data/app/components/daisy/layout/indicator_component.rb +55 -8
- data/app/components/daisy/layout/join_component.rb +71 -0
- data/app/components/daisy/layout/stack_component.rb +59 -0
- data/app/components/daisy/mockup/browser_component.rb +78 -0
- data/app/components/daisy/mockup/code_component.rb +144 -0
- data/app/components/daisy/mockup/device_component.rb +81 -0
- data/app/components/daisy/mockup/frame_component.rb +62 -0
- data/app/components/daisy/navigation/bottom_nav_component.rb +81 -2
- data/app/components/daisy/navigation/breadcrumbs_component.rb +40 -3
- data/app/components/daisy/navigation/link_component.rb +31 -6
- data/app/components/daisy/navigation/menu_component.rb +52 -20
- data/app/components/daisy/navigation/navbar_component.html.haml +1 -1
- data/app/components/daisy/navigation/navbar_component.rb +63 -2
- data/app/components/daisy/navigation/steps_component.rb +76 -0
- data/app/components/daisy/navigation/tabs_component.rb +110 -7
- data/app/components/hero/icon_component.rb +40 -0
- data/app/helpers/daisy/form_builder_helper.rb +159 -0
- data/lib/daisy.rb +10 -0
- data/lib/loco_motion/base_component.rb +9 -2
- data/lib/loco_motion/engine.rb +6 -0
- data/lib/loco_motion/helpers.rb +19 -0
- data/lib/loco_motion/version.rb +5 -0
- metadata +51 -5
@@ -1,7 +1,69 @@
|
|
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
|
+
#
|
1
31
|
class Daisy::Navigation::StepsComponent < LocoMotion::BaseComponent
|
2
32
|
|
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
|
+
#
|
3
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::BaseComponent
|
|
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
|
-
#
|
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
|
+
#
|
2
34
|
class Daisy::Navigation::TabsComponent < LocoMotion::BaseComponent
|
3
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
|
-
#
|
13
|
-
#
|
14
|
-
|
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::BaseComponent
|
|
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,6 +1,46 @@
|
|
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
|
+
#
|
1
22
|
class Hero::IconComponent < LocoMotion::BaseComponent
|
2
23
|
prepend LocoMotion::Concerns::TippableComponent
|
3
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
|
+
#
|
4
44
|
def initialize(*args, **kws, &block)
|
5
45
|
super
|
6
46
|
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Daisy
|
4
|
+
module FormBuilderHelper
|
5
|
+
# Extends ActionView::Helpers::FormBuilder with Daisy UI component methods
|
6
|
+
def self.included(base)
|
7
|
+
base.class_eval do
|
8
|
+
# Add the daisy_checkbox method to FormBuilder
|
9
|
+
def daisy_checkbox(name, **options)
|
10
|
+
# Get the object name from the form builder
|
11
|
+
object_name = @object_name.to_s
|
12
|
+
|
13
|
+
# Create a unique ID if not provided
|
14
|
+
options[:id] ||= "#{object_name}_#{name}"
|
15
|
+
|
16
|
+
# Set the name attribute
|
17
|
+
options[:name] = "#{object_name}[#{name}]"
|
18
|
+
|
19
|
+
# Pass the form builder's object to the component if it exists
|
20
|
+
if @object && @object.respond_to?(name) && !options.key?(:checked)
|
21
|
+
options[:checked] = @object.send(name)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Render the checkbox component
|
25
|
+
@template.daisy_checkbox(**options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Add the daisy_toggle method to FormBuilder
|
29
|
+
def daisy_toggle(name, **options)
|
30
|
+
# Get the object name from the form builder
|
31
|
+
object_name = @object_name.to_s
|
32
|
+
|
33
|
+
# Create a unique ID if not provided
|
34
|
+
options[:id] ||= "#{object_name}_#{name}"
|
35
|
+
|
36
|
+
# Set the name attribute
|
37
|
+
options[:name] = "#{object_name}[#{name}]"
|
38
|
+
|
39
|
+
# Pass the form builder's object to the component if it exists
|
40
|
+
if @object && @object.respond_to?(name) && !options.key?(:checked)
|
41
|
+
options[:checked] = @object.send(name)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Render the toggle component
|
45
|
+
@template.daisy_toggle(**options)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Add the daisy_radio method to FormBuilder
|
49
|
+
def daisy_radio(name, **options)
|
50
|
+
# Get the object name from the form builder
|
51
|
+
object_name = @object_name.to_s
|
52
|
+
|
53
|
+
# Create a unique ID if not provided
|
54
|
+
value = options[:value].to_s
|
55
|
+
options[:id] ||= "#{object_name}_#{name}_#{value}"
|
56
|
+
|
57
|
+
# Set the name attribute
|
58
|
+
options[:name] = "#{object_name}[#{name}]"
|
59
|
+
|
60
|
+
# Pass the form builder's object to the component if it exists
|
61
|
+
if @object && @object.respond_to?(name) && !options.key?(:checked)
|
62
|
+
options[:checked] = @object.send(name).to_s == value
|
63
|
+
end
|
64
|
+
|
65
|
+
# Render the radio button component
|
66
|
+
@template.daisy_radio(**options)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Add the daisy_label method to FormBuilder
|
70
|
+
def daisy_label(name, text = nil, **options, &block)
|
71
|
+
# Get the object name from the form builder
|
72
|
+
object_name = @object_name.to_s
|
73
|
+
|
74
|
+
# Create a for_id based on the name if not provided
|
75
|
+
options[:for] ||= "#{object_name}_#{name}"
|
76
|
+
|
77
|
+
# Add a humanized title from the name if not provided
|
78
|
+
options[:title] ||= text || name.to_s.humanize
|
79
|
+
|
80
|
+
# Render the label component
|
81
|
+
@template.daisy_label(**options, &block)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Add the daisy_range method to FormBuilder
|
85
|
+
def daisy_range(method, **options)
|
86
|
+
render_daisy_component(Daisy::DataInput::RangeComponent, method, **options)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Add the daisy_rating method to FormBuilder
|
90
|
+
def daisy_rating(method, **options)
|
91
|
+
render_daisy_component(Daisy::DataInput::RatingComponent, method, **options)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Add the daisy_file_input method to FormBuilder
|
95
|
+
def daisy_file_input(method, **options)
|
96
|
+
render_daisy_component(Daisy::DataInput::FileInputComponent, method, **options)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Add the daisy_text_input method to FormBuilder
|
100
|
+
def daisy_text_input(method, **options)
|
101
|
+
render_daisy_component(Daisy::DataInput::TextInputComponent, method, **options)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Add the daisy_text_area method to FormBuilder
|
105
|
+
def daisy_text_area(method, **options)
|
106
|
+
render_daisy_component(Daisy::DataInput::TextAreaComponent, method, **options)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Add the daisy_select method to FormBuilder
|
110
|
+
def daisy_select(method, options: nil, option_groups: nil, placeholder: nil,
|
111
|
+
options_css: nil, options_html: {}, **args, &block)
|
112
|
+
# Extract the name from the form builder's object_name and method
|
113
|
+
name = "#{object_name}[#{method}]"
|
114
|
+
|
115
|
+
# Get the current value from the object
|
116
|
+
value = object.try(method)
|
117
|
+
|
118
|
+
# Generate a default ID if not provided
|
119
|
+
id = args[:id] || "#{object_name}_#{method}"
|
120
|
+
|
121
|
+
# Build the component with the extracted form values and any additional options
|
122
|
+
@template.daisy_select(
|
123
|
+
name: name,
|
124
|
+
id: id,
|
125
|
+
value: value,
|
126
|
+
options: options,
|
127
|
+
options_css: options_css,
|
128
|
+
options_html: options_html,
|
129
|
+
placeholder: placeholder,
|
130
|
+
**args,
|
131
|
+
&block
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def render_daisy_component(component_class, method, **options)
|
138
|
+
# Get the object name from the form builder
|
139
|
+
object_name = @object_name.to_s
|
140
|
+
|
141
|
+
# Create a unique ID if not provided
|
142
|
+
options[:id] ||= "#{object_name}_#{method}"
|
143
|
+
|
144
|
+
# Set the name attribute
|
145
|
+
options[:name] ||= "#{object_name}[#{method}]"
|
146
|
+
|
147
|
+
# Pass the form builder's object to the component if it exists
|
148
|
+
options[:value] ||= object.try(method)
|
149
|
+
|
150
|
+
# Render the component
|
151
|
+
@template.render component_class.new(**options)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Include the FormBuilderHelper in ActionView::Helpers::FormBuilder
|
159
|
+
ActionView::Helpers::FormBuilder.include(Daisy::FormBuilderHelper)
|
data/lib/daisy.rb
CHANGED
@@ -22,8 +22,18 @@ module Daisy
|
|
22
22
|
#
|
23
23
|
module Feedback; end
|
24
24
|
|
25
|
+
#
|
26
|
+
# Holds all Data Input-type components.
|
27
|
+
#
|
28
|
+
module DataInput; end
|
29
|
+
|
25
30
|
#
|
26
31
|
# Holds all Layout-type components.
|
27
32
|
#
|
28
33
|
module Layout; end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Holds all Mockup-type components.
|
37
|
+
#
|
38
|
+
module Mockup; end
|
29
39
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class LocoMotion::BaseComponent < ViewComponent::Base
|
2
2
|
|
3
3
|
SELF_CLOSING_TAGS = %i[area base br col embed hr img input keygen link meta param source track wbr].freeze
|
4
|
+
EMPTY_PART_IGNORED_TAGS = %i[textarea].freeze
|
4
5
|
|
5
6
|
include Heroicons::IconsHelper
|
6
7
|
|
@@ -10,7 +11,7 @@ class LocoMotion::BaseComponent < ViewComponent::Base
|
|
10
11
|
class_attribute :valid_sizes, default: []
|
11
12
|
|
12
13
|
#
|
13
|
-
# Return the current
|
14
|
+
# Return the current configuration of this component.
|
14
15
|
#
|
15
16
|
# @return LocoMotion::ComponentConfig
|
16
17
|
#
|
@@ -225,12 +226,18 @@ class LocoMotion::BaseComponent < ViewComponent::Base
|
|
225
226
|
tag(tag_name, **rendered_html(part_name))
|
226
227
|
else
|
227
228
|
content_tag(tag_name, **rendered_html(part_name)) do
|
228
|
-
|
229
|
+
empty_part_content(tag_name)
|
229
230
|
end
|
230
231
|
end
|
231
232
|
end
|
232
233
|
end
|
233
234
|
|
235
|
+
def empty_part_content(tag_name)
|
236
|
+
unless EMPTY_PART_IGNORED_TAGS.include?(tag_name.to_sym)
|
237
|
+
"<!-- Empty Part Block //-->".html_safe
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
234
241
|
#
|
235
242
|
# Returns the user-provided or component-default HTML tag-name.
|
236
243
|
#
|
data/lib/loco_motion/engine.rb
CHANGED
@@ -4,5 +4,11 @@ module LocoMotion
|
|
4
4
|
|
5
5
|
config.autoload_paths << "#{root}/app"
|
6
6
|
config.autoload_paths << "#{root}/lib"
|
7
|
+
|
8
|
+
initializer "loco_motion.form_builder_extensions" do
|
9
|
+
ActiveSupport.on_load(:action_view) do
|
10
|
+
require_relative "../../app/helpers/daisy/form_builder_helper"
|
11
|
+
end
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
data/lib/loco_motion/helpers.rb
CHANGED
@@ -23,11 +23,24 @@ module LocoMotion
|
|
23
23
|
"Daisy::DataDisplay::CollapseComponent" => { names: "collapse", group: "Data", title: "Collapses", example: "collapses" },
|
24
24
|
"Daisy::DataDisplay::CountdownComponent" => { names: "countdown", group: "Data", title: "Countdowns", example: "countdowns" },
|
25
25
|
"Daisy::DataDisplay::DiffComponent" => { names: "diff", group: "Data", title: "Diffs", example: "diffs" },
|
26
|
+
"Daisy::DataDisplay::FigureComponent" => { names: "figure", group: "Data", title: "Figures", example: "figures" },
|
26
27
|
"Daisy::DataDisplay::KbdComponent" => { names: "kbd", group: "Data", title: "Keyboard (KBD)", example: "kbds" },
|
27
28
|
"Daisy::DataDisplay::StatComponent" => { names: "stat", group: "Data", title: "Stats", example: "stats" },
|
28
29
|
"Daisy::DataDisplay::TableComponent" => { names: "table", group: "Data", title: "Tables", example: "tables" },
|
29
30
|
"Daisy::DataDisplay::TimelineComponent" => { names: "timeline", group: "Data", title: "Timelines", example: "timelines" },
|
30
31
|
|
32
|
+
# Data Input
|
33
|
+
"Daisy::DataInput::CheckboxComponent" => { names: "checkbox", group: "Data Input", title: "Checkboxes", example: "checkboxes" },
|
34
|
+
"Daisy::DataInput::FileInputComponent" => { names: "file_input", group: "Data Input", title: "File Inputs", example: "file_inputs" },
|
35
|
+
"Daisy::DataInput::LabelComponent" => { names: "label", group: "Data Input", title: "Labels", example: "labels" },
|
36
|
+
"Daisy::DataInput::RadioButtonComponent" => { names: "radio", group: "Data Input", title: "Radio Buttons", example: "radio_buttons" },
|
37
|
+
"Daisy::DataInput::RangeComponent" => { names: "range", group: "Data Input", title: "Ranges", example: "ranges" },
|
38
|
+
"Daisy::DataInput::RatingComponent" => { names: "rating", group: "Data Input", title: "Ratings", example: "ratings" },
|
39
|
+
"Daisy::DataInput::SelectComponent" => { names: "select", group: "Data Input", title: "Selects", example: "selects" },
|
40
|
+
"Daisy::DataInput::TextInputComponent" => { names: "text_input", group: "Data Input", title: "Text Inputs", example: "text_inputs" },
|
41
|
+
"Daisy::DataInput::TextAreaComponent" => { names: "text_area", group: "Data Input", title: "Text Areas", example: "text_areas" },
|
42
|
+
"Daisy::DataInput::ToggleComponent" => { names: "toggle", group: "Data Input", title: "Toggles", example: "toggles" },
|
43
|
+
|
31
44
|
# Navigation
|
32
45
|
"Daisy::Navigation::BreadcrumbsComponent" => { names: "breadcrumbs", group: "Navigation", title: "Breadcrumbs", example: "breadcrumbs" },
|
33
46
|
"Daisy::Navigation::BottomNavComponent" => { names: "bottom_nav", group: "Navigation", title: "Bottom Navs", example: "bottom_navs" },
|
@@ -57,6 +70,12 @@ module LocoMotion
|
|
57
70
|
"Daisy::Layout::JoinComponent" => { names: "join", group: "Layout", title: "Joins", example: "joins" },
|
58
71
|
"Daisy::Layout::MaskComponent" => { names: nil, group: "Layout", title: "Masks", example: "masks" },
|
59
72
|
"Daisy::Layout::StackComponent" => { names: "stack", group: "Layout", title: "Stacks", example: "stacks" },
|
73
|
+
|
74
|
+
# Mockup
|
75
|
+
"Daisy::Mockup::BrowserComponent" => { names: "browser", group: "Mockup", title: "Browsers", example: "browsers" },
|
76
|
+
"Daisy::Mockup::CodeComponent" => { names: "code", group: "Mockup", title: "Code Blocks", example: "code_blocks" },
|
77
|
+
"Daisy::Mockup::DeviceComponent" => { names: "device", group: "Mockup", title: "Devices", example: "devices" },
|
78
|
+
"Daisy::Mockup::FrameComponent" => { names: "frame", group: "Mockup", title: "Frames", example: "frames" },
|
60
79
|
}
|
61
80
|
|
62
81
|
module Helpers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loco_motion-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topher Fangio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml-rails
|
@@ -45,6 +45,9 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '6.1'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '8.0'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,6 +55,9 @@ dependencies:
|
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '6.1'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '8.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: view_component
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,19 +227,39 @@ dependencies:
|
|
221
227
|
- !ruby/object:Gem::Version
|
222
228
|
version: '1.2'
|
223
229
|
- !ruby/object:Gem::Dependency
|
224
|
-
name:
|
230
|
+
name: pry
|
225
231
|
requirement: !ruby/object:Gem::Requirement
|
226
232
|
requirements:
|
227
233
|
- - "~>"
|
228
234
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
235
|
+
version: 0.15.0
|
230
236
|
type: :development
|
231
237
|
prerelease: false
|
232
238
|
version_requirements: !ruby/object:Gem::Requirement
|
233
239
|
requirements:
|
234
240
|
- - "~>"
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: 0.15.0
|
243
|
+
- !ruby/object:Gem::Dependency
|
244
|
+
name: rails
|
245
|
+
requirement: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ">="
|
235
248
|
- !ruby/object:Gem::Version
|
236
249
|
version: '6.1'
|
250
|
+
- - "<"
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '8.0'
|
253
|
+
type: :development
|
254
|
+
prerelease: false
|
255
|
+
version_requirements: !ruby/object:Gem::Requirement
|
256
|
+
requirements:
|
257
|
+
- - ">="
|
258
|
+
- !ruby/object:Gem::Version
|
259
|
+
version: '6.1'
|
260
|
+
- - "<"
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: '8.0'
|
237
263
|
- !ruby/object:Gem::Dependency
|
238
264
|
name: redcarpet
|
239
265
|
requirement: !ruby/object:Gem::Requirement
|
@@ -360,6 +386,7 @@ files:
|
|
360
386
|
- app/components/daisy/data_display/countdown_controller.js
|
361
387
|
- app/components/daisy/data_display/diff_component.html.haml
|
362
388
|
- app/components/daisy/data_display/diff_component.rb
|
389
|
+
- app/components/daisy/data_display/figure_component.rb
|
363
390
|
- app/components/daisy/data_display/kbd_component.rb
|
364
391
|
- app/components/daisy/data_display/stat_component.html.haml
|
365
392
|
- app/components/daisy/data_display/stat_component.rb
|
@@ -369,6 +396,19 @@ files:
|
|
369
396
|
- app/components/daisy/data_display/timeline_component.rb
|
370
397
|
- app/components/daisy/data_display/timeline_event_component.html.haml
|
371
398
|
- app/components/daisy/data_display/timeline_event_component.rb
|
399
|
+
- app/components/daisy/data_input/checkbox_component.rb
|
400
|
+
- app/components/daisy/data_input/file_input_component.rb
|
401
|
+
- app/components/daisy/data_input/label_component.rb
|
402
|
+
- app/components/daisy/data_input/radio_button_component.rb
|
403
|
+
- app/components/daisy/data_input/range_component.rb
|
404
|
+
- app/components/daisy/data_input/rating_component.html.haml
|
405
|
+
- app/components/daisy/data_input/rating_component.rb
|
406
|
+
- app/components/daisy/data_input/select_component.html.haml
|
407
|
+
- app/components/daisy/data_input/select_component.rb
|
408
|
+
- app/components/daisy/data_input/text_area_component.rb
|
409
|
+
- app/components/daisy/data_input/text_input_component.html.haml
|
410
|
+
- app/components/daisy/data_input/text_input_component.rb
|
411
|
+
- app/components/daisy/data_input/toggle_component.rb
|
372
412
|
- app/components/daisy/feedback/alert_component.html.haml
|
373
413
|
- app/components/daisy/feedback/alert_component.rb
|
374
414
|
- app/components/daisy/feedback/loading_component.rb
|
@@ -387,6 +427,10 @@ files:
|
|
387
427
|
- app/components/daisy/layout/indicator_component.rb
|
388
428
|
- app/components/daisy/layout/join_component.rb
|
389
429
|
- app/components/daisy/layout/stack_component.rb
|
430
|
+
- app/components/daisy/mockup/browser_component.rb
|
431
|
+
- app/components/daisy/mockup/code_component.rb
|
432
|
+
- app/components/daisy/mockup/device_component.rb
|
433
|
+
- app/components/daisy/mockup/frame_component.rb
|
390
434
|
- app/components/daisy/navigation/bottom_nav_component.rb
|
391
435
|
- app/components/daisy/navigation/breadcrumbs_component.html.haml
|
392
436
|
- app/components/daisy/navigation/breadcrumbs_component.rb
|
@@ -399,6 +443,7 @@ files:
|
|
399
443
|
- app/components/daisy/navigation/tabs_component.html.haml
|
400
444
|
- app/components/daisy/navigation/tabs_component.rb
|
401
445
|
- app/components/hero/icon_component.rb
|
446
|
+
- app/helpers/daisy/form_builder_helper.rb
|
402
447
|
- lib/daisy.rb
|
403
448
|
- lib/hero.rb
|
404
449
|
- lib/loco_motion.rb
|
@@ -410,6 +455,7 @@ files:
|
|
410
455
|
- lib/loco_motion/engine.rb
|
411
456
|
- lib/loco_motion/errors.rb
|
412
457
|
- lib/loco_motion/helpers.rb
|
458
|
+
- lib/loco_motion/version.rb
|
413
459
|
homepage: https://rubygems.org/gems/loco_motion-rails
|
414
460
|
licenses:
|
415
461
|
- MIT
|
@@ -423,7 +469,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
423
469
|
requirements:
|
424
470
|
- - ">="
|
425
471
|
- !ruby/object:Gem::Version
|
426
|
-
version: '0'
|
472
|
+
version: '3.0'
|
427
473
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
428
474
|
requirements:
|
429
475
|
- - ">="
|