loco_motion-rails 0.0.6 → 0.0.7
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 +95 -67
- data/app/components/daisy/actions/button_component.rb +5 -2
- data/app/components/daisy/actions/dropdown_component.rb +1 -1
- data/app/components/daisy/actions/modal_component.rb +56 -14
- data/app/components/daisy/actions/swap_component.rb +3 -1
- data/app/components/daisy/actions/theme_controller_component.rb +1 -1
- data/app/components/daisy/data_display/accordion_component.rb +2 -1
- data/app/components/daisy/data_display/avatar_component.rb +3 -1
- data/app/components/daisy/data_display/badge_component.rb +16 -2
- data/app/components/daisy/data_display/card_component.rb +2 -1
- data/app/components/daisy/data_display/carousel_component.rb +1 -1
- data/app/components/daisy/data_display/chat_component.rb +5 -8
- data/app/components/daisy/data_display/collapse_component.rb +3 -1
- data/app/components/daisy/data_display/countdown_component.rb +2 -1
- data/app/components/daisy/data_display/diff_component.rb +1 -1
- data/app/components/daisy/data_display/kbd_component.rb +14 -1
- data/app/components/daisy/data_display/stat_component.rb +3 -1
- data/app/components/daisy/data_display/table_component.rb +1 -1
- data/app/components/daisy/data_display/timeline_component.rb +1 -1
- data/app/components/daisy/data_display/timeline_event_component.rb +1 -1
- data/app/components/daisy/feedback/alert_component.rb +1 -1
- data/app/components/daisy/feedback/loading_component.rb +11 -0
- data/app/components/daisy/feedback/progress_component.rb +20 -0
- data/app/components/daisy/feedback/radial_progress_component.rb +29 -0
- data/app/components/daisy/feedback/skeleton_component.rb +9 -0
- data/app/components/daisy/feedback/toast_component.rb +9 -0
- data/app/components/daisy/feedback/tooltip_component.rb +41 -0
- data/app/components/daisy/layout/artboard_component.rb +11 -0
- data/app/components/daisy/layout/divider_component.rb +32 -0
- data/app/components/daisy/layout/drawer_component.html.haml +9 -0
- data/app/components/daisy/layout/drawer_component.rb +110 -0
- data/app/components/daisy/layout/footer_component.rb +29 -0
- data/app/components/daisy/layout/hero_component.html.haml +5 -0
- data/app/components/daisy/layout/hero_component.rb +21 -0
- data/app/components/daisy/layout/indicator_component.rb +36 -0
- data/app/components/daisy/layout/join_component.rb +1 -1
- data/app/components/daisy/layout/stack_component.rb +9 -0
- data/app/components/daisy/navigation/bottom_nav_component.rb +2 -2
- data/app/components/daisy/navigation/breadcrumbs_component.rb +1 -1
- data/app/components/daisy/navigation/link_component.rb +38 -10
- data/app/components/daisy/navigation/menu_component.rb +45 -5
- data/app/components/daisy/navigation/navbar_component.rb +1 -1
- data/app/components/daisy/navigation/steps_component.rb +2 -2
- data/app/components/daisy/navigation/tabs_component.rb +1 -1
- data/app/components/hero/icon_component.rb +10 -1
- data/lib/daisy.rb +13 -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 +89 -0
- data/lib/loco_motion.rb +6 -36
- metadata +35 -6
- 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
@@ -0,0 +1,29 @@
|
|
1
|
+
class Daisy::Feedback::RadialProgressComponent < LocoMotion::BaseComponent
|
2
|
+
|
3
|
+
def initialize(*args, **kws, &block)
|
4
|
+
super
|
5
|
+
|
6
|
+
@value = config_option(:value)
|
7
|
+
@size = config_option(:size)
|
8
|
+
@thickness = config_option(:thickness)
|
9
|
+
end
|
10
|
+
|
11
|
+
def before_render
|
12
|
+
add_css(:component, "radial-progress")
|
13
|
+
|
14
|
+
styles = []
|
15
|
+
|
16
|
+
styles << "--value: #{@value}" if @value != nil
|
17
|
+
styles << "--size: #{@size}" if @size != nil
|
18
|
+
styles << "--thickness: #{@thickness}" if @thickness != nil
|
19
|
+
|
20
|
+
add_html(:component, { role: "progressbar" })
|
21
|
+
add_html(:component, { style: styles.join(";") }) if styles.present?
|
22
|
+
end
|
23
|
+
|
24
|
+
def call
|
25
|
+
part(:component) { content }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# A component that displays a tooltip when the user hovers over it.
|
3
|
+
#
|
4
|
+
# @loco_example Basic Usage
|
5
|
+
# = daisy_tooltip "This is a tooltip" do
|
6
|
+
# %span Hover over me
|
7
|
+
#
|
8
|
+
class Daisy::Feedback::TooltipComponent < LocoMotion::BaseComponent
|
9
|
+
|
10
|
+
#
|
11
|
+
# Create a new instance of the Tooltip.
|
12
|
+
#
|
13
|
+
# @param args [Array] If provided, the first argument is considered the `tip`.
|
14
|
+
# @param kws [Hash] The keyword arguments for the component.
|
15
|
+
#
|
16
|
+
# @option kws tip [String] The text to display in the tooltip. Can be passed
|
17
|
+
# as the first positional argument, or as a keyword argument.
|
18
|
+
#
|
19
|
+
def initialize(*args, **kws, &block)
|
20
|
+
super
|
21
|
+
|
22
|
+
# Accept a `tip` keyword argument, or the first positional argument
|
23
|
+
@tip = config_option(:tip, args[0])
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Sets up the components CSS and HTML attributes.
|
28
|
+
#
|
29
|
+
def before_render
|
30
|
+
add_css(:component, "tooltip")
|
31
|
+
add_html(:component, { data: { tip: @tip } }) if @tip
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Renders the component and it's content (inline).
|
36
|
+
#
|
37
|
+
def call
|
38
|
+
part(:component) { content }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# The divider component is a simple horizontal or vertical line that separates
|
3
|
+
# content. It can be colored and have a label.
|
4
|
+
#
|
5
|
+
# @loco_example Basic Usage
|
6
|
+
# = daisy_divider
|
7
|
+
#
|
8
|
+
# @loco_example With Text
|
9
|
+
# = daisy_divider do
|
10
|
+
# Hello Dividers!
|
11
|
+
#
|
12
|
+
# @loco_example Horizontal Accented With Text
|
13
|
+
# = daisy_divider(css: "divider-horizontal divider-accent") do
|
14
|
+
# Accent Divider
|
15
|
+
#
|
16
|
+
class Daisy::Layout::DividerComponent < LocoMotion::BaseComponent
|
17
|
+
|
18
|
+
#
|
19
|
+
# Add the `divider` CSS class to the component.
|
20
|
+
#
|
21
|
+
def before_render
|
22
|
+
add_css(:component, "divider")
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Render the component and it's content.
|
27
|
+
#
|
28
|
+
def call
|
29
|
+
part(:component) { content }
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#
|
2
|
+
# The DrawerComponent shows a sidebar that can be toggled open and closed.
|
3
|
+
#
|
4
|
+
# @part input [LocoMotion::BaseComponent] The input checkbox that toggles the
|
5
|
+
# sidebar.
|
6
|
+
# @part content_wrapper [LocoMotion::BaseComponent] The wrapper for the page
|
7
|
+
# content.
|
8
|
+
# @part overlay [LocoMotion::BaseComponent] The overlay that covers the page
|
9
|
+
# when the sidebar is open.
|
10
|
+
#
|
11
|
+
# @slot sidebar [Daisy::Layout::DrawerSidebarComponent] The sidebar that is
|
12
|
+
# shown when the drawer is toggled open. Renders the overlay inside of itself.
|
13
|
+
#
|
14
|
+
# @loco_example Basic Usage
|
15
|
+
# = daisy_drawer do |drawer|
|
16
|
+
# - drawer.with_sidebar do
|
17
|
+
# .bg-base-100.p-4.w-40
|
18
|
+
# Hello sidebar!
|
19
|
+
#
|
20
|
+
# = daisy_button(tag_name: "label", css: "btn btn-primary", title: "Open Drawer", html: { for: drawer.id })
|
21
|
+
#
|
22
|
+
class Daisy::Layout::DrawerComponent < LocoMotion::BaseComponent
|
23
|
+
#
|
24
|
+
# The DrawerSidebarComponent is a child of the {DrawerComponent} and renders
|
25
|
+
# the drawer sidebar and the overlay.
|
26
|
+
#
|
27
|
+
class Daisy::Layout::DrawerSidebarComponent < LocoMotion::BaseComponent
|
28
|
+
#
|
29
|
+
# Add the `drawer-side` CSS class to the component.
|
30
|
+
#
|
31
|
+
def before_render
|
32
|
+
add_css(:component, "drawer-side")
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Render the sidebar, the overlay, and the content.
|
37
|
+
#
|
38
|
+
def call
|
39
|
+
part(:component) do
|
40
|
+
# We need to render the parent component's overlay inside of the sidebar
|
41
|
+
concat(loco_parent.part(:overlay))
|
42
|
+
concat(content)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
define_parts :input, :content_wrapper, :overlay
|
48
|
+
|
49
|
+
renders_one :sidebar, Daisy::Layout::DrawerSidebarComponent
|
50
|
+
|
51
|
+
#
|
52
|
+
# The ID of the drawer. Can be passed in as a configuration option, but
|
53
|
+
# defaults to a random UUID.
|
54
|
+
#
|
55
|
+
attr_reader :id
|
56
|
+
|
57
|
+
#
|
58
|
+
# Create a new instance of the DrawerComponent.
|
59
|
+
#
|
60
|
+
# @param kws [Hash] The keyword arguments passed to the component.
|
61
|
+
# @option kws [String] :id The ID of the drawer. Defaults to a random UUID.
|
62
|
+
#
|
63
|
+
def initialize(**kws)
|
64
|
+
super
|
65
|
+
|
66
|
+
@id = config_option(:id, SecureRandom.uuid)
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Sets up the various parts of the component.
|
71
|
+
#
|
72
|
+
def before_render
|
73
|
+
setup_component
|
74
|
+
setup_input
|
75
|
+
setup_content_wrapper
|
76
|
+
setup_overlay
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Adds the `drawer` class to the component itself.
|
81
|
+
#
|
82
|
+
def setup_component
|
83
|
+
add_css(:component, "drawer")
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Sets up the input checkbox that toggles the sidebar.
|
88
|
+
#
|
89
|
+
def setup_input
|
90
|
+
set_tag_name(:input, :input)
|
91
|
+
add_css(:input, "drawer-toggle")
|
92
|
+
add_html(:input, { type: "checkbox", id: @id })
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Adds the `drawer-content` class to the content wrapper.
|
97
|
+
#
|
98
|
+
def setup_content_wrapper
|
99
|
+
add_css(:content_wrapper, "drawer-content")
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Sets up the overlay that covers the page when the sidebar is open.
|
104
|
+
#
|
105
|
+
def setup_overlay
|
106
|
+
set_tag_name(:overlay, :label)
|
107
|
+
add_css(:overlay, "drawer-overlay")
|
108
|
+
add_html(:overlay, { for: @id, "aria-label": "close sidebar" })
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# The footer component is a simple container for the footer of a page. It can be
|
3
|
+
# used to hold copyright information, links to other pages, or any other
|
4
|
+
# information that should be displayed at the bottom of a page.
|
5
|
+
#
|
6
|
+
# @loco_example Basic Usage
|
7
|
+
# = daisy_footer(css: "bg-neutral text-neutral-content") do
|
8
|
+
# %nav
|
9
|
+
# = link_to "Home", root_path
|
10
|
+
#
|
11
|
+
# @loco_example With Text
|
12
|
+
# = daisy_footer(css: "bg-neutral text-neutral-content p-10 text-center text-sm") do
|
13
|
+
# Copyright © 2024
|
14
|
+
#
|
15
|
+
class Daisy::Layout::FooterComponent < LocoMotion::BaseComponent
|
16
|
+
#
|
17
|
+
# Add the `footer` CSS class to the component.
|
18
|
+
#
|
19
|
+
def before_render
|
20
|
+
add_css(:component, "footer")
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Render the component and it's content (inline).
|
25
|
+
#
|
26
|
+
def call
|
27
|
+
part(:component) { content }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# The HeroComponent is a layout component that is used to create a hero section.
|
3
|
+
#
|
4
|
+
# @part content_wrapper The wrapper for the content of the hero.
|
5
|
+
#
|
6
|
+
# @slot overlay [LocoMotion::BasicComponent] An optional `<div>` positioned to
|
7
|
+
# overlay underneath the hero and allow for styling behind it.
|
8
|
+
#
|
9
|
+
class Daisy::Layout::HeroComponent < LocoMotion::BaseComponent
|
10
|
+
define_part :content_wrapper
|
11
|
+
|
12
|
+
renders_one :overlay, LocoMotion::BasicComponent.build(css: "hero-overlay")
|
13
|
+
|
14
|
+
#
|
15
|
+
# Adds the necessary CSS classes to the component.
|
16
|
+
#
|
17
|
+
def before_render
|
18
|
+
add_css(:component, "hero")
|
19
|
+
add_css(:content_wrapper, "hero-content")
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# The IndicatorComponent provides items positioned around it's content with the
|
3
|
+
# intention of indicating a callout or something needing attention.
|
4
|
+
#
|
5
|
+
# @slot item The items to be rendered around the content. Allows multiple.
|
6
|
+
#
|
7
|
+
# @loco_example Basic Usage
|
8
|
+
# = daisy_indicator do |indicator|
|
9
|
+
# - indicator.with_item do
|
10
|
+
# = daisy_badge(title: "New!", css: "badge-accent")
|
11
|
+
#
|
12
|
+
# = daisy_button(title: "Checkout", left_icon: "shopping-cart")
|
13
|
+
#
|
14
|
+
class Daisy::Layout::IndicatorComponent < LocoMotion::BaseComponent
|
15
|
+
renders_many :items, LocoMotion::BasicComponent.build(css: "indicator-item")
|
16
|
+
|
17
|
+
#
|
18
|
+
# Adds the `indicator` CSS to the component
|
19
|
+
#
|
20
|
+
def before_render
|
21
|
+
add_css(:component, "indicator")
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Renders the component, all of the items, and any user-provided content.
|
26
|
+
#
|
27
|
+
def call
|
28
|
+
part(:component) do
|
29
|
+
items.each do |item|
|
30
|
+
concat(item)
|
31
|
+
end
|
32
|
+
|
33
|
+
concat(content) if content?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class Daisy::Navigation::BottomNavComponent < LocoMotion
|
1
|
+
class Daisy::Navigation::BottomNavComponent < LocoMotion::BaseComponent
|
2
2
|
|
3
|
-
class Daisy::Navigation::BottomNavSectionComponent < LocoMotion
|
3
|
+
class Daisy::Navigation::BottomNavSectionComponent < LocoMotion::BaseComponent
|
4
4
|
|
5
5
|
define_parts :icon, :title
|
6
6
|
|
@@ -2,23 +2,40 @@
|
|
2
2
|
# The Daisy::Navigation::LinkComponent is a simple component that renders an
|
3
3
|
# anchor tag.
|
4
4
|
#
|
5
|
-
class Daisy::Navigation::LinkComponent < LocoMotion
|
5
|
+
class Daisy::Navigation::LinkComponent < LocoMotion::BaseComponent
|
6
|
+
prepend LocoMotion::Concerns::TippableComponent
|
6
7
|
|
7
8
|
# Create a new instance of the LinkComponent.
|
8
9
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
10
|
+
# @param args [Array] Looks for **one** or **two** positional arguments.
|
11
|
+
# - If passed **two** positional arguments, the first is considered the `title`
|
12
|
+
# and the second is considered the `href`.
|
13
|
+
# - If passed only **one** positional argument, it is treated as the `href`
|
14
|
+
# and we assume the `title` will be provided in the block.
|
15
|
+
# - If no text is passed in the block, we will use the `href` as the title
|
16
|
+
# @param kws [Hash] The keyword arguments for the component.
|
13
17
|
#
|
14
|
-
# @
|
15
|
-
# @
|
16
|
-
# @
|
18
|
+
# @option kws title [String] The text to display in the link.
|
19
|
+
# @option kws href [String] The URL to visit when the link is clicked.
|
20
|
+
# @option kws target [String] The target attribute for the anchor tag.
|
17
21
|
def initialize(*args, **kws, &block)
|
18
22
|
super
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
if args.size == 1
|
25
|
+
# If given one arg, assume it's the href and / or the title (if no block is given)
|
26
|
+
@title = args[0]
|
27
|
+
@href = args[0]
|
28
|
+
elsif args.size == 2
|
29
|
+
# If given two args, assume the first is the title and the second is the href
|
30
|
+
@title = args[0]
|
31
|
+
@href = args[1]
|
32
|
+
else
|
33
|
+
# Otherwise, assume they pass everything as keyword arguments
|
34
|
+
@title = config_option(:title)
|
35
|
+
@href = config_option(:href)
|
36
|
+
end
|
37
|
+
|
38
|
+
@target = config_option(:target)
|
22
39
|
end
|
23
40
|
|
24
41
|
#
|
@@ -31,4 +48,15 @@ class Daisy::Navigation::LinkComponent < LocoMotion.configuration.base_component
|
|
31
48
|
add_html(:component, { href: @href }) if @href
|
32
49
|
add_html(:component, { target: @target }) if @target
|
33
50
|
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Renders the link component.
|
54
|
+
#
|
55
|
+
# Because this is an inline component which might be utlized alongside text,
|
56
|
+
# we utilize the `call` method instead of a template to ensure that no
|
57
|
+
# additional whitespace gets added to the output.
|
58
|
+
#
|
59
|
+
def call
|
60
|
+
part(:component) { content || @title }
|
61
|
+
end
|
34
62
|
end
|
@@ -1,25 +1,55 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# A component that renders a menu with items.
|
3
|
+
#
|
4
|
+
# @slot item [Daisy::Navigation::MenuItemComponent] Renders one or more menu
|
5
|
+
# items.
|
6
|
+
#
|
7
|
+
# @loco_example Basic Usage
|
8
|
+
# = daisy_menu do |menu|
|
9
|
+
# - # Menu Item with a grouping title via keyword argument
|
10
|
+
# - menu.with_item(title: "Group 1") do
|
11
|
+
# = link_to "Item 1 - 1", "#"
|
12
|
+
#
|
13
|
+
# - # Menu Item with a grouping title as the first positional argument
|
14
|
+
# - menu.with_item("Group 2") do
|
15
|
+
# = link_to "Item 2 - 1", "#"
|
16
|
+
#
|
17
|
+
# - # Menu Item with no grouping title
|
18
|
+
# - menu.with_item do
|
19
|
+
# = link_to "Item 2 - 2", "#"
|
20
|
+
#
|
21
|
+
class Daisy::Navigation::MenuComponent < LocoMotion::BaseComponent
|
2
22
|
|
3
23
|
#
|
4
24
|
# The items for the MenuComponent.
|
5
25
|
#
|
26
|
+
# @part title Wrapper for the title of the menu item.
|
6
27
|
#
|
7
|
-
class Daisy::Navigation::MenuItemComponent < LocoMotion
|
28
|
+
class Daisy::Navigation::MenuItemComponent < LocoMotion::BaseComponent
|
8
29
|
define_part :title
|
9
30
|
|
10
31
|
#
|
11
32
|
# Create a new instance of the MenuItemComponent.
|
12
33
|
#
|
13
|
-
# @param
|
14
|
-
#
|
34
|
+
# @param args [Array] If provided, the first argument is considered the
|
35
|
+
# `title`.
|
36
|
+
#
|
37
|
+
# @param kws [Hash] The keyword arguments for the component.
|
38
|
+
#
|
39
|
+
# @option kws title [String] Shows an additional title above the item.
|
40
|
+
# @option kws disabled [Boolean] Sets the item in a disabled state.
|
15
41
|
#
|
16
42
|
def initialize(*args, **kws, &block)
|
17
43
|
super
|
18
44
|
|
19
|
-
@simple_title = config_option(:title)
|
45
|
+
@simple_title = config_option(:title, args[0])
|
20
46
|
@disabled = config_option(:disabled)
|
21
47
|
end
|
22
48
|
|
49
|
+
#
|
50
|
+
# Adds the relevant Daisy classes and applies the disabled state if
|
51
|
+
# provided (utilizes Tailwind pointer-events-none).
|
52
|
+
#
|
23
53
|
def before_render
|
24
54
|
set_tag_name(:component, :li)
|
25
55
|
add_css(:component, "disabled pointer-events-none") if @disabled
|
@@ -28,6 +58,9 @@ class Daisy::Navigation::MenuComponent < LocoMotion.configuration.base_component
|
|
28
58
|
add_css(:title, "menu-title")
|
29
59
|
end
|
30
60
|
|
61
|
+
#
|
62
|
+
# Renders the menu item component including a title if present.
|
63
|
+
#
|
31
64
|
def call
|
32
65
|
part(:component) do
|
33
66
|
concat(part(:title) { @simple_title }) if @simple_title
|
@@ -38,10 +71,17 @@ class Daisy::Navigation::MenuComponent < LocoMotion.configuration.base_component
|
|
38
71
|
|
39
72
|
renders_many :items, Daisy::Navigation::MenuItemComponent
|
40
73
|
|
74
|
+
#
|
75
|
+
# Create a new instance of the MenuComponent. Passes any arguments to the
|
76
|
+
# BaseComponent.
|
77
|
+
#
|
41
78
|
def initialize(*args, **kws, &block)
|
42
79
|
super
|
43
80
|
end
|
44
81
|
|
82
|
+
#
|
83
|
+
# Sets the tag name to `<ul>` and adds the relevant Daisy classes.
|
84
|
+
#
|
45
85
|
def before_render
|
46
86
|
set_tag_name(:component, :ul)
|
47
87
|
add_css(:component, "menu")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Daisy::Navigation::NavbarComponent < LocoMotion
|
1
|
+
class Daisy::Navigation::NavbarComponent < LocoMotion::BaseComponent
|
2
2
|
renders_one :start, LocoMotion::BasicComponent.build(css: "navbar-start")
|
3
3
|
|
4
4
|
renders_one :center, LocoMotion::BasicComponent.build(css: "navbar-center")
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class Daisy::Navigation::StepsComponent < LocoMotion
|
1
|
+
class Daisy::Navigation::StepsComponent < LocoMotion::BaseComponent
|
2
2
|
|
3
|
-
class Daisy::Navigation::StepComponent < LocoMotion
|
3
|
+
class Daisy::Navigation::StepComponent < LocoMotion::BaseComponent
|
4
4
|
attr_reader :simple
|
5
5
|
def initialize(*args, **kws, &block)
|
6
6
|
super
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# This is the Tabs component.
|
2
|
-
class Daisy::Navigation::TabsComponent < LocoMotion
|
2
|
+
class Daisy::Navigation::TabsComponent < LocoMotion::BaseComponent
|
3
3
|
|
4
4
|
class TabComponent < LocoMotion::BasicComponent
|
5
5
|
define_parts :content_wrapper
|
@@ -1,4 +1,6 @@
|
|
1
|
-
class Hero::IconComponent < LocoMotion
|
1
|
+
class Hero::IconComponent < LocoMotion::BaseComponent
|
2
|
+
prepend LocoMotion::Concerns::TippableComponent
|
3
|
+
|
2
4
|
def initialize(*args, **kws, &block)
|
3
5
|
super
|
4
6
|
|
@@ -12,6 +14,13 @@ class Hero::IconComponent < LocoMotion.configuration.base_component_class
|
|
12
14
|
add_css(:component, "[:where(&)]:size-5")
|
13
15
|
end
|
14
16
|
|
17
|
+
#
|
18
|
+
# Renders the icon component.
|
19
|
+
#
|
20
|
+
# Because this is an inline component which might be utlized alongside text,
|
21
|
+
# we utilize the `call` method instead of a template to ensure that no
|
22
|
+
# additional whitespace gets added to the output.
|
23
|
+
#
|
15
24
|
def call
|
16
25
|
heroicon_tag(@icon, **rendered_html(:component))
|
17
26
|
end
|
data/lib/daisy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
#
|
2
|
+
# Parent module for all Daisy components.
|
3
|
+
#
|
4
4
|
module Daisy
|
5
5
|
#
|
6
6
|
# Holds all Action-type components.
|
@@ -16,4 +16,14 @@ module Daisy
|
|
16
16
|
# Holds all Navigation-type components.
|
17
17
|
#
|
18
18
|
module Navigation; end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Holds all Feedback-type components.
|
22
|
+
#
|
23
|
+
module Feedback; end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Holds all Layout-type components.
|
27
|
+
#
|
28
|
+
module Layout; end
|
19
29
|
end
|
data/lib/hero.rb
ADDED
@@ -3,7 +3,7 @@
|
|
3
3
|
# so that users can pass in all of the same CSS and HTML options that a standard
|
4
4
|
# component would have.
|
5
5
|
#
|
6
|
-
class LocoMotion::BasicComponent < LocoMotion
|
6
|
+
class LocoMotion::BasicComponent < LocoMotion::BaseComponent
|
7
7
|
|
8
8
|
def call
|
9
9
|
part(:component) do
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module LocoMotion
|
2
|
+
module Concerns
|
3
|
+
#
|
4
|
+
# Can be included in relevant components to allow a new `tip` attibute that
|
5
|
+
# automatically adds the `tooltip` CSS class and the `data-tip` attribute
|
6
|
+
# to the component.
|
7
|
+
#
|
8
|
+
module TippableComponent
|
9
|
+
#
|
10
|
+
# Calls the parent `before_render`. Then adds the `tooltip` CSS class and
|
11
|
+
# the `data-tip` attribute to the component if the `tip` attribute is
|
12
|
+
# present.
|
13
|
+
#
|
14
|
+
def before_render
|
15
|
+
super
|
16
|
+
|
17
|
+
tip = config_option(:tip)
|
18
|
+
|
19
|
+
if tip
|
20
|
+
add_css(:component, "tooltip")
|
21
|
+
add_html(:component, { data: { tip: tip } })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|