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,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# The TextInput component renders a DaisyUI styled text input field.
|
5
|
+
# It can be used standalone or with a form builder, and supports
|
6
|
+
# various styling options including different types, sizes and variants.
|
7
|
+
#
|
8
|
+
# The component provides slots to add content before and after the input field,
|
9
|
+
# making it easy to add icons, buttons, or other elements.
|
10
|
+
#
|
11
|
+
# @part input The actual input element that users can type into.
|
12
|
+
#
|
13
|
+
# @slot start Content to display before the input field.
|
14
|
+
# @slot end+ Content to display after the input field.
|
15
|
+
#
|
16
|
+
# @loco_example Basic Usage
|
17
|
+
# = daisy_text_input(name: "username", id: "username")
|
18
|
+
#
|
19
|
+
# @loco_example With Placeholder
|
20
|
+
# = daisy_text_input(name: "email", id: "email", placeholder: "Enter your email")
|
21
|
+
#
|
22
|
+
# @loco_example Different Types
|
23
|
+
# = daisy_text_input(name: "password", id: "password", type: "password")
|
24
|
+
# = daisy_text_input(name: "email", id: "email", type: "email")
|
25
|
+
#
|
26
|
+
# @loco_example With Icons
|
27
|
+
# = daisy_text_input(name: "search", placeholder: "Search...") do |text_input|
|
28
|
+
# - text_input.with_start do
|
29
|
+
# = hero_icon("magnifying-glass", size: 5, css: "text-gray-400")
|
30
|
+
#
|
31
|
+
# @loco_example With Start and End Content
|
32
|
+
# = daisy_text_input(name: "email", placeholder: "Email address") do |text_input|
|
33
|
+
# - text_input.with_start do
|
34
|
+
# = hero_icon("envelope", size: 5, css: "text-gray-400")
|
35
|
+
# - text_input.with_end do
|
36
|
+
# = daisy_button(title: "Verify", css: "h-full rounded-l-none")
|
37
|
+
#
|
38
|
+
# @loco_example Disabled Text Input
|
39
|
+
# = daisy_text_input(name: "username", id: "username", disabled: true)
|
40
|
+
#
|
41
|
+
class Daisy::DataInput::TextInputComponent < LocoMotion::BaseComponent
|
42
|
+
define_part :input
|
43
|
+
|
44
|
+
renders_one :start
|
45
|
+
renders_one :end
|
46
|
+
|
47
|
+
attr_reader :name, :id, :value, :placeholder, :type, :disabled, :required, :readonly
|
48
|
+
|
49
|
+
#
|
50
|
+
# Instantiate a new TextInput component.
|
51
|
+
#
|
52
|
+
# @param kws [Hash] The keyword arguments for the component.
|
53
|
+
#
|
54
|
+
# @option kws name [String] The name attribute for the text input.
|
55
|
+
#
|
56
|
+
# @option kws id [String] The ID attribute for the text input.
|
57
|
+
#
|
58
|
+
# @option kws value [String] The initial value of the text input.
|
59
|
+
#
|
60
|
+
# @option kws placeholder [String] Placeholder text for the text input.
|
61
|
+
#
|
62
|
+
# @option kws type [String] The type of input (text, password, email, etc.).
|
63
|
+
# Defaults to "text".
|
64
|
+
#
|
65
|
+
# @option kws disabled [Boolean] Whether the text input is disabled. Defaults to
|
66
|
+
# false.
|
67
|
+
#
|
68
|
+
# @option kws required [Boolean] Whether the text input is required for form
|
69
|
+
# validation. Defaults to false.
|
70
|
+
#
|
71
|
+
# @option kws readonly [Boolean] Whether the text input is read-only. Defaults to
|
72
|
+
# false.
|
73
|
+
#
|
74
|
+
def initialize(**kws)
|
75
|
+
super
|
76
|
+
|
77
|
+
@name = config_option(:name)
|
78
|
+
@id = config_option(:id)
|
79
|
+
@value = config_option(:value, nil)
|
80
|
+
@placeholder = config_option(:placeholder, nil)
|
81
|
+
@type = config_option(:type, "text")
|
82
|
+
@disabled = config_option(:disabled, false)
|
83
|
+
@required = config_option(:required, false)
|
84
|
+
@readonly = config_option(:readonly, false)
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Calls the {setup_component} method before rendering the component.
|
89
|
+
#
|
90
|
+
def before_render
|
91
|
+
setup_component
|
92
|
+
setup_input
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Sets up the component by configuring the tag name, CSS classes, and HTML
|
97
|
+
# attributes. Sets the tag to input with appropriate type and adds the 'input'
|
98
|
+
# CSS class.
|
99
|
+
#
|
100
|
+
# This configures various attributes of the text input including name, id, value,
|
101
|
+
# placeholder, type, and states like disabled, required, and readonly.
|
102
|
+
#
|
103
|
+
def setup_component
|
104
|
+
set_tag_name(:component, :label)
|
105
|
+
|
106
|
+
add_css(:component, "input [:where(&)]:flex [:where(&)]:items-center [:where(&)]:gap-2")
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Sets up the input part by configuring the tag name, CSS classes, and HTML
|
111
|
+
# attributes. Sets the tag to input with appropriate type and adds the grow
|
112
|
+
# styling to ensure the input expands to fill available space.
|
113
|
+
#
|
114
|
+
# This configures basic input attributes like name, id, value, placeholder,
|
115
|
+
# and states like disabled, required, and readonly.
|
116
|
+
#
|
117
|
+
def setup_input
|
118
|
+
set_tag_name(:input, :input)
|
119
|
+
add_css(:input, "[:where(&)]:grow")
|
120
|
+
add_html(:input, {
|
121
|
+
type: @type,
|
122
|
+
name: @name,
|
123
|
+
id: @id,
|
124
|
+
value: @value,
|
125
|
+
placeholder: @placeholder,
|
126
|
+
disabled: @disabled,
|
127
|
+
required: @required,
|
128
|
+
readonly: @readonly
|
129
|
+
})
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns the end section content.
|
133
|
+
#
|
134
|
+
# Since `end` is a reserved word in Ruby, we need to use a different method
|
135
|
+
# name in the template.
|
136
|
+
#
|
137
|
+
def end_content
|
138
|
+
self.end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# The Toggle component renders a DaisyUI styled toggle switch.
|
5
|
+
# It can be used standalone or with a form builder, and provides a visual way
|
6
|
+
# to toggle between two states (on/off).
|
7
|
+
#
|
8
|
+
# @loco_example Basic Usage
|
9
|
+
# = daisy_toggle(name: "notifications", id: "notifications")
|
10
|
+
#
|
11
|
+
# @loco_example Checked Toggle
|
12
|
+
# = daisy_toggle(name: "notifications", id: "notifications", checked: true)
|
13
|
+
#
|
14
|
+
# @loco_example Colored Toggle
|
15
|
+
# = daisy_toggle(name: "theme", id: "theme", css: "toggle-primary", checked: true)
|
16
|
+
#
|
17
|
+
# @loco_example Disabled Toggle
|
18
|
+
# = daisy_toggle(name: "disabled", id: "disabled", disabled: true)
|
19
|
+
#
|
20
|
+
class Daisy::DataInput::ToggleComponent < Daisy::DataInput::CheckboxComponent
|
21
|
+
#
|
22
|
+
# Instantiate a new Toggle component.
|
23
|
+
#
|
24
|
+
# This component accepts the same options as {Daisy::DataInput::CheckboxComponent},
|
25
|
+
# but always sets `toggle: true` to render the checkbox as a toggle switch.
|
26
|
+
#
|
27
|
+
# @param kws [Hash] The keyword arguments for the component. See
|
28
|
+
# {Daisy::DataInput::CheckboxComponent#initialize} for available options.
|
29
|
+
#
|
30
|
+
def initialize(**kws)
|
31
|
+
# Always force toggle to be true
|
32
|
+
kws[:toggle] = true
|
33
|
+
|
34
|
+
super(**kws)
|
35
|
+
end
|
36
|
+
end
|
@@ -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.
|
5
|
+
#
|
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.
|
3
32
|
#
|
4
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
|
|
@@ -1,6 +1,45 @@
|
|
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
|
+
#
|
1
22
|
class Daisy::Feedback::LoadingComponent < LocoMotion::BaseComponent
|
2
23
|
prepend LocoMotion::Concerns::TippableComponent
|
3
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
|
+
|
4
43
|
def before_render
|
5
44
|
add_css(:component, "loading")
|
6
45
|
end
|
@@ -1,5 +1,44 @@
|
|
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
|
+
#
|
1
21
|
class Daisy::Feedback::ProgressComponent < LocoMotion::BaseComponent
|
2
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
|
+
#
|
3
42
|
def initialize(*args, **kws, &block)
|
4
43
|
super
|
5
44
|
|
@@ -16,5 +55,4 @@ class Daisy::Feedback::ProgressComponent < LocoMotion::BaseComponent
|
|
16
55
|
def call
|
17
56
|
part(:component)
|
18
57
|
end
|
19
|
-
|
20
58
|
end
|
@@ -1,5 +1,49 @@
|
|
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
|
+
#
|
1
25
|
class Daisy::Feedback::RadialProgressComponent < LocoMotion::BaseComponent
|
2
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
|
+
#
|
3
47
|
def initialize(*args, **kws, &block)
|
4
48
|
super
|
5
49
|
|
@@ -26,4 +70,3 @@ class Daisy::Feedback::RadialProgressComponent < LocoMotion::BaseComponent
|
|
26
70
|
end
|
27
71
|
|
28
72
|
end
|
29
|
-
|
@@ -1,4 +1,48 @@
|
|
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
|
+
#
|
1
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
|
+
#
|
2
46
|
def before_render
|
3
47
|
add_css(:component, "skeleton")
|
4
48
|
end
|
@@ -1,4 +1,40 @@
|
|
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
|
+
#
|
1
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
|
+
#
|
2
38
|
def before_render
|
3
39
|
add_css(:component, "toast")
|
4
40
|
end
|
@@ -1,20 +1,56 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# The TooltipComponent displays informative text when users hover over an
|
3
|
+
# element. It can be used in two ways:
|
4
|
+
# 1. As a wrapper component around any HTML content.
|
5
|
+
# 2. Through the TippableComponent concern, which many components include.
|
6
|
+
#
|
7
|
+
# This component is also aliased as `daisy_tip` for convenience.
|
3
8
|
#
|
4
9
|
# @loco_example Basic Usage
|
5
|
-
# =
|
6
|
-
# %span
|
10
|
+
# = daisy_tip "Helpful information" do
|
11
|
+
# %span Need help?
|
12
|
+
#
|
13
|
+
# = daisy_tip "Delete this item", css: "tooltip-error" do
|
14
|
+
# = hero_icon("trash", css: "size-5 text-error")
|
15
|
+
#
|
16
|
+
# @loco_example Positioned Tips
|
17
|
+
# = daisy_tip "Opens settings menu", css: "tooltip-left" do
|
18
|
+
# = daisy_button(title: "Settings", icon: "cog-6-tooth")
|
19
|
+
#
|
20
|
+
# = daisy_tip "View user profile", css: "tooltip-bottom tooltip-info" do
|
21
|
+
# = daisy_avatar(src: image_path("avatars/user.jpg"))
|
22
|
+
#
|
23
|
+
# @loco_example Component Integration
|
24
|
+
# = daisy_button(title: "Save Changes",
|
25
|
+
# css: "btn-primary",
|
26
|
+
# tip: "Save your current progress")
|
27
|
+
#
|
28
|
+
# = daisy_chat do |chat|
|
29
|
+
# - chat.with_avatar(css: "tooltip-left tooltip-info",
|
30
|
+
# tip: "Online",
|
31
|
+
# src: image_path("avatars/user.jpg"))
|
32
|
+
# - chat.with_bubble do
|
33
|
+
# Hello!
|
7
34
|
#
|
8
35
|
class Daisy::Feedback::TooltipComponent < LocoMotion::BaseComponent
|
9
36
|
|
10
37
|
#
|
11
|
-
#
|
38
|
+
# Creates a new Tooltip component.
|
39
|
+
#
|
40
|
+
# @param args [Array] If provided, the first argument is used as the `tip`
|
41
|
+
# text.
|
42
|
+
# @param kws [Hash] Keyword arguments for customizing the tooltip.
|
12
43
|
#
|
13
|
-
# @
|
14
|
-
#
|
44
|
+
# @option kws tip [String] The text to display in the tooltip. Can be
|
45
|
+
# passed as the first positional argument or as a keyword argument.
|
15
46
|
#
|
16
|
-
# @option kws
|
17
|
-
#
|
47
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
48
|
+
# options include:
|
49
|
+
# - Position modifiers: `tooltip-top`, `tooltip-bottom`,
|
50
|
+
# `tooltip-left`, `tooltip-right`
|
51
|
+
# - Colors: `tooltip-primary`, `tooltip-secondary`, `tooltip-accent`,
|
52
|
+
# `tooltip-info`, `tooltip-success`, `tooltip-warning`, `tooltip-error`
|
53
|
+
# - Open state: `tooltip-open`
|
18
54
|
#
|
19
55
|
def initialize(*args, **kws, &block)
|
20
56
|
super
|
@@ -24,7 +60,7 @@ class Daisy::Feedback::TooltipComponent < LocoMotion::BaseComponent
|
|
24
60
|
end
|
25
61
|
|
26
62
|
#
|
27
|
-
# Sets up the
|
63
|
+
# Sets up the component's CSS and HTML attributes.
|
28
64
|
#
|
29
65
|
def before_render
|
30
66
|
add_css(:component, "tooltip")
|
@@ -32,7 +68,7 @@ class Daisy::Feedback::TooltipComponent < LocoMotion::BaseComponent
|
|
32
68
|
end
|
33
69
|
|
34
70
|
#
|
35
|
-
# Renders the component and
|
71
|
+
# Renders the component and its content (inline).
|
36
72
|
#
|
37
73
|
def call
|
38
74
|
part(:component) { content }
|
@@ -1,9 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# The ArtboardComponent provides a fixed-size container that mimics mobile
|
3
|
+
# device screens. It's particularly useful for:
|
4
|
+
# - Prototyping mobile interfaces.
|
5
|
+
# - Displaying responsive design examples.
|
6
|
+
# - Creating device-specific mockups.
|
7
|
+
#
|
8
|
+
# The component includes preset sizes for common mobile devices and supports
|
9
|
+
# both portrait and landscape orientations.
|
10
|
+
#
|
11
|
+
# @loco_example Portrait Mode
|
12
|
+
# = daisy_artboard(css: "phone-4") do
|
13
|
+
# = daisy_hero do
|
14
|
+
# iPhone 13 (375×812)
|
15
|
+
#
|
16
|
+
# @loco_example Landscape Mode
|
17
|
+
# = daisy_artboard(css: "phone-4 artboard-horizontal") do
|
18
|
+
# = daisy_hero do
|
19
|
+
# iPhone 13 (812×375)
|
20
|
+
#
|
21
|
+
# @loco_example Custom Demo Style
|
22
|
+
# = daisy_artboard(css: "phone-1 artboard-demo") do
|
23
|
+
# iPhone SE (320×568)
|
24
|
+
#
|
1
25
|
class Daisy::Layout::ArtboardComponent < LocoMotion::BaseComponent
|
2
26
|
|
27
|
+
#
|
28
|
+
# Creates a new Artboard component.
|
29
|
+
#
|
30
|
+
# @param args [Array] Positional arguments passed to the parent class.
|
31
|
+
# @param kws [Hash] Keyword arguments for customizing the artboard.
|
32
|
+
#
|
33
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
34
|
+
# options include:
|
35
|
+
# - Device sizes: `phone-1` (320×568), `phone-2` (375×667),
|
36
|
+
# `phone-3` (414×736), `phone-4` (375×812), `phone-5` (414×896),
|
37
|
+
# `phone-6` (320×1024)
|
38
|
+
# - Orientation: `artboard-horizontal` for landscape mode
|
39
|
+
# - Demo style: `artboard-demo` for visible borders and background
|
40
|
+
#
|
41
|
+
def initialize(*args, **kws, &block)
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Sets up the component's CSS classes.
|
47
|
+
#
|
3
48
|
def before_render
|
4
49
|
add_css(:component, "artboard")
|
5
50
|
end
|
6
51
|
|
52
|
+
#
|
53
|
+
# Renders the component and its content.
|
54
|
+
#
|
7
55
|
def call
|
8
56
|
part(:component) { content }
|
9
57
|
end
|