shadcn-ui 0.0.2 → 0.0.4
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/Rakefile +6 -3
- data/app/assets/stylesheets/{application.scss → application.css} +0 -27
- data/app/assets/stylesheets/application.tailwind.css +32 -160
- data/app/assets/stylesheets/shadcn.css +216 -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 +1 -1
- data/app/helpers/components/checkbox_helper.rb +2 -2
- data/app/helpers/components/collapsible_helper.rb +8 -0
- data/app/helpers/components/input_helper.rb +1 -1
- data/app/helpers/components/sheet_helper.rb +9 -0
- data/app/helpers/components/slider_helper.rb +1 -1
- data/app/helpers/components_helper.rb +11 -0
- data/app/helpers/examples_helper.rb +7 -3
- data/app/javascript/controllers/highlight_controller.js +0 -1
- data/app/javascript/controllers/ui/popover_controller.js +6 -2
- data/app/views/application/index.html.erb +625 -17
- 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/_card.html.erb +7 -1
- data/app/views/components/ui/_checkbox.html.erb +2 -1
- data/app/views/components/ui/_collapsible.html.erb +2 -6
- data/app/views/components/ui/_filter.html.erb +2 -1
- data/app/views/components/ui/_sheet.html.erb +1 -1
- data/app/views/documentation/generators.html.md +21 -0
- data/app/views/documentation/helpers.html.md +54 -0
- data/app/views/documentation/index.html.md +22 -0
- data/app/views/documentation/installation.html.md +130 -2
- data/app/views/documentation/javascript.html.md +8 -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 +37 -3
- 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/_preview.erb +2 -0
- data/app/views/examples/components/alert/code/_success.erb +3 -0
- data/app/views/examples/components/alert/code/_usage.erb +1 -0
- data/app/views/examples/components/alert-dialog/code/_preview.erb +6 -0
- data/app/views/examples/components/alert-dialog/code/_usage.erb +0 -0
- data/app/views/examples/components/alert-dialog.html.erb +8 -11
- data/app/views/examples/components/alert.html.erb +90 -8
- 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 +12 -17
- 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 +12 -20
- 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 +31 -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 +15 -1
- 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 +12 -10
- data/app/views/examples/components/dialog.html.erb +6 -15
- data/app/views/examples/components/dropdown-menu/_usage.html.erb +19 -0
- data/app/views/examples/components/dropdown-menu/code/_preview.erb +19 -0
- data/app/views/examples/components/dropdown-menu/code/_usage.erb +13 -0
- data/app/views/examples/components/dropdown-menu.html.erb +29 -15
- data/app/views/examples/components/filter/_usage.html.erb +14 -0
- data/app/views/examples/components/filter/code/_icon.html.erb +7 -0
- data/app/views/examples/components/filter/code/_preview.erb +3 -0
- data/app/views/examples/components/filter/code/_usage.erb +5 -0
- data/app/views/examples/components/filter.html.erb +27 -7
- data/app/views/examples/components/hover-card/_usage.html.erb +15 -0
- data/app/views/examples/components/hover-card/code/_preview.erb +13 -0
- data/app/views/examples/components/hover-card/code/_usage.erb +6 -0
- data/app/views/examples/components/hover-card.html.erb +12 -14
- data/app/views/examples/components/input/_usage.html.erb +10 -0
- data/app/views/examples/components/input/code/_borderless.erb +3 -0
- data/app/views/examples/components/input/code/_preview.erb +1 -0
- data/app/views/examples/components/input/code/_usage.erb +1 -0
- data/app/views/examples/components/input.html.erb +17 -3
- data/app/views/examples/components/label/_usage.html.erb +9 -0
- data/app/views/examples/components/label/code/_preview.erb +5 -0
- data/app/views/examples/components/label/code/_usage.erb +1 -0
- data/app/views/examples/components/label.html.erb +14 -5
- data/app/views/examples/components/popover/_usage.html.erb +12 -0
- data/app/views/examples/components/popover/code/_form.erb +23 -0
- data/app/views/examples/components/popover/code/_preview.erb +13 -0
- data/app/views/examples/components/popover/code/_usage.erb +7 -0
- data/app/views/examples/components/popover.html.erb +28 -24
- data/app/views/examples/components/progress/_usage.erb +9 -0
- data/app/views/examples/components/progress/code/_preview.erb +1 -0
- data/app/views/examples/components/progress/code/_usage.erb +1 -0
- data/app/views/examples/components/progress.html.erb +12 -2
- data/app/views/examples/components/separator/_usage.html.erb +10 -0
- data/app/views/examples/components/separator/code/_fancy.erb +21 -0
- data/app/views/examples/components/separator/code/_preview.erb +1 -0
- data/app/views/examples/components/separator/code/_usage.erb +1 -0
- data/app/views/examples/components/separator.html.erb +26 -19
- data/app/views/examples/components/sheet/_usage.html.erb +38 -0
- data/app/views/examples/components/sheet/code/_mobile_menu.erb +17 -0
- data/app/views/examples/components/sheet/code/_preview.erb +22 -0
- data/app/views/examples/components/sheet/code/_usage.erb +7 -0
- data/app/views/examples/components/sheet.html.erb +17 -10
- data/app/views/examples/components/skeleton/_usage.html.erb +9 -0
- data/app/views/examples/components/skeleton/code/_preview.erb +1 -0
- data/app/views/examples/components/skeleton/code/_usage.erb +1 -0
- data/app/views/examples/components/skeleton.html.erb +16 -2
- data/app/views/examples/components/slider/_usage.html.erb +11 -0
- data/app/views/examples/components/slider/code/_preview.erb +3 -0
- data/app/views/examples/components/slider/code/_usage.erb +1 -0
- data/app/views/examples/components/slider.html.erb +16 -2
- data/app/views/examples/components/textarea/_usage.html.erb +9 -0
- data/app/views/examples/components/textarea/code/_preview.erb +1 -0
- data/app/views/examples/components/textarea/code/_usage.erb +1 -0
- data/app/views/examples/components/textarea.html.erb +16 -2
- data/app/views/examples/components/toast/_usage.html.erb +11 -0
- data/app/views/examples/components/toast/code/_preview.erb +3 -0
- data/app/views/examples/components/toast/code/_usage.erb +2 -0
- data/app/views/examples/components/toast.html.erb +12 -4
- data/app/views/examples/components/toggle/_usage.html.erb +10 -0
- data/app/views/examples/components/toggle/code/_preview.erb +1 -0
- data/app/views/examples/components/toggle/code/_usage.erb +1 -0
- data/app/views/examples/components/toggle.html.erb +16 -2
- data/app/views/examples/components/tooltip/_usage.html.erb +11 -0
- data/app/views/examples/components/tooltip/code/_preview.erb +12 -0
- data/app/views/examples/components/tooltip/code/_usage.erb +7 -0
- data/app/views/examples/components/tooltip.html.erb +16 -13
- data/app/views/layouts/shared/_components.html.erb +44 -41
- data/config/environments/production.rb +4 -4
- data/config/shadcn.tailwind.js +98 -0
- data/config/tailwind.config.js +13 -74
- data/lib/components.json +7 -3
- 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
- metadata +97 -9
- data/lib/generators/shadcn_ui_generator.rb +0 -81
- /data/app/assets/stylesheets/{lambda.light.scss → lambda.light.css} +0 -0
- /data/app/views/examples/components/dialog/code/{form.erb → _form.erb} +0 -0
- /data/app/views/examples/components/dialog/code/{notifications.erb → _notifications.erb} +0 -0
- /data/app/views/examples/components/dialog/code/{preview.erb → _preview.erb} +0 -0
- /data/app/views/examples/components/dialog/code/{usage.erb → _usage.erb} +0 -0
@@ -2,22 +2,25 @@
|
|
2
2
|
description: "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it." %>
|
3
3
|
|
4
4
|
<% content_for :preview, flush: true do %>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<% end %>
|
9
|
-
<%= tooltip_content do %>
|
10
|
-
<div class="grid gap-2">
|
11
|
-
<div class="space-y-2">
|
12
|
-
<p class="text-sm text-muted-foreground">More will be revealed.</p>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
5
|
+
<div class="w-full flex justify-center">
|
6
|
+
<%= render_code_preview('tooltip') %>
|
7
|
+
</div>
|
17
8
|
<% end %>
|
18
9
|
|
19
10
|
<% content_for :code, flush: true do %>
|
20
|
-
|
11
|
+
<div class="w-full flex justify-center">
|
12
|
+
<%= code_partial("tooltip/preview", :erb) %>
|
13
|
+
</div>
|
21
14
|
<% end %>
|
22
15
|
|
23
16
|
<%= render_preview %>
|
17
|
+
|
18
|
+
<h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
|
19
|
+
<%= code_sample(language: "sh") do %>
|
20
|
+
rails generate shadcn-ui tooltip
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<h2 class="font-heading mt-12 scroll-m-20 border-b pb-2 mb-2 text-2xl font-semibold tracking-tight first:mt-0" id="usage">Usage</h2>
|
24
|
+
<%= code_partial("tooltip/usage", :erb) %>
|
25
|
+
|
26
|
+
<%= render_usage("tooltip") %>
|
@@ -7,53 +7,56 @@
|
|
7
7
|
<div class="grid grid-flow-row auto-rows-max text-sm">
|
8
8
|
<%= sidebar_link "Introduction", documentation_index_path %>
|
9
9
|
<%= sidebar_link "Installation", documentation_path("installation") %>
|
10
|
+
<%= sidebar_link "Generators", documentation_path("generators") %>
|
11
|
+
<%= sidebar_link "Helpers", documentation_path("helpers") %>
|
12
|
+
<%= sidebar_link "Stimulus", documentation_path("Javascript") %>
|
10
13
|
<%= sidebar_link "About", documentation_path("about") %>
|
11
14
|
</div>
|
12
15
|
</div>
|
13
16
|
<div class="pb-4">
|
14
17
|
<h4 class="mb-1 rounded-md px-2 py-1 text-sm font-semibold">Components</h4>
|
15
18
|
<div class="grid grid-flow-row auto-rows-max text-sm">
|
16
|
-
<%= sidebar_link "✅ Accordion", "/docs/components/accordion" %>
|
17
|
-
<%= sidebar_link "✅ Alert", "/docs/components/alert" %>
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
<%= sidebar_link "✅ Badge", "/docs/components/badge" %>
|
22
|
-
<%= sidebar_link "✅ Button", "/docs/components/button" %>
|
23
|
-
|
24
|
-
<%= sidebar_link "✅ Card", "/docs/components/card" %>
|
25
|
-
<%= sidebar_link "✅ Checkbox", "/docs/components/checkbox" %>
|
26
|
-
<%= sidebar_link "✅ Collapsible", "/docs/components/collapsible" %>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<%= sidebar_link "✅ Dialog", "/docs/components/dialog" %>
|
33
|
-
<%= sidebar_link "Dropdown Menu", "/docs/components/dropdown-menu" %>
|
34
|
-
<%= sidebar_link "➕ Filter", "/docs/components/filter" %>
|
35
|
-
|
36
|
-
<%= sidebar_link "✅ Hover Card", "/docs/components/hover-card" %>
|
37
|
-
<%= sidebar_link "✅ Input", "/docs/components/input" %>
|
38
|
-
<%= sidebar_link "✅ Label", "/docs/components/label" %>
|
39
|
-
|
40
|
-
|
41
|
-
<%= sidebar_link "✅ Popover", "/docs/components/popover" %>
|
42
|
-
<%= sidebar_link "✅ Progress", "/docs/components/progress" %>
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
<%= sidebar_link "✅ Separator", "/docs/components/separator" %>
|
47
|
-
<%= sidebar_link "✅ Sheet", "/docs/components/sheet" %>
|
48
|
-
<%= sidebar_link "✅ Skeleton", "/docs/components/skeleton" %>
|
49
|
-
<%= sidebar_link "✅ Slider", "/docs/components/slider" %>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
<%= sidebar_link "✅ Textarea", "/docs/components/textarea" %>
|
54
|
-
<%= sidebar_link "✅ Toast", "/docs/components/toast" %>
|
55
|
-
<%= sidebar_link "✅ Toggle", "/docs/components/toggle" %>
|
56
|
-
<%= sidebar_link "✅ Tooltip", "/docs/components/tooltip" %>
|
19
|
+
<%= sidebar_link "✅ 📖 Accordion", "/docs/components/accordion" %>
|
20
|
+
<%= sidebar_link "✅ 📖 Alert", "/docs/components/alert" %>
|
21
|
+
<%#= sidebar_link "✅ Alert Dialog", "/docs/components/alert-dialog" %>
|
22
|
+
<%#= sidebar_link "❌ Aspect Ratio", "/docs/components/aspect-ratio" %>
|
23
|
+
<%#= sidebar_link "❌ Avatar", "/docs/components/avatar" %>
|
24
|
+
<%= sidebar_link "✅ 📖 Badge", "/docs/components/badge" %>
|
25
|
+
<%= sidebar_link "✅ 📖 Button", "/docs/components/button" %>
|
26
|
+
<%#= sidebar_link "❌ Calendar", "/docs/components/calendar" %>
|
27
|
+
<%= sidebar_link "✅ 📖 Card", "/docs/components/card" %>
|
28
|
+
<%= sidebar_link "✅ 📖 Checkbox", "/docs/components/checkbox" %>
|
29
|
+
<%= sidebar_link "✅ 📖 Collapsible", "/docs/components/collapsible" %>
|
30
|
+
<%#= sidebar_link "Combobox", "/docs/components/combobox" %>
|
31
|
+
<%#= sidebar_link "Command", "/docs/components/command" %>
|
32
|
+
<%#= sidebar_link "Context Menu", "/docs/components/context-menu" %>
|
33
|
+
<%#= sidebar_link "Data Table", "/docs/components/data-table" %>
|
34
|
+
<%#= sidebar_link "Date Picker", "/docs/components/date-picker" %>
|
35
|
+
<%= sidebar_link "✅ 📖 Dialog", "/docs/components/dialog" %>
|
36
|
+
<%= sidebar_link "✅ 📖 Dropdown Menu", "/docs/components/dropdown-menu" %>
|
37
|
+
<%= sidebar_link "➕ 📖 Filter", "/docs/components/filter" %>
|
38
|
+
<%#= sidebar_link "Form", "/docs/components/form" %>
|
39
|
+
<%= sidebar_link "✅ 📖 Hover Card", "/docs/components/hover-card" %>
|
40
|
+
<%= sidebar_link "✅ 📖 Input", "/docs/components/input" %>
|
41
|
+
<%= sidebar_link "✅ 📖 Label", "/docs/components/label" %>
|
42
|
+
<%#= sidebar_link "Menubar", "/docs/components/menubar" %>
|
43
|
+
<%#= sidebar_link "Navigation Menu", "/docs/components/navigation-menu" %>
|
44
|
+
<%= sidebar_link "✅ 📖 Popover", "/docs/components/popover" %>
|
45
|
+
<%= sidebar_link "✅ 📖 Progress", "/docs/components/progress" %>
|
46
|
+
<%#= sidebar_link "Radio Group", "/docs/components/radio-group" %>
|
47
|
+
<%#= sidebar_link "Scroll Area", "/docs/components/scroll-area" %>
|
48
|
+
<%#= sidebar_link "Select", "/docs/components/select" %>
|
49
|
+
<%= sidebar_link "✅ 📖 Separator", "/docs/components/separator" %>
|
50
|
+
<%= sidebar_link "✅ 📖 Sheet", "/docs/components/sheet" %>
|
51
|
+
<%= sidebar_link "✅ 📖 Skeleton", "/docs/components/skeleton" %>
|
52
|
+
<%= sidebar_link "✅ 📖 Slider", "/docs/components/slider" %>
|
53
|
+
<%#= sidebar_link "Switch", "/docs/components/switch" %>
|
54
|
+
<%#= sidebar_link "Table", "/docs/components/table" %>
|
55
|
+
<%#= sidebar_link "Tabs", "/docs/components/tabs" %>
|
56
|
+
<%= sidebar_link "✅ 📖 Textarea", "/docs/components/textarea" %>
|
57
|
+
<%= sidebar_link "✅ 📖 Toast", "/docs/components/toast" %>
|
58
|
+
<%= sidebar_link "✅ 📖 Toggle", "/docs/components/toggle" %>
|
59
|
+
<%= sidebar_link "✅ 📖 Tooltip", "/docs/components/tooltip" %>
|
57
60
|
</div>
|
58
61
|
</div>
|
59
62
|
</div>
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = true
|
14
14
|
|
15
15
|
# Full error reports are disabled and caching is turned on.
|
16
|
-
config.consider_all_requests_local
|
16
|
+
config.consider_all_requests_local = false
|
17
17
|
config.action_controller.perform_caching = true
|
18
18
|
|
19
19
|
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
@@ -53,7 +53,7 @@ Rails.application.configure do
|
|
53
53
|
config.log_level = :info
|
54
54
|
|
55
55
|
# Prepend all log lines with the following tags.
|
56
|
-
config.log_tags = [
|
56
|
+
config.log_tags = [:request_id]
|
57
57
|
|
58
58
|
# Use a different cache store in production.
|
59
59
|
# config.cache_store = :mem_cache_store
|
@@ -83,9 +83,9 @@ Rails.application.configure do
|
|
83
83
|
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
|
84
84
|
|
85
85
|
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
86
|
-
logger
|
86
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
87
87
|
logger.formatter = config.log_formatter
|
88
|
-
config.logger
|
88
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
89
89
|
end
|
90
90
|
|
91
91
|
# Do not dump schema after migrations.
|
@@ -0,0 +1,98 @@
|
|
1
|
+
const defaultTheme = require("tailwindcss/defaultTheme");
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
darkMode: ["class"],
|
5
|
+
content: [
|
6
|
+
"./public/*.html",
|
7
|
+
"./app/helpers/**/*.rb",
|
8
|
+
"./app/javascript/**/*.js",
|
9
|
+
"./app/views/**/*.{erb,haml,html,slim}",
|
10
|
+
],
|
11
|
+
theme: {
|
12
|
+
container: {
|
13
|
+
center: true,
|
14
|
+
padding: "2rem",
|
15
|
+
screens: {
|
16
|
+
"2xl": "1400px",
|
17
|
+
},
|
18
|
+
},
|
19
|
+
extend: {
|
20
|
+
colors: {
|
21
|
+
border: "hsl(var(--border))",
|
22
|
+
input: "hsl(var(--input))",
|
23
|
+
ring: "hsl(var(--ring))",
|
24
|
+
background: "hsl(var(--background))",
|
25
|
+
foreground: "hsl(var(--foreground))",
|
26
|
+
primary: {
|
27
|
+
DEFAULT: "hsl(var(--primary))",
|
28
|
+
foreground: "hsl(var(--primary-foreground))",
|
29
|
+
},
|
30
|
+
secondary: {
|
31
|
+
DEFAULT: "hsl(var(--secondary))",
|
32
|
+
foreground: "hsl(var(--secondary-foreground))",
|
33
|
+
},
|
34
|
+
destructive: {
|
35
|
+
DEFAULT: "hsl(var(--destructive))",
|
36
|
+
foreground: "hsl(var(--destructive-foreground))",
|
37
|
+
},
|
38
|
+
success: {
|
39
|
+
DEFAULT: "hsl(var(--success))",
|
40
|
+
foreground: "hsl(var(--success-foreground))",
|
41
|
+
},
|
42
|
+
info: {
|
43
|
+
DEFAULT: "hsl(var(--info))",
|
44
|
+
foreground: "hsl(var(--info-foreground))",
|
45
|
+
},
|
46
|
+
attention: {
|
47
|
+
DEFAULT: "var(--yellow-50)",
|
48
|
+
foreground: "hsl(var(--attention-foreground))",
|
49
|
+
},
|
50
|
+
muted: {
|
51
|
+
DEFAULT: "hsl(var(--muted))",
|
52
|
+
foreground: "hsl(var(--muted-foreground))",
|
53
|
+
},
|
54
|
+
accent: {
|
55
|
+
DEFAULT: "hsl(var(--accent))",
|
56
|
+
foreground: "hsl(var(--accent-foreground))",
|
57
|
+
},
|
58
|
+
popover: {
|
59
|
+
DEFAULT: "hsl(var(--popover))",
|
60
|
+
foreground: "hsl(var(--popover-foreground))",
|
61
|
+
},
|
62
|
+
card: {
|
63
|
+
DEFAULT: "hsl(var(--card))",
|
64
|
+
foreground: "hsl(var(--card-foreground))",
|
65
|
+
},
|
66
|
+
},
|
67
|
+
borderRadius: {
|
68
|
+
lg: "var(--radius)",
|
69
|
+
md: "calc(var(--radius) - 2px)",
|
70
|
+
sm: "calc(var(--radius) - 4px)",
|
71
|
+
},
|
72
|
+
fontFamily: {
|
73
|
+
sans: ["var(--font-sans)", ...defaultTheme.fontFamily.sans],
|
74
|
+
},
|
75
|
+
keyframes: {
|
76
|
+
"accordion-down": {
|
77
|
+
from: { height: 0 },
|
78
|
+
to: { height: "var(--radix-accordion-content-height)" },
|
79
|
+
},
|
80
|
+
"accordion-up": {
|
81
|
+
from: { height: "var(--radix-accordion-content-height)" },
|
82
|
+
to: { height: 0 },
|
83
|
+
},
|
84
|
+
},
|
85
|
+
animation: {
|
86
|
+
"accordion-down": "accordion-down 0.2s ease-out",
|
87
|
+
"accordion-up": "accordion-up 0.2s ease-out",
|
88
|
+
},
|
89
|
+
},
|
90
|
+
},
|
91
|
+
plugins: [
|
92
|
+
require("@tailwindcss/forms"),
|
93
|
+
require("@tailwindcss/aspect-ratio"),
|
94
|
+
require("@tailwindcss/typography"),
|
95
|
+
require("@tailwindcss/container-queries"),
|
96
|
+
require("tailwindcss-animate"),
|
97
|
+
],
|
98
|
+
};
|
data/config/tailwind.config.js
CHANGED
@@ -1,86 +1,25 @@
|
|
1
|
-
const
|
1
|
+
const shadcnConfig = require("./shadcn.tailwind.js");
|
2
2
|
|
3
3
|
module.exports = {
|
4
|
-
|
5
|
-
content: [
|
6
|
-
"./public/*.html",
|
7
|
-
"./app/helpers/**/*.rb",
|
8
|
-
"./app/javascript/**/*.js",
|
9
|
-
"./app/views/**/*.{erb,haml,html,slim}",
|
10
|
-
],
|
4
|
+
...shadcnConfig,
|
11
5
|
theme: {
|
12
|
-
container: {
|
13
|
-
center: true,
|
14
|
-
padding: "2rem",
|
15
|
-
screens: {
|
16
|
-
"2xl": "1400px",
|
17
|
-
},
|
18
|
-
},
|
19
6
|
extend: {
|
20
7
|
colors: {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
primary: {
|
27
|
-
DEFAULT: "hsl(var(--primary))",
|
28
|
-
foreground: "hsl(var(--primary-foreground))",
|
29
|
-
},
|
30
|
-
secondary: {
|
31
|
-
DEFAULT: "hsl(var(--secondary))",
|
32
|
-
foreground: "hsl(var(--secondary-foreground))",
|
33
|
-
},
|
34
|
-
destructive: {
|
35
|
-
DEFAULT: "hsl(var(--destructive))",
|
36
|
-
foreground: "hsl(var(--destructive-foreground))",
|
37
|
-
},
|
38
|
-
muted: {
|
39
|
-
DEFAULT: "hsl(var(--muted))",
|
40
|
-
foreground: "hsl(var(--muted-foreground))",
|
41
|
-
},
|
42
|
-
accent: {
|
43
|
-
DEFAULT: "hsl(var(--accent))",
|
44
|
-
foreground: "hsl(var(--accent-foreground))",
|
8
|
+
...shadcnConfig.theme.extend.colors,
|
9
|
+
pink: "hsl(var(--pink))",
|
10
|
+
success: {
|
11
|
+
DEFAULT: "hsl(var(--success))",
|
12
|
+
foreground: "hsl(var(--success-foreground))",
|
45
13
|
},
|
46
|
-
|
47
|
-
DEFAULT: "hsl(var(--
|
48
|
-
foreground: "hsl(var(--
|
14
|
+
info: {
|
15
|
+
DEFAULT: "hsl(var(--info))",
|
16
|
+
foreground: "hsl(var(--info-foreground))",
|
49
17
|
},
|
50
|
-
|
51
|
-
DEFAULT: "hsl(var(--
|
52
|
-
foreground: "hsl(var(--
|
18
|
+
attention: {
|
19
|
+
DEFAULT: "hsl(var(--attention))",
|
20
|
+
foreground: "hsl(var(--attention-foreground))",
|
53
21
|
},
|
54
22
|
},
|
55
|
-
borderRadius: {
|
56
|
-
lg: `var(--radius)`,
|
57
|
-
md: `calc(var(--radius) - 2px)`,
|
58
|
-
sm: "calc(var(--radius) - 4px)",
|
59
|
-
},
|
60
|
-
fontFamily: {
|
61
|
-
sans: ["var(--font-sans)", ...defaultTheme.fontFamily.sans],
|
62
|
-
},
|
63
|
-
keyframes: {
|
64
|
-
"accordion-down": {
|
65
|
-
from: { height: 0 },
|
66
|
-
to: { height: "var(--radix-accordion-content-height)" },
|
67
|
-
},
|
68
|
-
"accordion-up": {
|
69
|
-
from: { height: "var(--radix-accordion-content-height)" },
|
70
|
-
to: { height: 0 },
|
71
|
-
},
|
72
|
-
},
|
73
|
-
animation: {
|
74
|
-
"accordion-down": "accordion-down 0.2s ease-out",
|
75
|
-
"accordion-up": "accordion-up 0.2s ease-out",
|
76
|
-
},
|
77
23
|
},
|
78
24
|
},
|
79
|
-
plugins: [
|
80
|
-
require("@tailwindcss/forms"),
|
81
|
-
require("@tailwindcss/aspect-ratio"),
|
82
|
-
require("@tailwindcss/typography"),
|
83
|
-
require("@tailwindcss/container-queries"),
|
84
|
-
require("tailwindcss-animate"),
|
85
|
-
],
|
86
25
|
};
|
data/lib/components.json
CHANGED
@@ -102,9 +102,13 @@
|
|
102
102
|
"name": "dropdown-menu",
|
103
103
|
"type": "components:ui",
|
104
104
|
"files": [
|
105
|
-
"app/helpers/components/
|
106
|
-
"app/views/components/ui/
|
107
|
-
"app/javascript/controllers/ui/
|
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"
|
108
112
|
]
|
109
113
|
},
|
110
114
|
"hover-card": {
|
@@ -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