loco_motion-rails 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/app/components/daisy/actions/button_component.html.haml +2 -2
- data/app/components/daisy/actions/button_component.rb +98 -59
- data/app/components/daisy/actions/dropdown_component.html.haml +1 -2
- data/app/components/daisy/actions/dropdown_component.rb +7 -10
- data/app/components/daisy/actions/modal_component.html.haml +10 -8
- data/app/components/daisy/actions/modal_component.rb +6 -6
- data/app/components/daisy/actions/swap_component.rb +13 -9
- data/app/components/daisy/actions/theme_controller.js +113 -0
- data/app/components/daisy/actions/theme_controller_component.rb +58 -17
- data/app/components/daisy/actions/theme_preview_component.html.haml +5 -0
- data/app/components/daisy/actions/theme_preview_component.rb +68 -0
- data/app/components/daisy/data_display/accordion_component.html.haml +0 -1
- data/app/components/daisy/data_display/accordion_component.rb +10 -3
- data/app/components/daisy/data_display/avatar_component.html.haml +1 -1
- data/app/components/daisy/data_display/avatar_component.rb +17 -7
- data/app/components/daisy/data_display/badge_component.rb +122 -4
- data/app/components/daisy/data_display/card_component.html.haml +1 -1
- data/app/components/daisy/data_display/card_component.rb +20 -6
- data/app/components/daisy/data_display/chat_component.rb +2 -2
- data/app/components/daisy/data_display/collapse_component.rb +9 -5
- data/app/components/daisy/data_display/countdown_component.rb +15 -5
- data/app/components/daisy/data_display/figure_component.rb +8 -3
- data/app/components/daisy/data_display/kbd_component.rb +13 -4
- data/app/components/daisy/data_display/list_component.html.haml +5 -0
- data/app/components/daisy/data_display/list_component.rb +82 -0
- data/app/components/daisy/data_display/list_item_component.rb +39 -0
- data/app/components/daisy/data_display/stat_component.html.haml +5 -6
- data/app/components/daisy/data_display/stat_component.rb +21 -8
- data/app/components/daisy/data_display/status_component.rb +47 -0
- data/app/components/daisy/data_display/timeline_component.rb +1 -1
- data/app/components/daisy/data_input/cally_component.html.haml +14 -0
- data/app/components/daisy/data_input/cally_component.rb +182 -0
- data/app/components/daisy/data_input/cally_input_component.html.haml +5 -0
- data/app/components/daisy/data_input/cally_input_component.rb +165 -0
- data/app/components/daisy/data_input/cally_input_controller.js +235 -0
- data/app/components/daisy/data_input/checkbox_component.html.haml +20 -0
- data/app/components/daisy/data_input/checkbox_component.rb +21 -7
- data/app/components/daisy/data_input/fieldset_component.html.haml +8 -0
- data/app/components/daisy/data_input/fieldset_component.rb +57 -0
- data/app/components/daisy/data_input/file_input_component.rb +6 -0
- data/app/components/daisy/data_input/filter_component.html.haml +3 -0
- data/app/components/daisy/data_input/filter_component.rb +221 -0
- data/app/components/daisy/data_input/label_component.rb +2 -2
- data/app/components/daisy/data_input/radio_button_component.rb +1 -1
- data/app/components/daisy/data_input/rating_component.html.haml +0 -2
- data/app/components/daisy/data_input/rating_component.rb +3 -2
- data/app/components/daisy/data_input/select_component.html.haml +27 -15
- data/app/components/daisy/data_input/select_component.rb +152 -10
- data/app/components/daisy/data_input/text_area_component.rb +11 -8
- data/app/components/daisy/data_input/text_input_component.html.haml +25 -4
- data/app/components/daisy/data_input/text_input_component.rb +38 -36
- data/app/components/daisy/data_input/toggle_component.rb +12 -0
- data/app/components/daisy/feedback/alert_component.html.haml +1 -1
- data/app/components/daisy/feedback/alert_component.rb +86 -2
- data/app/components/daisy/feedback/loading_component.rb +10 -3
- data/app/components/daisy/feedback/skeleton_component.rb +1 -1
- data/app/components/daisy/layout/divider_component.rb +4 -2
- data/app/components/daisy/layout/drawer_component.html.haml +0 -1
- data/app/components/daisy/layout/footer_component.rb +6 -6
- data/app/components/daisy/mockup/device_component.rb +15 -18
- data/app/components/daisy/navigation/breadcrumbs_component.html.haml +0 -1
- data/app/components/daisy/navigation/breadcrumbs_component.rb +84 -9
- data/app/components/daisy/navigation/dock_component.rb +146 -0
- data/app/components/daisy/navigation/link_component.rb +18 -9
- data/app/components/daisy/navigation/menu_component.rb +15 -9
- data/app/components/daisy/navigation/navbar_component.html.haml +1 -1
- data/app/components/daisy/navigation/navbar_component.rb +2 -13
- data/app/components/daisy/navigation/steps_component.rb +6 -6
- data/app/components/daisy/navigation/tabs_component.html.haml +0 -1
- data/app/components/daisy/navigation/tabs_component.rb +26 -16
- data/app/components/hero/icon_component.rb +15 -5
- data/app/helpers/daisy/form_builder_helper.rb +30 -3
- data/app/views/examples/daisy/data_input/filters.html.haml +62 -0
- data/lib/hero.rb +1 -1
- data/lib/loco_motion/base_component.rb +44 -1
- data/lib/loco_motion/component_config.rb +1 -0
- data/lib/loco_motion/concerns/iconable_component.rb +134 -0
- data/lib/loco_motion/concerns/labelable_component.rb +142 -0
- data/lib/loco_motion/concerns/linkable_component.rb +40 -0
- data/lib/loco_motion/concerns/tippable_component.rb +25 -10
- data/lib/loco_motion/helpers.rb +27 -18
- data/lib/loco_motion/patches/view_component/slot_loco_parent_patch.rb +37 -0
- data/lib/loco_motion/patches/view_component/slotable_default_patch.rb +21 -0
- data/lib/loco_motion/version.rb +1 -1
- data/lib/loco_motion.rb +12 -2
- metadata +65 -19
- data/app/components/daisy/actions/theme_controller_component.html.haml +0 -5
- data/app/components/daisy/layout/artboard_component.rb +0 -59
- data/app/components/daisy/navigation/bottom_nav_component.rb +0 -138
@@ -51,8 +51,10 @@ class Daisy::Layout::DividerComponent < LocoMotion::BaseComponent
|
|
51
51
|
# `divider-accent`, `divider-info`, `divider-success`,
|
52
52
|
# `divider-warning`, `divider-error`
|
53
53
|
#
|
54
|
-
def initialize(
|
54
|
+
def initialize(title = nil, **kws, &block)
|
55
55
|
super
|
56
|
+
|
57
|
+
@simple_title = config_option(:title, title)
|
56
58
|
end
|
57
59
|
|
58
60
|
#
|
@@ -66,7 +68,7 @@ class Daisy::Layout::DividerComponent < LocoMotion::BaseComponent
|
|
66
68
|
# Renders the component and its content.
|
67
69
|
#
|
68
70
|
def call
|
69
|
-
part(:component) { content }
|
71
|
+
part(:component) { content || @simple_title }
|
70
72
|
end
|
71
73
|
|
72
74
|
end
|
@@ -6,10 +6,10 @@
|
|
6
6
|
# - Contact details and social media links.
|
7
7
|
# - Newsletter signup forms.
|
8
8
|
#
|
9
|
-
#
|
10
|
-
#
|
9
|
+
# @note Footers are vertical by default. Use `footer-horizontal` to make it
|
10
|
+
# horizontal at your desired screen size (e.g., `lg:footer-horizontal`).
|
11
11
|
#
|
12
|
-
# @loco_example Basic Navigation Footer
|
12
|
+
# @loco_example Basic Navigation Footer (Vertical)
|
13
13
|
# = daisy_footer(css: "bg-neutral text-neutral-content p-10") do
|
14
14
|
# %nav
|
15
15
|
# %h6.footer-title Company
|
@@ -17,8 +17,8 @@
|
|
17
17
|
# = link_to "Contact", "/contact", class: "link-hover"
|
18
18
|
# = link_to "Jobs", "/careers", class: "link-hover"
|
19
19
|
#
|
20
|
-
# @loco_example
|
21
|
-
# = daisy_footer(css: "bg-base-200 text-base-content p-10") do
|
20
|
+
# @loco_example Horizontal Footer
|
21
|
+
# = daisy_footer(css: "bg-base-200 text-base-content p-10 lg:footer-horizontal") do
|
22
22
|
# %nav
|
23
23
|
# %h6.footer-title Products
|
24
24
|
# = link_to "Features", "#", class: "link-hover"
|
@@ -46,7 +46,7 @@ class Daisy::Layout::FooterComponent < LocoMotion::BaseComponent
|
|
46
46
|
# - Background: `bg-neutral`, `bg-base-200`
|
47
47
|
# - Text color: `text-neutral-content`, `text-base-content`
|
48
48
|
# - Spacing: `p-4`, `p-10`
|
49
|
-
# - Layout: `text-center`, `
|
49
|
+
# - Layout: `text-center`, `footer-horizontal` (or `lg:footer-horizontal` for large screens)
|
50
50
|
#
|
51
51
|
def initialize(**kws)
|
52
52
|
super
|
@@ -7,33 +7,30 @@
|
|
7
7
|
# - Building portfolio pieces.
|
8
8
|
#
|
9
9
|
# The component includes an optional camera element and a display area that
|
10
|
-
# can contain any content
|
10
|
+
# can contain any content with appropriate sizing classes.
|
11
11
|
#
|
12
12
|
# @part camera The device's camera element, shown at the top by default.
|
13
13
|
# @part display The main display area of the device.
|
14
14
|
#
|
15
15
|
# @loco_example Phone with Camera
|
16
|
-
# = daisy_device(css: "mockup-phone") do
|
17
|
-
#
|
18
|
-
# .
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# class: "rounded-lg")
|
16
|
+
# = daisy_device(css: "mockup-phone", display_css: "overflow-auto") do
|
17
|
+
# .flex.flex-col.gap-4.p-4.pt-12.pb-8.bg-white
|
18
|
+
# .text-2xl.font-bold
|
19
|
+
# My App
|
20
|
+
# = image_tag("screenshot.jpg",
|
21
|
+
# class: "rounded-lg")
|
23
22
|
#
|
24
23
|
# @loco_example Tablet without Camera
|
25
24
|
# = daisy_device(css: "mockup-phone border-primary",
|
26
|
-
# show_camera: false) do
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# Tablet Content Here
|
25
|
+
# display_css: "overflow-auto w-[736px] h-[414px]", show_camera: false) do
|
26
|
+
# .flex.flex-col.gap-4.p-4.bg-white
|
27
|
+
# Tablet Content Here
|
30
28
|
#
|
31
29
|
# @loco_example Styled Device
|
32
30
|
# = daisy_device(css: "mockup-phone border-4
|
33
|
-
# border-accent shadow-xl") do
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# Premium App Design
|
31
|
+
# border-accent shadow-xl", display_css: "w-[320px] h-[568px]") do
|
32
|
+
# .flex.flex-col.p-4.bg-gradient-to-br.from-primary.to-accent
|
33
|
+
# Premium App Design
|
37
34
|
#
|
38
35
|
class Daisy::Mockup::DeviceComponent < LocoMotion::BaseComponent
|
39
36
|
|
@@ -60,8 +57,8 @@ class Daisy::Mockup::DeviceComponent < LocoMotion::BaseComponent
|
|
60
57
|
# Sets up the component's CSS classes.
|
61
58
|
#
|
62
59
|
def before_render
|
63
|
-
add_css(:camera, "camera")
|
64
|
-
add_css(:display, "display")
|
60
|
+
add_css(:camera, "mockup-phone-camera")
|
61
|
+
add_css(:display, "mockup-phone-display")
|
65
62
|
add_css(:display, "!mt-0") if !@show_camera
|
66
63
|
end
|
67
64
|
|
@@ -7,16 +7,14 @@
|
|
7
7
|
# @slot items+ {LocoMotion::BasicComponent} The individual breadcrumb items.
|
8
8
|
# Each item is rendered as a list item (`<li>`) element.
|
9
9
|
#
|
10
|
-
# @
|
10
|
+
# @loco_example Basic breadcrumbs with text
|
11
11
|
# = daisy_breadcrumbs do |breadcrumbs|
|
12
|
-
# - breadcrumbs.with_item
|
13
|
-
#
|
14
|
-
# - breadcrumbs.with_item do
|
15
|
-
#
|
16
|
-
# - breadcrumbs.with_item do
|
17
|
-
# = link_to "Components", "#"
|
12
|
+
# - breadcrumbs.with_item(title: "Docs", href: "/")
|
13
|
+
# - breadcrumbs.with_item("Breadcrumbs", "/examples")
|
14
|
+
# - breadcrumbs.with_item(css: "italic") do
|
15
|
+
# This example
|
18
16
|
#
|
19
|
-
# @
|
17
|
+
# @loco_example Breadcrumbs with icons
|
20
18
|
# = daisy_breadcrumbs do |breadcrumbs|
|
21
19
|
# - breadcrumbs.with_item do
|
22
20
|
# = link_to "#" do
|
@@ -28,9 +26,82 @@
|
|
28
26
|
# Docs
|
29
27
|
#
|
30
28
|
class Daisy::Navigation::BreadcrumbsComponent < LocoMotion::BaseComponent
|
29
|
+
|
30
|
+
|
31
|
+
# Component for a single breadcrumb item in a breadcrumbs trail.
|
32
|
+
#
|
33
|
+
# @part link The link element wrapping the breadcrumb content when an href is
|
34
|
+
# provided.
|
35
|
+
#
|
36
|
+
# @loco_example Simple usage
|
37
|
+
# = render Daisy::Navigation::BreadcrumbItemComponent.new("Home", "/")
|
38
|
+
#
|
39
|
+
# @loco_example With icon
|
40
|
+
# = render Daisy::Navigation::BreadcrumbItemComponent.new("Home", "/", icon: :home)
|
41
|
+
#
|
42
|
+
# @see Daisy::Navigation::BreadcrumbsComponent
|
43
|
+
class Daisy::Navigation::BreadcrumbItemComponent < LocoMotion::BaseComponent
|
44
|
+
include LocoMotion::Concerns::IconableComponent
|
45
|
+
include LocoMotion::Concerns::TippableComponent
|
46
|
+
|
47
|
+
define_part :link
|
48
|
+
|
49
|
+
# Initialize a breadcrumb item component.
|
50
|
+
#
|
51
|
+
# @param title [String, nil] The display text for the breadcrumb.
|
52
|
+
#
|
53
|
+
# @param href [String, nil] The URL for the breadcrumb link.
|
54
|
+
#
|
55
|
+
# @param args [Array] Additional positional arguments passed to the
|
56
|
+
# component.
|
57
|
+
#
|
58
|
+
# @param kws [Hash] Additional keyword options.
|
59
|
+
#
|
60
|
+
# @option kws icon [Symbol] Icon name to display before the title.
|
61
|
+
#
|
62
|
+
# @option kws tip [String] Tooltip text shown on hover.
|
63
|
+
def initialize(title = nil, href = nil, *args, **kws)
|
64
|
+
super
|
65
|
+
|
66
|
+
@simple_title = config_option(:title, title)
|
67
|
+
@href = config_option(:href, href)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Configure the component before rendering.
|
71
|
+
#
|
72
|
+
# Sets the component tag to be a list item and configures the link part with
|
73
|
+
# the href value.
|
74
|
+
def before_render
|
75
|
+
set_tag_name(:component, :li)
|
76
|
+
|
77
|
+
set_tag_name(:link, "a")
|
78
|
+
add_html(:link, { href: @href })
|
79
|
+
end
|
80
|
+
|
81
|
+
def call
|
82
|
+
part(:component) do
|
83
|
+
if @href
|
84
|
+
part(:link) do
|
85
|
+
render_icon_and_content
|
86
|
+
end
|
87
|
+
else
|
88
|
+
render_icon_and_content
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Render the icon (if provided) and content.
|
94
|
+
#
|
95
|
+
# @return [String] The rendered HTML for the icon and content.
|
96
|
+
def render_icon_and_content
|
97
|
+
concat(render_icon)
|
98
|
+
concat(content || @simple_title)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
31
102
|
define_parts :list_wrapper
|
32
103
|
|
33
|
-
renders_many :items,
|
104
|
+
renders_many :items, Daisy::Navigation::BreadcrumbItemComponent
|
34
105
|
|
35
106
|
# Create a new instance of the BreadcrumbsComponent.
|
36
107
|
#
|
@@ -45,6 +116,10 @@ class Daisy::Navigation::BreadcrumbsComponent < LocoMotion::BaseComponent
|
|
45
116
|
super(**kws)
|
46
117
|
end
|
47
118
|
|
119
|
+
# Configure the component before rendering.
|
120
|
+
#
|
121
|
+
# Adds the breadcrumbs CSS class and sets the list wrapper to use an
|
122
|
+
# unordered list element.
|
48
123
|
def before_render
|
49
124
|
add_css(:component, "breadcrumbs")
|
50
125
|
set_tag_name(:list_wrapper, :ul)
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#
|
2
|
+
# Creates a dock navigation bar, typically used in mobile-friendly applications
|
3
|
+
# to provide quick access to important sections.
|
4
|
+
#
|
5
|
+
# @slot sections+ {Daisy::Navigation::DockSectionComponent} The sections to display in the dock.
|
6
|
+
#
|
7
|
+
# @loco_example Basic dock with icons
|
8
|
+
# = daisy_dock do |dock|
|
9
|
+
# - dock.with_section(icon: "home", href: "#")
|
10
|
+
# - dock.with_section(icon: "information-circle", href: "#", active: true)
|
11
|
+
# - dock.with_section(icon: "chart-bar", href: "#")
|
12
|
+
#
|
13
|
+
# @loco_example Dock with titles
|
14
|
+
# = daisy_dock do |dock|
|
15
|
+
# - dock.with_section(icon: "home", href: "#", title: "Home")
|
16
|
+
# - dock.with_section(icon: "information-circle", href: "#", title: "Info")
|
17
|
+
# - dock.with_section(icon: "chart-bar", href: "#", title: "Stats")
|
18
|
+
#
|
19
|
+
# @loco_example Colored dock
|
20
|
+
# = daisy_dock do |dock|
|
21
|
+
# - dock.with_section(icon: "home", href: "#", css: "text-primary")
|
22
|
+
# - dock.with_section(icon: "information-circle", href: "#", css: "text-secondary")
|
23
|
+
# - dock.with_section(icon: "chart-bar", href: "#", css: "text-accent")
|
24
|
+
#
|
25
|
+
class Daisy::Navigation::DockComponent < LocoMotion::BaseComponent
|
26
|
+
|
27
|
+
#
|
28
|
+
# A section within a Dock component.
|
29
|
+
#
|
30
|
+
# @part icon The icon element for the section.
|
31
|
+
# @part title The title element for the section.
|
32
|
+
#
|
33
|
+
# @loco_example Basic section with icon
|
34
|
+
# = daisy_dock do |dock|
|
35
|
+
# - dock.with_section(icon: "home", href: "#")
|
36
|
+
#
|
37
|
+
# @loco_example Active section with title
|
38
|
+
# = daisy_dock do |dock|
|
39
|
+
# - dock.with_section(icon: "information-circle", href: "#", active: true, title: "Info")
|
40
|
+
#
|
41
|
+
# @loco_example Custom title content
|
42
|
+
# = daisy_dock do |dock|
|
43
|
+
# - dock.with_section(icon: "chart-bar", href: "#") do
|
44
|
+
# .font-bold.text-xs
|
45
|
+
# Stats
|
46
|
+
#
|
47
|
+
class Daisy::Navigation::DockSectionComponent < LocoMotion::BaseComponent
|
48
|
+
include LocoMotion::Concerns::IconableComponent
|
49
|
+
include LocoMotion::Concerns::LinkableComponent
|
50
|
+
|
51
|
+
define_part :title
|
52
|
+
|
53
|
+
# Creates a new dock section.
|
54
|
+
#
|
55
|
+
# @param kws [Hash] The keyword arguments for the component.
|
56
|
+
#
|
57
|
+
# @option kws icon [String] The name of the icon to display.
|
58
|
+
#
|
59
|
+
# @option kws icon_variant [Symbol] The variant of the icon to use (default: :outline).
|
60
|
+
#
|
61
|
+
# @option kws icon_css [String] Additional CSS classes for the icon.
|
62
|
+
#
|
63
|
+
# @option kws title [String] Optional text to display below the icon.
|
64
|
+
#
|
65
|
+
# @option kws href [String] Optional URL to make the section a link.
|
66
|
+
#
|
67
|
+
# @option kws active [Boolean] Whether this section is currently active (default: false).
|
68
|
+
#
|
69
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
70
|
+
# options include:
|
71
|
+
# - Text color: `text-primary`, `text-secondary`, `text-accent`
|
72
|
+
# - Custom colors: `text-[#449944]`
|
73
|
+
#
|
74
|
+
def initialize(**kws)
|
75
|
+
super(**kws)
|
76
|
+
|
77
|
+
@icon_variant = config_option(:icon_variant, :outline)
|
78
|
+
@title = config_option(:title)
|
79
|
+
@active = config_option(:active, false)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Configure the component before rendering.
|
83
|
+
#
|
84
|
+
# Adds the dock-active class if this section is active and configures the
|
85
|
+
# title with appropriate styling.
|
86
|
+
def before_render
|
87
|
+
super
|
88
|
+
|
89
|
+
set_tag_name(:component, "button") unless @href
|
90
|
+
add_css(:component, "dock-active") if @active
|
91
|
+
|
92
|
+
set_tag_name(:title, :span)
|
93
|
+
add_css(:title, "dock-label")
|
94
|
+
end
|
95
|
+
|
96
|
+
# Render the dock section component with icon, title, and content.
|
97
|
+
#
|
98
|
+
# @return [String] The rendered HTML for the dock section.
|
99
|
+
def call
|
100
|
+
part(:component) do
|
101
|
+
concat(render_icon)
|
102
|
+
concat(part(:title) { @title }) if @title
|
103
|
+
concat(content)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
renders_many :sections, Daisy::Navigation::DockSectionComponent
|
110
|
+
|
111
|
+
# Creates a new dock component.
|
112
|
+
#
|
113
|
+
# @param kws [Hash] The keyword arguments for the component.
|
114
|
+
#
|
115
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
116
|
+
# options include:
|
117
|
+
# - Position: `relative`, `fixed bottom-0`
|
118
|
+
# - Width: `w-full`, `max-w-[400px]`
|
119
|
+
# - Border: `border`, `border-base-200`
|
120
|
+
# - Size: `dock-xs`, `dock-sm`, `dock-md`, `dock-lg`, `dock-xl`
|
121
|
+
#
|
122
|
+
def initialize(**kws)
|
123
|
+
super(**kws)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Configure the component before rendering.
|
127
|
+
#
|
128
|
+
# Adds the dock CSS class to the component.
|
129
|
+
def before_render
|
130
|
+
add_css(:component, "dock")
|
131
|
+
end
|
132
|
+
|
133
|
+
# Render the dock component with all its sections and content.
|
134
|
+
#
|
135
|
+
# @return [String] The rendered HTML for the dock component.
|
136
|
+
def call
|
137
|
+
part(:component) do
|
138
|
+
sections.each do |section|
|
139
|
+
concat(section)
|
140
|
+
end
|
141
|
+
|
142
|
+
concat(content)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
@@ -2,22 +2,23 @@
|
|
2
2
|
# Creates a styled link component that can be used for navigation or inline text
|
3
3
|
# links. This component is designed to work similarly to Rails' `link_to` helper.
|
4
4
|
#
|
5
|
-
# @
|
5
|
+
# @loco_example Link with custom styling
|
6
6
|
# = daisy_link "Components", "#", css: "link-primary text-xl"
|
7
7
|
#
|
8
|
-
# @
|
8
|
+
# @loco_example Link with block content
|
9
9
|
# = daisy_link "#", css: "link-hover" do
|
10
10
|
# = hero_icon("home")
|
11
11
|
# Home
|
12
12
|
#
|
13
|
-
# @
|
13
|
+
# @loco_example Link with positional arguments
|
14
14
|
# = daisy_link "Documentation", "#"
|
15
15
|
#
|
16
|
-
# @
|
16
|
+
# @loco_example Basic link with keyword arguments
|
17
17
|
# = daisy_link(title: "Home", href: "#")
|
18
18
|
#
|
19
19
|
class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
20
|
-
|
20
|
+
include LocoMotion::Concerns::TippableComponent
|
21
|
+
include LocoMotion::Concerns::LinkableComponent
|
21
22
|
|
22
23
|
# Create a new instance of the LinkComponent.
|
23
24
|
#
|
@@ -43,6 +44,9 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
|
43
44
|
# - State: `link-hover`
|
44
45
|
# - Text: `text-sm`, `text-xl`, `text-2xl`
|
45
46
|
#
|
47
|
+
# @option kws tip [String] The tooltip text to display when hovering over
|
48
|
+
# the component.
|
49
|
+
#
|
46
50
|
def initialize(*args, **kws)
|
47
51
|
super
|
48
52
|
|
@@ -68,10 +72,9 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
|
68
72
|
# if provided.
|
69
73
|
#
|
70
74
|
def before_render
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
add_html(:component, { target: @target }) if @target
|
75
|
+
super
|
76
|
+
|
77
|
+
setup_component
|
75
78
|
end
|
76
79
|
|
77
80
|
#
|
@@ -84,4 +87,10 @@ class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
|
84
87
|
def call
|
85
88
|
part(:component) { content || @title }
|
86
89
|
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def setup_component
|
94
|
+
add_css(:component, "link")
|
95
|
+
end
|
87
96
|
end
|
@@ -1,16 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#
|
2
4
|
# Creates a menu component for displaying a list of items, optionally with group titles.
|
3
5
|
#
|
6
|
+
# @note Vertical menus no longer have a default width. Use `w-full` or other width
|
7
|
+
# classes if you want to control the width.
|
8
|
+
#
|
4
9
|
# @slot items+ {Daisy::Navigation::MenuItemComponent} The menu items to display.
|
5
10
|
#
|
6
|
-
# @
|
11
|
+
# @loco_example Basic menu with items
|
7
12
|
# = daisy_menu do |menu|
|
8
13
|
# - menu.with_item do
|
9
14
|
# = link_to "Item 1", "#"
|
10
15
|
# - menu.with_item do
|
11
16
|
# = link_to "Item 2", "#"
|
12
17
|
#
|
13
|
-
# @
|
18
|
+
# @loco_example Menu with group titles
|
14
19
|
# = daisy_menu do |menu|
|
15
20
|
# - menu.with_item(title: "Group 1") do
|
16
21
|
# = link_to "Item 1-1", "#"
|
@@ -19,10 +24,10 @@
|
|
19
24
|
# = link_to "Item 2-1", "#"
|
20
25
|
# = link_to "Item 2-2", "#"
|
21
26
|
#
|
22
|
-
# @
|
27
|
+
# @loco_example Menu with disabled items
|
23
28
|
# = daisy_menu do |menu|
|
24
29
|
# - menu.with_item do
|
25
|
-
# = link_to "Active Item", "#"
|
30
|
+
# = link_to "Active Item", "#", class: "menu-active"
|
26
31
|
# - menu.with_item(disabled: true) do
|
27
32
|
# Disabled Item
|
28
33
|
#
|
@@ -33,15 +38,15 @@ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
|
33
38
|
#
|
34
39
|
# @part title The title element for the menu item.
|
35
40
|
#
|
36
|
-
# @
|
41
|
+
# @loco_example Basic menu item
|
37
42
|
# = menu.with_item do
|
38
43
|
# = link_to "Item", "#"
|
39
44
|
#
|
40
|
-
# @
|
45
|
+
# @loco_example Menu item with title
|
41
46
|
# = menu.with_item(title: "Group") do
|
42
47
|
# = link_to "Item", "#"
|
43
48
|
#
|
44
|
-
# @
|
49
|
+
# @loco_example Disabled menu item
|
45
50
|
# = menu.with_item(disabled: true) do
|
46
51
|
# = link_to "Item", "#"
|
47
52
|
#
|
@@ -63,6 +68,7 @@ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
|
63
68
|
# options include:
|
64
69
|
# - Text: `text-sm`, `text-base-content`
|
65
70
|
# - Spacing: `mt-4`, `mb-2`
|
71
|
+
# - State: `menu-active`, `menu-focus`, `menu-disabled`
|
66
72
|
#
|
67
73
|
def initialize(*args, **kws)
|
68
74
|
super(**kws)
|
@@ -77,7 +83,7 @@ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
|
77
83
|
#
|
78
84
|
def before_render
|
79
85
|
set_tag_name(:component, :li)
|
80
|
-
add_css(:component, "disabled pointer-events-none") if @disabled
|
86
|
+
add_css(:component, "menu-disabled pointer-events-none") if @disabled
|
81
87
|
|
82
88
|
set_tag_name(:title, :h2)
|
83
89
|
add_css(:title, "menu-title")
|
@@ -102,7 +108,7 @@ class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
|
102
108
|
#
|
103
109
|
# @option kws css [String] Additional CSS classes for styling. Common
|
104
110
|
# options include:
|
105
|
-
# -
|
111
|
+
# - Layout: `menu-horizontal`, `w-full`, `w-56`
|
106
112
|
# - Background: `bg-base-100`, `bg-neutral`
|
107
113
|
# - Border: `border`, `rounded-box`
|
108
114
|
# - Shadow: `shadow`, `shadow-lg`
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# @slot end {LocoMotion::BasicComponent} The right section of the navbar.
|
12
12
|
# Automatically gets the `navbar-end` CSS class.
|
13
13
|
#
|
14
|
-
# @
|
14
|
+
# @loco_example Basic navbar with logo and GitHub link
|
15
15
|
# = daisy_navbar(css: "bg-base-100") do |navbar|
|
16
16
|
# - navbar.with_start do
|
17
17
|
# = image_tag("logo.png", class: "h-8")
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# - navbar.with_end do
|
21
21
|
# = link_to "GitHub", "https://github.com", target: "_blank"
|
22
22
|
#
|
23
|
-
# @
|
23
|
+
# @loco_example Navbar with all sections and dropdown
|
24
24
|
# = daisy_navbar(css: "bg-base-100") do |navbar|
|
25
25
|
# - navbar.with_start do
|
26
26
|
# %span.text-lg.italic Brand
|
@@ -59,15 +59,4 @@ class Daisy::Navigation::NavbarComponent < LocoMotion::BaseComponent
|
|
59
59
|
def before_render
|
60
60
|
add_css(:component, "navbar")
|
61
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
|
73
62
|
end
|
@@ -8,21 +8,21 @@
|
|
8
8
|
# @slot steps+ {Daisy::Navigation::StepsComponent::StepComponent} The individual
|
9
9
|
# steps to display.
|
10
10
|
#
|
11
|
-
# @
|
11
|
+
# @loco_example Basic steps with progress
|
12
12
|
# = daisy_steps do |steps|
|
13
13
|
# - steps.with_step(title: "Write Code", css: "step-primary")
|
14
14
|
# - steps.with_step(title: "Release Code", css: "step-primary")
|
15
15
|
# - steps.with_step(title: "Profit", css: "step-secondary")
|
16
16
|
# - steps.with_step(title: "Rule the World")
|
17
17
|
#
|
18
|
-
# @
|
18
|
+
# @loco_example Vertical steps
|
19
19
|
# = daisy_steps(css: "steps-vertical") do |steps|
|
20
20
|
# - steps.with_step(title: "Write Code", css: "step-primary")
|
21
21
|
# - steps.with_step(title: "Release Code", css: "step-primary")
|
22
22
|
# - steps.with_step(title: "Profit", css: "step-secondary")
|
23
23
|
# - steps.with_step(title: "Rule the World")
|
24
24
|
#
|
25
|
-
# @
|
25
|
+
# @loco_example Custom step content
|
26
26
|
# = daisy_steps do |steps|
|
27
27
|
# - steps.with_step(number: "AB")
|
28
28
|
# - steps.with_step(number: "★")
|
@@ -33,13 +33,13 @@ class Daisy::Navigation::StepsComponent < LocoMotion::BaseComponent
|
|
33
33
|
#
|
34
34
|
# A step within a StepsComponent.
|
35
35
|
#
|
36
|
-
# @
|
36
|
+
# @loco_example Basic step with title
|
37
37
|
# = steps.with_step(title: "Step 1")
|
38
38
|
#
|
39
|
-
# @
|
39
|
+
# @loco_example Step with custom number
|
40
40
|
# = steps.with_step(number: "★", title: "Special Step")
|
41
41
|
#
|
42
|
-
# @
|
42
|
+
# @loco_example Step with custom content
|
43
43
|
# = steps.with_step(number: "1") do
|
44
44
|
# .flex.gap-2
|
45
45
|
# = hero_icon("check")
|