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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -0
  3. data/.prettierrc.json +6 -0
  4. data/README.md +260 -0
  5. data/Rakefile +6 -3
  6. data/app/assets/stylesheets/{application.scss → application.css} +0 -27
  7. data/app/assets/stylesheets/application.tailwind.css +46 -73
  8. data/app/assets/stylesheets/shadcn.css +216 -0
  9. data/app/controllers/components_controller.rb +1 -1
  10. data/app/controllers/documentation_controller.rb +10 -0
  11. data/app/helpers/application_helper.rb +19 -0
  12. data/app/helpers/components/accordion_helper.rb +14 -1
  13. data/app/helpers/components/alert_helper.rb +4 -2
  14. data/app/helpers/components/button_helper.rb +2 -1
  15. data/app/helpers/components/card_helper.rb +2 -2
  16. data/app/helpers/components/checkbox_helper.rb +2 -2
  17. data/app/helpers/components/collapsible_helper.rb +8 -0
  18. data/app/helpers/components/filter_helper.rb +12 -0
  19. data/app/helpers/components/input_helper.rb +21 -0
  20. data/app/helpers/components/label_helper.rb +5 -0
  21. data/app/helpers/components/list_helper.rb +15 -0
  22. data/app/helpers/components/progress_helper.rb +5 -0
  23. data/app/helpers/components/sheet_helper.rb +29 -0
  24. data/app/helpers/components/skeleton_helper.rb +5 -0
  25. data/app/helpers/components/slider_helper.rb +5 -0
  26. data/app/helpers/components_helper.rb +11 -0
  27. data/app/helpers/documentation_helper.rb +2 -0
  28. data/app/helpers/examples_helper.rb +1 -2
  29. data/app/javascript/controllers/theme_controller.js +25 -0
  30. data/app/javascript/controllers/ui/dialog_controller.js +3 -1
  31. data/app/javascript/controllers/ui/dropdown_controller.js +2 -22
  32. data/app/javascript/controllers/ui/filter_controller.js +20 -0
  33. data/app/javascript/controllers/ui/popover_controller.js +29 -1
  34. data/app/javascript/controllers/ui/sheet_controller.js +33 -0
  35. data/app/javascript/controllers/ui/slider_controller.js +14 -0
  36. data/app/javascript/controllers/ui/tooltip_controller.js +1 -1
  37. data/app/views/application/index.html.erb +122 -0
  38. data/app/views/components/ui/_accordion.html.erb +2 -2
  39. data/app/views/components/ui/_alert.html.erb +15 -3
  40. data/app/views/components/ui/_alert_dialog.html.erb +1 -1
  41. data/app/views/components/ui/_card.html.erb +2 -2
  42. data/app/views/components/ui/_checkbox.html.erb +3 -7
  43. data/app/views/components/ui/_collapsible.html.erb +2 -6
  44. data/app/views/components/ui/_command.html.erb +0 -0
  45. data/app/views/components/ui/_dialog.html.erb +1 -1
  46. data/app/views/components/ui/_filter.html.erb +14 -0
  47. data/app/views/components/ui/_input.html.erb +8 -0
  48. data/app/views/components/ui/_label.html.erb +3 -0
  49. data/app/views/components/ui/_list.html.erb +5 -0
  50. data/app/views/components/ui/_progress.html.erb +15 -0
  51. data/app/views/components/ui/_sheet.html.erb +44 -0
  52. data/app/views/components/ui/_skeleton.html.erb +1 -0
  53. data/app/views/components/ui/_slider.html.erb +2 -0
  54. data/app/views/components/ui/_textarea.html.erb +1 -1
  55. data/app/views/components/ui/shared/{_dialog_background.html.erb → _backdrop.html.erb} +1 -0
  56. data/app/views/components/ui/svg/_check.html.erb +11 -0
  57. data/app/views/documentation/about.html.md +20 -0
  58. data/app/views/documentation/generators.html.md +1 -0
  59. data/app/views/documentation/index.html.erb.bak +70 -0
  60. data/app/views/documentation/index.html.md +37 -0
  61. data/app/views/documentation/installation.html.md +377 -0
  62. data/app/views/examples/components/accordion/_usage.html.erb +15 -0
  63. data/app/views/examples/components/accordion/code/_block.html.erb +8 -0
  64. data/app/views/examples/components/accordion/code/_description.html.erb +7 -0
  65. data/app/views/examples/components/accordion/code/preview.erb +3 -0
  66. data/app/views/examples/components/accordion/code/usage.erb +16 -0
  67. data/app/views/examples/components/accordion.html.erb +36 -0
  68. data/app/views/examples/components/alert/_usage.html.erb +10 -0
  69. data/app/views/examples/components/alert/code/_attention.erb +3 -0
  70. data/app/views/examples/components/alert/code/_destructive.erb +2 -0
  71. data/app/views/examples/components/alert/code/_info.erb +3 -0
  72. data/app/views/examples/components/alert/code/_no_icon.erb +3 -0
  73. data/app/views/examples/components/alert/code/_success.erb +3 -0
  74. data/app/views/examples/components/alert/code/preview.erb +2 -0
  75. data/app/views/examples/components/alert/code/usage.erb +1 -0
  76. data/app/views/examples/components/alert.html.erb +90 -7
  77. data/app/views/examples/components/badge/_usage.html.erb +10 -0
  78. data/app/views/examples/components/badge/code/preview.erb +5 -0
  79. data/app/views/examples/components/badge/code/usage.erb +1 -0
  80. data/app/views/examples/components/badge.html.erb +11 -4
  81. data/app/views/examples/components/button/_usage.html.erb +19 -0
  82. data/app/views/examples/components/button/code/preview.erb +13 -0
  83. data/app/views/examples/components/button/code/usage.erb +6 -0
  84. data/app/views/examples/components/button.html.erb +20 -6
  85. data/app/views/examples/components/card/_usage.html.erb +21 -0
  86. data/app/views/examples/components/card/code/_form.erb +72 -0
  87. data/app/views/examples/components/card/code/_notifications.erb +61 -0
  88. data/app/views/examples/components/card/code/preview.erb +6 -0
  89. data/app/views/examples/components/card/code/usage.erb +3 -0
  90. data/app/views/examples/components/card.html.erb +35 -143
  91. data/app/views/examples/components/checkbox/_usage.html.erb +9 -0
  92. data/app/views/examples/components/checkbox/code/preview.erb +2 -0
  93. data/app/views/examples/components/checkbox/code/usage.erb +1 -0
  94. data/app/views/examples/components/checkbox.html.erb +14 -0
  95. data/app/views/examples/components/collapsible/_usage.html.erb +16 -0
  96. data/app/views/examples/components/collapsible/code/preview.erb +9 -0
  97. data/app/views/examples/components/collapsible/code/usage.erb +7 -0
  98. data/app/views/examples/components/collapsible.html.erb +13 -3
  99. data/app/views/examples/components/dialog.html.erb +1 -1
  100. data/app/views/examples/components/filter.html.erb +25 -0
  101. data/app/views/examples/components/input.html.erb +18 -0
  102. data/app/views/examples/components/label.html.erb +13 -0
  103. data/app/views/examples/components/progress.html.erb +12 -0
  104. data/app/views/examples/components/sheet.html.erb +19 -0
  105. data/app/views/examples/components/skeleton.html.erb +12 -0
  106. data/app/views/examples/components/slider.html.erb +12 -0
  107. data/app/views/layouts/application.html.erb +2 -3
  108. data/app/views/layouts/component.html.erb +2 -2
  109. data/app/views/layouts/documentation.html.erb +39 -0
  110. data/app/views/layouts/shared/_components.html.erb +62 -0
  111. data/app/views/layouts/shared/_header.html.erb +25 -33
  112. data/app/views/layouts/shared/_sidebar.html.erb +10 -0
  113. data/config/application.rb +2 -1
  114. data/config/importmap.rb +6 -6
  115. data/config/initializers/markdown.rb +24 -0
  116. data/config/routes.rb +7 -1
  117. data/config/shadcn.tailwind.js +98 -0
  118. data/config/tailwind.config.js +13 -74
  119. data/lib/components.json +305 -0
  120. data/lib/generators/shadcn-ui_generator.rb +201 -0
  121. data/lib/shadcn-ui/version.rb +1 -1
  122. data/package-lock.json +90 -3
  123. data/package.json +4 -0
  124. data/public/accordion.png +0 -0
  125. metadata +81 -7
  126. data/app/views/layouts/_sidebar.html.erb +0 -270
  127. data/lib/generators/shadcn_ui_generator.rb +0 -32
  128. /data/app/assets/stylesheets/{lambda.light.scss → lambda.light.css} +0 -0
@@ -0,0 +1,377 @@
1
+ # Installation
2
+
3
+ The more automated way to install the components into your application is via the gem packaged
4
+ within this application. The gem provides generators that will setup your applications as best as
5
+ possible without potentially overwriting any existing code as well as copy components and their
6
+ dependencies to your application.
7
+
8
+ ## Add the Gem
9
+
10
+ First step is adding the gem to your gemfile.
11
+
12
+ ```sh
13
+ bundle add shadcn-ui
14
+ bundle install
15
+ ```
16
+
17
+ ## Install and Setup Dependencies
18
+
19
+ ### TailwindCSS
20
+
21
+ The components need a few things in order to render and function properly
22
+
23
+ 1. Tailwindcss must be installed in your application. If it's not already, I recommend just using
24
+ the `tailwindcss-rails` gem and running its installer to bootstrap your application with
25
+ TailwindCSS.
26
+
27
+ 2. A few tailwindcss npm packages are required by the theme and the best way to get them is to add
28
+ them to your package.json or even if you're application doesn't use node packages because you use
29
+ importmaps or something else, having a package.json will still work only to allow the tailwind
30
+ cli to compile the themes. The easiest way I've found to include everything you need is by
31
+ including only one package that will include the rest of them, `tailwind-animate`. Create a
32
+ package.json if you need via `echo '{}' >> package.json`.
33
+
34
+ ```
35
+ npm install -D tailwind-animate
36
+ ```
37
+
38
+ These are the requirements if you want to add them individually:
39
+
40
+ ```
41
+ @tailwindcss/forms
42
+ @tailwindcss/aspect-ratio
43
+ @tailwindcss/typography
44
+ @tailwindcss/container-queries
45
+ tailwindcss-animate
46
+ ```
47
+
48
+ ### shadcn CSS - Required
49
+
50
+ #### shadcn.css
51
+
52
+ These steps were not automated and are required to be done manually.
53
+
54
+ The components also require a few CSS variables to be set in order to render properly. It's a two
55
+ step process, first, the gem installation should have added `app/assets/stylesheets/shadcn.css` to
56
+ your application. You need to make sure this is included within `application.tailwind.css`, which
57
+ should have happened automatically, but double check.
58
+
59
+ ```
60
+ @import "shadcn.css";
61
+ @tailwind base;
62
+ @tailwind components;
63
+ @tailwind utilities;
64
+ ```
65
+
66
+ #### shadcn.tailwind.js
67
+
68
+ The installation also should have added a `config/shadcn.tailwind.js` file to your application. This
69
+ file is required to be included in your `tailwind.config.js` file. The best way to include it is to
70
+ `require` it in your `tailwind.config.js` file and expand the configuration settings. This is what a
71
+ newly setup `tailwind.config.js` file should look like after the inclusion of the
72
+ `shadcn.tailwind.js` settings.
73
+
74
+ ```js
75
+ const defaultTheme = require("tailwindcss/defaultTheme");
76
+ const shadcnConfig = require("./shadcn.tailwind.js");
77
+
78
+ module.exports = {
79
+ content: [
80
+ "./public/*.html",
81
+ "./app/helpers/**/*.rb",
82
+ "./app/javascript/**/*.js",
83
+ "./app/views/**/*.{erb,haml,html,slim}",
84
+ ],
85
+ theme: {
86
+ extend: {
87
+ fontFamily: {
88
+ sans: ["Inter var", ...defaultTheme.fontFamily.sans],
89
+ },
90
+ },
91
+ },
92
+ plugins: [
93
+ require("@tailwindcss/forms"),
94
+ require("@tailwindcss/aspect-ratio"),
95
+ require("@tailwindcss/typography"),
96
+ require("@tailwindcss/container-queries"),
97
+ ],
98
+ ...shadcnConfig,
99
+ };
100
+ ```
101
+
102
+ You could also just use the shadcnConfig as the default Tailwind settings needed are also defined
103
+ there..
104
+
105
+ ```js
106
+ const shadcnConfig = require("./shadcn.tailwind.js");
107
+
108
+ module.exports = {
109
+ ...shadcnConfig,
110
+ };
111
+ ```
112
+
113
+ After that feel free to add further customizatios to your tailwind config. For an existing tailwind
114
+ config, just add shadcnConfig to the end of the config object. It will override any settings needed
115
+ by being at the end. And obviously feel free to inspect shadcnConfig and keep only what's reui
116
+
117
+ ## End
118
+
119
+ That's it! You are now set to start
120
+ [installing components via the generator]("/documentation/generators") and rendering them into your
121
+ views.
122
+
123
+ # Manual Installation
124
+
125
+ Prior to the initial gem release, you can use this as an alpha by cloning this repository and
126
+ starting up the app as you would a standard rails app.
127
+
128
+ ```sh
129
+ git clone https://github.com/aviflombaum/shadcn-rails.git
130
+ cd shadcn-rails
131
+ bundle install
132
+ ./bin/dev
133
+ ```
134
+
135
+ There are very few dependencies and no database so it should just boot up. Visit
136
+ http://localhost:3000 to see the demo app which is also the documentation. You'll be able to browse
137
+ the components at http://localhost:3000/components.
138
+
139
+ If there's a component you want to try in your app, you will be copying the code from this app to
140
+ yours. There's a few other steps you'll need.
141
+
142
+ ## Installing a Component
143
+
144
+ ### Add Tailwind CSS
145
+
146
+ Components are styled using Tailwind CSS. You need to install Tailwind CSS in your project.
147
+
148
+ [Follow the Tailwind CSS installation instructions to get started.](https://tailwindcss.com/docs/installation)
149
+
150
+ ### Add dependencies
151
+
152
+ If you haven't already, install Tailwind into your rails application by adding `tailwindcss-rails`
153
+ to your `Gemfile` and install tailwind into your app:
154
+
155
+ ```sh
156
+ ./bin/bundle add tailwindcss-rails
157
+ ./bin/rails tailwindcss:install
158
+ ```
159
+
160
+ Then install ./bin/rails tailwindcss:install
161
+
162
+ ### Configure tailwind.config.js
163
+
164
+ Here's what my `tailwind.config.js` file looks like:
165
+
166
+ ```js
167
+ const defaultTheme = require("tailwindcss/defaultTheme");
168
+
169
+ module.exports = {
170
+ darkMode: ["class"],
171
+ content: [
172
+ "./public/*.html",
173
+ "./app/helpers/**/*.rb",
174
+ "./app/javascript/**/*.js",
175
+ "./app/views/**/*.{erb,haml,html,slim}",
176
+ ],
177
+ theme: {
178
+ container: {
179
+ center: true,
180
+ padding: "2rem",
181
+ screens: {
182
+ "2xl": "1400px",
183
+ },
184
+ },
185
+ extend: {
186
+ colors: {
187
+ border: "hsl(var(--border))",
188
+ input: "hsl(var(--input))",
189
+ ring: "hsl(var(--ring))",
190
+ background: "hsl(var(--background))",
191
+ foreground: "hsl(var(--foreground))",
192
+ primary: {
193
+ DEFAULT: "hsl(var(--primary))",
194
+ foreground: "hsl(var(--primary-foreground))",
195
+ },
196
+ secondary: {
197
+ DEFAULT: "hsl(var(--secondary))",
198
+ foreground: "hsl(var(--secondary-foreground))",
199
+ },
200
+ destructive: {
201
+ DEFAULT: "hsl(var(--destructive))",
202
+ foreground: "hsl(var(--destructive-foreground))",
203
+ },
204
+ muted: {
205
+ DEFAULT: "hsl(var(--muted))",
206
+ foreground: "hsl(var(--muted-foreground))",
207
+ },
208
+ accent: {
209
+ DEFAULT: "hsl(var(--accent))",
210
+ foreground: "hsl(var(--accent-foreground))",
211
+ },
212
+ popover: {
213
+ DEFAULT: "hsl(var(--popover))",
214
+ foreground: "hsl(var(--popover-foreground))",
215
+ },
216
+ card: {
217
+ DEFAULT: "hsl(var(--card))",
218
+ foreground: "hsl(var(--card-foreground))",
219
+ },
220
+ },
221
+ borderRadius: {
222
+ lg: "var(--radius)",
223
+ md: "calc(var(--radius) - 2px)",
224
+ sm: "calc(var(--radius) - 4px)",
225
+ },
226
+ fontFamily: {
227
+ sans: ["var(--font-sans)", ...defaultTheme.fontFamily.sans],
228
+ },
229
+ keyframes: {
230
+ "accordion-down": {
231
+ from: { height: 0 },
232
+ to: { height: "var(--radix-accordion-content-height)" },
233
+ },
234
+ "accordion-up": {
235
+ from: { height: "var(--radix-accordion-content-height)" },
236
+ to: { height: 0 },
237
+ },
238
+ },
239
+ animation: {
240
+ "accordion-down": "accordion-down 0.2s ease-out",
241
+ "accordion-up": "accordion-up 0.2s ease-out",
242
+ },
243
+ },
244
+ },
245
+ plugins: [
246
+ require("@tailwindcss/forms"),
247
+ require("@tailwindcss/aspect-ratio"),
248
+ require("@tailwindcss/typography"),
249
+ require("@tailwindcss/container-queries"),
250
+ require("tailwindcss-animate"),
251
+ ],
252
+ };
253
+ ```
254
+
255
+ ### Configure styles
256
+
257
+ Add the following to your app/assets/stylesheets/application.tailwind.css file.
258
+
259
+ ```css
260
+ @tailwind base;
261
+ @tailwind components;
262
+ @tailwind utilities;
263
+
264
+ @layer base {
265
+ :root {
266
+ --background: 0 0% 100%;
267
+ --foreground: 222.2 47.4% 11.2%;
268
+
269
+ --muted: 210 40% 96.1%;
270
+ --muted-foreground: 215.4 16.3% 46.9%;
271
+
272
+ --popover: 0 0% 100%;
273
+ --popover-foreground: 222.2 47.4% 11.2%;
274
+
275
+ --border: 214.3 31.8% 91.4%;
276
+ --input: 214.3 31.8% 91.4%;
277
+
278
+ --card: 0 0% 100%;
279
+ --card-foreground: 222.2 47.4% 11.2%;
280
+
281
+ --primary: 222.2 47.4% 11.2%;
282
+ --primary-foreground: 210 40% 98%;
283
+
284
+ --secondary: 210 40% 96.1%;
285
+ --secondary-foreground: 222.2 47.4% 11.2%;
286
+
287
+ --accent: 210 40% 96.1%;
288
+ --accent-foreground: 222.2 47.4% 11.2%;
289
+
290
+ --destructive: 0 100% 50%;
291
+ --destructive-foreground: 210 40% 98%;
292
+
293
+ --ring: 215 20.2% 65.1%;
294
+
295
+ --radius: 0.5rem;
296
+ }
297
+
298
+ .dark {
299
+ --background: 224 71% 4%;
300
+ --foreground: 213 31% 91%;
301
+
302
+ --muted: 223 47% 11%;
303
+ --muted-foreground: 215.4 16.3% 56.9%;
304
+
305
+ --accent: 216 34% 17%;
306
+ --accent-foreground: 210 40% 98%;
307
+
308
+ --popover: 224 71% 4%;
309
+ --popover-foreground: 215 20.2% 65.1%;
310
+
311
+ --border: 216 34% 17%;
312
+ --input: 216 34% 17%;
313
+
314
+ --card: 224 71% 4%;
315
+ --card-foreground: 213 31% 91%;
316
+
317
+ --primary: 210 40% 98%;
318
+ --primary-foreground: 222.2 47.4% 1.2%;
319
+
320
+ --secondary: 222.2 47.4% 11.2%;
321
+ --secondary-foreground: 210 40% 98%;
322
+
323
+ --destructive: 0 63% 31%;
324
+ --destructive-foreground: 210 40% 98%;
325
+
326
+ --ring: 216 34% 17%;
327
+
328
+ --radius: 0.5rem;
329
+ }
330
+ }
331
+
332
+ @layer base {
333
+ * {
334
+ @apply border-border;
335
+ }
336
+ body {
337
+ @apply bg-background text-foreground;
338
+ font-feature-settings:
339
+ "rlig" 1,
340
+ "calt" 1;
341
+ }
342
+ }
343
+ ```
344
+
345
+ ### Copy Component Files
346
+
347
+ For example, if you want to use the Accordion component, you would copy the following files to your
348
+ application:
349
+
350
+ - `app/javascript/controllers/components/ui/accordion_controller.js` The Stimulus controller for any
351
+ component that requires javascript.
352
+ - `app/helpers/components/accordion_helper.rb` The helper for the component that allows for easy
353
+ rendering within views.
354
+ - `app/views/components/ui/_accordion.html.erb` The html for the component.
355
+
356
+ Once those are copied in your application you can render an accordion with:
357
+
358
+ ```
359
+ <%%= render_accordion title: "Did you know?",
360
+ description: "You can wrap shadcn helpers in any
361
+ component library you want!" %>
362
+ ```
363
+
364
+ Result:
365
+
366
+ <img src="/accordion.png" alt="Example of Accordion" />
367
+
368
+ See the component's demo page in `app/views/examples/components/accordion.html.erb` for more
369
+ examples.
370
+
371
+ This will be similar for each component.
372
+
373
+ # Conclusion
374
+
375
+ You can freely mix and match both styles as your application evolves. The end goal of each of them
376
+ is to get the component code into your application so you can further customize and take ownership
377
+ of your design system.
@@ -0,0 +1,15 @@
1
+ <p class="leading-7 [&:not(:first-child)]:mt-6">The Accordion component introduces:</p>
2
+
3
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
4
+ <li><%= code("app/helpers/components/accordion_helper.rb") %></li>
5
+ <li><%= code("app/views/components/ui/_accordion.html.erb") %></li>
6
+ <li><%= code("app/javascript/controllers/ui/accordion_controller.js") %></li>
7
+ </ul>
8
+
9
+ <p class="leading-7 [&:not(:first-child)]:mt-6">
10
+ The method <%= code("render_accordion") %> defined in <%= code("app/helpers/components/accordion_helper.rb") %>
11
+ accepts a <%= code("title:") %> and <%= code("description:") %> keyword arguments in the inline usage.</p>
12
+
13
+ <p class="leading-7 [&:not(:first-child)]:mt-6">When passed only a <%= code("title") %> argument, the helper will accept a block to be rendered as the content for the description.</p>
14
+
15
+ <p class="leading-7 [&:not(:first-child)]:mt-6">When passed no arguments, the block passed to the accordion helper must call <%= code("accordion_title") %> and <%= code("accordion_description") %> both of which accept blocks for the content for those portals within the component.</p>
@@ -0,0 +1,8 @@
1
+ <%= render_accordion do %>
2
+ <%= accordion_title do %>
3
+ <em>If you need to customize the title</em>
4
+ <% end %>
5
+ <%= accordion_description do %>
6
+ Use the full block format.
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= render_accordion title: "Embed components in the description of an accordion" do %>
2
+ <%= accordion_description do %>
3
+ <%= render_card title: "A Simple Card", class: "w-full" do %>
4
+ <p class="p-6">But it could be anything really, give it a try.</p>
5
+ <% end %>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= render_accordion title: "Did you know?", description: "You can wrap shadcn helpers in any
2
+ component library you want!" %>
3
+ <%= render_accordion title: "Use the generators.", description: "Add components with #{code("rails g shadcn_ui add accordion")}".html_safe %>
@@ -0,0 +1,16 @@
1
+ # Inline
2
+ <%= render_accordion(title:, :description) %>
3
+
4
+ # Description Block
5
+ <%= render_accordion(title:) do %>
6
+
7
+ <% end %>
8
+
9
+ # Title and Description Block
10
+ <% render_accordion do %>
11
+ <%= content_for :title do e%>
12
+ <% end %>
13
+
14
+ <%= content_for :description do e%>
15
+ <% end %>
16
+ <% end %>
@@ -10,8 +10,44 @@
10
10
  </div>
11
11
  <% end %>
12
12
 
13
+ <% content_for :code, flush: true do %>
14
+ <%= code_partial("accordion/code/preview", :erb) %>
15
+ <% end %>
16
+
13
17
  <%= render_preview %>
14
18
 
15
19
  <h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
16
20
 
21
+ <%= code_sample(language: "sh") do %>
22
+ rails generate shadcn-ui accodordion
23
+ <% end %>
24
+
17
25
  <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>
26
+
27
+ <%= code_partial("accordion/code/usage", :erb) %>
28
+
29
+ <%= render_usage("accordion") %>
30
+
31
+ <% content_for :examples, flush: true do %>
32
+ <div class="w-full flex justify-center">
33
+ <%= render "examples/components/accordion/code/description" %>
34
+ </div>
35
+ <% end %>
36
+
37
+ <% content_for :code, flush: true do %>
38
+ <%= code_partial("accordion/code/_description.html", :erb) %>
39
+ <% end %>
40
+
41
+ <%= render_example %>
42
+
43
+ <% content_for :examples, flush: true do %>
44
+ <div class="w-full flex justify-center">
45
+ <%= render "examples/components/accordion/code/block" %>
46
+ </div>
47
+ <% end %>
48
+
49
+ <% content_for :code, flush: true do %>
50
+ <%= code_partial("accordion/code/_block.html", :erb) %>
51
+ <% end %>
52
+
53
+ <%= render_example %>
@@ -0,0 +1,10 @@
1
+ <p class="leading-7 [&:not(:first-child)]:mt-6">The Alert component introduces:</p>
2
+
3
+ <ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
4
+ <li><%= code("app/helpers/components/alert_helper.rb") %></li>
5
+ <li><%= code("app/views/components/ui/_alert.html.erb") %></li>
6
+ </ul>
7
+
8
+ <p class="leading-7 [&:not(:first-child)]:mt-6">
9
+ The method <%= code("render_alert") %> defined in <%= code("app/helpers/components/alert_helper.rb") %>
10
+ accepts a <%= code("title:") %> and <%= code("description:") %> required keyword arguments along with an optional <%= code("variant:") %> argument for the kind of alert to render. Skip the icon by setting the optional argument <%= code("icon:") %> to <%= code("false") %>.</p>
@@ -0,0 +1,3 @@
1
+
2
+ <%= render_alert(variant: :attention, title: "Attention",
3
+ description: "This variant is :attention") %>
@@ -0,0 +1,2 @@
1
+ <%= render_alert(variant: :error, title: "Error",
2
+ description: "This variant is :error, :danger, :alert, :destructive") %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= render_alert(variant: :info, title: "Info",
3
+ description: "This variant is :info") %>
@@ -0,0 +1,3 @@
1
+ <% %><%= render_alert icon: false,
2
+ title: "Skip the Icon",
3
+ description: "By setting icon: to false in your render_alert call." %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= render_alert(variant: :success, title: "Success",
3
+ description: "This variant is :success") %>
@@ -0,0 +1,2 @@
1
+ <%= render_alert title: "Did you know?",
2
+ description: "You can wrap shadcn helpers in any component library you want!" %>
@@ -0,0 +1 @@
1
+ <%= render_alert title:, description:, variant: %>
@@ -4,19 +4,102 @@
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
7
+ <div class="w-full">
8
+ <%= render_alert title: "Did you know?", description: "You can wrap shadcn helpers in any
9
9
  component library you want!" %>
10
- </div>
10
+ </div>
11
+ <% end %>
11
12
 
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>
13
+ <% content_for :code, flush: true do %>
14
+ <%= code_partial("alert/code/preview", :erb) %>
16
15
  <% end %>
17
16
 
18
17
  <%= render_preview %>
19
18
 
20
19
  <h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
20
+ <%= code_sample(language: "sh") do %>
21
+ rails generate shadcn-ui accodordion
22
+ <% end %>
21
23
 
22
24
  <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
+
26
+ <%= code_partial("alert/code/usage", :erb) %>
27
+
28
+ <%= render_usage("alert") %>
29
+
30
+ <% content_for :examples, flush: true do %>
31
+ <div class="w-full flex justify-center">
32
+ <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">
33
+ <svg class="h-4 w-4 text-success" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
34
+ <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>
35
+ </svg>
36
+ <h5 class="mb-1 font-medium leading-none tracking-tight">Success</h5>
37
+ <div class="text-sm [&amp;_p]:leading-relaxed">This variant is :success</div>
38
+ </div>
39
+ </div>
40
+ <% end %>
41
+
42
+ <% content_for :code, flush: true do %>
43
+ <%= code_partial("alert/code/_success", :erb) %>
44
+ <% end %>
45
+ <%= render_example %>
46
+
47
+ <% content_for :examples, flush: true do %>
48
+ <div class="w-full flex justify-center">
49
+ <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">
50
+ <svg class="h-4 w-4 text-info" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
51
+ <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>
52
+ </svg>
53
+ <h5 class="mb-1 font-medium leading-none tracking-tight">Info</h5>
54
+ <div class="text-sm [&amp;_p]:leading-relaxed">This variant is :info</div>
55
+ </div>
56
+ </div>
57
+ <% end %>
58
+
59
+ <% content_for :code, flush: true do %>
60
+ <%= code_partial("alert/code/_info", :erb) %>
61
+ <% end %>
62
+
63
+ <%= render_example %>
64
+
65
+ <% content_for :examples, flush: true do %>
66
+ <div class="w-full flex justify-center">
67
+ <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">
68
+ <svg class="h-4 w-4 text-attention" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
69
+ <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>
70
+ </svg>
71
+ <h5 class="mb-1 font-medium leading-none tracking-tight">Attention</h5>
72
+ <div class="text-sm [&amp;_p]:leading-relaxed">This variant is :attention</div>
73
+ </div>
74
+ </div>
75
+ <% end %>
76
+
77
+ <% content_for :code, flush: true do %>
78
+ <%= code_partial("alert/code/_attention", :erb) %>
79
+ <% end %>
80
+
81
+ <%= render_example %>
82
+
83
+ <% content_for :examples, flush: true do %>
84
+ <div class="w-full flex justify-center">
85
+ <%= render "examples/components/alert/code/destructive" %>
86
+ </div>
87
+ <% end %>
88
+
89
+ <% content_for :code, flush: true do %>
90
+ <%= code_partial("alert/code/_destructive", :erb) %>
91
+ <% end %>
92
+
93
+ <%= render_example %>
94
+
95
+ <% content_for :examples, flush: true do %>
96
+ <div class="w-full flex justify-center">
97
+ <%= render "examples/components/alert/code/no_icon" %>
98
+ </div>
99
+ <% end %>
100
+
101
+ <% content_for :code, flush: true do %>
102
+ <%= code_partial("alert/code/_no_icon", :erb) %>
103
+ <% end %>
104
+
105
+ <%= 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: %>