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.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -0
  3. data/Rakefile +6 -3
  4. data/app/assets/stylesheets/{application.scss → application.css} +0 -27
  5. data/app/assets/stylesheets/application.tailwind.css +32 -160
  6. data/app/assets/stylesheets/shadcn.css +216 -0
  7. data/app/helpers/components/accordion_helper.rb +14 -1
  8. data/app/helpers/components/alert_helper.rb +4 -2
  9. data/app/helpers/components/button_helper.rb +2 -1
  10. data/app/helpers/components/card_helper.rb +1 -1
  11. data/app/helpers/components/checkbox_helper.rb +2 -2
  12. data/app/helpers/components/collapsible_helper.rb +8 -0
  13. data/app/helpers/components/input_helper.rb +1 -1
  14. data/app/helpers/components/sheet_helper.rb +9 -0
  15. data/app/helpers/components/slider_helper.rb +1 -1
  16. data/app/helpers/components_helper.rb +11 -0
  17. data/app/helpers/examples_helper.rb +7 -3
  18. data/app/javascript/controllers/highlight_controller.js +0 -1
  19. data/app/javascript/controllers/ui/popover_controller.js +6 -2
  20. data/app/views/application/index.html.erb +625 -17
  21. data/app/views/components/ui/_accordion.html.erb +2 -2
  22. data/app/views/components/ui/_alert.html.erb +15 -3
  23. data/app/views/components/ui/_card.html.erb +7 -1
  24. data/app/views/components/ui/_checkbox.html.erb +2 -1
  25. data/app/views/components/ui/_collapsible.html.erb +2 -6
  26. data/app/views/components/ui/_filter.html.erb +2 -1
  27. data/app/views/components/ui/_sheet.html.erb +1 -1
  28. data/app/views/documentation/generators.html.md +21 -0
  29. data/app/views/documentation/helpers.html.md +54 -0
  30. data/app/views/documentation/index.html.md +22 -0
  31. data/app/views/documentation/installation.html.md +130 -2
  32. data/app/views/documentation/javascript.html.md +8 -0
  33. data/app/views/examples/components/accordion/_usage.html.erb +15 -0
  34. data/app/views/examples/components/accordion/code/_block.html.erb +8 -0
  35. data/app/views/examples/components/accordion/code/_description.html.erb +7 -0
  36. data/app/views/examples/components/accordion/code/_preview.erb +3 -0
  37. data/app/views/examples/components/accordion/code/_usage.erb +16 -0
  38. data/app/views/examples/components/accordion.html.erb +37 -3
  39. data/app/views/examples/components/alert/_usage.html.erb +10 -0
  40. data/app/views/examples/components/alert/code/_attention.erb +3 -0
  41. data/app/views/examples/components/alert/code/_destructive.erb +2 -0
  42. data/app/views/examples/components/alert/code/_info.erb +3 -0
  43. data/app/views/examples/components/alert/code/_no_icon.erb +3 -0
  44. data/app/views/examples/components/alert/code/_preview.erb +2 -0
  45. data/app/views/examples/components/alert/code/_success.erb +3 -0
  46. data/app/views/examples/components/alert/code/_usage.erb +1 -0
  47. data/app/views/examples/components/alert-dialog/code/_preview.erb +6 -0
  48. data/app/views/examples/components/alert-dialog/code/_usage.erb +0 -0
  49. data/app/views/examples/components/alert-dialog.html.erb +8 -11
  50. data/app/views/examples/components/alert.html.erb +90 -8
  51. data/app/views/examples/components/badge/_usage.html.erb +10 -0
  52. data/app/views/examples/components/badge/code/_preview.erb +5 -0
  53. data/app/views/examples/components/badge/code/_usage.erb +1 -0
  54. data/app/views/examples/components/badge.html.erb +12 -17
  55. data/app/views/examples/components/button/_usage.html.erb +19 -0
  56. data/app/views/examples/components/button/code/_preview.erb +13 -0
  57. data/app/views/examples/components/button/code/_usage.erb +6 -0
  58. data/app/views/examples/components/button.html.erb +12 -20
  59. data/app/views/examples/components/card/_usage.html.erb +21 -0
  60. data/app/views/examples/components/card/code/_form.erb +72 -0
  61. data/app/views/examples/components/card/code/_notifications.erb +61 -0
  62. data/app/views/examples/components/card/code/_preview.erb +6 -0
  63. data/app/views/examples/components/card/code/_usage.erb +3 -0
  64. data/app/views/examples/components/card.html.erb +31 -143
  65. data/app/views/examples/components/checkbox/_usage.html.erb +9 -0
  66. data/app/views/examples/components/checkbox/code/_preview.erb +2 -0
  67. data/app/views/examples/components/checkbox/code/_usage.erb +1 -0
  68. data/app/views/examples/components/checkbox.html.erb +15 -1
  69. data/app/views/examples/components/collapsible/_usage.html.erb +16 -0
  70. data/app/views/examples/components/collapsible/code/_preview.erb +9 -0
  71. data/app/views/examples/components/collapsible/code/_usage.erb +7 -0
  72. data/app/views/examples/components/collapsible.html.erb +12 -10
  73. data/app/views/examples/components/dialog.html.erb +6 -15
  74. data/app/views/examples/components/dropdown-menu/_usage.html.erb +19 -0
  75. data/app/views/examples/components/dropdown-menu/code/_preview.erb +19 -0
  76. data/app/views/examples/components/dropdown-menu/code/_usage.erb +13 -0
  77. data/app/views/examples/components/dropdown-menu.html.erb +29 -15
  78. data/app/views/examples/components/filter/_usage.html.erb +14 -0
  79. data/app/views/examples/components/filter/code/_icon.html.erb +7 -0
  80. data/app/views/examples/components/filter/code/_preview.erb +3 -0
  81. data/app/views/examples/components/filter/code/_usage.erb +5 -0
  82. data/app/views/examples/components/filter.html.erb +27 -7
  83. data/app/views/examples/components/hover-card/_usage.html.erb +15 -0
  84. data/app/views/examples/components/hover-card/code/_preview.erb +13 -0
  85. data/app/views/examples/components/hover-card/code/_usage.erb +6 -0
  86. data/app/views/examples/components/hover-card.html.erb +12 -14
  87. data/app/views/examples/components/input/_usage.html.erb +10 -0
  88. data/app/views/examples/components/input/code/_borderless.erb +3 -0
  89. data/app/views/examples/components/input/code/_preview.erb +1 -0
  90. data/app/views/examples/components/input/code/_usage.erb +1 -0
  91. data/app/views/examples/components/input.html.erb +17 -3
  92. data/app/views/examples/components/label/_usage.html.erb +9 -0
  93. data/app/views/examples/components/label/code/_preview.erb +5 -0
  94. data/app/views/examples/components/label/code/_usage.erb +1 -0
  95. data/app/views/examples/components/label.html.erb +14 -5
  96. data/app/views/examples/components/popover/_usage.html.erb +12 -0
  97. data/app/views/examples/components/popover/code/_form.erb +23 -0
  98. data/app/views/examples/components/popover/code/_preview.erb +13 -0
  99. data/app/views/examples/components/popover/code/_usage.erb +7 -0
  100. data/app/views/examples/components/popover.html.erb +28 -24
  101. data/app/views/examples/components/progress/_usage.erb +9 -0
  102. data/app/views/examples/components/progress/code/_preview.erb +1 -0
  103. data/app/views/examples/components/progress/code/_usage.erb +1 -0
  104. data/app/views/examples/components/progress.html.erb +12 -2
  105. data/app/views/examples/components/separator/_usage.html.erb +10 -0
  106. data/app/views/examples/components/separator/code/_fancy.erb +21 -0
  107. data/app/views/examples/components/separator/code/_preview.erb +1 -0
  108. data/app/views/examples/components/separator/code/_usage.erb +1 -0
  109. data/app/views/examples/components/separator.html.erb +26 -19
  110. data/app/views/examples/components/sheet/_usage.html.erb +38 -0
  111. data/app/views/examples/components/sheet/code/_mobile_menu.erb +17 -0
  112. data/app/views/examples/components/sheet/code/_preview.erb +22 -0
  113. data/app/views/examples/components/sheet/code/_usage.erb +7 -0
  114. data/app/views/examples/components/sheet.html.erb +17 -10
  115. data/app/views/examples/components/skeleton/_usage.html.erb +9 -0
  116. data/app/views/examples/components/skeleton/code/_preview.erb +1 -0
  117. data/app/views/examples/components/skeleton/code/_usage.erb +1 -0
  118. data/app/views/examples/components/skeleton.html.erb +16 -2
  119. data/app/views/examples/components/slider/_usage.html.erb +11 -0
  120. data/app/views/examples/components/slider/code/_preview.erb +3 -0
  121. data/app/views/examples/components/slider/code/_usage.erb +1 -0
  122. data/app/views/examples/components/slider.html.erb +16 -2
  123. data/app/views/examples/components/textarea/_usage.html.erb +9 -0
  124. data/app/views/examples/components/textarea/code/_preview.erb +1 -0
  125. data/app/views/examples/components/textarea/code/_usage.erb +1 -0
  126. data/app/views/examples/components/textarea.html.erb +16 -2
  127. data/app/views/examples/components/toast/_usage.html.erb +11 -0
  128. data/app/views/examples/components/toast/code/_preview.erb +3 -0
  129. data/app/views/examples/components/toast/code/_usage.erb +2 -0
  130. data/app/views/examples/components/toast.html.erb +12 -4
  131. data/app/views/examples/components/toggle/_usage.html.erb +10 -0
  132. data/app/views/examples/components/toggle/code/_preview.erb +1 -0
  133. data/app/views/examples/components/toggle/code/_usage.erb +1 -0
  134. data/app/views/examples/components/toggle.html.erb +16 -2
  135. data/app/views/examples/components/tooltip/_usage.html.erb +11 -0
  136. data/app/views/examples/components/tooltip/code/_preview.erb +12 -0
  137. data/app/views/examples/components/tooltip/code/_usage.erb +7 -0
  138. data/app/views/examples/components/tooltip.html.erb +16 -13
  139. data/app/views/layouts/shared/_components.html.erb +44 -41
  140. data/config/environments/production.rb +4 -4
  141. data/config/shadcn.tailwind.js +98 -0
  142. data/config/tailwind.config.js +13 -74
  143. data/lib/components.json +7 -3
  144. data/lib/generators/shadcn-ui_generator.rb +201 -0
  145. data/lib/shadcn-ui/version.rb +1 -1
  146. data/package-lock.json +90 -3
  147. data/package.json +4 -0
  148. metadata +97 -9
  149. data/lib/generators/shadcn_ui_generator.rb +0 -81
  150. /data/app/assets/stylesheets/{lambda.light.scss → lambda.light.css} +0 -0
  151. /data/app/views/examples/components/dialog/code/{form.erb → _form.erb} +0 -0
  152. /data/app/views/examples/components/dialog/code/{notifications.erb → _notifications.erb} +0 -0
  153. /data/app/views/examples/components/dialog/code/{preview.erb → _preview.erb} +0 -0
  154. /data/app/views/examples/components/dialog/code/{usage.erb → _usage.erb} +0 -0
@@ -4,19 +4,101 @@
4
4
  description: "Displays a callout for user attention" %>
5
5
 
6
6
  <% content_for :preview, flush: true do %>
7
- <div class="w-full">
8
- <%= render_alert title: "Did you know?", description: "You can wrap shadcn helpers in any
9
- component library you want!" %>
10
- </div>
7
+ <div class="w-full">
8
+ <%= render_code_preview('alert') %>
9
+ </div>
10
+ <% end %>
11
11
 
12
- <div class="w-full">
13
- <%= render_alert(variant: :error, title: "Did you know?", description: "You can wrap shadcn
14
- helpers in any component library you want!") %>
15
- </div>
12
+ <% content_for :code, flush: true do %>
13
+ <%= code_partial("alert/preview", :erb) %>
16
14
  <% end %>
17
15
 
18
16
  <%= render_preview %>
19
17
 
20
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 alert
21
+ <% end %>
21
22
 
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"><a href="/docs/components/dialog#usage">Usage</a></h2>
24
+
25
+ <%= code_partial("alert/usage", :erb) %>
26
+
27
+ <%= render_usage("alert") %>
28
+
29
+ <% content_for :examples, flush: true do %>
30
+ <div class="w-full flex justify-center">
31
+ <div role="alert" class="border-success/50 text-success dark:border-success [&amp;>svg]:text-success relative w-full rounded-lg border p-4 [&amp;:has(svg)]:pl-11 [&amp;>svg+div]:translate-y-[-3px] [&amp;>svg]:absolute [&amp;>svg]:left-4 [&amp;>svg]:top-4">
32
+ <svg class="h-4 w-4 text-success" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
33
+ <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"></path>
34
+ </svg>
35
+ <h5 class="mb-1 font-medium leading-none tracking-tight">Success</h5>
36
+ <div class="text-sm [&amp;_p]:leading-relaxed">This variant is :success</div>
37
+ </div>
38
+ </div>
39
+ <% end %>
40
+
41
+ <% content_for :code, flush: true do %>
42
+ <%= code_partial("alert/success", :erb) %>
43
+ <% end %>
44
+ <%= render_example %>
45
+
46
+ <% content_for :examples, flush: true do %>
47
+ <div class="w-full flex justify-center">
48
+ <div role="alert" class="border-info/50 text-info dark:border-info [&amp;>svg]:text-info relative w-full rounded-lg border p-4 [&amp;:has(svg)]:pl-11 [&amp;>svg+div]:translate-y-[-3px] [&amp;>svg]:absolute [&amp;>svg]:left-4 [&amp;>svg]:top-4">
49
+ <svg class="h-4 w-4 text-info" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
50
+ <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd"></path>
51
+ </svg>
52
+ <h5 class="mb-1 font-medium leading-none tracking-tight">Info</h5>
53
+ <div class="text-sm [&amp;_p]:leading-relaxed">This variant is :info</div>
54
+ </div>
55
+ </div>
56
+ <% end %>
57
+
58
+ <% content_for :code, flush: true do %>
59
+ <%= code_partial("alert/info", :erb) %>
60
+ <% end %>
61
+
62
+ <%= render_example %>
63
+
64
+ <% content_for :examples, flush: true do %>
65
+ <div class="w-full flex justify-center">
66
+ <div role="alert" class="border-attention/50 text-attention dark:border-attention [&amp;>svg]:text-attention relative w-full rounded-lg border p-4 [&amp;:has(svg)]:pl-11 [&amp;>svg+div]:translate-y-[-3px] [&amp;>svg]:absolute [&amp;>svg]:left-4 [&amp;>svg]:top-4">
67
+ <svg class="h-4 w-4 text-attention" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
68
+ <path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path>
69
+ </svg>
70
+ <h5 class="mb-1 font-medium leading-none tracking-tight">Attention</h5>
71
+ <div class="text-sm [&amp;_p]:leading-relaxed">This variant is :attention</div>
72
+ </div>
73
+ </div>
74
+ <% end %>
75
+
76
+ <% content_for :code, flush: true do %>
77
+ <%= code_partial("alert/attention", :erb) %>
78
+ <% end %>
79
+
80
+ <%= render_example %>
81
+
82
+ <% content_for :examples, flush: true do %>
83
+ <div class="w-full flex justify-center">
84
+ <%= render "examples/components/alert/code/destructive" %>
85
+ </div>
86
+ <% end %>
87
+
88
+ <% content_for :code, flush: true do %>
89
+ <%= code_partial("alert/destructive", :erb) %>
90
+ <% end %>
91
+
92
+ <%= render_example %>
93
+
94
+ <% content_for :examples, flush: true do %>
95
+ <div class="w-full flex justify-center">
96
+ <%= render "examples/components/alert/code/no_icon" %>
97
+ </div>
98
+ <% end %>
99
+
100
+ <% content_for :code, flush: true do %>
101
+ <%= code_partial("alert/no_icon", :erb) %>
102
+ <% end %>
103
+
104
+ <%= render_example %>
@@ -0,0 +1,10 @@
1
+ <p class="leading-7 [&:not(:first-child)]:mt-6">The Badge component introduces:</p>
2
+
3
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
4
+ <li><%= code("app/helpers/components/badge_helper.rb") %></li>
5
+ <li><%= code("app/views/components/ui/_badge.html.erb") %></li>
6
+ </ul>
7
+
8
+ <p class="leading-7 [&:not(:first-child)]:mt-6">
9
+ The method <%= code("render_badge") %> defined in <%= code("app/helpers/components/badge_helper.rb") %>
10
+ accepts a <%= code("text:") %> required keyword argument along with an optional <%= code("variant:") %> argument for the kind of badge to render.</p>
@@ -0,0 +1,5 @@
1
+ <%= render_badge text: "Badge" %>
2
+ <%= render_badge text: "Secondary", variant: :secondary %>
3
+ <%= render_badge text: "Destructive", variant: :destructive %>
4
+ <%= render_badge text: "Outline", variant: :outline %>
5
+ <%= render_badge text: "Ghost", variant: :ghost %>
@@ -0,0 +1 @@
1
+ <%= render_badge text:, variant: %>
@@ -5,26 +5,21 @@
5
5
  description: "Displays a badge or a component that looks like a badge." %>
6
6
 
7
7
  <%= content_for :preview, flush: true do %>
8
- <div class="w-full mx-auto flex justify-center"><%= render_badge text: "Badge" %></div>
9
- <div class="w-full mx-auto flex justify-center">
10
- <%= render_badge text: "Secondary", variant: :secondary %>
11
- </div>
12
- <div class="w-full mx-auto flex justify-center">
13
- <%= render_badge text: "Destructive", variant: :destructive %>
14
- </div>
15
- <div class="w-full mx-auto flex justify-center">
16
- <%= render_badge text: "Outline", variant: :outline %>
17
- </div>
18
- <div class="w-full mx-auto flex justify-center">
19
- <%= render_badge text: "Ghost", variant: :ghost %>
20
- </div>
21
- <div class="w-full mx-auto flex justify-center">
22
- <%= render_badge text: "Ghost Link", variant: :ghost, as: :link %>
23
- </div>
8
+ <%= render_code_preview('badge') %>
9
+ <% end %>
10
+
11
+ <% content_for :code, flush: true do %>
12
+ <%= code_partial("badge/preview", :erb) %>
24
13
  <% end %>
25
14
 
26
15
  <%= render_preview %>
27
16
 
28
17
  <h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
18
+ <%= code_sample(language: "sh") do %>
19
+ rails generate shadcn-ui badge
20
+ <% end %>
21
+
22
+ <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>
23
+ <%= code_partial("badge/usage", :erb) %>
29
24
 
30
- <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"><a href="/docs/components/dialog#usage">Usage</a></h2>
25
+ <%= render_usage("badge") %>
@@ -0,0 +1,19 @@
1
+ <p class="leading-7 [&:not(:first-child)]:mt-6">The Button component introduces:</p>
2
+
3
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
4
+ <li><%= code("app/helpers/components/button_helper.rb") %></li>
5
+ <li><%= code("app/views/components/ui/_button.html.erb") %></li>
6
+ </ul>
7
+
8
+ <p class="leading-7 [&:not(:first-child)]:mt-6">
9
+
10
+ <p>The method <%= code("render_button") %> defined in <%= code("app/helpers/components/button_helper.rb") %>
11
+ accepts a first argument for the text of the button or as a <%= code("text:") %> keyword argument.</p>
12
+
13
+ <p>Optional arguments for the button include:
14
+
15
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
16
+ <li><%= code("variant:") %>, including <%= code(":secondary") %>, <%= code(":destructive") %>, <%= code(":outline") %>, and <%= code(":ghost") %></li>
17
+ <li><%= code("as:") %> which allows the button to be rendered as a <%= code("<a>") %> tag.</li>
18
+ <li>A <%= code("block") %> can be passed to render the text including other elements such as icons.</li>
19
+ </ul>
@@ -0,0 +1,13 @@
1
+ <%= render_button "Button" %>
2
+
3
+ <%= render_button variant: :secondary do %>
4
+ <svg class="h-4 w-4 mr-2 text-primary" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
5
+ <path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd"></path>
6
+ </svg> Secondary with Icon
7
+ <% end %>
8
+
9
+ <%= render_button text: "Destructive", variant: :destructive %>
10
+ <%= render_button text: "Outline", variant: :outline %>
11
+ <%= render_button text: "Ghost", variant: :ghost %>
12
+ <%= render_button "Link", as: :link, href: "/" %>
13
+ <%= render_button text: "Ghost Link", variant: :ghost, as: :link %>
@@ -0,0 +1,6 @@
1
+ <%= render_button(label, text: nil,
2
+ variant: :default,
3
+ as: :button,
4
+ href: nil,
5
+ data: {},
6
+ **options, &block) %>
@@ -5,29 +5,21 @@
5
5
  description: "Displays a button or a component that looks like a button." %>
6
6
 
7
7
  <%= content_for :preview, flush: true do %>
8
- <div class="w-full mx-auto flex justify-center"><%= render_button text: "Button" %></div>
9
- <div class="w-full mx-auto flex justify-center">
10
- <%= render_button text: "Link", as: :link, href: "/" %>
11
- </div>
12
- <div class="w-full mx-auto flex justify-center">
13
- <%= render_button text: "Secondary", variant: :secondary %>
14
- </div>
15
- <div class="w-full mx-auto flex justify-center">
16
- <%= render_button text: "Destructive", variant: :destructive %>
17
- </div>
18
- <div class="w-full mx-auto flex justify-center">
19
- <%= render_button text: "Outline", variant: :outline %>
20
- </div>
21
- <div class="w-full mx-auto flex justify-center">
22
- <%= render_button text: "Ghost", variant: :ghost %>
23
- </div>
24
- <div class="w-full mx-auto flex justify-center">
25
- <%= render_button text: "Ghost Link", variant: :ghost, as: :link %>
26
- </div>
8
+ <%= render_code_preview('button') %>
9
+ <% end %>
10
+
11
+ <% content_for :code, flush: true do %>
12
+ <%= code_partial("button/preview", :erb) %>
27
13
  <% end %>
28
14
 
29
15
  <%= render_preview %>
30
16
 
31
17
  <h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
18
+ <%= code_sample(language: "sh") do %>
19
+ rails generate shadcn-ui button
20
+ <% end %>
21
+
22
+ <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>
23
+ <%= code_partial("button/usage", :erb) %>
32
24
 
33
- <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"><a href="/docs/components/dialog#usage">Usage</a></h2>
25
+ <%= render_usage("button") %>
@@ -0,0 +1,21 @@
1
+ <p class="leading-7 [&:not(:first-child)]:mt-6">The Card component introduces:</p>
2
+
3
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
4
+ <li><%= code("app/helpers/components/card_helper.rb") %></li>
5
+ <li><%= code("app/views/components/ui/_card.html.erb") %></li>
6
+ </ul>
7
+
8
+ <p class="leading-7 [&:not(:first-child)]:mt-6">
9
+
10
+ <p>The method <%= code("render_card") %> defined in <%= code("app/helpers/components/card_helper.rb") %>
11
+ accepts optional keyword arguments for each section of content in the card, offering maximum flexibility. </p>
12
+
13
+ <p>The sections are.</p>
14
+
15
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
16
+ <li><%= code("title:") %>, for the header of the card, will be rendered in a large bold font.</li>
17
+ <li><%= code("subtitle:") %> for a muted title under the main title..</li>
18
+ <li>A <%= code("body:") %> The main content section. Without providing either a keyword argument or a block, an empty card will be rendered.</li>
19
+ </ul>
20
+
21
+ <p><em>Note:</em> Padding to the body is applied logically leaving you to define it when a block is passed with the presence of a title, otherwise, a default padding is provided to simplify the markup. Feel free to edit this in <%= code("app/views/components/ui/_card.html.erb") %>,
@@ -0,0 +1,72 @@
1
+ <%= render_card title: "Card with Form" do %>
2
+ <div class="p-6 pt-0">
3
+ <form>
4
+ <div class="grid w-full items-center gap-4">
5
+ <div class="flex flex-col space-y-1.5">
6
+ <label
7
+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
8
+ for="name">Name</label><input
9
+ class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
10
+ id="name"
11
+ placeholder="Name of your project">
12
+ </div>
13
+ <div class="flex flex-col space-y-1.5">
14
+ <label
15
+ class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
16
+ for="name">Framework</label><button
17
+ type="button"
18
+ role="combobox"
19
+ aria-controls="radix-:r76:"
20
+ aria-expanded="false"
21
+ aria-autocomplete="none"
22
+ dir="ltr"
23
+ data-state="closed"
24
+ data-placeholder=""
25
+ class="flex h-10 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50">
26
+ <span style="pointer-events: none">Select</span><svg
27
+ xmlns="http://www.w3.org/2000/svg"
28
+ width="24"
29
+ height="24"
30
+ viewBox="0 0 24 24"
31
+ fill="none"
32
+ stroke="currentColor"
33
+ stroke-width="2"
34
+ stroke-linecap="round"
35
+ stroke-linejoin="round"
36
+ class="h-4 w-4 opacity-50"
37
+ aria-hidden="true">
38
+ <polyline points="6 9 12 15 18 9"></polyline>
39
+ </svg></button><select
40
+ aria-hidden="true"
41
+ tabindex="-1"
42
+ style="
43
+ position: absolute;
44
+ border: 0px;
45
+ width: 1px;
46
+ height: 1px;
47
+ padding: 0px;
48
+ margin: -1px;
49
+ overflow: hidden;
50
+ clip: rect(0px, 0px, 0px, 0px);
51
+ white-space: nowrap;
52
+ overflow-wrap: normal;
53
+ ">
54
+ <option value=""></option>
55
+ <option value="next">Next.js</option>
56
+ <option value="sveltekit">SvelteKit</option>
57
+ <option value="astro">Astro</option>
58
+ <option value="nuxt">Nuxt.js</option>
59
+ </select>
60
+ </div>
61
+ </div>
62
+ </form>
63
+ </div>
64
+ <div class="items-center p-6 pt-0 flex justify-between">
65
+ <button
66
+ class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2">
67
+ Cancel</button><button
68
+ class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2">
69
+ Deploy
70
+ </button>
71
+ </div>
72
+ <% end %>
@@ -0,0 +1,61 @@
1
+ <%= render_card title: "Notifications", footer: render_button(text: "Mark all as read", class:
2
+ "w-full") do %>
3
+ <div class="p-6 pt-0 grid gap-4">
4
+ <div class="flex items-center space-x-4 rounded-md border p-4">
5
+ <svg
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ width="24"
8
+ height="24"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ stroke-width="2"
13
+ stroke-linecap="round"
14
+ stroke-linejoin="round"
15
+ class="lucide lucide-bell-ring">
16
+ <path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"></path>
17
+ <path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"></path>
18
+ <path d="M4 2C2.8 3.7 2 5.7 2 8"></path>
19
+ <path d="M22 8c0-2.3-.8-4.3-2-6"></path>
20
+ </svg>
21
+ <div class="flex-1 space-y-1">
22
+ <p class="text-sm font-medium leading-none">Push Notifications</p>
23
+ <p class="text-sm text-muted-foreground">Send notifications to device.</p>
24
+ </div>
25
+ <button
26
+ type="button"
27
+ role="switch"
28
+ aria-checked="false"
29
+ data-state="unchecked"
30
+ value="on"
31
+ class="peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input">
32
+ <span
33
+ data-state="unchecked"
34
+ class="pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"></span>
35
+ </button>
36
+ </div>
37
+ <div>
38
+ <div class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0">
39
+ <span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500"></span>
40
+ <div class="space-y-1">
41
+ <p class="text-sm font-medium leading-none">Your call has been confirmed.</p>
42
+ <p class="text-sm text-muted-foreground">1 hour ago</p>
43
+ </div>
44
+ </div>
45
+ <div class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0">
46
+ <span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500"></span>
47
+ <div class="space-y-1">
48
+ <p class="text-sm font-medium leading-none">You have a new message!</p>
49
+ <p class="text-sm text-muted-foreground">1 hour ago</p>
50
+ </div>
51
+ </div>
52
+ <div class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0">
53
+ <span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500"></span>
54
+ <div class="space-y-1">
55
+ <p class="text-sm font-medium leading-none">Your subscription is expiring soon!</p>
56
+ <p class="text-sm text-muted-foreground">2 hours ago</p>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= render_card body: "The Most Basic of Cards" %>
2
+
3
+ <%= render_card title: "Did you know?",
4
+ subtitle: "This is kinda cool.",
5
+ body: "You can embed any HTML in the body with a block.",
6
+ footer: "Have a great day!" %>
@@ -0,0 +1,3 @@
1
+ <%= render(title: nil, subtitle: nil, body: nil, footer: nil:) do %>
2
+ <!-- Optional Body Block -->
3
+ <% end %>
@@ -4,153 +4,41 @@
4
4
  description: "Displays a card with header, content, and footer." %>
5
5
 
6
6
  <%= content_for :preview, flush: true do %>
7
- <div class="w-full flex justify-center"><%= render_card body: "The Most Basic of Cards" %></div>
8
- <div class="w-full flex justify-center">
9
- <%= render_card title: "Did you know?", body: "You can embed any HTML in the body of a card by
10
- yielding to a block for the body?", subtitle: "This is important." %>
11
- </div>
7
+ <%= render_code_preview('card') %>
8
+ <% end %>
12
9
 
13
- <div class="w-full flex justify-center">
14
- <%= render_card title: "Card with Form" do %>
15
- <div class="p-6 pt-0">
16
- <form>
17
- <div class="grid w-full items-center gap-4">
18
- <div class="flex flex-col space-y-1.5">
19
- <label
20
- class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
21
- for="name">Name</label><input
22
- class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
23
- id="name"
24
- placeholder="Name of your project">
25
- </div>
26
- <div class="flex flex-col space-y-1.5">
27
- <label
28
- class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
29
- for="name">Framework</label><button
30
- type="button"
31
- role="combobox"
32
- aria-controls="radix-:r76:"
33
- aria-expanded="false"
34
- aria-autocomplete="none"
35
- dir="ltr"
36
- data-state="closed"
37
- data-placeholder=""
38
- class="flex h-10 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50">
39
- <span style="pointer-events: none">Select</span><svg
40
- xmlns="http://www.w3.org/2000/svg"
41
- width="24"
42
- height="24"
43
- viewBox="0 0 24 24"
44
- fill="none"
45
- stroke="currentColor"
46
- stroke-width="2"
47
- stroke-linecap="round"
48
- stroke-linejoin="round"
49
- class="h-4 w-4 opacity-50"
50
- aria-hidden="true">
51
- <polyline points="6 9 12 15 18 9"></polyline>
52
- </svg></button><select
53
- aria-hidden="true"
54
- tabindex="-1"
55
- style="
56
- position: absolute;
57
- border: 0px;
58
- width: 1px;
59
- height: 1px;
60
- padding: 0px;
61
- margin: -1px;
62
- overflow: hidden;
63
- clip: rect(0px, 0px, 0px, 0px);
64
- white-space: nowrap;
65
- overflow-wrap: normal;
66
- ">
67
- <option value=""></option>
68
- <option value="next">Next.js</option>
69
- <option value="sveltekit">SvelteKit</option>
70
- <option value="astro">Astro</option>
71
- <option value="nuxt">Nuxt.js</option>
72
- </select>
73
- </div>
74
- </div>
75
- </form>
76
- </div>
77
- <div class="items-center p-6 pt-0 flex justify-between">
78
- <button
79
- class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-10 px-4 py-2">
80
- Cancel</button><button
81
- class="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2">
82
- Deploy
83
- </button>
84
- </div>
85
- <% end %>
86
- </div>
87
- <div class="w-full flex justify-center">
88
- <%= render_card title: "Notifications", footer: render_button(text: "Mark all as read", class:
89
- "w-full") do %>
90
- <div class="p-6 pt-0 grid gap-4">
91
- <div class="flex items-center space-x-4 rounded-md border p-4">
92
- <svg
93
- xmlns="http://www.w3.org/2000/svg"
94
- width="24"
95
- height="24"
96
- viewBox="0 0 24 24"
97
- fill="none"
98
- stroke="currentColor"
99
- stroke-width="2"
100
- stroke-linecap="round"
101
- stroke-linejoin="round"
102
- class="lucide lucide-bell-ring">
103
- <path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"></path>
104
- <path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"></path>
105
- <path d="M4 2C2.8 3.7 2 5.7 2 8"></path>
106
- <path d="M22 8c0-2.3-.8-4.3-2-6"></path>
107
- </svg>
108
- <div class="flex-1 space-y-1">
109
- <p class="text-sm font-medium leading-none">Push Notifications</p>
110
- <p class="text-sm text-muted-foreground">Send notifications to device.</p>
111
- </div>
112
- <button
113
- type="button"
114
- role="switch"
115
- aria-checked="false"
116
- data-state="unchecked"
117
- value="on"
118
- class="peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input">
119
- <span
120
- data-state="unchecked"
121
- class="pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"></span>
122
- </button>
123
- </div>
124
- <div>
125
- <div class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0">
126
- <span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500"></span>
127
- <div class="space-y-1">
128
- <p class="text-sm font-medium leading-none">Your call has been confirmed.</p>
129
- <p class="text-sm text-muted-foreground">1 hour ago</p>
130
- </div>
131
- </div>
132
- <div class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0">
133
- <span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500"></span>
134
- <div class="space-y-1">
135
- <p class="text-sm font-medium leading-none">You have a new message!</p>
136
- <p class="text-sm text-muted-foreground">1 hour ago</p>
137
- </div>
138
- </div>
139
- <div class="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0">
140
- <span class="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500"></span>
141
- <div class="space-y-1">
142
- <p class="text-sm font-medium leading-none">Your subscription is expiring soon!</p>
143
- <p class="text-sm text-muted-foreground">2 hours ago</p>
144
- </div>
145
- </div>
146
- </div>
147
- </div>
148
- <% end %>
149
- </div>
10
+ <% content_for :code, flush: true do %>
11
+ <%= code_partial("card/preview", :erb) %>
150
12
  <% end %>
151
13
 
152
14
  <%= render_preview %>
153
15
 
154
16
  <h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
17
+ <%= code_sample(language: "sh") do %>
18
+ rails generate shadcn-ui card
19
+ <% end %>
20
+
21
+ <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>
22
+ <%= code_partial("card/usage", :erb) %>
23
+
24
+ <%= render_usage("card") %>
25
+
26
+ <% content_for :examples, flush: true do %>
27
+ <%= render "examples/components/card/code/form" %>
28
+ <% end %>
29
+
30
+ <% content_for :code, flush: true do %>
31
+ <%= code_partial("card/form", :erb) %>
32
+ <% end %>
33
+
34
+ <%= render_example %>
35
+
36
+ <% content_for :examples, flush: true do %>
37
+ <%= render "examples/components/card/code/notifications" %>
38
+ <% end %>
39
+
40
+ <% content_for :code, flush: true do %>
41
+ <%= code_partial("card/notifications", :erb) %>
42
+ <% end %>
155
43
 
156
- <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"><a href="/docs/components/dialog#usage">Usage</a></h2>
44
+ <%= render_example %>
@@ -0,0 +1,9 @@
1
+ <p class="leading-7 [&:not(:first-child)]:mt-6">The Checkbox component introduces:</p>
2
+
3
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
4
+ <li><%= code("app/helpers/components/checkbox_helper.rb") %></li>
5
+ <li><%= code("app/views/components/ui/_checkbox.html.erb") %></li>
6
+ <li><%= code("app/javascript/controllers/ui/checkbox_controller.js") %></li>
7
+ </ul>
8
+
9
+ <p class="leading-7 [&:not(:first-child)]:mt-6"><%= code("render_checkbox") %> accepts two required arguments, one for the <%= code("name:") %> of the checkbox which will pair with <%= code("label:") %> of the checkbox. The toggle functionality is controller by <%= code("app/javascript/controllers/ui/checkbox_controller.js") %>.</p>
@@ -0,0 +1,2 @@
1
+ <%= render_checkbox name: "terms",
2
+ label: "Accept terms and conditions" %>
@@ -0,0 +1 @@
1
+ <%= render_checkbox(label:, name:) %>