loco_motion-rails 0.0.7 โ 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 +45 -1
- 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/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/lib/daisy.rb +5 -0
- data/lib/loco_motion/helpers.rb +7 -0
- data/lib/loco_motion/version.rb +5 -0
- metadata +25 -5
@@ -1,19 +1,49 @@
|
|
1
1
|
#
|
2
|
-
# The
|
3
|
-
#
|
2
|
+
# The Chat component renders a messaging interface with support for avatars,
|
3
|
+
# message bubbles, and optional header and footer content. It's perfect for
|
4
|
+
# displaying conversations, comments, or any message-based interactions.
|
4
5
|
#
|
5
|
-
# @slot
|
6
|
-
#
|
7
|
-
# @option avatar [String] icon A heroicon to be displayed instead of an image.
|
6
|
+
# @slot avatar An optional avatar for the message sender. Uses the
|
7
|
+
# {AvatarComponent} with preset styling for chat messages.
|
8
8
|
#
|
9
|
-
# @slot header
|
10
|
-
#
|
11
|
-
#
|
9
|
+
# @slot header A header section above the message bubbles, typically used for
|
10
|
+
# sender name or timestamp.
|
11
|
+
#
|
12
|
+
# @slot footer A footer section below the message bubbles, often used for
|
13
|
+
# message status or metadata.
|
14
|
+
#
|
15
|
+
# @slot bubble+ One or more message bubbles containing the actual message
|
16
|
+
# content.
|
12
17
|
#
|
13
18
|
# @loco_example Basic Usage
|
14
|
-
# = daisy_chat
|
19
|
+
# = daisy_chat do |chat|
|
20
|
+
# - chat.with_bubble do
|
21
|
+
# Hello! How can I help you today?
|
22
|
+
#
|
23
|
+
# @loco_example With Avatar
|
24
|
+
# = daisy_chat do |chat|
|
25
|
+
# - chat.with_avatar(src: "avatar.jpg")
|
26
|
+
# - chat.with_bubble do
|
27
|
+
# Hi there! I'm your assistant.
|
28
|
+
#
|
29
|
+
# @loco_example Complete Message
|
30
|
+
# = daisy_chat do |chat|
|
31
|
+
# - chat.with_avatar(icon: "user")
|
32
|
+
# - chat.with_header do
|
33
|
+
# .font-bold John Doe
|
34
|
+
# .text-xs 2 minutes ago
|
35
|
+
# - chat.with_bubble do
|
36
|
+
# Can you help me with my account?
|
37
|
+
# - chat.with_bubble do
|
38
|
+
# I can't seem to find the settings page.
|
39
|
+
# - chat.with_footer do
|
40
|
+
# .text-xs Sent from Web App
|
41
|
+
#
|
42
|
+
# @loco_example End-aligned Chat
|
43
|
+
# = daisy_chat(css: "chat-end") do |chat|
|
44
|
+
# - chat.with_avatar(src: "user.jpg")
|
15
45
|
# - chat.with_bubble do
|
16
|
-
#
|
46
|
+
# Sure! The settings page is under your profile menu.
|
17
47
|
#
|
18
48
|
class Daisy::DataDisplay::ChatComponent < LocoMotion::BaseComponent
|
19
49
|
renders_one :avatar, Daisy::DataDisplay::AvatarComponent.build(css: "chat-image", icon_css: "size-6 text-base-100", wrapper_css: "w-10 rounded-full")
|
@@ -1,3 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# The Collapse component creates an expandable/collapsible section of content
|
3
|
+
# with a title that toggles visibility. It's similar to the Accordion component
|
4
|
+
# but designed for standalone use rather than groups.
|
5
|
+
#
|
6
|
+
# Includes the {LocoMotion::Concerns::TippableComponent} module to enable easy
|
7
|
+
# tooltip addition.
|
8
|
+
#
|
9
|
+
# @part title The clickable title bar that toggles the content visibility.
|
10
|
+
# @part wrapper The container for the collapsible content.
|
11
|
+
#
|
12
|
+
# @slot title Custom content for the title bar. You can also provide a simple
|
13
|
+
# title string via the title option.
|
14
|
+
#
|
15
|
+
# @loco_example Basic Usage
|
16
|
+
# = daisy_collapse(title: "Click to expand") do
|
17
|
+
# This content can be shown or hidden.
|
18
|
+
#
|
19
|
+
# @loco_example With Custom Title
|
20
|
+
# = daisy_collapse do |collapse|
|
21
|
+
# - collapse.with_title do
|
22
|
+
# .flex.items-center.gap-2
|
23
|
+
# = heroicon_tag "chevron-down"
|
24
|
+
# Advanced Settings
|
25
|
+
# %p These are some advanced configuration options.
|
26
|
+
# = daisy_button("Apply Settings")
|
27
|
+
#
|
28
|
+
# @loco_example With Focus Mode
|
29
|
+
# = daisy_collapse(checkbox: false) do |collapse|
|
30
|
+
# - collapse.with_title do
|
31
|
+
# Click or use keyboard to toggle
|
32
|
+
# This content can be focused and toggled with the keyboard.
|
33
|
+
#
|
34
|
+
# @loco_example With Arrow
|
35
|
+
# = daisy_collapse(title: "Expandable Section", css: "collapse-arrow") do
|
36
|
+
# This section has an arrow indicator.
|
37
|
+
#
|
38
|
+
# @loco_example With Plus/Minus
|
39
|
+
# = daisy_collapse(title: "Expandable Section", css: "collapse-plus") do
|
40
|
+
# This section has a plus/minus indicator.
|
41
|
+
#
|
1
42
|
class Daisy::DataDisplay::CollapseComponent < LocoMotion::BaseComponent
|
2
43
|
prepend LocoMotion::Concerns::TippableComponent
|
3
44
|
|
@@ -5,8 +46,24 @@ class Daisy::DataDisplay::CollapseComponent < LocoMotion::BaseComponent
|
|
5
46
|
|
6
47
|
renders_one :title
|
7
48
|
|
8
|
-
|
49
|
+
# @return [String] The title text when using the simple title option.
|
50
|
+
attr_reader :simple_title
|
9
51
|
|
52
|
+
# @return [Boolean] Whether to use a checkbox for toggle state (true) or
|
53
|
+
# focus/tabindex mode (false).
|
54
|
+
attr_reader :checkbox
|
55
|
+
|
56
|
+
#
|
57
|
+
# Creates a new collapse component.
|
58
|
+
#
|
59
|
+
# @param kws [Hash] The keyword arguments for the component.
|
60
|
+
#
|
61
|
+
# @option kws title [String] The text to display in the title bar. You can
|
62
|
+
# also provide custom title content using the title slot.
|
63
|
+
#
|
64
|
+
# @option kws checkbox [Boolean] Whether to use a checkbox for toggle state
|
65
|
+
# (true) or focus/tabindex mode (false). Defaults to true.
|
66
|
+
#
|
10
67
|
def initialize(*args, **kws, &block)
|
11
68
|
super
|
12
69
|
|
@@ -1,9 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# The Countdown component displays a timer that counts down to or up from a
|
3
|
+
# specific duration. It can show days, hours, minutes, and seconds with
|
4
|
+
# customizable separators and formats.
|
5
|
+
#
|
6
|
+
# Includes the {LocoMotion::Concerns::TippableComponent} module to enable easy
|
7
|
+
# tooltip addition.
|
8
|
+
#
|
9
|
+
# @part days The container for the days value.
|
10
|
+
# @part hours The container for the hours value.
|
11
|
+
# @part minutes The container for the minutes value.
|
12
|
+
# @part seconds The container for the seconds value.
|
13
|
+
#
|
14
|
+
# @loco_example Basic Usage
|
15
|
+
# = daisy_countdown(1.day + 2.hours + 30.minutes)
|
16
|
+
#
|
17
|
+
# @loco_example With Word Separators
|
18
|
+
# = daisy_countdown(5.days + 12.hours + 45.minutes, modifier: :words) do |cd|
|
19
|
+
# 1 day 12 hours 45 minutes remaining
|
20
|
+
#
|
21
|
+
# @loco_example With Letter Separators
|
22
|
+
# = daisy_countdown(24.hours + 59.minutes + 59.seconds, modifier: :letters) do |cd|
|
23
|
+
# 24h 59m 59s left
|
24
|
+
#
|
25
|
+
# @loco_example With Custom Separator
|
26
|
+
# = daisy_countdown(3.hours + 30.minutes, separator: " โ ")
|
27
|
+
#
|
1
28
|
class Daisy::DataDisplay::CountdownComponent < LocoMotion::BaseComponent
|
2
29
|
prepend LocoMotion::Concerns::TippableComponent
|
3
30
|
|
4
31
|
define_parts :days, :hours, :minutes, :seconds
|
5
32
|
define_modifiers :words, :letters
|
6
33
|
|
34
|
+
#
|
35
|
+
# Creates a new countdown component.
|
36
|
+
#
|
37
|
+
# @param duration [ActiveSupport::Duration] The duration to count down from.
|
38
|
+
# Can be created using Rails duration helpers like 1.day, 2.hours, etc.
|
39
|
+
#
|
40
|
+
# @param kws [Hash] The keyword arguments for the component.
|
41
|
+
#
|
42
|
+
# @option kws [ActiveSupport::Duration] :duration The duration to count down
|
43
|
+
# from. Alternative to providing it as the first argument.
|
44
|
+
#
|
45
|
+
# @option kws [Symbol] :modifier Optional display modifier. Use :words for
|
46
|
+
# "days", "hours", etc., or :letters for "d", "h", etc.
|
47
|
+
#
|
48
|
+
# @option kws [String] :separator The separator to use between time parts.
|
49
|
+
# Defaults to ":". Ignored when using :words or :letters modifiers.
|
50
|
+
#
|
51
|
+
# @option kws [String] :parts_css CSS classes to apply to all time parts
|
52
|
+
# (days, hours, minutes, seconds).
|
53
|
+
#
|
54
|
+
# @option kws [Hash] :parts_html HTML attributes to apply to all time parts.
|
55
|
+
#
|
7
56
|
def initialize(*args, **kws, &block)
|
8
57
|
super
|
9
58
|
|
@@ -1,4 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# The Diff component displays two items side by side with a resizable divider
|
3
|
+
# between them. It's perfect for comparing content or showing before/after
|
4
|
+
# states. The component requires exactly two items to function properly.
|
5
|
+
#
|
6
|
+
# @part resizer The draggable divider between items that allows resizing.
|
7
|
+
#
|
8
|
+
# @slot item Two items to be compared. Exactly two items must be provided.
|
9
|
+
#
|
10
|
+
# @loco_example Basic Usage
|
11
|
+
# = daisy_diff do |diff|
|
12
|
+
# - diff.with_item do
|
13
|
+
# %img{ src: "before.jpg", alt: "Before" }
|
14
|
+
# - diff.with_item do
|
15
|
+
# %img{ src: "after.jpg", alt: "After" }
|
16
|
+
#
|
17
|
+
# @loco_example With Text Content
|
18
|
+
# = daisy_diff do |diff|
|
19
|
+
# - diff.with_item do
|
20
|
+
# .p-4.prose
|
21
|
+
# %h3 Original Text
|
22
|
+
# %p Here is the first version of the text...
|
23
|
+
# - diff.with_item do
|
24
|
+
# .p-4.prose
|
25
|
+
# %h3 Revised Text
|
26
|
+
# %p Here is the improved version...
|
27
|
+
#
|
28
|
+
# @loco_example With Custom Resizer
|
29
|
+
# = daisy_diff(resizer_css: "bg-primary hover:bg-primary-focus") do |diff|
|
30
|
+
# - diff.with_item do
|
31
|
+
# %img{ src: "before.jpg", alt: "Before" }
|
32
|
+
# - diff.with_item do
|
33
|
+
# %img{ src: "after.jpg", alt: "After" }
|
34
|
+
#
|
1
35
|
class Daisy::DataDisplay::DiffComponent < LocoMotion::BaseComponent
|
36
|
+
#
|
37
|
+
# A component for rendering individual items within the diff comparison.
|
38
|
+
#
|
2
39
|
class ItemComponent < LocoMotion::BasicComponent
|
3
40
|
def set_index(index)
|
4
41
|
@index = index
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# The FigureComponent is used to display images with optional captions. It is
|
3
|
+
# commonly used within cards and other content containers.
|
4
|
+
#
|
5
|
+
# @part image The image element when a source URL is provided.
|
6
|
+
#
|
7
|
+
# @loco_example Basic Usage
|
8
|
+
# = daisy_figure(src: "example.jpg")
|
9
|
+
#
|
10
|
+
# @loco_example With Caption
|
11
|
+
# = daisy_figure(src: "example.jpg") do
|
12
|
+
# A beautiful landscape
|
13
|
+
#
|
14
|
+
# @loco_example Without Image
|
15
|
+
# = daisy_figure do
|
16
|
+
# Content when no image is provided
|
17
|
+
#
|
18
|
+
class Daisy::DataDisplay::FigureComponent < LocoMotion::BaseComponent
|
19
|
+
define_part :image, tag_name: :img
|
20
|
+
|
21
|
+
# Creates a new figure component.
|
22
|
+
#
|
23
|
+
# @param kws [Hash] The keyword arguments for the component.
|
24
|
+
#
|
25
|
+
# @option kws src [String] URL of the image to display in the figure.
|
26
|
+
#
|
27
|
+
# @option kws css [String] Additional CSS classes for styling.
|
28
|
+
#
|
29
|
+
def initialize(**kws, &block)
|
30
|
+
super
|
31
|
+
|
32
|
+
@src = kws[:src]
|
33
|
+
end
|
34
|
+
|
35
|
+
def before_render
|
36
|
+
set_tag_name(:component, :figure)
|
37
|
+
add_html(:image, src: @src) if @src
|
38
|
+
end
|
39
|
+
|
40
|
+
def call
|
41
|
+
part(:component) do
|
42
|
+
if @src
|
43
|
+
part(:image)
|
44
|
+
else
|
45
|
+
content
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,10 +1,58 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
|
+
# The Kbd (Keyboard) component displays keyboard inputs or shortcuts in a
|
3
|
+
# visually distinct way. It's perfect for showing keyboard shortcuts,
|
4
|
+
# key combinations, or individual key presses in documentation or tutorials.
|
5
|
+
#
|
6
|
+
# Includes the {LocoMotion::Concerns::TippableComponent} module to enable easy
|
7
|
+
# tooltip addition.
|
8
|
+
#
|
9
|
+
# @note This is an inline component that renders as a `<span>` to avoid adding
|
10
|
+
# extra whitespace when used within text.
|
11
|
+
#
|
12
|
+
# @loco_example Basic Usage
|
13
|
+
# %p
|
14
|
+
# Press
|
15
|
+
# = daisy_kbd("Ctrl")
|
16
|
+
# = daisy_kbd("C")
|
17
|
+
# to copy.
|
18
|
+
#
|
19
|
+
# @loco_example With Tooltip
|
20
|
+
# %p
|
21
|
+
# Press
|
22
|
+
# = daisy_kbd("โ", tip: "Command")
|
23
|
+
# = daisy_kbd("P")
|
24
|
+
# to print.
|
25
|
+
#
|
26
|
+
# @loco_example Key Combinations
|
27
|
+
# %p
|
28
|
+
# Press
|
29
|
+
# = daisy_kbd("Alt")
|
30
|
+
# +
|
31
|
+
# = daisy_kbd("Shift")
|
32
|
+
# +
|
33
|
+
# = daisy_kbd("M")
|
34
|
+
# to open the menu.
|
35
|
+
#
|
36
|
+
# @loco_example Special Keys
|
37
|
+
# %p
|
38
|
+
# Press
|
39
|
+
# = daisy_kbd("โต")
|
40
|
+
# or
|
41
|
+
# = daisy_kbd("Enter")
|
42
|
+
# to confirm.
|
43
|
+
#
|
2
44
|
class Daisy::DataDisplay::KbdComponent < LocoMotion::BaseComponent
|
3
45
|
prepend LocoMotion::Concerns::TippableComponent
|
4
46
|
|
5
47
|
set_component_name :kbd
|
6
48
|
|
7
|
-
#
|
49
|
+
#
|
50
|
+
# Creates a new kbd component.
|
51
|
+
#
|
52
|
+
# @param text [String] The text to display in the keyboard component.
|
53
|
+
#
|
54
|
+
# @param kws [Hash] The keyword arguments for the component.
|
55
|
+
#
|
8
56
|
def initialize(*args, **kws, &block)
|
9
57
|
super
|
10
58
|
|
@@ -1,4 +1,45 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
|
+
# The Stat component displays a statistic or metric with optional title,
|
3
|
+
# description, and figure. It's perfect for dashboards, summaries, or any
|
4
|
+
# situation where you need to highlight important numbers or metrics.
|
5
|
+
#
|
6
|
+
# Includes the {LocoMotion::Concerns::TippableComponent} module to enable easy
|
7
|
+
# tooltip addition.
|
8
|
+
#
|
9
|
+
# @part title The title section above the value.
|
10
|
+
# @part value The main value or metric being displayed.
|
11
|
+
# @part description Additional text below the value.
|
12
|
+
# @part figure An optional figure (usually an icon or small image) to display.
|
13
|
+
#
|
14
|
+
# @slot title Custom content for the title section. You can also provide a
|
15
|
+
# simple title string via the title option.
|
16
|
+
#
|
17
|
+
# @slot description Custom content for the description section. You can also
|
18
|
+
# provide a simple description string via the description option.
|
19
|
+
#
|
20
|
+
# @slot figure Custom content for the figure section. You can also provide an
|
21
|
+
# image via the src option or an icon via the icon option.
|
22
|
+
#
|
23
|
+
# @loco_example Basic Usage
|
24
|
+
# = daisy_stat(title: "Downloads", value: "31K", css: "bg-base-200")
|
25
|
+
#
|
26
|
+
# @loco_example With Description
|
27
|
+
# = daisy_stat(title: "New Users", value: "2.6K", description: "โ๏ธ 400 (22%)", css: "bg-base-200")
|
28
|
+
#
|
29
|
+
# @loco_example With Icon
|
30
|
+
# = daisy_stat(title: "Page Views", value: "89,400", icon: "eye", css: "bg-base-200") do |stat|
|
31
|
+
# = stat.with_description do
|
32
|
+
# .flex.items-center.gap-1
|
33
|
+
# = heroicon_tag "arrow-up", class: "size-4 text-success"
|
34
|
+
# %span.text-success 14%
|
35
|
+
# from last month
|
36
|
+
#
|
37
|
+
# @loco_example With Custom Figure
|
38
|
+
# = daisy_stat(title: "Success Rate", value: "98%", css: "bg-base-200") do |stat|
|
39
|
+
# = stat.with_figure do
|
40
|
+
# .text-success
|
41
|
+
# = heroicon_tag "check-circle", class: "size-10"
|
42
|
+
#
|
2
43
|
class Daisy::DataDisplay::StatComponent < LocoMotion::BaseComponent
|
3
44
|
prepend LocoMotion::Concerns::TippableComponent
|
4
45
|
|
@@ -10,10 +51,31 @@ class Daisy::DataDisplay::StatComponent < LocoMotion::BaseComponent
|
|
10
51
|
renders_one :description
|
11
52
|
renders_one :figure
|
12
53
|
|
54
|
+
# @return [String] The title text when using the simple title option.
|
13
55
|
attr_reader :simple_title
|
56
|
+
|
57
|
+
# @return [String] The description text when using the simple description
|
58
|
+
# option.
|
14
59
|
attr_reader :simple_description
|
15
60
|
|
16
|
-
#
|
61
|
+
#
|
62
|
+
# Creates a new stat component.
|
63
|
+
#
|
64
|
+
# @param kws [Hash] The keyword arguments for the component.
|
65
|
+
#
|
66
|
+
# @option kws [String] :title The text to display in the title section.
|
67
|
+
# You can also provide custom title content using the title slot.
|
68
|
+
#
|
69
|
+
# @option kws [String] :description The text to display in the description
|
70
|
+
# section. You can also provide custom description content using the
|
71
|
+
# description slot.
|
72
|
+
#
|
73
|
+
# @option kws [String] :src URL of an image to display in the figure
|
74
|
+
# section.
|
75
|
+
#
|
76
|
+
# @option kws [String] :icon Name of a heroicon to display in the figure
|
77
|
+
# section.
|
78
|
+
#
|
17
79
|
def initialize(*args, **kws, &block)
|
18
80
|
super
|
19
81
|
|
@@ -35,9 +97,5 @@ class Daisy::DataDisplay::StatComponent < LocoMotion::BaseComponent
|
|
35
97
|
add_css(:value, "stat-value")
|
36
98
|
add_css(:description, "stat-desc")
|
37
99
|
add_css(:figure, "stat-figure")
|
38
|
-
|
39
|
-
if @src.nil?
|
40
|
-
|
41
|
-
end
|
42
100
|
end
|
43
101
|
end
|
@@ -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.
|
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" }
|
3
64
|
#
|
4
|
-
# @!parse class Daisy::DataDisplay::TableComponent < LocoMotion::BaseComponent; end
|
5
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::BaseComponent
|
|
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::BaseComponent
|
|
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::BaseComponent
|
|
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::BaseComponent
|
|
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::BaseComponent
|
|
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,3 +1,48 @@
|
|
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
|
+
#
|
1
46
|
class Daisy::DataDisplay::TimelineComponent < LocoMotion::BaseComponent
|
2
47
|
renders_many :events, Daisy::DataDisplay::TimelineEventComponent
|
3
48
|
|