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
@@ -0,0 +1,144 @@
|
|
1
|
+
#
|
2
|
+
# The CodeComponent creates stylized code blocks for displaying code snippets,
|
3
|
+
# terminal output, or any text that benefits from monospace formatting.
|
4
|
+
# Common use cases include:
|
5
|
+
# - Displaying code examples.
|
6
|
+
# - Showing terminal commands and output.
|
7
|
+
# - Highlighting important configuration settings.
|
8
|
+
# - Creating interactive tutorials.
|
9
|
+
#
|
10
|
+
# The component supports line prefixes (e.g., for line numbers or command
|
11
|
+
# prompts), syntax highlighting via CSS classes, and multi-line code blocks.
|
12
|
+
#
|
13
|
+
# @slot lines+ [Daisy::Mockup::CodeLineComponent] Individual lines of code,
|
14
|
+
# each with optional prefix and styling.
|
15
|
+
#
|
16
|
+
# @loco_example Basic Command with Prefix
|
17
|
+
# = daisy_code(prefix: "$") do
|
18
|
+
# yarn add @profoundry-us/loco_motion
|
19
|
+
#
|
20
|
+
# @loco_example Multi-line Terminal Output
|
21
|
+
# = daisy_code do |code|
|
22
|
+
# - code.with_line(prefix: "$") do
|
23
|
+
# npm install
|
24
|
+
# - code.with_line(prefix: ">", css: "text-warning") do
|
25
|
+
# Installing packages...
|
26
|
+
# - code.with_line(prefix: ">", css: "text-success") do
|
27
|
+
# Done in 2.45s
|
28
|
+
#
|
29
|
+
# @loco_example Code Block with Highlighting
|
30
|
+
# = daisy_code do |code|
|
31
|
+
# - code.with_line(prefix: "1") do
|
32
|
+
# def hello_world
|
33
|
+
# - code.with_line(prefix: "2", css: "bg-warning") do
|
34
|
+
# puts "Hello, world!"
|
35
|
+
# - code.with_line(prefix: "3") do
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# @loco_example Plain Code Block
|
39
|
+
# = daisy_code do
|
40
|
+
# :plain
|
41
|
+
# class Example
|
42
|
+
# def initialize
|
43
|
+
# @value = 42
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
class Daisy::Mockup::CodeComponent < LocoMotion::BaseComponent
|
48
|
+
|
49
|
+
#
|
50
|
+
# A component for rendering individual lines within a code block.
|
51
|
+
#
|
52
|
+
# @part code The code content for this line.
|
53
|
+
#
|
54
|
+
class Daisy::Mockup::CodeLineComponent < LocoMotion::BaseComponent
|
55
|
+
define_parts :code
|
56
|
+
|
57
|
+
#
|
58
|
+
# Creates a new code line.
|
59
|
+
#
|
60
|
+
# @option kws prefix [String] Optional prefix for the line (e.g., "$",
|
61
|
+
# ">", or line numbers).
|
62
|
+
# @option kws css [String] Additional CSS classes for styling the line.
|
63
|
+
#
|
64
|
+
def initialize(**kws)
|
65
|
+
super(**kws)
|
66
|
+
|
67
|
+
@prefix = config_option(:prefix)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Sets up the component's HTML tags and attributes.
|
72
|
+
#
|
73
|
+
def before_render
|
74
|
+
set_tag_name(:component, :pre)
|
75
|
+
set_tag_name(:code, :code)
|
76
|
+
|
77
|
+
add_html(:component, { "data-prefix": @prefix }) if @prefix
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Renders the line with its code content.
|
82
|
+
#
|
83
|
+
def call
|
84
|
+
part(:component) do
|
85
|
+
part(:code) do
|
86
|
+
content
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
define_parts :pre, :code
|
93
|
+
renders_many :lines, Daisy::Mockup::CodeLineComponent
|
94
|
+
|
95
|
+
#
|
96
|
+
# Creates a new code block component.
|
97
|
+
#
|
98
|
+
# @option kws prefix [String] Optional prefix for all lines (if not using
|
99
|
+
# individual line prefixes).
|
100
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
101
|
+
# options include:
|
102
|
+
# - Size: `w-full`, `max-w-3xl`
|
103
|
+
# - Background: `bg-base-300`, `bg-neutral`
|
104
|
+
# - Text: `text-sm`, `text-base-content`
|
105
|
+
#
|
106
|
+
def initialize(**kws)
|
107
|
+
super(**kws)
|
108
|
+
|
109
|
+
@prefix = config_option(:prefix)
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Sets up the component's CSS classes and HTML attributes.
|
114
|
+
#
|
115
|
+
def before_render
|
116
|
+
add_css(:component, "mockup-code")
|
117
|
+
|
118
|
+
set_tag_name(:pre, :pre)
|
119
|
+
set_tag_name(:code, :code)
|
120
|
+
|
121
|
+
add_html(:pre, { "data-prefix": @prefix }) if @prefix
|
122
|
+
|
123
|
+
# If the prefix is blank, add some left margin and hide the :before
|
124
|
+
# pseudo-element used for the prefix
|
125
|
+
add_css(:pre, "before:!hidden ml-6") if @prefix.blank?
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# Renders the code block with its lines or direct content.
|
130
|
+
#
|
131
|
+
def call
|
132
|
+
part(:component) do
|
133
|
+
if lines.any?
|
134
|
+
lines.each { |line| concat(line) }
|
135
|
+
else
|
136
|
+
part(:pre) do
|
137
|
+
part(:code) do
|
138
|
+
content
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#
|
2
|
+
# The DeviceComponent creates realistic device mockups for showcasing mobile
|
3
|
+
# and tablet applications. Common use cases include:
|
4
|
+
# - Displaying mobile app screenshots.
|
5
|
+
# - Creating marketing materials.
|
6
|
+
# - Demonstrating responsive designs.
|
7
|
+
# - Building portfolio pieces.
|
8
|
+
#
|
9
|
+
# The component includes an optional camera element and a display area that
|
10
|
+
# can contain any content, typically an ArtboardComponent for proper sizing.
|
11
|
+
#
|
12
|
+
# @part camera The device's camera element, shown at the top by default.
|
13
|
+
# @part display The main display area of the device.
|
14
|
+
#
|
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")
|
23
|
+
#
|
24
|
+
# @loco_example Tablet without Camera
|
25
|
+
# = 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
|
30
|
+
#
|
31
|
+
# @loco_example Styled Device
|
32
|
+
# = 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
|
37
|
+
#
|
38
|
+
class Daisy::Mockup::DeviceComponent < LocoMotion::BaseComponent
|
39
|
+
|
40
|
+
define_parts :camera, :display
|
41
|
+
|
42
|
+
#
|
43
|
+
# Creates a new Device component.
|
44
|
+
#
|
45
|
+
# @option kws show_camera [Boolean] Whether to show the camera element
|
46
|
+
# (default: true).
|
47
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
48
|
+
# options include:
|
49
|
+
# - Type: `mockup-phone`
|
50
|
+
# - Border: `border-2`, `border-primary`
|
51
|
+
# - Shadow: `shadow-lg`, `shadow-xl`
|
52
|
+
#
|
53
|
+
def initialize(**kws)
|
54
|
+
super(**kws)
|
55
|
+
|
56
|
+
@show_camera = config_option(:show_camera, true)
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Sets up the component's CSS classes.
|
61
|
+
#
|
62
|
+
def before_render
|
63
|
+
add_css(:camera, "camera")
|
64
|
+
add_css(:display, "display")
|
65
|
+
add_css(:display, "!mt-0") if !@show_camera
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Renders the device with its camera (if enabled) and display content.
|
70
|
+
#
|
71
|
+
def call
|
72
|
+
part(:component) do
|
73
|
+
concat(part(:camera)) if @show_camera
|
74
|
+
|
75
|
+
concat(part(:display) do
|
76
|
+
content
|
77
|
+
end)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# The FrameComponent creates a simple window-like container for showcasing
|
3
|
+
# content. Similar to the BrowserComponent but without the toolbar, it's
|
4
|
+
# perfect for:
|
5
|
+
# - Displaying application screenshots.
|
6
|
+
# - Creating simple window mockups.
|
7
|
+
# - Framing content in presentations.
|
8
|
+
# - Building marketing materials.
|
9
|
+
#
|
10
|
+
# The component provides a clean, minimal window frame that can be styled
|
11
|
+
# to match your design needs.
|
12
|
+
#
|
13
|
+
# @loco_example Basic Frame
|
14
|
+
# = daisy_frame(css: "border border-base-300") do
|
15
|
+
# .border-t.border-base-300.p-4
|
16
|
+
# Window content here
|
17
|
+
#
|
18
|
+
# @loco_example Styled Frame
|
19
|
+
# = daisy_frame(css: "bg-primary border-2") do
|
20
|
+
# .bg-base-100.border-t.p-8.text-center
|
21
|
+
# = image_tag("logo.png",
|
22
|
+
# class: "max-w-xs mx-auto")
|
23
|
+
# %p.mt-4
|
24
|
+
# Professional window mockup
|
25
|
+
#
|
26
|
+
# @loco_example Image Frame
|
27
|
+
# = daisy_frame(css: "shadow-xl") do
|
28
|
+
# .p-0
|
29
|
+
# = image_tag("screenshot.jpg",
|
30
|
+
# class: "w-full")
|
31
|
+
#
|
32
|
+
class Daisy::Mockup::FrameComponent < LocoMotion::BaseComponent
|
33
|
+
#
|
34
|
+
# Creates a new Frame component.
|
35
|
+
#
|
36
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
37
|
+
# options include:
|
38
|
+
# - Size: `w-full`, `max-w-4xl`
|
39
|
+
# - Border: `border`, `border-primary`
|
40
|
+
# - Background: `bg-base-100`, `bg-primary`
|
41
|
+
# - Shadow: `shadow-lg`, `shadow-xl`
|
42
|
+
#
|
43
|
+
def initialize(**kws)
|
44
|
+
super(**kws)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Sets up the component's CSS classes.
|
49
|
+
#
|
50
|
+
def before_render
|
51
|
+
add_css(:component, "mockup-window")
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Renders the frame with its content.
|
56
|
+
#
|
57
|
+
def call
|
58
|
+
part(:component) do
|
59
|
+
content
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,11 +1,76 @@
|
|
1
|
+
#
|
2
|
+
# Creates a bottom navigation bar, typically used in mobile-friendly applications
|
3
|
+
# to provide quick access to important sections.
|
4
|
+
#
|
5
|
+
# @slot sections+ {Daisy::Navigation::BottomNavSectionComponent} The sections to display in the navigation bar.
|
6
|
+
#
|
7
|
+
# @example Basic bottom nav with icons
|
8
|
+
# = daisy_bottom_nav do |nav|
|
9
|
+
# - nav.with_section(icon: "home", href: "#")
|
10
|
+
# - nav.with_section(icon: "information-circle", href: "#", active: true)
|
11
|
+
# - nav.with_section(icon: "chart-bar", href: "#")
|
12
|
+
#
|
13
|
+
# @example Bottom nav with titles
|
14
|
+
# = daisy_bottom_nav do |nav|
|
15
|
+
# - nav.with_section(icon: "home", href: "#", title: "Home")
|
16
|
+
# - nav.with_section(icon: "information-circle", href: "#", title: "Info")
|
17
|
+
# - nav.with_section(icon: "chart-bar", href: "#", title: "Stats")
|
18
|
+
#
|
19
|
+
# @example Colored bottom nav
|
20
|
+
# = daisy_bottom_nav do |nav|
|
21
|
+
# - nav.with_section(icon: "home", href: "#", css: "text-primary")
|
22
|
+
# - nav.with_section(icon: "information-circle", href: "#", css: "text-secondary")
|
23
|
+
# - nav.with_section(icon: "chart-bar", href: "#", css: "text-accent")
|
24
|
+
#
|
1
25
|
class Daisy::Navigation::BottomNavComponent < LocoMotion::BaseComponent
|
2
26
|
|
27
|
+
#
|
28
|
+
# A section within a Bottom Navigation component.
|
29
|
+
#
|
30
|
+
# @part icon The icon element for the section.
|
31
|
+
# @part title The title element for the section.
|
32
|
+
#
|
33
|
+
# @example Basic section with icon
|
34
|
+
# = daisy_bottom_nav do |nav|
|
35
|
+
# - nav.with_section(icon: "home", href: "#")
|
36
|
+
#
|
37
|
+
# @example Active section with title
|
38
|
+
# = daisy_bottom_nav do |nav|
|
39
|
+
# - nav.with_section(icon: "information-circle", href: "#", active: true, title: "Info")
|
40
|
+
#
|
41
|
+
# @example Custom title content
|
42
|
+
# = daisy_bottom_nav do |nav|
|
43
|
+
# - nav.with_section(icon: "chart-bar", href: "#") do
|
44
|
+
# .font-bold.text-xs
|
45
|
+
# Stats
|
46
|
+
#
|
3
47
|
class Daisy::Navigation::BottomNavSectionComponent < LocoMotion::BaseComponent
|
4
48
|
|
5
49
|
define_parts :icon, :title
|
6
50
|
|
7
|
-
|
8
|
-
|
51
|
+
# Creates a new bottom navigation section.
|
52
|
+
#
|
53
|
+
# @param kws [Hash] The keyword arguments for the component.
|
54
|
+
#
|
55
|
+
# @option kws icon [String] The name of the icon to display.
|
56
|
+
#
|
57
|
+
# @option kws icon_variant [Symbol] The variant of the icon to use (default: :outline).
|
58
|
+
#
|
59
|
+
# @option kws icon_css [String] Additional CSS classes for the icon.
|
60
|
+
#
|
61
|
+
# @option kws title [String] Optional text to display below the icon.
|
62
|
+
#
|
63
|
+
# @option kws href [String] Optional URL to make the section a link.
|
64
|
+
#
|
65
|
+
# @option kws active [Boolean] Whether this section is currently active (default: false).
|
66
|
+
#
|
67
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
68
|
+
# options include:
|
69
|
+
# - Text color: `text-primary`, `text-secondary`, `text-accent`
|
70
|
+
# - Custom colors: `text-[#449944]`
|
71
|
+
#
|
72
|
+
def initialize(**kws)
|
73
|
+
super(**kws)
|
9
74
|
|
10
75
|
@icon = config_option(:icon)
|
11
76
|
@icon_variant = config_option(:icon_variant, :outline)
|
@@ -42,6 +107,20 @@ class Daisy::Navigation::BottomNavComponent < LocoMotion::BaseComponent
|
|
42
107
|
|
43
108
|
renders_many :sections, Daisy::Navigation::BottomNavSectionComponent
|
44
109
|
|
110
|
+
# Creates a new bottom navigation component.
|
111
|
+
#
|
112
|
+
# @param kws [Hash] The keyword arguments for the component.
|
113
|
+
#
|
114
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
115
|
+
# options include:
|
116
|
+
# - Position: `relative`, `fixed bottom-0`
|
117
|
+
# - Width: `w-full`, `max-w-[400px]`
|
118
|
+
# - Border: `border`, `border-base-200`
|
119
|
+
#
|
120
|
+
def initialize(**kws)
|
121
|
+
super(**kws)
|
122
|
+
end
|
123
|
+
|
45
124
|
def before_render
|
46
125
|
add_css(:component, "btm-nav")
|
47
126
|
end
|
@@ -1,15 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Creates a breadcrumb navigation component to show the user's location within
|
3
|
+
# a website or app.
|
4
|
+
#
|
5
|
+
# @part list_wrapper The unordered list element that wraps the breadcrumb items.
|
6
|
+
#
|
7
|
+
# @slot items+ {LocoMotion::BasicComponent} The individual breadcrumb items.
|
8
|
+
# Each item is rendered as a list item (`<li>`) element.
|
9
|
+
#
|
10
|
+
# @example Basic breadcrumbs with text
|
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", "#"
|
18
|
+
#
|
19
|
+
# @example Breadcrumbs with icons
|
20
|
+
# = daisy_breadcrumbs do |breadcrumbs|
|
21
|
+
# - breadcrumbs.with_item do
|
22
|
+
# = link_to "#" do
|
23
|
+
# = hero_icon("home", css: "size-4 mr-1")
|
24
|
+
# Home
|
25
|
+
# - breadcrumbs.with_item do
|
26
|
+
# = link_to "#" do
|
27
|
+
# = hero_icon("document", css: "size-4 mr-1")
|
28
|
+
# Docs
|
29
|
+
#
|
1
30
|
class Daisy::Navigation::BreadcrumbsComponent < LocoMotion::BaseComponent
|
2
31
|
define_parts :list_wrapper
|
3
32
|
|
4
33
|
renders_many :items, LocoMotion::BasicComponent.build(tag_name: :li)
|
5
34
|
|
6
|
-
|
7
|
-
|
35
|
+
# Create a new instance of the BreadcrumbsComponent.
|
36
|
+
#
|
37
|
+
# @param kws [Hash] The keyword arguments for the component.
|
38
|
+
#
|
39
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
40
|
+
# options include:
|
41
|
+
# - Text: `text-sm`, `text-base-content`
|
42
|
+
# - Spacing: `space-x-2`, `gap-4`
|
43
|
+
#
|
44
|
+
def initialize(**kws)
|
45
|
+
super(**kws)
|
8
46
|
end
|
9
47
|
|
10
48
|
def before_render
|
11
49
|
add_css(:component, "breadcrumbs")
|
12
|
-
|
13
50
|
set_tag_name(:list_wrapper, :ul)
|
14
51
|
end
|
15
52
|
end
|
@@ -1,6 +1,20 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
2
|
+
# Creates a styled link component that can be used for navigation or inline text
|
3
|
+
# links. This component is designed to work similarly to Rails' `link_to` helper.
|
4
|
+
#
|
5
|
+
# @example Link with custom styling
|
6
|
+
# = daisy_link "Components", "#", css: "link-primary text-xl"
|
7
|
+
#
|
8
|
+
# @example Link with block content
|
9
|
+
# = daisy_link "#", css: "link-hover" do
|
10
|
+
# = hero_icon("home")
|
11
|
+
# Home
|
12
|
+
#
|
13
|
+
# @example Link with positional arguments
|
14
|
+
# = daisy_link "Documentation", "#"
|
15
|
+
#
|
16
|
+
# @example Basic link with keyword arguments
|
17
|
+
# = daisy_link(title: "Home", href: "#")
|
4
18
|
#
|
5
19
|
class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
6
20
|
prepend LocoMotion::Concerns::TippableComponent
|
@@ -12,13 +26,24 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
|
12
26
|
# and the second is considered the `href`.
|
13
27
|
# - If passed only **one** positional argument, it is treated as the `href`
|
14
28
|
# and we assume the `title` will be provided in the block.
|
15
|
-
# - If no text is passed in the block, we will use the `href` as the title
|
29
|
+
# - If no text is passed in the block, we will use the `href` as the title.
|
30
|
+
#
|
16
31
|
# @param kws [Hash] The keyword arguments for the component.
|
17
32
|
#
|
18
|
-
# @option kws title [String] The text to display in the link.
|
33
|
+
# @option kws title [String] The text to display in the link. Not required if
|
34
|
+
# providing block content.
|
35
|
+
#
|
19
36
|
# @option kws href [String] The URL to visit when the link is clicked.
|
20
|
-
#
|
21
|
-
|
37
|
+
#
|
38
|
+
# @option kws target [String] The target attribute for the anchor tag (e.g., "_blank").
|
39
|
+
#
|
40
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
41
|
+
# options include:
|
42
|
+
# - Style: `link-primary`, `link-secondary`, `link-accent`
|
43
|
+
# - State: `link-hover`
|
44
|
+
# - Text: `text-sm`, `text-xl`, `text-2xl`
|
45
|
+
#
|
46
|
+
def initialize(*args, **kws)
|
22
47
|
super
|
23
48
|
|
24
49
|
if args.size == 1
|
@@ -1,34 +1,53 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# Creates a menu component for displaying a list of items, optionally with group titles.
|
3
3
|
#
|
4
|
-
# @slot
|
5
|
-
# items.
|
4
|
+
# @slot items+ {Daisy::Navigation::MenuItemComponent} The menu items to display.
|
6
5
|
#
|
7
|
-
# @
|
6
|
+
# @example Basic menu with items
|
8
7
|
# = daisy_menu do |menu|
|
9
|
-
# -
|
10
|
-
#
|
11
|
-
#
|
8
|
+
# - menu.with_item do
|
9
|
+
# = link_to "Item 1", "#"
|
10
|
+
# - menu.with_item do
|
11
|
+
# = link_to "Item 2", "#"
|
12
12
|
#
|
13
|
-
#
|
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", "#"
|
14
18
|
# - menu.with_item("Group 2") do
|
15
|
-
# = link_to "Item 2
|
19
|
+
# = link_to "Item 2-1", "#"
|
20
|
+
# = link_to "Item 2-2", "#"
|
16
21
|
#
|
17
|
-
#
|
22
|
+
# @example Menu with disabled items
|
23
|
+
# = daisy_menu do |menu|
|
18
24
|
# - menu.with_item do
|
19
|
-
# = link_to "Item
|
25
|
+
# = link_to "Active Item", "#"
|
26
|
+
# - menu.with_item(disabled: true) do
|
27
|
+
# Disabled Item
|
20
28
|
#
|
21
29
|
class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
22
30
|
|
23
31
|
#
|
24
|
-
#
|
32
|
+
# A menu item component that can optionally have a title and be disabled.
|
33
|
+
#
|
34
|
+
# @part title The title element for the menu item.
|
25
35
|
#
|
26
|
-
# @
|
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", "#"
|
27
47
|
#
|
28
48
|
class Daisy::Navigation::MenuItemComponent < LocoMotion::BaseComponent
|
29
49
|
define_part :title
|
30
50
|
|
31
|
-
#
|
32
51
|
# Create a new instance of the MenuItemComponent.
|
33
52
|
#
|
34
53
|
# @param args [Array] If provided, the first argument is considered the
|
@@ -37,10 +56,16 @@ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
|
37
56
|
# @param kws [Hash] The keyword arguments for the component.
|
38
57
|
#
|
39
58
|
# @option kws title [String] Shows an additional title above the item.
|
59
|
+
#
|
40
60
|
# @option kws disabled [Boolean] Sets the item in a disabled state.
|
41
61
|
#
|
42
|
-
|
43
|
-
|
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)
|
44
69
|
|
45
70
|
@simple_title = config_option(:title, args[0])
|
46
71
|
@disabled = config_option(:disabled)
|
@@ -71,12 +96,19 @@ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
|
71
96
|
|
72
97
|
renders_many :items, Daisy::Navigation::MenuItemComponent
|
73
98
|
|
99
|
+
# Create a new instance of the MenuComponent.
|
100
|
+
#
|
101
|
+
# @param kws [Hash] The keyword arguments for the component.
|
74
102
|
#
|
75
|
-
#
|
76
|
-
#
|
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`
|
77
109
|
#
|
78
|
-
def initialize(
|
79
|
-
super
|
110
|
+
def initialize(**kws)
|
111
|
+
super(**kws)
|
80
112
|
end
|
81
113
|
|
82
114
|
#
|
@@ -1,12 +1,73 @@
|
|
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
|
+
#
|
1
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
|
-
|
7
|
-
|
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
|