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,53 +1,89 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
#
|
2
|
+
# The Card component is a flexible container for displaying content with a
|
3
|
+
# consistent style. It can include images, titles, text, and actions.
|
4
|
+
#
|
5
|
+
# Includes the {LocoMotion::Concerns::TippableComponent} module to enable easy
|
6
|
+
# tooltip addition.
|
7
|
+
#
|
8
|
+
# @part body The main content area of the card.
|
9
|
+
# @part title The title text container when using the simple title option.
|
10
|
+
#
|
11
|
+
# @slot title A custom title section, typically rendered as an `h2` element.
|
12
|
+
# @slot top_figure {Daisy::DataDisplay::FigureComponent} An optional figure
|
13
|
+
# (usually an image) to display at the top of the card.
|
14
|
+
# @slot bottom_figure {Daisy::DataDisplay::FigureComponent} An optional figure
|
15
|
+
# (usually an image) to display at the bottom of the card.
|
16
|
+
# @slot actions A container for action buttons or links, typically displayed at
|
17
|
+
# the bottom of the card.
|
18
|
+
#
|
19
|
+
# @loco_example Basic Usage
|
20
|
+
# = daisy_card(title: "Simple Card") do
|
21
|
+
# This is a basic card with just a title and some content.
|
22
|
+
#
|
23
|
+
# @loco_example With Top Image
|
24
|
+
# = daisy_card do |card|
|
25
|
+
# - card.with_top_figure(src: "example.jpg")
|
26
|
+
# - card.with_title { "Card with Image" }
|
27
|
+
# A card with an image at the top and a custom title.
|
28
|
+
#
|
29
|
+
# @loco_example With Actions
|
30
|
+
# = daisy_card do |card|
|
31
|
+
# - card.with_title { "Interactive Card" }
|
32
|
+
# This card has buttons for user interaction.
|
33
|
+
# - card.with_actions do
|
34
|
+
# = daisy_button("Learn More")
|
35
|
+
# = daisy_button("Share")
|
36
|
+
#
|
37
|
+
# @loco_example Complex Layout
|
38
|
+
# = daisy_card do |card|
|
39
|
+
# - card.with_top_figure(src: "header.jpg")
|
40
|
+
# - card.with_title do
|
41
|
+
# .flex.items-center.gap-2
|
42
|
+
# = heroicon_tag "star"
|
43
|
+
# Featured Article
|
44
|
+
# %p{ class: "text-base-content/70" } A beautifully designed card with rich content.
|
45
|
+
# - card.with_bottom_figure(src: "footer.jpg")
|
46
|
+
# - card.with_actions do
|
47
|
+
# .flex.justify-between.w-full
|
48
|
+
# = daisy_button("Read More")
|
49
|
+
# .flex.gap-2
|
50
|
+
# = daisy_button(icon: "heart", tip: "Like")
|
51
|
+
# = daisy_button(icon: "share", tip: "Share")
|
52
|
+
#
|
53
|
+
class Daisy::DataDisplay::CardComponent < LocoMotion::BaseComponent
|
54
|
+
prepend LocoMotion::Concerns::TippableComponent
|
29
55
|
|
30
56
|
renders_one :title, LocoMotion::BasicComponent.build(tag_name: :h2, css: "card-title")
|
31
|
-
renders_one :top_figure,
|
32
|
-
renders_one :bottom_figure,
|
57
|
+
renders_one :top_figure, Daisy::DataDisplay::FigureComponent.build(css: "card-image")
|
58
|
+
renders_one :bottom_figure, Daisy::DataDisplay::FigureComponent.build(css: "card-image")
|
33
59
|
renders_one :actions, LocoMotion::BasicComponent.build(css: "card-actions")
|
34
60
|
|
35
|
-
|
61
|
+
# @return [String] The title text when using the simple title option.
|
62
|
+
attr_reader :simple_title
|
63
|
+
|
64
|
+
# Creates a new card component.
|
65
|
+
#
|
66
|
+
# @param kws [Hash] The keyword arguments for the component.
|
67
|
+
#
|
68
|
+
# @option kws title [String] Optional simple title text. For more complex
|
69
|
+
# titles, use the `with_title` method instead.
|
70
|
+
#
|
71
|
+
# @option kws css [String] Additional CSS classes for styling. Common
|
72
|
+
# options include:
|
73
|
+
# - Image Side: `image-full` (image becomes background)
|
74
|
+
# - Borders: `bordered`
|
75
|
+
# - Compact: `compact` (less padding)
|
76
|
+
# - Colors: `bg-base-100`, `bg-primary`, `bg-secondary`
|
77
|
+
#
|
78
|
+
def initialize(**kws, &block)
|
36
79
|
super
|
37
80
|
|
38
81
|
@simple_title = kws[:title]
|
39
|
-
end
|
40
|
-
|
41
|
-
def before_render
|
42
|
-
setup_component
|
43
|
-
setup_body
|
44
|
-
end
|
45
82
|
|
46
|
-
def setup_component
|
47
83
|
add_css(:component, "card")
|
48
84
|
end
|
49
85
|
|
50
|
-
def
|
51
|
-
|
86
|
+
def before_render
|
87
|
+
with_title { simple_title } if simple_title && !title?
|
52
88
|
end
|
53
89
|
end
|
@@ -1,4 +1,42 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# The Carousel component displays a horizontal scrolling list of items, such as
|
3
|
+
# images, cards, or any other content. It's useful for showcasing multiple
|
4
|
+
# items in a space-efficient manner.
|
5
|
+
#
|
6
|
+
# @slot item+ Multiple items to display in the carousel. Each item will be
|
7
|
+
# displayed side by side and can be scrolled horizontally.
|
8
|
+
#
|
9
|
+
# @loco_example Basic Usage with Images
|
10
|
+
# = daisy_carousel do |carousel|
|
11
|
+
# - carousel.with_item do
|
12
|
+
# %img{ src: "image1.jpg", class: "w-full" }
|
13
|
+
# - carousel.with_item do
|
14
|
+
# %img{ src: "image2.jpg", class: "w-full" }
|
15
|
+
# - carousel.with_item do
|
16
|
+
# %img{ src: "image3.jpg", class: "w-full" }
|
17
|
+
#
|
18
|
+
# @loco_example With Cards
|
19
|
+
# = daisy_carousel do |carousel|
|
20
|
+
# - carousel.with_item do
|
21
|
+
# = daisy_card(title: "Card 1") do
|
22
|
+
# First card content
|
23
|
+
# - carousel.with_item do
|
24
|
+
# = daisy_card(title: "Card 2") do
|
25
|
+
# Second card content
|
26
|
+
#
|
27
|
+
# @loco_example With Custom Styling
|
28
|
+
# = daisy_carousel(css: "h-96 rounded-box") do |carousel|
|
29
|
+
# - carousel.with_item(css: "w-1/2") do
|
30
|
+
# .bg-primary.text-primary-content.p-4.h-full
|
31
|
+
# %h2.text-2xl First Slide
|
32
|
+
# %p Some content for the first slide
|
33
|
+
# - carousel.with_item(css: "w-1/2") do
|
34
|
+
# .bg-secondary.text-secondary-content.p-4.h-full
|
35
|
+
# %h2.text-2xl Second Slide
|
36
|
+
# %p Some content for the second slide
|
37
|
+
#
|
38
|
+
class Daisy::DataDisplay::CarouselComponent < LocoMotion::BaseComponent
|
39
|
+
# A component for rendering individual items within the carousel.
|
2
40
|
class ItemComponent < LocoMotion::BasicComponent
|
3
41
|
def before_render
|
4
42
|
add_css(:component, "carousel-item")
|
@@ -1,24 +1,51 @@
|
|
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
|
-
# @slot bubble [LocoMotion::BasicComponent] Renders one or more bubbles.
|
9
|
+
# @slot header A header section above the message bubbles, typically used for
|
10
|
+
# sender name or timestamp.
|
12
11
|
#
|
13
|
-
#
|
12
|
+
# @slot footer A footer section below the message bubbles, often used for
|
13
|
+
# message status or metadata.
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# - chat.with_bubble do
|
18
|
-
# I can't believe it's not the weekend yet!
|
19
|
-
# ```
|
15
|
+
# @slot bubble+ One or more message bubbles containing the actual message
|
16
|
+
# content.
|
20
17
|
#
|
21
|
-
|
18
|
+
# @loco_example Basic Usage
|
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")
|
45
|
+
# - chat.with_bubble do
|
46
|
+
# Sure! The settings page is under your profile menu.
|
47
|
+
#
|
48
|
+
class Daisy::DataDisplay::ChatComponent < LocoMotion::BaseComponent
|
22
49
|
renders_one :avatar, Daisy::DataDisplay::AvatarComponent.build(css: "chat-image", icon_css: "size-6 text-base-100", wrapper_css: "w-10 rounded-full")
|
23
50
|
renders_one :header, LocoMotion::BasicComponent.build(css: "chat-header [:where(&)]:text-neutral-500")
|
24
51
|
renders_one :footer, LocoMotion::BasicComponent.build(css: "chat-footer [:where(&)]:text-neutral-500")
|
@@ -1,10 +1,69 @@
|
|
1
|
-
|
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
|
+
#
|
42
|
+
class Daisy::DataDisplay::CollapseComponent < LocoMotion::BaseComponent
|
43
|
+
prepend LocoMotion::Concerns::TippableComponent
|
44
|
+
|
2
45
|
define_parts :title, :wrapper
|
3
46
|
|
4
47
|
renders_one :title
|
5
48
|
|
6
|
-
|
49
|
+
# @return [String] The title text when using the simple title option.
|
50
|
+
attr_reader :simple_title
|
51
|
+
|
52
|
+
# @return [Boolean] Whether to use a checkbox for toggle state (true) or
|
53
|
+
# focus/tabindex mode (false).
|
54
|
+
attr_reader :checkbox
|
7
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
|
+
#
|
8
67
|
def initialize(*args, **kws, &block)
|
9
68
|
super
|
10
69
|
|
@@ -1,8 +1,58 @@
|
|
1
|
-
|
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
|
+
#
|
28
|
+
class Daisy::DataDisplay::CountdownComponent < LocoMotion::BaseComponent
|
29
|
+
prepend LocoMotion::Concerns::TippableComponent
|
2
30
|
|
3
31
|
define_parts :days, :hours, :minutes, :seconds
|
4
32
|
define_modifiers :words, :letters
|
5
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
|
+
#
|
6
56
|
def initialize(*args, **kws, &block)
|
7
57
|
super
|
8
58
|
|
@@ -1,4 +1,41 @@
|
|
1
|
-
|
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
|
+
#
|
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,8 +1,58 @@
|
|
1
|
-
#
|
2
|
-
|
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
|
+
#
|
44
|
+
class Daisy::DataDisplay::KbdComponent < LocoMotion::BaseComponent
|
45
|
+
prepend LocoMotion::Concerns::TippableComponent
|
46
|
+
|
3
47
|
set_component_name :kbd
|
4
48
|
|
5
|
-
#
|
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
|
+
#
|
6
56
|
def initialize(*args, **kws, &block)
|
7
57
|
super
|
8
58
|
|
@@ -13,6 +63,17 @@ class Daisy::DataDisplay::KbdComponent < LocoMotion.configuration.base_component
|
|
13
63
|
setup_component
|
14
64
|
end
|
15
65
|
|
66
|
+
#
|
67
|
+
# Renders the kbd (Keyboard) component.
|
68
|
+
#
|
69
|
+
# Because this is an inline component which might be utlized alongside text,
|
70
|
+
# we utilize the `call` method instead of a template to ensure that no
|
71
|
+
# additional whitespace gets added to the output.
|
72
|
+
#
|
73
|
+
def call
|
74
|
+
part(:component) { content }
|
75
|
+
end
|
76
|
+
|
16
77
|
private
|
17
78
|
|
18
79
|
def setup_component
|
@@ -1,5 +1,48 @@
|
|
1
|
-
#
|
2
|
-
|
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
|
+
#
|
43
|
+
class Daisy::DataDisplay::StatComponent < LocoMotion::BaseComponent
|
44
|
+
prepend LocoMotion::Concerns::TippableComponent
|
45
|
+
|
3
46
|
set_component_name :stat
|
4
47
|
|
5
48
|
define_parts :title, :value, :description, :figure
|
@@ -8,10 +51,31 @@ class Daisy::DataDisplay::StatComponent < LocoMotion.configuration.base_componen
|
|
8
51
|
renders_one :description
|
9
52
|
renders_one :figure
|
10
53
|
|
54
|
+
# @return [String] The title text when using the simple title option.
|
11
55
|
attr_reader :simple_title
|
56
|
+
|
57
|
+
# @return [String] The description text when using the simple description
|
58
|
+
# option.
|
12
59
|
attr_reader :simple_description
|
13
60
|
|
14
|
-
#
|
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
|
+
#
|
15
79
|
def initialize(*args, **kws, &block)
|
16
80
|
super
|
17
81
|
|
@@ -33,9 +97,5 @@ class Daisy::DataDisplay::StatComponent < LocoMotion.configuration.base_componen
|
|
33
97
|
add_css(:value, "stat-value")
|
34
98
|
add_css(:description, "stat-desc")
|
35
99
|
add_css(:figure, "stat-figure")
|
36
|
-
|
37
|
-
if @src.nil?
|
38
|
-
|
39
|
-
end
|
40
100
|
end
|
41
101
|
end
|