daisyui 1.0.0 → 1.0.1
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/lib/daisy_ui/label.rb +51 -3
- data/lib/daisy_ui/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 618724b24d6d8e24b2af9f8c3ec73c54e2585780f7f08f95e7b95a695003f884
|
|
4
|
+
data.tar.gz: bf4a1d586b782bf36402fee0854198004977d3be75a9e814181933ceb4451275
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0679796916b581e19c7d519f006cf63f2cef7304148339f84c59129e03244ef7da2c10b0060e1ec232bb272cba04067cf181b3eb9fd58e50e1ed2df1a88ea3d
|
|
7
|
+
data.tar.gz: b8b705ab2250dfeda5953ae36f9e9a45fdeee9f5200aba740f683c64b5e5a3501e8c21a6c85dba6e500ec9fd33c02d47aff78bbefda7383b4906b71b2fc5d8d9
|
data/lib/daisy_ui/label.rb
CHANGED
|
@@ -1,15 +1,63 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module DaisyUI
|
|
4
|
+
# Label component for wrapping inputs, selects, or creating floating labels
|
|
5
|
+
#
|
|
6
|
+
# @example Floating label
|
|
7
|
+
# DaisyUI::Label.new(:floating) do
|
|
8
|
+
# input(type: "text", placeholder: "Email", class: "input input-md")
|
|
9
|
+
# span { "Your Email" }
|
|
10
|
+
# end
|
|
11
|
+
#
|
|
12
|
+
# @example Input wrapper with label
|
|
13
|
+
# DaisyUI::Label.new(:input) do |label|
|
|
14
|
+
# label.text("https://")
|
|
15
|
+
# input(type: "text", placeholder: "URL")
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# @example Select wrapper with label
|
|
19
|
+
# DaisyUI::Label.new(:select) do |label|
|
|
20
|
+
# label.text("Type")
|
|
21
|
+
# select do
|
|
22
|
+
# option { "Personal" }
|
|
23
|
+
# option { "Business" }
|
|
24
|
+
# end
|
|
25
|
+
# end
|
|
4
26
|
class Label < Base
|
|
5
|
-
|
|
27
|
+
# No default component_class - it varies based on usage
|
|
28
|
+
# (floating-label, input, or select)
|
|
29
|
+
self.component_class = nil
|
|
30
|
+
|
|
31
|
+
register_modifiers(
|
|
32
|
+
# "sm:floating-label"
|
|
33
|
+
# "md:floating-label"
|
|
34
|
+
# "lg:floating-label"
|
|
35
|
+
floating: "floating-label",
|
|
36
|
+
# "sm:input"
|
|
37
|
+
# "md:input"
|
|
38
|
+
# "lg:input"
|
|
39
|
+
input: "input",
|
|
40
|
+
# "sm:select"
|
|
41
|
+
# "md:select"
|
|
42
|
+
# "lg:select"
|
|
43
|
+
select: "select"
|
|
44
|
+
)
|
|
6
45
|
|
|
7
46
|
def view_template(&)
|
|
8
47
|
label(class: classes, **attributes, &)
|
|
9
48
|
end
|
|
10
49
|
|
|
11
|
-
|
|
12
|
-
|
|
50
|
+
# Renders label text for input/select wrappers
|
|
51
|
+
# For floating labels, use a plain span instead
|
|
52
|
+
#
|
|
53
|
+
# @example
|
|
54
|
+
# label.text("Username")
|
|
55
|
+
# label.text { "Email Address" }
|
|
56
|
+
# label.text("https://", class: "custom-class")
|
|
57
|
+
def text(content = nil, **options, &block)
|
|
58
|
+
span(class: component_classes("label", options: options), **options) do
|
|
59
|
+
content || yield
|
|
60
|
+
end
|
|
13
61
|
end
|
|
14
62
|
end
|
|
15
63
|
end
|
data/lib/daisy_ui/version.rb
CHANGED