shadcn-rails 0.2.0 → 0.2.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/CHANGELOG.md +66 -2
- data/README.md +21 -8
- data/__mocks__/@floating-ui/dom.js +67 -0
- data/app/assets/javascripts/shadcn/controllers/combobox_controller.js +23 -2
- data/app/assets/javascripts/shadcn/controllers/context_menu_controller.js +4 -31
- data/app/assets/javascripts/shadcn/controllers/dropdown_controller.js +32 -41
- data/app/assets/javascripts/shadcn/controllers/hover_card_controller.js +29 -55
- data/app/assets/javascripts/shadcn/controllers/popover_controller.js +29 -54
- data/app/assets/javascripts/shadcn/controllers/select_controller.js +26 -8
- data/app/assets/javascripts/shadcn/controllers/tooltip_controller.js +28 -59
- data/app/assets/javascripts/shadcn/index.js +7 -1
- data/app/assets/javascripts/shadcn/utils/floating.js +179 -0
- data/app/assets/stylesheets/shadcn/base.css +32 -0
- data/app/components/shadcn/accordion_component.html.erb +8 -0
- data/app/components/shadcn/accordion_component.rb +6 -15
- data/app/components/shadcn/alert_component.html.erb +6 -0
- data/app/components/shadcn/alert_component.rb +0 -18
- data/app/components/shadcn/alert_dialog_component.html.erb +12 -0
- data/app/components/shadcn/alert_dialog_component.rb +7 -27
- data/app/components/shadcn/aspect_ratio_component.html.erb +7 -0
- data/app/components/shadcn/aspect_ratio_component.rb +4 -19
- data/app/components/shadcn/avatar_component.html.erb +20 -0
- data/app/components/shadcn/avatar_component.rb +8 -36
- data/app/components/shadcn/badge_component.html.erb +1 -0
- data/app/components/shadcn/badge_component.rb +0 -11
- data/app/components/shadcn/base_component.rb +15 -2
- data/app/components/shadcn/breadcrumb_component.html.erb +5 -0
- data/app/components/shadcn/breadcrumb_component.rb +6 -16
- data/app/components/shadcn/button_component.html.erb +18 -0
- data/app/components/shadcn/button_component.rb +1 -41
- data/app/components/shadcn/card_component.html.erb +8 -0
- data/app/components/shadcn/card_component.rb +2 -6
- data/app/components/shadcn/checkbox_component.html.erb +32 -0
- data/app/components/shadcn/checkbox_component.rb +4 -43
- data/app/components/shadcn/collapsible_component.html.erb +8 -0
- data/app/components/shadcn/collapsible_component.rb +6 -15
- data/app/components/shadcn/context_menu_component.html.erb +11 -0
- data/app/components/shadcn/context_menu_component.rb +6 -26
- data/app/components/shadcn/dialog_component.html.erb +14 -0
- data/app/components/shadcn/dialog_component.rb +8 -29
- data/app/components/shadcn/drawer_component.html.erb +12 -0
- data/app/components/shadcn/drawer_component.rb +7 -27
- data/app/components/shadcn/dropdown_menu_component.html.erb +14 -0
- data/app/components/shadcn/dropdown_menu_component.rb +9 -29
- data/app/components/shadcn/field_component.rb +7 -8
- data/app/components/shadcn/hover_card_component.html.erb +12 -0
- data/app/components/shadcn/hover_card_component.rb +7 -26
- data/app/components/shadcn/input_component.html.erb +18 -0
- data/app/components/shadcn/input_component.rb +2 -27
- data/app/components/shadcn/input_otp_component.rb +3 -3
- data/app/components/shadcn/kbd_component.html.erb +1 -0
- data/app/components/shadcn/kbd_component.rb +3 -10
- data/app/components/shadcn/label_component.html.erb +3 -0
- data/app/components/shadcn/label_component.rb +2 -18
- data/app/components/shadcn/menubar_component.html.erb +6 -0
- data/app/components/shadcn/menubar_component.rb +4 -15
- data/app/components/shadcn/native_select_component.html.erb +22 -0
- data/app/components/shadcn/native_select_component.rb +9 -39
- data/app/components/shadcn/navigation_menu_component.html.erb +6 -0
- data/app/components/shadcn/navigation_menu_component.rb +4 -15
- data/app/components/shadcn/pagination_component.html.erb +5 -0
- data/app/components/shadcn/pagination_component.rb +11 -15
- data/app/components/shadcn/popover_component.html.erb +15 -0
- data/app/components/shadcn/popover_component.rb +10 -30
- data/app/components/shadcn/progress_component.html.erb +13 -0
- data/app/components/shadcn/progress_component.rb +6 -26
- data/app/components/shadcn/radio_group_component.html.erb +8 -0
- data/app/components/shadcn/radio_group_component.rb +12 -26
- data/app/components/shadcn/scroll_area_component.html.erb +7 -0
- data/app/components/shadcn/scroll_area_component.rb +4 -16
- data/app/components/shadcn/select_component.html.erb +46 -0
- data/app/components/shadcn/select_component.rb +6 -80
- data/app/components/shadcn/separator_component.html.erb +5 -0
- data/app/components/shadcn/separator_component.rb +6 -14
- data/app/components/shadcn/sheet_component.html.erb +12 -0
- data/app/components/shadcn/sheet_component.rb +7 -27
- data/app/components/shadcn/sidebar_component.rb +2 -2
- data/app/components/shadcn/skeleton_component.html.erb +1 -0
- data/app/components/shadcn/skeleton_component.rb +4 -2
- data/app/components/shadcn/slider_component.html.erb +12 -0
- data/app/components/shadcn/slider_component.rb +2 -21
- data/app/components/shadcn/spinner_component.html.erb +18 -0
- data/app/components/shadcn/spinner_component.rb +2 -30
- data/app/components/shadcn/switch_component.html.erb +72 -0
- data/app/components/shadcn/switch_component.rb +4 -82
- data/app/components/shadcn/table_component.html.erb +9 -0
- data/app/components/shadcn/table_component.rb +2 -10
- data/app/components/shadcn/tabs_component.html.erb +8 -0
- data/app/components/shadcn/tabs_component.rb +4 -17
- data/app/components/shadcn/textarea_component.html.erb +13 -0
- data/app/components/shadcn/textarea_component.rb +6 -22
- data/app/components/shadcn/toast_component.html.erb +36 -0
- data/app/components/shadcn/toast_component.rb +6 -54
- data/app/components/shadcn/toggle_component.html.erb +12 -0
- data/app/components/shadcn/toggle_component.rb +6 -21
- data/app/components/shadcn/toggle_group_component.html.erb +14 -0
- data/app/components/shadcn/toggle_group_component.rb +6 -29
- data/app/components/shadcn/tooltip_component.html.erb +20 -0
- data/app/components/shadcn/tooltip_component.rb +13 -38
- data/lib/generators/shadcn/add/USAGE +24 -0
- data/lib/generators/shadcn/add/add_generator.rb +279 -0
- data/lib/generators/shadcn/install/USAGE +22 -0
- data/lib/generators/shadcn/install/install_generator.rb +8 -3
- data/lib/generators/shadcn/install/templates/initializer.rb.tt +7 -27
- data/lib/generators/shadcn/install/templates/shadcn.yml.tt +15 -31
- data/lib/shadcn/rails/version.rb +1 -1
- metadata +47 -45
- data/.dockerignore +0 -40
- data/CLAUDE.md +0 -612
- data/PROGRESS.md +0 -495
- data/Rakefile +0 -95
- data/__tests__/controllers/__snapshots__/calendar_controller.test.js.snap +0 -13
- data/__tests__/controllers/__snapshots__/popover_controller.test.js.snap +0 -46
- data/__tests__/controllers/__snapshots__/sheet_controller.test.js.snap +0 -111
- data/__tests__/controllers/__snapshots__/tabs_controller.test.js.snap +0 -27
- data/__tests__/controllers/accordion_controller.test.js +0 -904
- data/__tests__/controllers/calendar_controller.test.js +0 -1370
- data/__tests__/controllers/carousel_controller.test.js +0 -912
- data/__tests__/controllers/checkbox_controller.test.js +0 -454
- data/__tests__/controllers/collapsible_controller.test.js +0 -407
- data/__tests__/controllers/combobox_controller.test.js +0 -971
- data/__tests__/controllers/context_menu_controller.test.js +0 -905
- data/__tests__/controllers/date_picker_controller.test.js +0 -636
- data/__tests__/controllers/dialog_controller.test.js +0 -878
- data/__tests__/controllers/drawer_controller.test.js +0 -995
- data/__tests__/controllers/menubar_controller.test.js +0 -737
- data/__tests__/controllers/navigation_menu_controller.test.js +0 -599
- data/__tests__/controllers/popover_controller.test.js +0 -982
- data/__tests__/controllers/radio_group_controller.test.js +0 -640
- data/__tests__/controllers/resizable_controller.test.js +0 -680
- data/__tests__/controllers/select_controller.test.js +0 -678
- data/__tests__/controllers/sheet_controller.test.js +0 -986
- data/__tests__/controllers/slider_controller.test.js +0 -1036
- data/__tests__/controllers/switch_controller.test.js +0 -424
- data/__tests__/controllers/tabs_controller.test.js +0 -907
- data/__tests__/controllers/toggle_group_controller.test.js +0 -839
- data/__tests__/controllers/tooltip_controller.test.js +0 -808
- data/__tests__/helpers/stimulus-test-helper.js +0 -203
- data/babel.config.cjs +0 -5
- data/bin/bump +0 -321
- data/bin/console +0 -11
- data/bin/release +0 -205
- data/bin/setup +0 -8
- data/bin/test +0 -75
- data/jest.config.js +0 -19
- data/jest.setup.js +0 -8
- data/lib/generators/shadcn/component/component_generator.rb +0 -188
- data/lib/generators/shadcn/theme/theme_generator.rb +0 -128
- data/package-lock.json +0 -7438
- data/package.json +0 -71
- data/rollup.config.js +0 -29
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<textarea class="<%= textarea_classes %>"<% if @name %>
|
|
2
|
+
name="<%= ERB::Util.html_escape_once(@name) %>"<% end %><% if @id %>
|
|
3
|
+
id="<%= ERB::Util.html_escape_once(@id) %>"<% end %><% if @placeholder %>
|
|
4
|
+
placeholder="<%= ERB::Util.html_escape_once(@placeholder) %>"<% end %><% if @rows %>
|
|
5
|
+
rows="<%= @rows %>"<% end %><% if @cols %>
|
|
6
|
+
cols="<%= @cols %>"<% end %><% if @disabled %>
|
|
7
|
+
disabled<% end %><% if @required %>
|
|
8
|
+
required<% end %><% if @readonly %>
|
|
9
|
+
readonly<% end %><% if @autofocus %>
|
|
10
|
+
autofocus<% end %><% if @minlength %>
|
|
11
|
+
minlength="<%= @minlength %>"<% end %><% if @maxlength %>
|
|
12
|
+
maxlength="<%= @maxlength %>"<% end %>
|
|
13
|
+
<%= tag_attributes %>><%= textarea_content %></textarea>
|
|
@@ -55,30 +55,14 @@ module Shadcn
|
|
|
55
55
|
@maxlength = maxlength
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def call
|
|
59
|
-
content_tag(:textarea, @value || content, textarea_attributes)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
58
|
private
|
|
63
59
|
|
|
64
|
-
def
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
cols: @cols,
|
|
71
|
-
disabled: @disabled || nil,
|
|
72
|
-
required: @required || nil,
|
|
73
|
-
readonly: @readonly || nil,
|
|
74
|
-
autofocus: @autofocus || nil,
|
|
75
|
-
minlength: @minlength,
|
|
76
|
-
maxlength: @maxlength,
|
|
77
|
-
class: merge_classes(BASE_CLASSES)
|
|
78
|
-
}
|
|
79
|
-
attrs.merge!(html_options)
|
|
80
|
-
attrs.merge!(build_data)
|
|
81
|
-
attrs.compact
|
|
60
|
+
def textarea_classes
|
|
61
|
+
merge_classes(BASE_CLASSES)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def textarea_content
|
|
65
|
+
@value || content
|
|
82
66
|
end
|
|
83
67
|
end
|
|
84
68
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<li class="<%= toast_classes %>"
|
|
2
|
+
role="status"
|
|
3
|
+
aria-live="polite"
|
|
4
|
+
data-controller="shadcn--toast"
|
|
5
|
+
data-shadcn--toast-duration-value="<%= @duration %>"
|
|
6
|
+
data-shadcn--toast-open-value="<%= @open %>"
|
|
7
|
+
data-state="<%= data_state %>"
|
|
8
|
+
<%= tag_attributes %>>
|
|
9
|
+
<div class="grid gap-1">
|
|
10
|
+
<%= title %>
|
|
11
|
+
<%= description %>
|
|
12
|
+
<%= content %>
|
|
13
|
+
</div>
|
|
14
|
+
<%= action %>
|
|
15
|
+
<% if has_custom_close? %>
|
|
16
|
+
<%= close %>
|
|
17
|
+
<% else %>
|
|
18
|
+
<button type="button"
|
|
19
|
+
class="absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600"
|
|
20
|
+
data-action="click->shadcn--toast#close"
|
|
21
|
+
aria-label="Close">
|
|
22
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
23
|
+
width="16"
|
|
24
|
+
height="16"
|
|
25
|
+
viewBox="0 0 24 24"
|
|
26
|
+
fill="none"
|
|
27
|
+
class="h-4 w-4">
|
|
28
|
+
<path d="M18 6 6 18M6 6l12 12"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
stroke-width="2"
|
|
31
|
+
stroke-linecap="round"
|
|
32
|
+
stroke-linejoin="round" />
|
|
33
|
+
</svg>
|
|
34
|
+
</button>
|
|
35
|
+
<% end %>
|
|
36
|
+
</li>
|
|
@@ -49,66 +49,18 @@ module Shadcn
|
|
|
49
49
|
@open = open
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def call
|
|
53
|
-
content_tag(:li, toast_content, toast_attributes)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
52
|
private
|
|
57
53
|
|
|
58
|
-
def toast_content
|
|
59
|
-
safe_join([
|
|
60
|
-
content_wrapper,
|
|
61
|
-
action,
|
|
62
|
-
close_button
|
|
63
|
-
].compact)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def content_wrapper
|
|
67
|
-
content_tag(:div, safe_join([title, description, content].compact), class: "grid gap-1")
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def close_button
|
|
71
|
-
close || default_close_button
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def default_close_button
|
|
75
|
-
content_tag(:button, close_icon, {
|
|
76
|
-
type: "button",
|
|
77
|
-
class: "absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
78
|
-
"data-action": "click->shadcn--toast#close",
|
|
79
|
-
"aria-label": "Close"
|
|
80
|
-
})
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def close_icon
|
|
84
|
-
content_tag(:svg,
|
|
85
|
-
content_tag(:path, nil, d: "M18 6 6 18M6 6l12 12", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round"),
|
|
86
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
87
|
-
width: "16",
|
|
88
|
-
height: "16",
|
|
89
|
-
viewBox: "0 0 24 24",
|
|
90
|
-
fill: "none",
|
|
91
|
-
class: "h-4 w-4"
|
|
92
|
-
)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
54
|
def toast_classes
|
|
96
55
|
cn(BASE_CLASSES, VARIANTS[@variant], class_name)
|
|
97
56
|
end
|
|
98
57
|
|
|
99
|
-
def
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"data-shadcn--toast-duration-value": @duration,
|
|
106
|
-
"data-shadcn--toast-open-value": @open.to_s,
|
|
107
|
-
"data-state": @open ? "open" : "closed"
|
|
108
|
-
}
|
|
109
|
-
attrs.merge!(html_options)
|
|
110
|
-
attrs.merge!(build_data)
|
|
111
|
-
attrs.compact
|
|
58
|
+
def has_custom_close?
|
|
59
|
+
close?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def data_state
|
|
63
|
+
@open ? "open" : "closed"
|
|
112
64
|
end
|
|
113
65
|
end
|
|
114
66
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<button type="button"
|
|
2
|
+
class="<%= toggle_classes %>"
|
|
3
|
+
<%= "disabled" if @disabled %>
|
|
4
|
+
aria-pressed="<%= @pressed %>"
|
|
5
|
+
<%= "aria-label=\"#{ERB::Util.html_escape_once(@aria_label)}\"".html_safe if @aria_label %>
|
|
6
|
+
data-state="<%= data_state %>"
|
|
7
|
+
data-controller="shadcn--toggle"
|
|
8
|
+
data-action="click->shadcn--toggle#toggle"
|
|
9
|
+
data-shadcn--toggle-pressed-value="<%= @pressed %>"
|
|
10
|
+
<%= tag_attributes %>>
|
|
11
|
+
<%= content %>
|
|
12
|
+
</button>
|
|
@@ -49,29 +49,14 @@ module Shadcn
|
|
|
49
49
|
@aria_label = aria_label
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def call
|
|
53
|
-
content_tag(:button, toggle_attributes) do
|
|
54
|
-
content
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
52
|
private
|
|
59
53
|
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"aria-label": @aria_label,
|
|
67
|
-
"data-state": @pressed ? "on" : "off",
|
|
68
|
-
"data-controller": "shadcn--toggle",
|
|
69
|
-
"data-action": "click->shadcn--toggle#toggle",
|
|
70
|
-
"data-shadcn--toggle-pressed-value": @pressed.to_s
|
|
71
|
-
}
|
|
72
|
-
attrs.merge!(html_options)
|
|
73
|
-
attrs.merge!(build_data)
|
|
74
|
-
attrs.compact
|
|
54
|
+
def toggle_classes
|
|
55
|
+
cn(BASE_CLASSES, VARIANTS[@variant], SIZES[@size], class_name)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def data_state
|
|
59
|
+
@pressed ? "on" : "off"
|
|
75
60
|
end
|
|
76
61
|
end
|
|
77
62
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<div role="group"
|
|
2
|
+
class="<%= group_classes %>"
|
|
3
|
+
data-controller="shadcn--toggle-group"
|
|
4
|
+
data-shadcn--toggle-group-type-value="<%= @type %>"
|
|
5
|
+
data-shadcn--toggle-group-value-value="<%= value_string %>"
|
|
6
|
+
<%= tag_attributes %>>
|
|
7
|
+
<% if has_name? %>
|
|
8
|
+
<input type="hidden"
|
|
9
|
+
name="<%= @name %>"
|
|
10
|
+
value="<%= value_string %>"
|
|
11
|
+
data-shadcn--toggle-group-target="input" />
|
|
12
|
+
<% end %>
|
|
13
|
+
<%= safe_join(items.map(&:to_s)) %>
|
|
14
|
+
</div>
|
|
@@ -56,41 +56,18 @@ module Shadcn
|
|
|
56
56
|
@name = name
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
def call
|
|
60
|
-
content_tag(:div, group_content, group_attributes)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
59
|
private
|
|
64
60
|
|
|
65
|
-
def
|
|
66
|
-
|
|
67
|
-
hidden_input,
|
|
68
|
-
items.map(&:to_s)
|
|
69
|
-
].flatten.compact)
|
|
61
|
+
def group_classes
|
|
62
|
+
merge_classes(BASE_CLASSES)
|
|
70
63
|
end
|
|
71
64
|
|
|
72
|
-
def
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tag(:input,
|
|
76
|
-
type: "hidden",
|
|
77
|
-
name: @name,
|
|
78
|
-
value: Array(@value).join(","),
|
|
79
|
-
"data-shadcn--toggle-group-target": "input"
|
|
80
|
-
)
|
|
65
|
+
def has_name?
|
|
66
|
+
@name.present?
|
|
81
67
|
end
|
|
82
68
|
|
|
83
|
-
def
|
|
84
|
-
|
|
85
|
-
role: "group",
|
|
86
|
-
class: merge_classes(BASE_CLASSES),
|
|
87
|
-
"data-controller": "shadcn--toggle-group",
|
|
88
|
-
"data-shadcn--toggle-group-type-value": @type.to_s,
|
|
89
|
-
"data-shadcn--toggle-group-value-value": Array(@value).join(",")
|
|
90
|
-
}
|
|
91
|
-
attrs.merge!(html_options)
|
|
92
|
-
attrs.merge!(build_data)
|
|
93
|
-
attrs.compact
|
|
69
|
+
def value_string
|
|
70
|
+
Array(@value).join(",")
|
|
94
71
|
end
|
|
95
72
|
end
|
|
96
73
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<span class="<%= tooltip_classes %>"
|
|
2
|
+
data-controller="<%= tooltip_data_attrs[:controller] %>"
|
|
3
|
+
data-shadcn--tooltip-side-value="<%= tooltip_data_attrs[:"shadcn--tooltip-side-value"] %>"
|
|
4
|
+
data-shadcn--tooltip-align-value="<%= tooltip_data_attrs[:"shadcn--tooltip-align-value"] %>"
|
|
5
|
+
data-shadcn--tooltip-delay-value="<%= tooltip_data_attrs[:"shadcn--tooltip-delay-value"] %>"
|
|
6
|
+
data-shadcn--tooltip-skip-delay-value="<%= tooltip_data_attrs[:"shadcn--tooltip-skip-delay-value"] %>"
|
|
7
|
+
<%= tag_attributes %>>
|
|
8
|
+
<span data-shadcn--tooltip-target="trigger"
|
|
9
|
+
data-action="mouseenter->shadcn--tooltip#show mouseleave->shadcn--tooltip#hide focus->shadcn--tooltip#show blur->shadcn--tooltip#hide">
|
|
10
|
+
<%= content %>
|
|
11
|
+
</span>
|
|
12
|
+
<div class="<%= tooltip_content_classes %>"
|
|
13
|
+
role="tooltip"
|
|
14
|
+
data-shadcn--tooltip-target="content"
|
|
15
|
+
data-side="<%= @side %>"
|
|
16
|
+
data-state="closed"
|
|
17
|
+
hidden>
|
|
18
|
+
<%= ERB::Util.html_escape_once(@tooltip_content) %>
|
|
19
|
+
</div>
|
|
20
|
+
</span>
|
|
@@ -18,7 +18,7 @@ module Shadcn
|
|
|
18
18
|
# <% end %>
|
|
19
19
|
#
|
|
20
20
|
class TooltipComponent < BaseComponent
|
|
21
|
-
CONTENT_CLASSES = "z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground
|
|
21
|
+
CONTENT_CLASSES = "z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground whitespace-nowrap animate-tooltip-in data-[state=closed]:animate-tooltip-out"
|
|
22
22
|
|
|
23
23
|
# @param text [String] Tooltip text content
|
|
24
24
|
# @param side [Symbol] Side to show tooltip (:top, :right, :bottom, :left)
|
|
@@ -41,49 +41,24 @@ module Shadcn
|
|
|
41
41
|
super(**options)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def call
|
|
45
|
-
content_tag(:span, tooltip_structure, tooltip_attributes)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
44
|
private
|
|
49
45
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
trigger_wrapper,
|
|
53
|
-
tooltip_content_element
|
|
54
|
-
])
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def trigger_wrapper
|
|
58
|
-
content_tag(:span, content, {
|
|
59
|
-
"data-shadcn--tooltip-target": "trigger",
|
|
60
|
-
"data-action": "mouseenter->shadcn--tooltip#show mouseleave->shadcn--tooltip#hide focus->shadcn--tooltip#show blur->shadcn--tooltip#hide"
|
|
61
|
-
})
|
|
46
|
+
def tooltip_classes
|
|
47
|
+
cn("relative inline-block", class_name)
|
|
62
48
|
end
|
|
63
49
|
|
|
64
|
-
def
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
})
|
|
50
|
+
def tooltip_data_attrs
|
|
51
|
+
{
|
|
52
|
+
controller: "shadcn--tooltip",
|
|
53
|
+
"shadcn--tooltip-side-value": @side.to_s,
|
|
54
|
+
"shadcn--tooltip-align-value": @align.to_s,
|
|
55
|
+
"shadcn--tooltip-delay-value": @delay_duration,
|
|
56
|
+
"shadcn--tooltip-skip-delay-value": @skip_delay_duration
|
|
57
|
+
}
|
|
73
58
|
end
|
|
74
59
|
|
|
75
|
-
def
|
|
76
|
-
|
|
77
|
-
class: cn("relative inline-block", class_name),
|
|
78
|
-
"data-controller": "shadcn--tooltip",
|
|
79
|
-
"data-shadcn--tooltip-side-value": @side.to_s,
|
|
80
|
-
"data-shadcn--tooltip-align-value": @align.to_s,
|
|
81
|
-
"data-shadcn--tooltip-delay-value": @delay_duration,
|
|
82
|
-
"data-shadcn--tooltip-skip-delay-value": @skip_delay_duration
|
|
83
|
-
}
|
|
84
|
-
attrs.merge!(html_options)
|
|
85
|
-
attrs.merge!(build_data)
|
|
86
|
-
attrs.compact
|
|
60
|
+
def tooltip_content_classes
|
|
61
|
+
CONTENT_CLASSES
|
|
87
62
|
end
|
|
88
63
|
end
|
|
89
64
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Adds shadcn components to your Rails application for customization.
|
|
3
|
+
|
|
4
|
+
This copies the component source code into your app so you can modify it.
|
|
5
|
+
Local components take precedence over the gem's built-in components.
|
|
6
|
+
|
|
7
|
+
Examples:
|
|
8
|
+
rails generate shadcn:add button
|
|
9
|
+
rails generate shadcn:add button card dialog
|
|
10
|
+
rails generate shadcn:add dialog --exclude-controllers
|
|
11
|
+
rails generate shadcn:add --all
|
|
12
|
+
rails generate shadcn:add --list
|
|
13
|
+
|
|
14
|
+
This will create:
|
|
15
|
+
app/components/shadcn/button_component.rb
|
|
16
|
+
app/javascript/controllers/shadcn/dialog_controller.js (if applicable)
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--list List all available components
|
|
20
|
+
--all Add all available components
|
|
21
|
+
--include-controllers Include Stimulus controllers (default: true)
|
|
22
|
+
--exclude-controllers Exclude Stimulus controllers
|
|
23
|
+
--force Overwrite existing files
|
|
24
|
+
--path=PATH Path for components (default: app/components)
|