shadcn-ui 0.0.1 → 0.0.3
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/.env +1 -0
- data/.prettierrc.json +6 -0
- data/README.md +260 -0
- data/Rakefile +6 -3
- data/app/assets/stylesheets/{application.scss → application.css} +0 -27
- data/app/assets/stylesheets/application.tailwind.css +46 -73
- data/app/assets/stylesheets/shadcn.css +216 -0
- data/app/controllers/components_controller.rb +1 -1
- data/app/controllers/documentation_controller.rb +10 -0
- data/app/helpers/application_helper.rb +19 -0
- data/app/helpers/components/accordion_helper.rb +14 -1
- data/app/helpers/components/alert_helper.rb +4 -2
- data/app/helpers/components/button_helper.rb +2 -1
- data/app/helpers/components/card_helper.rb +2 -2
- data/app/helpers/components/checkbox_helper.rb +2 -2
- data/app/helpers/components/collapsible_helper.rb +8 -0
- data/app/helpers/components/filter_helper.rb +12 -0
- data/app/helpers/components/input_helper.rb +21 -0
- data/app/helpers/components/label_helper.rb +5 -0
- data/app/helpers/components/list_helper.rb +15 -0
- data/app/helpers/components/progress_helper.rb +5 -0
- data/app/helpers/components/sheet_helper.rb +29 -0
- data/app/helpers/components/skeleton_helper.rb +5 -0
- data/app/helpers/components/slider_helper.rb +5 -0
- data/app/helpers/components_helper.rb +11 -0
- data/app/helpers/documentation_helper.rb +2 -0
- data/app/helpers/examples_helper.rb +1 -2
- data/app/javascript/controllers/theme_controller.js +25 -0
- data/app/javascript/controllers/ui/dialog_controller.js +3 -1
- data/app/javascript/controllers/ui/dropdown_controller.js +2 -22
- data/app/javascript/controllers/ui/filter_controller.js +20 -0
- data/app/javascript/controllers/ui/popover_controller.js +29 -1
- data/app/javascript/controllers/ui/sheet_controller.js +33 -0
- data/app/javascript/controllers/ui/slider_controller.js +14 -0
- data/app/javascript/controllers/ui/tooltip_controller.js +1 -1
- data/app/views/application/index.html.erb +122 -0
- data/app/views/components/ui/_accordion.html.erb +2 -2
- data/app/views/components/ui/_alert.html.erb +15 -3
- data/app/views/components/ui/_alert_dialog.html.erb +1 -1
- data/app/views/components/ui/_card.html.erb +2 -2
- data/app/views/components/ui/_checkbox.html.erb +3 -7
- data/app/views/components/ui/_collapsible.html.erb +2 -6
- data/app/views/components/ui/_command.html.erb +0 -0
- data/app/views/components/ui/_dialog.html.erb +1 -1
- data/app/views/components/ui/_filter.html.erb +14 -0
- data/app/views/components/ui/_input.html.erb +8 -0
- data/app/views/components/ui/_label.html.erb +3 -0
- data/app/views/components/ui/_list.html.erb +5 -0
- data/app/views/components/ui/_progress.html.erb +15 -0
- data/app/views/components/ui/_sheet.html.erb +44 -0
- data/app/views/components/ui/_skeleton.html.erb +1 -0
- data/app/views/components/ui/_slider.html.erb +2 -0
- data/app/views/components/ui/_textarea.html.erb +1 -1
- data/app/views/components/ui/shared/{_dialog_background.html.erb → _backdrop.html.erb} +1 -0
- data/app/views/components/ui/svg/_check.html.erb +11 -0
- data/app/views/documentation/about.html.md +20 -0
- data/app/views/documentation/generators.html.md +1 -0
- data/app/views/documentation/index.html.erb.bak +70 -0
- data/app/views/documentation/index.html.md +37 -0
- data/app/views/documentation/installation.html.md +377 -0
- data/app/views/examples/components/accordion/_usage.html.erb +15 -0
- data/app/views/examples/components/accordion/code/_block.html.erb +8 -0
- data/app/views/examples/components/accordion/code/_description.html.erb +7 -0
- data/app/views/examples/components/accordion/code/preview.erb +3 -0
- data/app/views/examples/components/accordion/code/usage.erb +16 -0
- data/app/views/examples/components/accordion.html.erb +36 -0
- data/app/views/examples/components/alert/_usage.html.erb +10 -0
- data/app/views/examples/components/alert/code/_attention.erb +3 -0
- data/app/views/examples/components/alert/code/_destructive.erb +2 -0
- data/app/views/examples/components/alert/code/_info.erb +3 -0
- data/app/views/examples/components/alert/code/_no_icon.erb +3 -0
- data/app/views/examples/components/alert/code/_success.erb +3 -0
- data/app/views/examples/components/alert/code/preview.erb +2 -0
- data/app/views/examples/components/alert/code/usage.erb +1 -0
- data/app/views/examples/components/alert.html.erb +90 -7
- data/app/views/examples/components/badge/_usage.html.erb +10 -0
- data/app/views/examples/components/badge/code/preview.erb +5 -0
- data/app/views/examples/components/badge/code/usage.erb +1 -0
- data/app/views/examples/components/badge.html.erb +11 -4
- data/app/views/examples/components/button/_usage.html.erb +19 -0
- data/app/views/examples/components/button/code/preview.erb +13 -0
- data/app/views/examples/components/button/code/usage.erb +6 -0
- data/app/views/examples/components/button.html.erb +20 -6
- data/app/views/examples/components/card/_usage.html.erb +21 -0
- data/app/views/examples/components/card/code/_form.erb +72 -0
- data/app/views/examples/components/card/code/_notifications.erb +61 -0
- data/app/views/examples/components/card/code/preview.erb +6 -0
- data/app/views/examples/components/card/code/usage.erb +3 -0
- data/app/views/examples/components/card.html.erb +35 -143
- data/app/views/examples/components/checkbox/_usage.html.erb +9 -0
- data/app/views/examples/components/checkbox/code/preview.erb +2 -0
- data/app/views/examples/components/checkbox/code/usage.erb +1 -0
- data/app/views/examples/components/checkbox.html.erb +14 -0
- data/app/views/examples/components/collapsible/_usage.html.erb +16 -0
- data/app/views/examples/components/collapsible/code/preview.erb +9 -0
- data/app/views/examples/components/collapsible/code/usage.erb +7 -0
- data/app/views/examples/components/collapsible.html.erb +13 -3
- data/app/views/examples/components/dialog.html.erb +1 -1
- data/app/views/examples/components/filter.html.erb +25 -0
- data/app/views/examples/components/input.html.erb +18 -0
- data/app/views/examples/components/label.html.erb +13 -0
- data/app/views/examples/components/progress.html.erb +12 -0
- data/app/views/examples/components/sheet.html.erb +19 -0
- data/app/views/examples/components/skeleton.html.erb +12 -0
- data/app/views/examples/components/slider.html.erb +12 -0
- data/app/views/layouts/application.html.erb +2 -3
- data/app/views/layouts/component.html.erb +2 -2
- data/app/views/layouts/documentation.html.erb +39 -0
- data/app/views/layouts/shared/_components.html.erb +62 -0
- data/app/views/layouts/shared/_header.html.erb +25 -33
- data/app/views/layouts/shared/_sidebar.html.erb +10 -0
- data/config/application.rb +2 -1
- data/config/importmap.rb +6 -6
- data/config/initializers/markdown.rb +24 -0
- data/config/routes.rb +7 -1
- data/config/shadcn.tailwind.js +98 -0
- data/config/tailwind.config.js +13 -74
- data/lib/components.json +305 -0
- data/lib/generators/shadcn-ui_generator.rb +201 -0
- data/lib/shadcn-ui/version.rb +1 -1
- data/package-lock.json +90 -3
- data/package.json +4 -0
- data/public/accordion.png +0 -0
- metadata +81 -7
- data/app/views/layouts/_sidebar.html.erb +0 -270
- data/lib/generators/shadcn_ui_generator.rb +0 -32
- /data/app/assets/stylesheets/{lambda.light.scss → lambda.light.css} +0 -0
data/lib/components.json
ADDED
@@ -0,0 +1,305 @@
|
|
1
|
+
{
|
2
|
+
"accordion": {
|
3
|
+
"name": "accordion",
|
4
|
+
"type": "components:ui",
|
5
|
+
"files": [
|
6
|
+
"app/helpers/components/accordion_helper.rb",
|
7
|
+
"app/views/components/ui/_accordion.html.erb",
|
8
|
+
"app/javascript/controllers/ui/accordion_controller.js"
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"alert": {
|
12
|
+
"name": "alert",
|
13
|
+
"type": "components:ui",
|
14
|
+
"files": [
|
15
|
+
"app/helpers/components/alert_helper.rb",
|
16
|
+
"app/views/components/ui/_alert.html.erb",
|
17
|
+
"app/javascript/controllers/ui/alert_controller.js"
|
18
|
+
]
|
19
|
+
},
|
20
|
+
"alert-dialog": {
|
21
|
+
"name": "alert-dialog",
|
22
|
+
"type": "components:ui",
|
23
|
+
"files": [
|
24
|
+
"app/helpers/components/alert-dialog_helper.rb",
|
25
|
+
"app/views/components/ui/_alert-dialog.html.erb",
|
26
|
+
"app/javascript/controllers/ui/alert-dialog_controller.js"
|
27
|
+
]
|
28
|
+
},
|
29
|
+
"badge": {
|
30
|
+
"name": "badge",
|
31
|
+
"type": "components:ui",
|
32
|
+
"files": [
|
33
|
+
"app/helpers/components/badge_helper.rb",
|
34
|
+
"app/views/components/ui/_badge.html.erb",
|
35
|
+
"app/javascript/controllers/ui/badge_controller.js"
|
36
|
+
]
|
37
|
+
},
|
38
|
+
"button": {
|
39
|
+
"name": "button",
|
40
|
+
"type": "components:ui",
|
41
|
+
"files": [
|
42
|
+
"app/helpers/components/button_helper.rb",
|
43
|
+
"app/views/components/ui/_button.html.erb",
|
44
|
+
"app/javascript/controllers/ui/button_controller.js"
|
45
|
+
]
|
46
|
+
},
|
47
|
+
"card": {
|
48
|
+
"name": "card",
|
49
|
+
"type": "components:ui",
|
50
|
+
"files": [
|
51
|
+
"app/helpers/components/card_helper.rb",
|
52
|
+
"app/views/components/ui/_card.html.erb",
|
53
|
+
"app/javascript/controllers/ui/card_controller.js"
|
54
|
+
]
|
55
|
+
},
|
56
|
+
"checkbox": {
|
57
|
+
"name": "checkbox",
|
58
|
+
"type": "components:ui",
|
59
|
+
"files": [
|
60
|
+
"app/helpers/components/checkbox_helper.rb",
|
61
|
+
"app/views/components/ui/_checkbox.html.erb",
|
62
|
+
"app/javascript/controllers/ui/checkbox_controller.js"
|
63
|
+
]
|
64
|
+
},
|
65
|
+
"collapsible": {
|
66
|
+
"name": "collapsible",
|
67
|
+
"type": "components:ui",
|
68
|
+
"files": [
|
69
|
+
"app/helpers/components/collapsible_helper.rb",
|
70
|
+
"app/views/components/ui/_collapsible.html.erb",
|
71
|
+
"app/javascript/controllers/ui/collapsible_controller.js"
|
72
|
+
]
|
73
|
+
},
|
74
|
+
"command": {
|
75
|
+
"name": "command",
|
76
|
+
"type": "components:ui",
|
77
|
+
"files": [
|
78
|
+
"app/helpers/components/command_helper.rb",
|
79
|
+
"app/views/components/ui/_command.html.erb",
|
80
|
+
"app/javascript/controllers/ui/command_controller.js"
|
81
|
+
]
|
82
|
+
},
|
83
|
+
"context-menu": {
|
84
|
+
"name": "context-menu",
|
85
|
+
"type": "components:ui",
|
86
|
+
"files": [
|
87
|
+
"app/helpers/components/context-menu_helper.rb",
|
88
|
+
"app/views/components/ui/_context-menu.html.erb",
|
89
|
+
"app/javascript/controllers/ui/context-menu_controller.js"
|
90
|
+
]
|
91
|
+
},
|
92
|
+
"dialog": {
|
93
|
+
"name": "dialog",
|
94
|
+
"type": "components:ui",
|
95
|
+
"files": [
|
96
|
+
"app/helpers/components/dialog_helper.rb",
|
97
|
+
"app/views/components/ui/_dialog.html.erb",
|
98
|
+
"app/javascript/controllers/ui/dialog_controller.js"
|
99
|
+
]
|
100
|
+
},
|
101
|
+
"dropdown-menu": {
|
102
|
+
"name": "dropdown-menu",
|
103
|
+
"type": "components:ui",
|
104
|
+
"files": [
|
105
|
+
"app/helpers/components/dropdown_menu_helper.rb",
|
106
|
+
"app/views/components/ui/_dropdown_menu.html.erb",
|
107
|
+
"app/javascript/controllers/ui/dropdown_controller.js"
|
108
|
+
],
|
109
|
+
"dependencies": [
|
110
|
+
{ "component": "popover" },
|
111
|
+
"app/views/components/ui/shared/_menu_item.html.erb"
|
112
|
+
]
|
113
|
+
},
|
114
|
+
"hover-card": {
|
115
|
+
"name": "hover-card",
|
116
|
+
"type": "components:ui",
|
117
|
+
"files": [
|
118
|
+
"app/helpers/components/hover-card_helper.rb",
|
119
|
+
"app/views/components/ui/_hover-card.html.erb",
|
120
|
+
"app/javascript/controllers/ui/hover-card_controller.js"
|
121
|
+
]
|
122
|
+
},
|
123
|
+
"input": {
|
124
|
+
"name": "input",
|
125
|
+
"type": "components:ui",
|
126
|
+
"files": [
|
127
|
+
"app/helpers/components/input_helper.rb",
|
128
|
+
"app/views/components/ui/_input.html.erb",
|
129
|
+
"app/javascript/controllers/ui/input_controller.js"
|
130
|
+
]
|
131
|
+
},
|
132
|
+
"label": {
|
133
|
+
"name": "label",
|
134
|
+
"type": "components:ui",
|
135
|
+
"files": [
|
136
|
+
"app/helpers/components/label_helper.rb",
|
137
|
+
"app/views/components/ui/_label.html.erb",
|
138
|
+
"app/javascript/controllers/ui/label_controller.js"
|
139
|
+
]
|
140
|
+
},
|
141
|
+
"menubar": {
|
142
|
+
"name": "menubar",
|
143
|
+
"type": "components:ui",
|
144
|
+
"files": [
|
145
|
+
"app/helpers/components/menubar_helper.rb",
|
146
|
+
"app/views/components/ui/_menubar.html.erb",
|
147
|
+
"app/javascript/controllers/ui/menubar_controller.js"
|
148
|
+
]
|
149
|
+
},
|
150
|
+
"navigation-menu": {
|
151
|
+
"name": "navigation-menu",
|
152
|
+
"type": "components:ui",
|
153
|
+
"files": [
|
154
|
+
"app/helpers/components/navigation-menu_helper.rb",
|
155
|
+
"app/views/components/ui/_navigation-menu.html.erb",
|
156
|
+
"app/javascript/controllers/ui/navigation-menu_controller.js"
|
157
|
+
]
|
158
|
+
},
|
159
|
+
"popover": {
|
160
|
+
"name": "popover",
|
161
|
+
"type": "components:ui",
|
162
|
+
"files": [
|
163
|
+
"app/helpers/components/popover_helper.rb",
|
164
|
+
"app/views/components/ui/_popover.html.erb",
|
165
|
+
"app/javascript/controllers/ui/popover_controller.js"
|
166
|
+
]
|
167
|
+
},
|
168
|
+
"progress": {
|
169
|
+
"name": "progress",
|
170
|
+
"type": "components:ui",
|
171
|
+
"files": [
|
172
|
+
"app/helpers/components/progress_helper.rb",
|
173
|
+
"app/views/components/ui/_progress.html.erb",
|
174
|
+
"app/javascript/controllers/ui/progress_controller.js"
|
175
|
+
]
|
176
|
+
},
|
177
|
+
"radio-group": {
|
178
|
+
"name": "radio-group",
|
179
|
+
"type": "components:ui",
|
180
|
+
"files": [
|
181
|
+
"app/helpers/components/radio-group_helper.rb",
|
182
|
+
"app/views/components/ui/_radio-group.html.erb",
|
183
|
+
"app/javascript/controllers/ui/radio-group_controller.js"
|
184
|
+
]
|
185
|
+
},
|
186
|
+
"scroll-area": {
|
187
|
+
"name": "scroll-area",
|
188
|
+
"type": "components:ui",
|
189
|
+
"files": [
|
190
|
+
"app/helpers/components/scroll-area_helper.rb",
|
191
|
+
"app/views/components/ui/_scroll-area.html.erb",
|
192
|
+
"app/javascript/controllers/ui/scroll-area_controller.js"
|
193
|
+
]
|
194
|
+
},
|
195
|
+
"select": {
|
196
|
+
"name": "select",
|
197
|
+
"type": "components:ui",
|
198
|
+
"files": [
|
199
|
+
"app/helpers/components/select_helper.rb",
|
200
|
+
"app/views/components/ui/_select.html.erb",
|
201
|
+
"app/javascript/controllers/ui/select_controller.js"
|
202
|
+
]
|
203
|
+
},
|
204
|
+
"separator": {
|
205
|
+
"name": "separator",
|
206
|
+
"type": "components:ui",
|
207
|
+
"files": [
|
208
|
+
"app/helpers/components/separator_helper.rb",
|
209
|
+
"app/views/components/ui/_separator.html.erb",
|
210
|
+
"app/javascript/controllers/ui/separator_controller.js"
|
211
|
+
]
|
212
|
+
},
|
213
|
+
"sheet": {
|
214
|
+
"name": "sheet",
|
215
|
+
"type": "components:ui",
|
216
|
+
"files": [
|
217
|
+
"app/helpers/components/sheet_helper.rb",
|
218
|
+
"app/views/components/ui/_sheet.html.erb",
|
219
|
+
"app/javascript/controllers/ui/sheet_controller.js"
|
220
|
+
]
|
221
|
+
},
|
222
|
+
"skeleton": {
|
223
|
+
"name": "skeleton",
|
224
|
+
"type": "components:ui",
|
225
|
+
"files": [
|
226
|
+
"app/helpers/components/skeleton_helper.rb",
|
227
|
+
"app/views/components/ui/_skeleton.html.erb",
|
228
|
+
"app/javascript/controllers/ui/skeleton_controller.js"
|
229
|
+
]
|
230
|
+
},
|
231
|
+
"slider": {
|
232
|
+
"name": "slider",
|
233
|
+
"type": "components:ui",
|
234
|
+
"files": [
|
235
|
+
"app/helpers/components/slider_helper.rb",
|
236
|
+
"app/views/components/ui/_slider.html.erb",
|
237
|
+
"app/javascript/controllers/ui/slider_controller.js"
|
238
|
+
]
|
239
|
+
},
|
240
|
+
"switch": {
|
241
|
+
"name": "switch",
|
242
|
+
"type": "components:ui",
|
243
|
+
"files": [
|
244
|
+
"app/helpers/components/switch_helper.rb",
|
245
|
+
"app/views/components/ui/_switch.html.erb",
|
246
|
+
"app/javascript/controllers/ui/switch_controller.js"
|
247
|
+
]
|
248
|
+
},
|
249
|
+
"table": {
|
250
|
+
"name": "table",
|
251
|
+
"type": "components:ui",
|
252
|
+
"files": [
|
253
|
+
"app/helpers/components/table_helper.rb",
|
254
|
+
"app/views/components/ui/_table.html.erb",
|
255
|
+
"app/javascript/controllers/ui/table_controller.js"
|
256
|
+
]
|
257
|
+
},
|
258
|
+
"tabs": {
|
259
|
+
"name": "tabs",
|
260
|
+
"type": "components:ui",
|
261
|
+
"files": [
|
262
|
+
"app/helpers/components/tabs_helper.rb",
|
263
|
+
"app/views/components/ui/_tabs.html.erb",
|
264
|
+
"app/javascript/controllers/ui/tabs_controller.js"
|
265
|
+
]
|
266
|
+
},
|
267
|
+
"textarea": {
|
268
|
+
"name": "textarea",
|
269
|
+
"type": "components:ui",
|
270
|
+
"files": [
|
271
|
+
"app/helpers/components/textarea_helper.rb",
|
272
|
+
"app/views/components/ui/_textarea.html.erb",
|
273
|
+
"app/javascript/controllers/ui/textarea_controller.js"
|
274
|
+
]
|
275
|
+
},
|
276
|
+
"toast": {
|
277
|
+
"name": "toast",
|
278
|
+
"type": "components:ui",
|
279
|
+
"files": [
|
280
|
+
"app/helpers/components/toast_helper.rb",
|
281
|
+
"app/views/components/ui/_toast.html.erb",
|
282
|
+
"app/javascript/controllers/ui/toast_controller.js",
|
283
|
+
"app/javascript/controllers/ui/use-toast.js",
|
284
|
+
"app/javascript/controllers/ui/toaster.js"
|
285
|
+
]
|
286
|
+
},
|
287
|
+
"toggle": {
|
288
|
+
"name": "toggle",
|
289
|
+
"type": "components:ui",
|
290
|
+
"files": [
|
291
|
+
"app/helpers/components/toggle_helper.rb",
|
292
|
+
"app/views/components/ui/_toggle.html.erb",
|
293
|
+
"app/javascript/controllers/ui/toggle_controller.js"
|
294
|
+
]
|
295
|
+
},
|
296
|
+
"tooltip": {
|
297
|
+
"name": "tooltip",
|
298
|
+
"type": "components:ui",
|
299
|
+
"files": [
|
300
|
+
"app/helpers/components/tooltip_helper.rb",
|
301
|
+
"app/views/components/ui/_tooltip.html.erb",
|
302
|
+
"app/javascript/controllers/ui/tooltip_controller.js"
|
303
|
+
]
|
304
|
+
}
|
305
|
+
}
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require "json"
|
2
|
+
require "rails/generators/base"
|
3
|
+
|
4
|
+
class ShadcnUiGenerator < Rails::Generators::Base
|
5
|
+
namespace "shadcn-ui"
|
6
|
+
|
7
|
+
attr_reader :component_name, :target_rails_root, :options
|
8
|
+
|
9
|
+
argument :component, required: false, desc: "The name of the component to install"
|
10
|
+
argument :rails_root, required: false, desc: "Path to the Rails root directory"
|
11
|
+
|
12
|
+
def self.banner
|
13
|
+
"rails generate shadcn-ui <component_name> [--remove] [rails_root_path]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(args, *options)
|
17
|
+
super
|
18
|
+
@component_name = component
|
19
|
+
@target_rails_root = rails_root || Rails.root
|
20
|
+
@options = options.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def preprocess_sources
|
24
|
+
check_target_app
|
25
|
+
end
|
26
|
+
|
27
|
+
def install_component
|
28
|
+
if component_valid?
|
29
|
+
copy_files
|
30
|
+
else
|
31
|
+
display_available_components
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def check_target_app
|
38
|
+
puts "Checking for tailwind..."
|
39
|
+
puts "...tailwind found." if check_for_tailwind
|
40
|
+
|
41
|
+
puts "Checking for shadcn.css..."
|
42
|
+
check_for_shadcn_css
|
43
|
+
|
44
|
+
puts "Checking for shadcn import..."
|
45
|
+
check_for_shadcn_css_import
|
46
|
+
|
47
|
+
puts "Checking for shadcn.tailwind.js..."
|
48
|
+
check_for_shadcn_tailwind_js
|
49
|
+
|
50
|
+
puts "Checking for component_helper.rb"
|
51
|
+
check_for_component_helper
|
52
|
+
end
|
53
|
+
|
54
|
+
def available_components
|
55
|
+
if !@available_components
|
56
|
+
gem_lib_path = File.expand_path("../../lib", __dir__)
|
57
|
+
components_file = File.read(File.join(gem_lib_path, "components.json"))
|
58
|
+
@available_components = JSON.parse(components_file)
|
59
|
+
else
|
60
|
+
@available_components
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def display_available_components
|
65
|
+
puts self.class.banner
|
66
|
+
puts "\nAvailable components:"
|
67
|
+
|
68
|
+
available_components.each do |component, _|
|
69
|
+
description = "# A #{component} component"
|
70
|
+
banner_line = "rails g shadcn_ui #{component}:install #{" " * (20 - component.length)} #{description}"
|
71
|
+
puts banner_line
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def copy_files
|
76
|
+
return unless component_valid?
|
77
|
+
puts "Installing #{component_name} component..."
|
78
|
+
|
79
|
+
install_component_files(component_name)
|
80
|
+
component_data["dependencies"]&.each do |dependency|
|
81
|
+
if dependency.is_a?(String)
|
82
|
+
copy_file(dependency)
|
83
|
+
elsif dependency.is_a?(Hash)
|
84
|
+
install_component_files(dependency["component"])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
puts "#{component_name.capitalize} component installed!"
|
88
|
+
end
|
89
|
+
|
90
|
+
def install_component_files(key)
|
91
|
+
return unless component_valid?(key)
|
92
|
+
|
93
|
+
available_components[key]["files"].each do |file|
|
94
|
+
copy_file(file)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def copy_file(file)
|
99
|
+
source_path = File.expand_path(File.join("../../", file), __dir__)
|
100
|
+
destination_path = File.expand_path(File.join(target_rails_root, file))
|
101
|
+
if File.exist?(source_path)
|
102
|
+
FileUtils.mkdir_p(File.dirname(destination_path))
|
103
|
+
puts "...copying #{file}"
|
104
|
+
FileUtils.cp(source_path, destination_path)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def component_data(name = nil)
|
109
|
+
@component_data ||= available_components[component_name]
|
110
|
+
end
|
111
|
+
|
112
|
+
def component_valid?(name = nil)
|
113
|
+
name ||= component_name
|
114
|
+
name.present? && available_components.key?(name) && component_data
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_for_tailwind
|
118
|
+
tailwind_file_path = File.join(target_rails_root, "app/assets/stylesheets/application.tailwind.css")
|
119
|
+
|
120
|
+
if File.exist?(tailwind_file_path)
|
121
|
+
true
|
122
|
+
else
|
123
|
+
abort "shadcn-ui requires Tailwind CSS. Please include tailwindcss-rails in your Gemfile and run `rails g tailwind:install` to install Tailwind CSS."
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def check_for_shadcn_css
|
128
|
+
shadcn_file_path = "app/assets/stylesheets/shadcn.css"
|
129
|
+
if File.exist?(File.expand_path(File.join(target_rails_root, shadcn_file_path)))
|
130
|
+
puts "...found shadcn.css"
|
131
|
+
true
|
132
|
+
else
|
133
|
+
source_path = File.expand_path(File.join("../../", shadcn_file_path), __dir__)
|
134
|
+
destination_path = File.expand_path(File.join(target_rails_root, shadcn_file_path))
|
135
|
+
puts "...copying shadcn.css to app/assets/stylesheets/shadcn.css"
|
136
|
+
FileUtils.cp(source_path, destination_path)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def check_for_shadcn_css_import
|
141
|
+
tailwind_file_path = File.join(target_rails_root, "app/assets/stylesheets/application.tailwind.css")
|
142
|
+
|
143
|
+
if File.file?(tailwind_file_path)
|
144
|
+
matched_file = File.readlines(tailwind_file_path).any? { |s| s.include?("shadcn.css") }
|
145
|
+
if !matched_file
|
146
|
+
puts "Importing shadcn.css into application.tailwind.css..."
|
147
|
+
insert_import_first_line(tailwind_file_path, "@import \"shadcn.css\";")
|
148
|
+
end
|
149
|
+
else
|
150
|
+
puts "application.tailwind.css does not exist."
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def insert_import_line(file_path, line)
|
155
|
+
file_contents = File.read(file_path)
|
156
|
+
new_contents = file_contents.gsub(/@tailwind\s+utilities;/, "\\0\n#{line}\n")
|
157
|
+
File.write(file_path, new_contents)
|
158
|
+
end
|
159
|
+
|
160
|
+
def insert_import_first_line(file_path, line)
|
161
|
+
file_contents = File.read(file_path)
|
162
|
+
new_contents = "#{line}\n#{file_contents}"
|
163
|
+
File.write(file_path, new_contents)
|
164
|
+
end
|
165
|
+
|
166
|
+
def check_for_shadcn_tailwind_js
|
167
|
+
shadcn_tailwind_path = "config/shadcn.tailwind.js"
|
168
|
+
if File.exist?(File.expand_path(File.join(target_rails_root, shadcn_tailwind_path)))
|
169
|
+
puts "...found shadcn.tailwind.js"
|
170
|
+
true
|
171
|
+
else
|
172
|
+
source_path = File.expand_path(File.join("../../", shadcn_tailwind_path), __dir__)
|
173
|
+
destination_path = File.expand_path(File.join(target_rails_root, shadcn_tailwind_path))
|
174
|
+
puts "...copying shadcn.tailwind.js to config/shadcn.tailwind.js"
|
175
|
+
puts "Make sure to include shadcn.tailwind.js in your tailwind.config.js"
|
176
|
+
puts "const shadcnConfig = require('./shadcn.tailwind.js');"
|
177
|
+
puts "module.exports = {
|
178
|
+
...shadcnConfig,
|
179
|
+
};"
|
180
|
+
|
181
|
+
FileUtils.cp(source_path, destination_path)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def check_for_component_helper
|
186
|
+
component_helper_path = "app/helpers/components_helper.rb"
|
187
|
+
if File.exist?(File.expand_path(File.join(target_rails_root, component_helper_path)))
|
188
|
+
puts "...found components_helper.rb"
|
189
|
+
true
|
190
|
+
else
|
191
|
+
source_path = File.expand_path(File.join("../../", component_helper_path), __dir__)
|
192
|
+
destination_path = File.expand_path(File.join(target_rails_root, component_helper_path))
|
193
|
+
puts "...copying components_helper.rb app/helpers"
|
194
|
+
|
195
|
+
FileUtils.cp(source_path, destination_path)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Two things - you need the helper helpers
|
201
|
+
# you have to put @import on the 3rd line after the tailwind directives? Is that possible? It's because of border-border...worse case you can just use the actual styles
|
data/lib/shadcn-ui/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -8,6 +8,10 @@
|
|
8
8
|
"tailwindcss-animate": "^1.0.6"
|
9
9
|
},
|
10
10
|
"devDependencies": {
|
11
|
+
"@tailwindcss/aspect-ratio": "^0.4.2",
|
12
|
+
"@tailwindcss/container-queries": "^0.1.1",
|
13
|
+
"@tailwindcss/forms": "^0.5.3",
|
14
|
+
"@tailwindcss/typography": "^0.5.9",
|
11
15
|
"prettier": "^3.0.0"
|
12
16
|
}
|
13
17
|
},
|
@@ -112,6 +116,64 @@
|
|
112
116
|
"node": ">= 8"
|
113
117
|
}
|
114
118
|
},
|
119
|
+
"node_modules/@tailwindcss/aspect-ratio": {
|
120
|
+
"version": "0.4.2",
|
121
|
+
"resolved": "https://registry.npmjs.org/@tailwindcss/aspect-ratio/-/aspect-ratio-0.4.2.tgz",
|
122
|
+
"integrity": "sha512-8QPrypskfBa7QIMuKHg2TA7BqES6vhBrDLOv8Unb6FcFyd3TjKbc6lcmb9UPQHxfl24sXoJ41ux/H7qQQvfaSQ==",
|
123
|
+
"dev": true,
|
124
|
+
"peerDependencies": {
|
125
|
+
"tailwindcss": ">=2.0.0 || >=3.0.0 || >=3.0.0-alpha.1"
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"node_modules/@tailwindcss/container-queries": {
|
129
|
+
"version": "0.1.1",
|
130
|
+
"resolved": "https://registry.npmjs.org/@tailwindcss/container-queries/-/container-queries-0.1.1.tgz",
|
131
|
+
"integrity": "sha512-p18dswChx6WnTSaJCSGx6lTmrGzNNvm2FtXmiO6AuA1V4U5REyoqwmT6kgAsIMdjo07QdAfYXHJ4hnMtfHzWgA==",
|
132
|
+
"dev": true,
|
133
|
+
"peerDependencies": {
|
134
|
+
"tailwindcss": ">=3.2.0"
|
135
|
+
}
|
136
|
+
},
|
137
|
+
"node_modules/@tailwindcss/forms": {
|
138
|
+
"version": "0.5.3",
|
139
|
+
"resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.3.tgz",
|
140
|
+
"integrity": "sha512-y5mb86JUoiUgBjY/o6FJSFZSEttfb3Q5gllE4xoKjAAD+vBrnIhE4dViwUuow3va8mpH4s9jyUbUbrRGoRdc2Q==",
|
141
|
+
"dev": true,
|
142
|
+
"dependencies": {
|
143
|
+
"mini-svg-data-uri": "^1.2.3"
|
144
|
+
},
|
145
|
+
"peerDependencies": {
|
146
|
+
"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1"
|
147
|
+
}
|
148
|
+
},
|
149
|
+
"node_modules/@tailwindcss/typography": {
|
150
|
+
"version": "0.5.9",
|
151
|
+
"resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.9.tgz",
|
152
|
+
"integrity": "sha512-t8Sg3DyynFysV9f4JDOVISGsjazNb48AeIYQwcL+Bsq5uf4RYL75C1giZ43KISjeDGBaTN3Kxh7Xj/vRSMJUUg==",
|
153
|
+
"dev": true,
|
154
|
+
"dependencies": {
|
155
|
+
"lodash.castarray": "^4.4.0",
|
156
|
+
"lodash.isplainobject": "^4.0.6",
|
157
|
+
"lodash.merge": "^4.6.2",
|
158
|
+
"postcss-selector-parser": "6.0.10"
|
159
|
+
},
|
160
|
+
"peerDependencies": {
|
161
|
+
"tailwindcss": ">=3.0.0 || insiders"
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser": {
|
165
|
+
"version": "6.0.10",
|
166
|
+
"resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz",
|
167
|
+
"integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==",
|
168
|
+
"dev": true,
|
169
|
+
"dependencies": {
|
170
|
+
"cssesc": "^3.0.0",
|
171
|
+
"util-deprecate": "^1.0.2"
|
172
|
+
},
|
173
|
+
"engines": {
|
174
|
+
"node": ">=4"
|
175
|
+
}
|
176
|
+
},
|
115
177
|
"node_modules/any-promise": {
|
116
178
|
"version": "1.3.0",
|
117
179
|
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
|
@@ -241,7 +303,6 @@
|
|
241
303
|
"version": "3.0.0",
|
242
304
|
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
|
243
305
|
"integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==",
|
244
|
-
"peer": true,
|
245
306
|
"bin": {
|
246
307
|
"cssesc": "bin/cssesc"
|
247
308
|
},
|
@@ -474,6 +535,24 @@
|
|
474
535
|
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
|
475
536
|
"peer": true
|
476
537
|
},
|
538
|
+
"node_modules/lodash.castarray": {
|
539
|
+
"version": "4.4.0",
|
540
|
+
"resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
|
541
|
+
"integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==",
|
542
|
+
"dev": true
|
543
|
+
},
|
544
|
+
"node_modules/lodash.isplainobject": {
|
545
|
+
"version": "4.0.6",
|
546
|
+
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
|
547
|
+
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==",
|
548
|
+
"dev": true
|
549
|
+
},
|
550
|
+
"node_modules/lodash.merge": {
|
551
|
+
"version": "4.6.2",
|
552
|
+
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
|
553
|
+
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
|
554
|
+
"dev": true
|
555
|
+
},
|
477
556
|
"node_modules/merge2": {
|
478
557
|
"version": "1.4.1",
|
479
558
|
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
@@ -496,6 +575,15 @@
|
|
496
575
|
"node": ">=8.6"
|
497
576
|
}
|
498
577
|
},
|
578
|
+
"node_modules/mini-svg-data-uri": {
|
579
|
+
"version": "1.4.4",
|
580
|
+
"resolved": "https://registry.npmjs.org/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz",
|
581
|
+
"integrity": "sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==",
|
582
|
+
"dev": true,
|
583
|
+
"bin": {
|
584
|
+
"mini-svg-data-uri": "cli.js"
|
585
|
+
}
|
586
|
+
},
|
499
587
|
"node_modules/minimatch": {
|
500
588
|
"version": "3.1.2",
|
501
589
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
@@ -992,8 +1080,7 @@
|
|
992
1080
|
"node_modules/util-deprecate": {
|
993
1081
|
"version": "1.0.2",
|
994
1082
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
995
|
-
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
996
|
-
"peer": true
|
1083
|
+
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
997
1084
|
},
|
998
1085
|
"node_modules/wrappy": {
|
999
1086
|
"version": "1.0.2",
|
data/package.json
CHANGED
Binary file
|