fernandes-ui 0.1.4 → 0.1.5
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/app/behaviors/ui/button_behavior.rb +7 -5
- data/app/behaviors/ui/button_group_behavior.rb +6 -4
- data/app/behaviors/ui/input_group_button_behavior.rb +5 -3
- data/app/views/ui/_item.html.erb +6 -1
- data/app/views/ui/field/_label.html.erb +2 -1
- data/app/views/ui/field/_separator.html.erb +7 -1
- data/lib/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: 0ab5b35505a4982cf54fe428f57b804589eb6ff88617cb32db0479457eba0372
|
|
4
|
+
data.tar.gz: 69136c3a3fbdace951ebdef92be717c6ba71548fdf4bc0ce354ff4333881248b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ae95aa7368c39e640f7b079b1500f76a2088d8306914d33c0b32ae540225b1b1ca8015b3902f58c5019ec1ec5ca281d9ebe79de4a308149a67ea2576a7664ba
|
|
7
|
+
data.tar.gz: d0853a4b120da156420eb3edcac3e9e26e0a09b31299074342df5c3ca00cc451993c7a0d661bf9f74bcd0add7922f7eed60126328f6490f32d5e47c23eecc841
|
|
@@ -66,7 +66,7 @@ module UI::ButtonBehavior
|
|
|
66
66
|
|
|
67
67
|
# Base classes applied to all buttons
|
|
68
68
|
def button_base_classes
|
|
69
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-
|
|
69
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[var(--radius,0.5rem)] text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive has-[>svg]:px-3"
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# Variant-specific classes based on @variant
|
|
@@ -77,7 +77,7 @@ module UI::ButtonBehavior
|
|
|
77
77
|
when "destructive"
|
|
78
78
|
"bg-destructive text-destructive-foreground hover:bg-destructive/90 text-white"
|
|
79
79
|
when "outline"
|
|
80
|
-
"
|
|
80
|
+
"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:hover:bg-input/50"
|
|
81
81
|
when "secondary"
|
|
82
82
|
"bg-secondary text-secondary-foreground hover:bg-secondary/80"
|
|
83
83
|
when "ghost"
|
|
@@ -90,8 +90,10 @@ module UI::ButtonBehavior
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
# Size-specific classes based on @size
|
|
93
|
+
# Normalizes size to handle both :icon_sm (underscore) and "icon-sm" (hyphen) formats
|
|
93
94
|
def button_size_classes
|
|
94
|
-
|
|
95
|
+
normalized_size = @size.to_s.tr("-", "_")
|
|
96
|
+
case normalized_size
|
|
95
97
|
when "default"
|
|
96
98
|
"h-9 px-4 py-2"
|
|
97
99
|
when "sm"
|
|
@@ -100,9 +102,9 @@ module UI::ButtonBehavior
|
|
|
100
102
|
"h-10 px-8"
|
|
101
103
|
when "icon"
|
|
102
104
|
"h-9 w-9"
|
|
103
|
-
when "
|
|
105
|
+
when "icon_sm"
|
|
104
106
|
"h-8 w-8"
|
|
105
|
-
when "
|
|
107
|
+
when "icon_lg"
|
|
106
108
|
"h-10 w-10"
|
|
107
109
|
else
|
|
108
110
|
"h-9 px-4 py-2"
|
|
@@ -42,14 +42,16 @@ module UI::ButtonGroupBehavior
|
|
|
42
42
|
|
|
43
43
|
# Orientation-specific classes based on @orientation
|
|
44
44
|
# Matches shadcn/ui v4 exactly
|
|
45
|
-
# Note: We exclude [role=menu] elements from border-radius rules
|
|
45
|
+
# Note: We exclude [role=menu], nested [data-slot=button-group], and [data-state] (popover/tooltip content) elements from border-radius rules
|
|
46
|
+
# Note: We use !important on border-radius rules to override button's shorthand `rounded-[var(--radius)]`
|
|
47
|
+
# Note: We use :has(+[data-state]) to exclude elements followed by popover/tooltip content from rounded-r-none
|
|
46
48
|
def button_group_orientation_classes
|
|
47
49
|
case @orientation.to_s
|
|
48
50
|
when "vertical"
|
|
49
|
-
"flex-col [&>*:not(:first-child):not([role=menu])]:rounded-t-none [&>*:not(:first-child):not([role=menu])]:border-t-0 [&>*:not(:last-child):not([role=menu])]:rounded-b-none"
|
|
51
|
+
"flex-col [&>*:not(:first-child):not([role=menu]):not([data-slot=button-group]):not([data-state])]:!rounded-t-none [&>*:not(:first-child):not([role=menu]):not([data-slot=button-group]):not([data-state])]:border-t-0 [&>*:not(:last-child):not(:has(+[data-state])):not([role=menu]):not([data-slot=button-group]):not([data-state])]:!rounded-b-none"
|
|
50
52
|
else # horizontal (default)
|
|
51
|
-
"[&>*:not(:first-child):not([role=menu])]:rounded-l-none [&>*:not(:first-child):not([role=menu])]:border-l-0 " \
|
|
52
|
-
"[&>*:not(:last-child):not(:has(+[role=menu])):not([role=menu])]:rounded-r-none"
|
|
53
|
+
"[&>*:not(:first-child):not([role=menu]):not([data-slot=button-group]):not([data-state])]:!rounded-l-none [&>*:not(:first-child):not([role=menu]):not([data-slot=button-group]):not([data-state])]:border-l-0 " \
|
|
54
|
+
"[&>*:not(:last-child):not(:has(+[role=menu])):not(:has(+[data-state])):not([role=menu]):not([data-slot=button-group]):not([data-state])]:!rounded-r-none"
|
|
53
55
|
end
|
|
54
56
|
end
|
|
55
57
|
end
|
|
@@ -73,15 +73,17 @@ module UI::InputGroupButtonBehavior
|
|
|
73
73
|
|
|
74
74
|
# Size-specific classes
|
|
75
75
|
# Uses calc(var(--radius, 0.375rem) - 5px) to create slightly smaller rounded corners for nested buttons
|
|
76
|
+
# Normalizes size to handle both :icon_xs (underscore) and "icon-xs" (hyphen) formats
|
|
76
77
|
def input_group_button_size_classes
|
|
77
|
-
|
|
78
|
+
normalized_size = @size.to_s.tr("-", "_")
|
|
79
|
+
case normalized_size
|
|
78
80
|
when "xs"
|
|
79
81
|
"h-6 gap-1 px-2 rounded-[calc(var(--radius,0.375rem)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2"
|
|
80
82
|
when "sm"
|
|
81
83
|
"h-8 px-2.5 gap-1.5 rounded-[calc(var(--radius,0.375rem)-5px)] has-[>svg]:px-2.5"
|
|
82
|
-
when "
|
|
84
|
+
when "icon_xs"
|
|
83
85
|
"size-6 rounded-[calc(var(--radius,0.375rem)-5px)] p-0 has-[>svg]:p-0"
|
|
84
|
-
when "
|
|
86
|
+
when "icon_sm"
|
|
85
87
|
"size-8 rounded-[calc(var(--radius,0.375rem)-5px)] p-0 has-[>svg]:p-0"
|
|
86
88
|
else
|
|
87
89
|
"h-6 gap-1 px-2 rounded-[calc(var(--radius,0.375rem)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2"
|
data/app/views/ui/_item.html.erb
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
<% extend UI::ItemBehavior -%>
|
|
2
2
|
<% @variant = local_assigns.fetch(:variant, "default") -%>
|
|
3
3
|
<% @size = local_assigns.fetch(:size, "default") -%>
|
|
4
|
+
<% @as_child = local_assigns.fetch(:as_child, false) -%>
|
|
4
5
|
<% @classes = local_assigns.fetch(:classes, "") -%>
|
|
5
|
-
<% @attributes = local_assigns.except(:variant, :size, :classes) -%>
|
|
6
|
+
<% @attributes = local_assigns.except(:variant, :size, :as_child, :classes) -%>
|
|
6
7
|
<% attrs = item_html_attributes.merge(@attributes) -%>
|
|
8
|
+
<% if @as_child -%>
|
|
9
|
+
<%= yield(attrs) %>
|
|
10
|
+
<% else -%>
|
|
7
11
|
<div class="<%= attrs[:class] %>" data-slot="<%= attrs[:"data-slot"] %>" data-variant="<%= attrs[:"data-variant"] %>" data-size="<%= attrs[:"data-size"] %>">
|
|
8
12
|
<%= yield %>
|
|
9
13
|
</div>
|
|
14
|
+
<% end -%>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<%# FieldLabel Component - Label styled for form fields %>
|
|
2
2
|
<%
|
|
3
3
|
content ||= local_assigns.fetch(:content, nil)
|
|
4
|
+
@for_id = local_assigns.fetch(:for_id, nil)
|
|
4
5
|
@classes = local_assigns.fetch(:classes, "")
|
|
5
6
|
@attributes = local_assigns.fetch(:attributes, {})
|
|
6
7
|
|
|
@@ -10,6 +11,6 @@
|
|
|
10
11
|
# Get HTML attributes from behavior
|
|
11
12
|
all_attributes = field_label_html_attributes.deep_merge(@attributes)
|
|
12
13
|
-%>
|
|
13
|
-
<%= content_tag :
|
|
14
|
+
<%= content_tag :label, all_attributes do %>
|
|
14
15
|
<%= content || yield %>
|
|
15
16
|
<% end %>
|
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
# Get HTML attributes from behavior
|
|
11
11
|
all_attributes = field_separator_html_attributes.deep_merge(@attributes)
|
|
12
|
+
has_children = content.present? || block_given?
|
|
12
13
|
-%>
|
|
13
14
|
<%= content_tag :div, all_attributes do %>
|
|
14
|
-
<%=
|
|
15
|
+
<%= render "ui/separator", classes: "absolute inset-0 top-1/2" %>
|
|
16
|
+
<% if has_children %>
|
|
17
|
+
<span data-slot="field-separator-content" class="bg-background text-muted-foreground relative mx-auto block w-fit px-2">
|
|
18
|
+
<%= content || yield %>
|
|
19
|
+
</span>
|
|
20
|
+
<% end %>
|
|
15
21
|
<% end %>
|
data/lib/ui/version.rb
CHANGED