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.
- checksums.yaml +4 -4
- data/README.md +139 -67
- data/app/components/daisy/actions/button_component.rb +112 -8
- data/app/components/daisy/actions/dropdown_component.html.haml +5 -5
- data/app/components/daisy/actions/dropdown_component.rb +95 -26
- data/app/components/daisy/actions/modal_component.html.haml +3 -2
- data/app/components/daisy/actions/modal_component.rb +111 -20
- data/app/components/daisy/actions/swap_component.rb +117 -6
- data/app/components/daisy/actions/theme_controller_component.html.haml +1 -1
- data/app/components/daisy/actions/theme_controller_component.rb +37 -2
- data/app/components/daisy/data_display/accordion_component.rb +81 -4
- data/app/components/daisy/data_display/avatar_component.rb +39 -17
- data/app/components/daisy/data_display/badge_component.rb +49 -5
- data/app/components/daisy/data_display/card_component.html.haml +5 -13
- data/app/components/daisy/data_display/card_component.rb +76 -40
- data/app/components/daisy/data_display/carousel_component.rb +39 -1
- data/app/components/daisy/data_display/chat_component.rb +42 -15
- data/app/components/daisy/data_display/collapse_component.rb +61 -2
- data/app/components/daisy/data_display/countdown_component.rb +51 -1
- data/app/components/daisy/data_display/diff_component.rb +38 -1
- data/app/components/daisy/data_display/figure_component.rb +49 -0
- data/app/components/daisy/data_display/kbd_component.rb +64 -3
- data/app/components/daisy/data_display/stat_component.rb +67 -7
- data/app/components/daisy/data_display/table_component.rb +100 -35
- data/app/components/daisy/data_display/timeline_component.rb +46 -1
- data/app/components/daisy/data_display/timeline_event_component.rb +40 -2
- data/app/components/daisy/feedback/alert_component.rb +47 -2
- data/app/components/daisy/feedback/loading_component.rb +50 -0
- data/app/components/daisy/feedback/progress_component.rb +58 -0
- data/app/components/daisy/feedback/radial_progress_component.rb +72 -0
- data/app/components/daisy/feedback/skeleton_component.rb +53 -0
- data/app/components/daisy/feedback/toast_component.rb +45 -0
- data/app/components/daisy/feedback/tooltip_component.rb +77 -0
- data/app/components/daisy/layout/artboard_component.rb +59 -0
- data/app/components/daisy/layout/divider_component.rb +72 -0
- data/app/components/daisy/layout/drawer_component.html.haml +9 -0
- data/app/components/daisy/layout/drawer_component.rb +155 -0
- data/app/components/daisy/layout/footer_component.rb +69 -0
- data/app/components/daisy/layout/hero_component.html.haml +5 -0
- data/app/components/daisy/layout/hero_component.rb +83 -0
- data/app/components/daisy/layout/indicator_component.rb +83 -0
- data/app/components/daisy/layout/join_component.rb +72 -1
- data/app/components/daisy/layout/stack_component.rb +68 -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 +83 -4
- data/app/components/daisy/navigation/breadcrumbs_component.rb +41 -4
- data/app/components/daisy/navigation/link_component.rb +66 -13
- data/app/components/daisy/navigation/menu_component.rb +83 -11
- data/app/components/daisy/navigation/navbar_component.html.haml +1 -1
- data/app/components/daisy/navigation/navbar_component.rb +64 -3
- data/app/components/daisy/navigation/steps_component.rb +78 -2
- data/app/components/daisy/navigation/tabs_component.rb +112 -9
- data/app/components/hero/icon_component.rb +50 -1
- data/lib/daisy.rb +18 -3
- data/lib/hero.rb +7 -0
- data/lib/loco_motion/basic_component.rb +1 -1
- data/lib/loco_motion/concerns/tippable_component.rb +26 -0
- data/lib/loco_motion/configuration.rb +35 -0
- data/lib/loco_motion/helpers.rb +96 -0
- data/lib/loco_motion/version.rb +5 -0
- data/lib/loco_motion.rb +6 -36
- metadata +58 -9
- data/app/components/daisy/data_display/badge_component.html.haml +0 -2
- data/app/components/daisy/data_display/kbd_component.html.haml +0 -2
- data/app/components/daisy/navigation/link_component.html.haml +0 -4
- data/lib/daisy/helpers.rb +0 -61
@@ -1,15 +1,85 @@
|
|
1
1
|
#
|
2
|
-
# The Table component
|
2
|
+
# The Table component creates structured data tables with support for headers,
|
3
|
+
# multiple sections, and complex layouts. It provides a clean, semantic way to
|
4
|
+
# display tabular data while maintaining proper HTML structure.
|
3
5
|
#
|
4
|
-
#
|
5
|
-
|
6
|
+
# @slot head A header section containing column titles.
|
7
|
+
# @slot body A body section containing rows of data.
|
8
|
+
# @slot row+ Individual rows that can be added directly to the table.
|
9
|
+
# @slot section+ Multiple sections, each with its own header and body, for
|
10
|
+
# complex table layouts.
|
11
|
+
#
|
12
|
+
# @loco_example Basic Usage
|
13
|
+
# = daisy_table do |table|
|
14
|
+
# - table.with_head do |head|
|
15
|
+
# - head.with_column { "Name" }
|
16
|
+
# - head.with_column { "Role" }
|
17
|
+
# - head.with_column { "Department" }
|
18
|
+
#
|
19
|
+
# - table.with_row do |row|
|
20
|
+
# - row.with_column { "John Smith" }
|
21
|
+
# - row.with_column { "Developer" }
|
22
|
+
# - row.with_column { "Engineering" }
|
23
|
+
#
|
24
|
+
# - table.with_row do |row|
|
25
|
+
# - row.with_column { "Jane Doe" }
|
26
|
+
# - row.with_column { "Designer" }
|
27
|
+
# - row.with_column { "Product" }
|
28
|
+
#
|
29
|
+
# @loco_example With Body Container
|
30
|
+
# = daisy_table do |table|
|
31
|
+
# - table.with_head do |head|
|
32
|
+
# - head.with_column { "Product" }
|
33
|
+
# - head.with_column { "Price" }
|
34
|
+
#
|
35
|
+
# - table.with_body do |body|
|
36
|
+
# - body.with_row do |row|
|
37
|
+
# - row.with_column { "Basic Plan" }
|
38
|
+
# - row.with_column { "$10/mo" }
|
39
|
+
# - body.with_row do |row|
|
40
|
+
# - row.with_column { "Pro Plan" }
|
41
|
+
# - row.with_column { "$20/mo" }
|
42
|
+
#
|
43
|
+
# @loco_example With Multiple Sections
|
44
|
+
# = daisy_table do |table|
|
45
|
+
# - table.with_section do |section|
|
46
|
+
# - section.with_head do |head|
|
47
|
+
# - head.with_column { "Active Users" }
|
48
|
+
# - head.with_column { "Status" }
|
49
|
+
#
|
50
|
+
# - section.with_body do |body|
|
51
|
+
# - body.with_row do |row|
|
52
|
+
# - row.with_column { "Alice" }
|
53
|
+
# - row.with_column { "Online" }
|
54
|
+
#
|
55
|
+
# - table.with_section do |section|
|
56
|
+
# - section.with_head do |head|
|
57
|
+
# - head.with_column { "Inactive Users" }
|
58
|
+
# - head.with_column { "Last Seen" }
|
59
|
+
#
|
60
|
+
# - section.with_body do |body|
|
61
|
+
# - body.with_row do |row|
|
62
|
+
# - row.with_column { "Bob" }
|
63
|
+
# - row.with_column { "2 days ago" }
|
64
|
+
#
|
65
|
+
class Daisy::DataDisplay::TableComponent < LocoMotion::BaseComponent
|
6
66
|
|
67
|
+
#
|
68
|
+
# A component for rendering individual header cells (`<th>`) within a table
|
69
|
+
# header row.
|
70
|
+
#
|
7
71
|
class HeadColumnComponent < LocoMotion::BasicComponent
|
8
72
|
def before_render
|
9
73
|
set_tag_name :component, :th
|
10
74
|
end
|
11
75
|
end
|
12
76
|
|
77
|
+
#
|
78
|
+
# A component for rendering the table header (`<thead>`) section. Contains
|
79
|
+
# header columns that define the structure of the table.
|
80
|
+
#
|
81
|
+
# @slot column+ Individual header cells within the header row.
|
82
|
+
#
|
13
83
|
class HeadComponent < LocoMotion::BasicComponent
|
14
84
|
renders_many :columns, HeadColumnComponent
|
15
85
|
|
@@ -28,12 +98,20 @@ class Daisy::DataDisplay::TableComponent < LocoMotion.configuration.base_compone
|
|
28
98
|
end
|
29
99
|
end
|
30
100
|
|
101
|
+
#
|
102
|
+
# A component for rendering individual data cells (`<td>`) within a table row.
|
103
|
+
#
|
31
104
|
class BodyColumnComponent < LocoMotion::BasicComponent
|
32
105
|
def before_render
|
33
106
|
set_tag_name :component, :td
|
34
107
|
end
|
35
108
|
end
|
36
109
|
|
110
|
+
#
|
111
|
+
# A component for rendering table rows (`<tr>`) containing data cells.
|
112
|
+
#
|
113
|
+
# @slot column+ Individual data cells within the row.
|
114
|
+
#
|
37
115
|
class BodyRowComponent < LocoMotion::BasicComponent
|
38
116
|
renders_many :columns, BodyColumnComponent
|
39
117
|
|
@@ -50,6 +128,12 @@ class Daisy::DataDisplay::TableComponent < LocoMotion.configuration.base_compone
|
|
50
128
|
end
|
51
129
|
end
|
52
130
|
|
131
|
+
#
|
132
|
+
# A component for rendering the table body (`<tbody>`) section. Contains rows
|
133
|
+
# of data.
|
134
|
+
#
|
135
|
+
# @slot row+ Individual rows of data within the body.
|
136
|
+
#
|
53
137
|
class BodyComponent < LocoMotion::BasicComponent
|
54
138
|
renders_many :rows, BodyRowComponent
|
55
139
|
|
@@ -59,15 +143,21 @@ class Daisy::DataDisplay::TableComponent < LocoMotion.configuration.base_compone
|
|
59
143
|
|
60
144
|
def call
|
61
145
|
part(:component) do
|
62
|
-
|
63
|
-
|
64
|
-
concat(row)
|
65
|
-
end
|
146
|
+
rows.each do |row|
|
147
|
+
concat(row)
|
66
148
|
end
|
67
149
|
end
|
68
150
|
end
|
69
151
|
end
|
70
152
|
|
153
|
+
#
|
154
|
+
# A component for grouping related table content into sections. Each section
|
155
|
+
# can have its own header and body, allowing for complex table layouts.
|
156
|
+
#
|
157
|
+
# @slot head A header section for this group of data.
|
158
|
+
# @slot body A body section for this group of data.
|
159
|
+
# @slot row+ Individual rows that can be added directly to this section.
|
160
|
+
#
|
71
161
|
class SectionComponent < LocoMotion::BasicComponent
|
72
162
|
renders_one :head, HeadComponent
|
73
163
|
renders_one :body, BodyComponent
|
@@ -78,7 +168,7 @@ class Daisy::DataDisplay::TableComponent < LocoMotion.configuration.base_compone
|
|
78
168
|
end
|
79
169
|
|
80
170
|
def call
|
81
|
-
# Sections can't be rendered inside a
|
171
|
+
# Sections can't be rendered inside a `<table>` tag, so we don't render the
|
82
172
|
# typical `part(:component)` here.
|
83
173
|
concat(head) if head?
|
84
174
|
|
@@ -103,33 +193,8 @@ class Daisy::DataDisplay::TableComponent < LocoMotion.configuration.base_compone
|
|
103
193
|
|
104
194
|
#
|
105
195
|
# Instantiate a new Table component. This component takes no content, but
|
106
|
-
# requires you to utilize the optional
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# @example
|
110
|
-
# = daisy_table do |table|
|
111
|
-
# - table.head do |head|
|
112
|
-
# - head.with_column do
|
113
|
-
# Column 1
|
114
|
-
# - head.with_column do
|
115
|
-
# Column 2
|
116
|
-
#
|
117
|
-
# - table.with_row do |row|
|
118
|
-
# - row.with_column do
|
119
|
-
# Row 1 - Column 1
|
120
|
-
# - row.with_column do
|
121
|
-
# Row 1 - Column 2
|
122
|
-
# - table.with_row do |row|
|
123
|
-
# - row.with_column do
|
124
|
-
# Row 2 - Column 1
|
125
|
-
# - row.with_column do
|
126
|
-
# Row 2 - Column 2
|
127
|
-
#
|
128
|
-
# For more complex tables, you can use the <code>section</code> slot which
|
129
|
-
# takes a <code>head</code> and <code>body</code> slot allowing you to build a
|
130
|
-
# table with multiple headers and bodies.
|
131
|
-
#
|
132
|
-
# Please see the demo for more examples of usage.
|
196
|
+
# requires you to utilize the optional `head` slot, and one of the `body` or
|
197
|
+
# `rows` slots.
|
133
198
|
#
|
134
199
|
def initialize(*args, **kws, &block)
|
135
200
|
super
|
@@ -1,4 +1,49 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# The Timeline component displays a list of events in chronological order,
|
3
|
+
# either vertically or horizontally. It's perfect for showing history,
|
4
|
+
# progress, or any sequence of events that should be displayed in order.
|
5
|
+
#
|
6
|
+
# @slot event+ Individual events in the timeline. Each event can have start,
|
7
|
+
# middle, and end sections.
|
8
|
+
#
|
9
|
+
# @loco_example Basic Vertical Timeline
|
10
|
+
# = daisy_timeline do |timeline|
|
11
|
+
# - timeline.with_event(start: "2023", end: "Launched product") do |event|
|
12
|
+
# - event.with_middle { "🚀" }
|
13
|
+
#
|
14
|
+
# - timeline.with_event(start: "2024", end: "1M users") do |event|
|
15
|
+
# - event.with_middle { "🎉" }
|
16
|
+
#
|
17
|
+
# @loco_example Horizontal Timeline
|
18
|
+
# = daisy_timeline(css: "timeline-horizontal") do |timeline|
|
19
|
+
# - timeline.with_event(start: "Q1", end: "Planning") do |event|
|
20
|
+
# - event.with_middle { "📋" }
|
21
|
+
#
|
22
|
+
# - timeline.with_event(start: "Q2", end: "Development") do |event|
|
23
|
+
# - event.with_middle { "💻" }
|
24
|
+
#
|
25
|
+
# - timeline.with_event(start: "Q3", end: "Testing") do |event|
|
26
|
+
# - event.with_middle { "🧪" }
|
27
|
+
#
|
28
|
+
# - timeline.with_event(start: "Q4", end: "Launch") do |event|
|
29
|
+
# - event.with_middle { "🚀" }
|
30
|
+
#
|
31
|
+
# @loco_example Custom Content (Vertical)
|
32
|
+
# = daisy_timeline do |timeline|
|
33
|
+
# - timeline.with_event do |event|
|
34
|
+
# - event.with_start do
|
35
|
+
# .font-bold Jan 2024
|
36
|
+
# %div{ class: "text-sm text-base-content/70" } Q1
|
37
|
+
#
|
38
|
+
# - event.with_middle do
|
39
|
+
# .bg-primary.text-primary-content.p-2.rounded-full
|
40
|
+
# = heroicon_tag "star"
|
41
|
+
#
|
42
|
+
# - event.with_end do
|
43
|
+
# %h3.font-bold Milestone Reached
|
44
|
+
# %div{ class: "text-base-content/70" } Exceeded quarterly goals
|
45
|
+
#
|
46
|
+
class Daisy::DataDisplay::TimelineComponent < LocoMotion::BaseComponent
|
2
47
|
renders_many :events, Daisy::DataDisplay::TimelineEventComponent
|
3
48
|
|
4
49
|
def before_render
|
@@ -1,4 +1,28 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# A component for rendering individual events within a timeline. Each event can
|
3
|
+
# have three sections: start (typically a date or time), middle (an icon or
|
4
|
+
# marker), and end (the event description).
|
5
|
+
#
|
6
|
+
# @part start The container for the start content (e.g., date/time).
|
7
|
+
# @part middle The container for the middle content.
|
8
|
+
# @part middle_icon Container for a simple icon when not using custom middle
|
9
|
+
# content.
|
10
|
+
# @part end The container for the end content (e.g., description).
|
11
|
+
# @part separator The line connecting this event to the next one.
|
12
|
+
#
|
13
|
+
# @slot start Custom content for the start section. You can also provide
|
14
|
+
# simple text via the start option.
|
15
|
+
#
|
16
|
+
# @slot middle Custom content for the middle section. You can also provide
|
17
|
+
# simple text via the middle option, or an icon via the middle_icon option.
|
18
|
+
#
|
19
|
+
# @slot end Custom content for the end section. You can also provide simple
|
20
|
+
# text via the end option.
|
21
|
+
#
|
22
|
+
# @note The middle and middle_icon options are mutually exclusive. If both are
|
23
|
+
# provided, middle takes precedence.
|
24
|
+
#
|
25
|
+
class Daisy::DataDisplay::TimelineEventComponent < LocoMotion::BaseComponent
|
2
26
|
renders_one :start, LocoMotion::BasicComponent.build(css: "timeline-start")
|
3
27
|
renders_one :middle, LocoMotion::BasicComponent.build(css: "timeline-middle")
|
4
28
|
renders_one :end, LocoMotion::BasicComponent.build(css: "timeline-end")
|
@@ -6,7 +30,21 @@ class Daisy::DataDisplay::TimelineEventComponent < LocoMotion.configuration.base
|
|
6
30
|
define_parts :start, :middle, :middle_icon, :end, :separator
|
7
31
|
|
8
32
|
#
|
9
|
-
#
|
33
|
+
# Creates a new timeline event component.
|
34
|
+
#
|
35
|
+
# @param kws [Hash] The keyword arguments for the component.
|
36
|
+
#
|
37
|
+
# @option kws [String] :start Text to display in the start section. You can
|
38
|
+
# also provide custom content using the start slot.
|
39
|
+
#
|
40
|
+
# @option kws [String] :middle Text to display in the middle section. You
|
41
|
+
# can also provide custom content using the middle slot.
|
42
|
+
#
|
43
|
+
# @option kws [String] :middle_icon Name of a heroicon to display in the
|
44
|
+
# middle section. Ignored if middle is provided.
|
45
|
+
#
|
46
|
+
# @option kws [String] :end Text to display in the end section. You can
|
47
|
+
# also provide custom content using the end slot.
|
10
48
|
#
|
11
49
|
def initialize(*args, **kws, &block)
|
12
50
|
super(*args, **kws, &block)
|
@@ -1,9 +1,54 @@
|
|
1
1
|
#
|
2
|
-
# The AlertComponent displays an important message to users.
|
2
|
+
# The AlertComponent displays an important message to users. It can be used to
|
3
|
+
# show information, success messages, warnings, or errors. Alerts can include
|
4
|
+
# an optional icon at the start and customizable content.
|
3
5
|
#
|
4
|
-
|
6
|
+
# @part icon [Heroicon] An optional icon displayed at the start of
|
7
|
+
# the alert. Uses the Heroicon system.
|
8
|
+
#
|
9
|
+
# @part content_wrapper [HTML] A wrapper for the main content of the alert.
|
10
|
+
# This allows for proper spacing and alignment with the icon.
|
11
|
+
#
|
12
|
+
# @loco_example Basic Alert
|
13
|
+
# = daisy_alert do
|
14
|
+
# This is a standard alert message.
|
15
|
+
#
|
16
|
+
# @loco_example Alert with Icon
|
17
|
+
# = daisy_alert(icon: "information-circle", icon_html: { variant: :outline }) do
|
18
|
+
# Here's some important information!
|
19
|
+
#
|
20
|
+
# @loco_example Alert Types
|
21
|
+
# = daisy_alert(icon: "information-circle", css: "alert-info", icon_html: { variant: :outline }) do
|
22
|
+
# Information alert.
|
23
|
+
#
|
24
|
+
# = daisy_alert(icon: "check-circle", css: "alert-success", icon_html: { variant: :outline }) do
|
25
|
+
# Success alert.
|
26
|
+
#
|
27
|
+
# = daisy_alert(icon: "exclamation-triangle", css: "alert-warning", icon_html: { variant: :outline }) do
|
28
|
+
# Warning alert.
|
29
|
+
#
|
30
|
+
# = daisy_alert(icon: "exclamation-circle", css: "alert-error", icon_html: { variant: :outline }) do
|
31
|
+
# Error alert.
|
32
|
+
#
|
33
|
+
class Daisy::Feedback::AlertComponent < LocoMotion::BaseComponent
|
5
34
|
define_parts :icon, :content_wrapper
|
6
35
|
|
36
|
+
#
|
37
|
+
# Creates a new Alert component.
|
38
|
+
#
|
39
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
40
|
+
# @param kws [Hash] Keyword arguments for customizing the alert.
|
41
|
+
#
|
42
|
+
# @option kws icon [String] The name of the Heroicon to display at the
|
43
|
+
# start of the alert.
|
44
|
+
#
|
45
|
+
# @option kws icon_html [Hash] Additional HTML attributes for the icon
|
46
|
+
# element. Options include `variant: :outline` or `variant: :solid`.
|
47
|
+
#
|
48
|
+
# @option kws css [String] Additional CSS classes for the alert. Use
|
49
|
+
# `alert-info`, `alert-success`, `alert-warning`, or `alert-error` for
|
50
|
+
# different alert types.
|
51
|
+
#
|
7
52
|
def initialize(*args, **kws, &block)
|
8
53
|
super
|
9
54
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# The LoadingComponent displays an animated indicator to show that a process is
|
3
|
+
# running in the background. It supports multiple animation styles and can be
|
4
|
+
# customized with different colors and sizes.
|
5
|
+
#
|
6
|
+
# Includes the {LocoMotion::Concerns::TippableComponent} module to enable easy
|
7
|
+
# tooltip addition.
|
8
|
+
#
|
9
|
+
# @loco_example Basic Loading Spinners
|
10
|
+
# = daisy_loading(css: "loading-spinner text-primary")
|
11
|
+
# = daisy_loading(css: "loading-dots text-secondary")
|
12
|
+
# = daisy_loading(css: "loading-ring text-accent")
|
13
|
+
#
|
14
|
+
# @loco_example Other Loading Styles
|
15
|
+
# = daisy_loader(css: "loading-ball text-info")
|
16
|
+
# = daisy_loader(css: "loading-bars text-success")
|
17
|
+
# = daisy_loader(css: "loading-infinity text-error")
|
18
|
+
#
|
19
|
+
# @note The helper method is also aliased as `daisy_loader` for better
|
20
|
+
# readability, but CSS classes must still use the `loading-*` prefix.
|
21
|
+
#
|
22
|
+
class Daisy::Feedback::LoadingComponent < LocoMotion::BaseComponent
|
23
|
+
prepend LocoMotion::Concerns::TippableComponent
|
24
|
+
|
25
|
+
#
|
26
|
+
# Creates a new Loading component.
|
27
|
+
#
|
28
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
29
|
+
# @param kws [Hash] Keyword arguments for customizing the loader.
|
30
|
+
#
|
31
|
+
# @option kws css [String] Additional CSS classes for the loader. Available
|
32
|
+
# styles include: `loading-spinner`, `loading-dots`, `loading-ring`,
|
33
|
+
# `loading-ball`, `loading-bars`, and `loading-infinity`. Can be combined
|
34
|
+
# with color classes like `text-primary` or `text-success`.
|
35
|
+
#
|
36
|
+
# @option kws tip [String] Optional tooltip text to display when hovering
|
37
|
+
# over the loader. Added by the TippableComponent module.
|
38
|
+
#
|
39
|
+
def initialize(*args, **kws, &block)
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def before_render
|
44
|
+
add_css(:component, "loading")
|
45
|
+
end
|
46
|
+
|
47
|
+
def call
|
48
|
+
part(:component)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# The ProgressComponent displays a horizontal bar that indicates the completion
|
3
|
+
# status of a process. It can show determinate progress with a specific value
|
4
|
+
# or indeterminate progress with an animated bar.
|
5
|
+
#
|
6
|
+
# The component renders as an HTML `<progress>` element and supports various
|
7
|
+
# colors and styles through CSS classes.
|
8
|
+
#
|
9
|
+
# @loco_example Basic Progress Bars
|
10
|
+
# = daisy_progress(value: 25)
|
11
|
+
# = daisy_progress(css: "progress-primary", value: 50)
|
12
|
+
# = daisy_progress(css: "progress-secondary", value: 75)
|
13
|
+
# = daisy_progress(css: "progress-accent", value: 100)
|
14
|
+
#
|
15
|
+
# @loco_example Indeterminate Progress Bars
|
16
|
+
# = daisy_progress(css: "progress-info")
|
17
|
+
# = daisy_progress(css: "progress-success ![animation-delay:250ms]")
|
18
|
+
# = daisy_progress(css: "progress-warning ![animation-delay:500ms]")
|
19
|
+
# = daisy_progress(css: "progress-error ![animation-delay:750ms]")
|
20
|
+
#
|
21
|
+
class Daisy::Feedback::ProgressComponent < LocoMotion::BaseComponent
|
22
|
+
|
23
|
+
#
|
24
|
+
# Creates a new Progress component.
|
25
|
+
#
|
26
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
27
|
+
# @param kws [Hash] Keyword arguments for customizing the progress bar.
|
28
|
+
#
|
29
|
+
# @option kws value [Integer, nil] The current progress value. Set to `nil`
|
30
|
+
# for an indeterminate progress bar that animates continuously. Defaults
|
31
|
+
# to `nil`.
|
32
|
+
#
|
33
|
+
# @option kws max [Integer] The maximum value for the progress bar.
|
34
|
+
# Defaults to `100` to easily work with percentage values.
|
35
|
+
#
|
36
|
+
# @option kws css [String] Additional CSS classes for the progress bar.
|
37
|
+
# Available styles include: `progress-primary`, `progress-secondary`,
|
38
|
+
# `progress-accent`, `progress-info`, `progress-success`,
|
39
|
+
# `progress-warning`, and `progress-error`. Can be combined with utility
|
40
|
+
# classes like `![animation-delay:250ms]` for staggered animations.
|
41
|
+
#
|
42
|
+
def initialize(*args, **kws, &block)
|
43
|
+
super
|
44
|
+
|
45
|
+
@value = config_option(:value, nil)
|
46
|
+
@max = config_option(:max, 100)
|
47
|
+
end
|
48
|
+
|
49
|
+
def before_render
|
50
|
+
set_tag_name(:component, :progress)
|
51
|
+
add_css(:component, "progress")
|
52
|
+
add_html(:component, { value: @value, max: @max }) if @value != nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def call
|
56
|
+
part(:component)
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#
|
2
|
+
# The RadialProgressComponent displays a circular progress indicator that can be
|
3
|
+
# customized with different sizes, thicknesses, and colors. The component can
|
4
|
+
# also contain content within its circular display.
|
5
|
+
#
|
6
|
+
# The progress is always displayed as a percentage (0-100) due to the way the
|
7
|
+
# component is rendered using CSS custom properties.
|
8
|
+
#
|
9
|
+
# @loco_example Basic Usage
|
10
|
+
# = daisy_radial(value: 66) do
|
11
|
+
# 66%
|
12
|
+
#
|
13
|
+
# @loco_example With Icons
|
14
|
+
# = daisy_radial(value: 68) do
|
15
|
+
# = hero_icon("beaker", css: "size-8 text-purple-500")
|
16
|
+
#
|
17
|
+
# = daisy_radial(value: 52, css: "text-success") do
|
18
|
+
# 52%
|
19
|
+
#
|
20
|
+
# @loco_example Custom Size and Styling
|
21
|
+
# = daisy_radial(value: 19, size: "15rem", thickness: "4px",
|
22
|
+
# css: "bg-primary text-primary-content text-3xl") do
|
23
|
+
# 19%
|
24
|
+
#
|
25
|
+
class Daisy::Feedback::RadialProgressComponent < LocoMotion::BaseComponent
|
26
|
+
|
27
|
+
#
|
28
|
+
# Creates a new Radial Progress component.
|
29
|
+
#
|
30
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
31
|
+
# @param kws [Hash] Keyword arguments for customizing the radial progress.
|
32
|
+
#
|
33
|
+
# @option kws value [Integer] The current progress value as a
|
34
|
+
# percentage (0-100). Required for the progress to be displayed.
|
35
|
+
#
|
36
|
+
# @option kws size [String] The size of the radial progress component.
|
37
|
+
# Must include CSS units (e.g., "5rem", "100px"). Defaults to "5rem".
|
38
|
+
#
|
39
|
+
# @option kws thickness [String] The thickness of the progress ring. Must
|
40
|
+
# include CSS units (e.g., "4px", "0.5rem"). Defaults to one-tenth of
|
41
|
+
# the size.
|
42
|
+
#
|
43
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
44
|
+
# options include color classes like `text-success` or `text-error`,
|
45
|
+
# background colors like `bg-primary`, and text sizing like `text-3xl`.
|
46
|
+
#
|
47
|
+
def initialize(*args, **kws, &block)
|
48
|
+
super
|
49
|
+
|
50
|
+
@value = config_option(:value)
|
51
|
+
@size = config_option(:size)
|
52
|
+
@thickness = config_option(:thickness)
|
53
|
+
end
|
54
|
+
|
55
|
+
def before_render
|
56
|
+
add_css(:component, "radial-progress")
|
57
|
+
|
58
|
+
styles = []
|
59
|
+
|
60
|
+
styles << "--value: #{@value}" if @value != nil
|
61
|
+
styles << "--size: #{@size}" if @size != nil
|
62
|
+
styles << "--thickness: #{@thickness}" if @thickness != nil
|
63
|
+
|
64
|
+
add_html(:component, { role: "progressbar" })
|
65
|
+
add_html(:component, { style: styles.join(";") }) if styles.present?
|
66
|
+
end
|
67
|
+
|
68
|
+
def call
|
69
|
+
part(:component) { content }
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# The SkeletonComponent creates loading placeholder elements that mimic the
|
3
|
+
# shape and size of content that is being loaded. This provides users with a
|
4
|
+
# visual indication of the content's layout before it arrives, reducing
|
5
|
+
# perceived loading times and improving user experience.
|
6
|
+
#
|
7
|
+
# Skeletons can be used in two ways:
|
8
|
+
# 1. As standalone shapes with custom dimensions.
|
9
|
+
# 2. As a modifier class on existing components to create component-specific
|
10
|
+
# loading states.
|
11
|
+
#
|
12
|
+
# @loco_example Basic Shapes
|
13
|
+
# = daisy_skeleton(css: "w-24 h-24 rounded-full")
|
14
|
+
# = daisy_skeleton(css: "w-36 h-20")
|
15
|
+
# = daisy_skeleton(css: "w-48 h-5")
|
16
|
+
#
|
17
|
+
# @loco_example Component Loading States
|
18
|
+
# = daisy_badge(css: "badge-lg skeleton text-slate-400") do
|
19
|
+
# Loading...
|
20
|
+
#
|
21
|
+
# = daisy_button(css: "skeleton text-transparent") do
|
22
|
+
# Loading...
|
23
|
+
#
|
24
|
+
# = daisy_alert(css: "skeleton")
|
25
|
+
#
|
26
|
+
# = daisy_chat do |chat|
|
27
|
+
# - chat.with_avatar(wrapper_css: "skeleton")
|
28
|
+
# - chat.with_bubble(css: "skeleton text-transparent") do
|
29
|
+
# Loading...
|
30
|
+
#
|
31
|
+
class Daisy::Feedback::SkeletonComponent < LocoMotion::BaseComponent
|
32
|
+
#
|
33
|
+
# Creates a new Skeleton component.
|
34
|
+
#
|
35
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
36
|
+
# @param kws [Hash] Keyword arguments for customizing the skeleton.
|
37
|
+
#
|
38
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
39
|
+
# options include:
|
40
|
+
# - Dimensions: `w-24`, `h-20`
|
41
|
+
# - Shapes: `rounded-full`, `rounded-lg`
|
42
|
+
# - Colors: `bg-base-200`
|
43
|
+
# When using with other components, combine with `text-transparent` to
|
44
|
+
# hide placeholder text.
|
45
|
+
#
|
46
|
+
def before_render
|
47
|
+
add_css(:component, "skeleton")
|
48
|
+
end
|
49
|
+
|
50
|
+
def call
|
51
|
+
part(:component) { content }
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# The ToastComponent provides a container for displaying non-critical messages
|
3
|
+
# to users, typically positioned at the edges of the viewport. Toasts are
|
4
|
+
# commonly used for temporary notifications, success messages, or error alerts
|
5
|
+
# that don't require immediate user action.
|
6
|
+
#
|
7
|
+
# @note Currently, this component only handles positioning. JavaScript
|
8
|
+
# functionality for showing/hiding toasts will be implemented in a future
|
9
|
+
# Stimulus ToastController.
|
10
|
+
#
|
11
|
+
# @loco_example Basic Toast with Alert
|
12
|
+
# = daisy_toast do
|
13
|
+
# = daisy_alert(icon: "check-circle", css: "alert-success text-white") do
|
14
|
+
# Yay! Something went well!
|
15
|
+
#
|
16
|
+
# @loco_example Multiple Alerts in Toast
|
17
|
+
# = daisy_toast do
|
18
|
+
# = daisy_alert(icon: "check-circle", css: "alert-success text-white") do
|
19
|
+
# Operation successful!
|
20
|
+
#
|
21
|
+
# = daisy_alert(icon: "exclamation-circle", css: "alert-error text-white") do
|
22
|
+
# An error occurred.
|
23
|
+
#
|
24
|
+
class Daisy::Feedback::ToastComponent < LocoMotion::BaseComponent
|
25
|
+
#
|
26
|
+
# Creates a new Toast component.
|
27
|
+
#
|
28
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
29
|
+
# @param kws [Hash] Keyword arguments for customizing the toast.
|
30
|
+
#
|
31
|
+
# @option kws css [String] Additional CSS classes for styling. By default,
|
32
|
+
# toasts are positioned in the bottom-right corner of the viewport.
|
33
|
+
# Common options include:
|
34
|
+
# - Position modifiers: `toast-top`, `toast-bottom`, `toast-center`,
|
35
|
+
# `toast-start`, `toast-end`
|
36
|
+
# - Stack order: `z-50`
|
37
|
+
#
|
38
|
+
def before_render
|
39
|
+
add_css(:component, "toast")
|
40
|
+
end
|
41
|
+
|
42
|
+
def call
|
43
|
+
part(:component) { content }
|
44
|
+
end
|
45
|
+
end
|