shadcn-ui 0.0.3 → 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/app/controllers/documentation_controller.rb +0 -1
- data/app/helpers/components/input_helper.rb +1 -1
- data/app/helpers/components/slider_helper.rb +1 -1
- data/app/helpers/examples_helper.rb +6 -1
- 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/_card.html.erb +7 -1
- data/app/views/components/ui/_filter.html.erb +2 -1
- data/app/views/documentation/generators.html.md +20 -0
- data/app/views/documentation/helpers.html.md +54 -0
- data/app/views/documentation/javascript.html.md +8 -0
- data/app/views/examples/components/accordion.html.erb +5 -7
- 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 +9 -10
- data/app/views/examples/components/badge.html.erb +3 -15
- data/app/views/examples/components/button.html.erb +3 -25
- data/app/views/examples/components/card/code/{preview.erb → _preview.erb} +1 -1
- data/app/views/examples/components/card.html.erb +5 -9
- data/app/views/examples/components/checkbox/code/_preview.erb +2 -0
- data/app/views/examples/components/checkbox.html.erb +3 -3
- data/app/views/examples/components/collapsible.html.erb +3 -11
- data/app/views/examples/components/dialog.html.erb +5 -14
- 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 +35 -33
- data/config/environments/production.rb +4 -4
- data/lib/shadcn-ui/version.rb +1 -1
- metadata +74 -20
- data/app/views/examples/components/checkbox/code/preview.erb +0 -2
- /data/app/views/examples/components/accordion/code/{preview.erb → _preview.erb} +0 -0
- /data/app/views/examples/components/accordion/code/{usage.erb → _usage.erb} +0 -0
- /data/app/views/examples/components/alert/code/{preview.erb → _preview.erb} +0 -0
- /data/app/views/examples/components/alert/code/{usage.erb → _usage.erb} +0 -0
- /data/app/views/examples/components/badge/code/{preview.erb → _preview.erb} +0 -0
- /data/app/views/examples/components/badge/code/{usage.erb → _usage.erb} +0 -0
- /data/app/views/examples/components/button/code/{preview.erb → _preview.erb} +0 -0
- /data/app/views/examples/components/button/code/{usage.erb → _usage.erb} +0 -0
- /data/app/views/examples/components/card/code/{usage.erb → _usage.erb} +0 -0
- /data/app/views/examples/components/checkbox/code/{usage.erb → _usage.erb} +0 -0
- /data/app/views/examples/components/collapsible/code/{preview.erb → _preview.erb} +0 -0
- /data/app/views/examples/components/collapsible/code/{usage.erb → _usage.erb} +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
@@ -8,6 +8,12 @@
|
|
8
8
|
<% end %>
|
9
9
|
</div>
|
10
10
|
<% end %>
|
11
|
-
|
11
|
+
<% if !block && !title %>
|
12
|
+
<%= content_tag( :div, class: "p-6" ){ body } %>
|
13
|
+
<% elsif !block %>
|
14
|
+
<%= content_tag( :div, class: "px-6" ){ body } %>
|
15
|
+
<% else %>
|
16
|
+
<%= body %>
|
17
|
+
<% end %>
|
12
18
|
<% if footer %><footer class="mx-6 mb-6"><%= footer %></footer><% end %>
|
13
19
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div data-controller="ui--filter">
|
2
2
|
<%= render_card do %>
|
3
3
|
<div class="flex items-center">
|
4
|
-
|
4
|
+
<%= content_for :filter_icon %>
|
5
5
|
<%= render_input name: "filter", placeholder: "Filter items...", style: :borderless, class: input_class, data: {"ui--filter-target": "source", action: "input->ui--filter#filter"} %></div>
|
6
6
|
<%= render_separator %>
|
7
7
|
<div class="<%= options[:class] %>">
|
@@ -12,3 +12,4 @@
|
|
12
12
|
end %>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
15
|
+
</div>
|
@@ -1 +1,21 @@
|
|
1
1
|
# Component Generators
|
2
|
+
|
3
|
+
The gem adds generators to your application to help you copy the code from this application into
|
4
|
+
yours.
|
5
|
+
|
6
|
+
Each time you run the generator it will check to make sure you have the prerequisites, like Tailwind
|
7
|
+
and the shadcn stylesheet, and if not, do its best to reconcile that for you.
|
8
|
+
|
9
|
+
After that it will copy the component files into your application. If you edit the component,
|
10
|
+
re-running the generator for it will remove your edits. **Re-running a component generator is
|
11
|
+
basically reinstalling it and overwriting any changes you might have made.**
|
12
|
+
|
13
|
+
The generator will show up in `rails g` and it is called `shadcn-ui`
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```
|
18
|
+
rails generate shadcn-ui <component_name>
|
19
|
+
```
|
20
|
+
|
21
|
+
You can list out the available components from `rails g shadcn-ui`.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Component Helpers
|
2
|
+
|
3
|
+
The main entry point to using the component is always a `render_<component>` method defined in the
|
4
|
+
helper located in `app/helpers/components/<component>_helper.rb`.
|
5
|
+
|
6
|
+
The main responsibility of the component's render method is to ultimatelly render the component's
|
7
|
+
partial, located in `app/views/components/ui/_<component>.html.erb`.
|
8
|
+
|
9
|
+
The component partial generally will integrate all the content passed to the component helper,
|
10
|
+
whether through arguments or blocks.
|
11
|
+
|
12
|
+
The render helper generally takes a hash of arguments, and a block. The arguments are used for
|
13
|
+
required values for the HTML or for the content. Blocks generally correspond to inner content or
|
14
|
+
sections for the component.
|
15
|
+
|
16
|
+
<%= code_partial("dialog/usage", :erb) %>
|
17
|
+
|
18
|
+
Here the `render_dialog` helper takes a block, and the block is used to render the `dialog_trigger`
|
19
|
+
within the corresponding DOM along with the `dialog_content` as a sibling.
|
20
|
+
|
21
|
+
Inner content is generally rendered with a `content_for` call, and the component render method will
|
22
|
+
yield to the block, capture the content, and pass it along to the main partial.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
module Components::DialogHelper
|
26
|
+
def render_dialog(**options, &block)
|
27
|
+
content = capture(&block) if block
|
28
|
+
render "components/ui/dialog", content: content, **options
|
29
|
+
end
|
30
|
+
|
31
|
+
def dialog_trigger(&block)
|
32
|
+
content_for :dialog_trigger, capture(&block), flush: true
|
33
|
+
end
|
34
|
+
|
35
|
+
def dialog_content(&block)
|
36
|
+
content_for :dialog_content, capture(&block), flush: true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
That is a pretty standard example of how the components work. The component partial is responsible
|
42
|
+
for the end result HTML.
|
43
|
+
|
44
|
+
## Options
|
45
|
+
|
46
|
+
Most of the components accept a variaty of DOM/HTML/Data related options. Sometimes these are
|
47
|
+
explcitly defined in the render method, and sometimes they are globed as an `**options` argument.
|
48
|
+
This should be standardized. As much as possible, I've tried to ensure that these are correctly
|
49
|
+
accounted for and passed along to the final html/dom elements, but I imagine that is not the case
|
50
|
+
everywhere. **Would love it if you raised an issue when you find this.**
|
51
|
+
|
52
|
+
## Standardiziation
|
53
|
+
|
54
|
+
As I add more components and see edge cases, I will move to standardizing the API.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Stimulus Controllers
|
2
|
+
|
3
|
+
Many components are paired with a stimulus controller that lives in
|
4
|
+
`app/javascript/controllers/ui/<component>_controller.js`. As much as possible I try to avoid adding
|
5
|
+
depedencies and currently this application is managing them with importmaps and I'm pretty sure if
|
6
|
+
you're not using importmaps, this breaks.
|
7
|
+
|
8
|
+
The Stimulus controllers frankly need a lot of work.
|
@@ -4,14 +4,12 @@
|
|
4
4
|
|
5
5
|
<% content_for :preview, flush: true do %>
|
6
6
|
<div class="w-full">
|
7
|
-
<%=
|
8
|
-
component library you want!" %>
|
9
|
-
<%= render_accordion title: "Use the generators.", description: "Add components with #{code("rails g shadcn_ui add accordion")}".html_safe %>
|
7
|
+
<%= render_code_preview('accordion') %>
|
10
8
|
</div>
|
11
9
|
<% end %>
|
12
10
|
|
13
11
|
<% content_for :code, flush: true do %>
|
14
|
-
<%= code_partial("accordion/
|
12
|
+
<%= code_partial("accordion/preview", :erb) %>
|
15
13
|
<% end %>
|
16
14
|
|
17
15
|
<%= render_preview %>
|
@@ -24,7 +22,7 @@ rails generate shadcn-ui accodordion
|
|
24
22
|
|
25
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>
|
26
24
|
|
27
|
-
<%= code_partial("accordion/
|
25
|
+
<%= code_partial("accordion/usage", :erb) %>
|
28
26
|
|
29
27
|
<%= render_usage("accordion") %>
|
30
28
|
|
@@ -35,7 +33,7 @@ rails generate shadcn-ui accodordion
|
|
35
33
|
<% end %>
|
36
34
|
|
37
35
|
<% content_for :code, flush: true do %>
|
38
|
-
<%= code_partial("accordion/
|
36
|
+
<%= code_partial("accordion/description.html", :erb) %>
|
39
37
|
<% end %>
|
40
38
|
|
41
39
|
<%= render_example %>
|
@@ -47,7 +45,7 @@ rails generate shadcn-ui accodordion
|
|
47
45
|
<% end %>
|
48
46
|
|
49
47
|
<% content_for :code, flush: true do %>
|
50
|
-
<%= code_partial("accordion/
|
48
|
+
<%= code_partial("accordion/block.html", :erb) %>
|
51
49
|
<% end %>
|
52
50
|
|
53
51
|
<%= render_example %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= render_alert_dialog(
|
2
|
+
trigger: render_button("Open Dialog", variant: :outline, data: {action: "ui--dialog#open" }),
|
3
|
+
continue: render_button("Continue"),
|
4
|
+
label: "Are you absolutely sure?",
|
5
|
+
description: "This action cannot be undone. This will permanently delete your account and remove your data from our servers.",
|
6
|
+
) %>
|
File without changes
|
@@ -3,22 +3,19 @@
|
|
3
3
|
title: "Alert Dialog",
|
4
4
|
description: "A modal dialog that interrupts the user with important content and expects a response." %>
|
5
5
|
|
6
|
-
|
7
|
-
<div class="w-full flex justify-center">
|
8
|
-
|
6
|
+
<% content_for :preview, flush: true do %>
|
7
|
+
<div class="w-full flex justify-center">
|
8
|
+
<%= render_code_preview('alert-dialog') %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
9
11
|
|
10
|
-
|
11
|
-
<%=
|
12
|
-
trigger: render_button("Open Dialog", variant: :outline, data: {action: "ui--dialog#open" }),
|
13
|
-
continue: render_button("Continue"),
|
14
|
-
label: "Are you absolutely sure?",
|
15
|
-
description: "This action cannot be undone. This will permanently delete your account and remove your data from our servers.",
|
16
|
-
) %>
|
17
|
-
</div>
|
12
|
+
<% content_for :code, flush: true do %>
|
13
|
+
<%= code_partial("alert-dialog/preview", :erb) %>
|
18
14
|
<% end %>
|
19
15
|
|
20
16
|
<%= render_preview %>
|
21
17
|
|
18
|
+
|
22
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>
|
23
20
|
|
24
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"><a href="/docs/components/dialog#usage">Usage</a></h2>
|
@@ -5,25 +5,24 @@
|
|
5
5
|
|
6
6
|
<% content_for :preview, flush: true do %>
|
7
7
|
<div class="w-full">
|
8
|
-
<%=
|
9
|
-
component library you want!" %>
|
8
|
+
<%= render_code_preview('alert') %>
|
10
9
|
</div>
|
11
10
|
<% end %>
|
12
11
|
|
13
12
|
<% content_for :code, flush: true do %>
|
14
|
-
<%= code_partial("alert/
|
13
|
+
<%= code_partial("alert/preview", :erb) %>
|
15
14
|
<% end %>
|
16
15
|
|
17
16
|
<%= render_preview %>
|
18
17
|
|
19
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>
|
20
19
|
<%= code_sample(language: "sh") do %>
|
21
|
-
|
20
|
+
rails generate shadcn-ui alert
|
22
21
|
<% end %>
|
23
22
|
|
24
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>
|
25
24
|
|
26
|
-
<%= code_partial("alert/
|
25
|
+
<%= code_partial("alert/usage", :erb) %>
|
27
26
|
|
28
27
|
<%= render_usage("alert") %>
|
29
28
|
|
@@ -40,7 +39,7 @@
|
|
40
39
|
<% end %>
|
41
40
|
|
42
41
|
<% content_for :code, flush: true do %>
|
43
|
-
<%= code_partial("alert/
|
42
|
+
<%= code_partial("alert/success", :erb) %>
|
44
43
|
<% end %>
|
45
44
|
<%= render_example %>
|
46
45
|
|
@@ -57,7 +56,7 @@
|
|
57
56
|
<% end %>
|
58
57
|
|
59
58
|
<% content_for :code, flush: true do %>
|
60
|
-
<%= code_partial("alert/
|
59
|
+
<%= code_partial("alert/info", :erb) %>
|
61
60
|
<% end %>
|
62
61
|
|
63
62
|
<%= render_example %>
|
@@ -75,7 +74,7 @@
|
|
75
74
|
<% end %>
|
76
75
|
|
77
76
|
<% content_for :code, flush: true do %>
|
78
|
-
<%= code_partial("alert/
|
77
|
+
<%= code_partial("alert/attention", :erb) %>
|
79
78
|
<% end %>
|
80
79
|
|
81
80
|
<%= render_example %>
|
@@ -87,7 +86,7 @@
|
|
87
86
|
<% end %>
|
88
87
|
|
89
88
|
<% content_for :code, flush: true do %>
|
90
|
-
<%= code_partial("alert/
|
89
|
+
<%= code_partial("alert/destructive", :erb) %>
|
91
90
|
<% end %>
|
92
91
|
|
93
92
|
<%= render_example %>
|
@@ -99,7 +98,7 @@
|
|
99
98
|
<% end %>
|
100
99
|
|
101
100
|
<% content_for :code, flush: true do %>
|
102
|
-
<%= code_partial("alert/
|
101
|
+
<%= code_partial("alert/no_icon", :erb) %>
|
103
102
|
<% end %>
|
104
103
|
|
105
104
|
<%= render_example %>
|
@@ -5,23 +5,11 @@
|
|
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
|
-
|
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>
|
8
|
+
<%= render_code_preview('badge') %>
|
21
9
|
<% end %>
|
22
10
|
|
23
11
|
<% content_for :code, flush: true do %>
|
24
|
-
<%= code_partial("badge/
|
12
|
+
<%= code_partial("badge/preview", :erb) %>
|
25
13
|
<% end %>
|
26
14
|
|
27
15
|
<%= render_preview %>
|
@@ -32,6 +20,6 @@
|
|
32
20
|
<% end %>
|
33
21
|
|
34
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>
|
35
|
-
<%= code_partial("badge/
|
23
|
+
<%= code_partial("badge/usage", :erb) %>
|
36
24
|
|
37
25
|
<%= render_usage("badge") %>
|
@@ -5,33 +5,11 @@
|
|
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
|
-
|
9
|
-
<div class="w-full mx-auto flex justify-center">
|
10
|
-
<%= render_button variant: :secondary do %>
|
11
|
-
<svg class="h-4 w-4 mr-2 text-primary" viewBox="0 0 20 20" fill="none" stroke="currentColor" aria-hidden="true">
|
12
|
-
<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>
|
13
|
-
</svg> Secondary with Icon
|
14
|
-
<% end %>
|
15
|
-
</div>
|
16
|
-
<div class="w-full mx-auto flex justify-center">
|
17
|
-
<%= render_button text: "Destructive", variant: :destructive %>
|
18
|
-
</div>
|
19
|
-
<div class="w-full mx-auto flex justify-center">
|
20
|
-
<%= render_button text: "Outline", variant: :outline %>
|
21
|
-
</div>
|
22
|
-
<div class="w-full mx-auto flex justify-center">
|
23
|
-
<%= render_button text: "Ghost", variant: :ghost %>
|
24
|
-
</div>
|
25
|
-
<div class="w-full mx-auto flex justify-center">
|
26
|
-
<%= render_button "Link", as: :link, href: "/" %>
|
27
|
-
</div>
|
28
|
-
<div class="w-full mx-auto flex justify-center">
|
29
|
-
<%= render_button text: "Ghost Link", variant: :ghost, as: :link %>
|
30
|
-
</div>
|
8
|
+
<%= render_code_preview('button') %>
|
31
9
|
<% end %>
|
32
10
|
|
33
11
|
<% content_for :code, flush: true do %>
|
34
|
-
<%= code_partial("button/
|
12
|
+
<%= code_partial("button/preview", :erb) %>
|
35
13
|
<% end %>
|
36
14
|
|
37
15
|
<%= render_preview %>
|
@@ -42,6 +20,6 @@
|
|
42
20
|
<% end %>
|
43
21
|
|
44
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>
|
45
|
-
<%= code_partial("button/
|
23
|
+
<%= code_partial("button/usage", :erb) %>
|
46
24
|
|
47
25
|
<%= render_usage("button") %>
|
@@ -4,15 +4,11 @@
|
|
4
4
|
description: "Displays a card with header, content, and footer." %>
|
5
5
|
|
6
6
|
<%= content_for :preview, flush: true do %>
|
7
|
-
|
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.", footer: "Have a great day!" %>
|
11
|
-
</div>
|
7
|
+
<%= render_code_preview('card') %>
|
12
8
|
<% end %>
|
13
9
|
|
14
10
|
<% content_for :code, flush: true do %>
|
15
|
-
<%= code_partial("card/
|
11
|
+
<%= code_partial("card/preview", :erb) %>
|
16
12
|
<% end %>
|
17
13
|
|
18
14
|
<%= render_preview %>
|
@@ -23,7 +19,7 @@
|
|
23
19
|
<% end %>
|
24
20
|
|
25
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>
|
26
|
-
<%= code_partial("card/
|
22
|
+
<%= code_partial("card/usage", :erb) %>
|
27
23
|
|
28
24
|
<%= render_usage("card") %>
|
29
25
|
|
@@ -32,7 +28,7 @@
|
|
32
28
|
<% end %>
|
33
29
|
|
34
30
|
<% content_for :code, flush: true do %>
|
35
|
-
<%= code_partial("card/
|
31
|
+
<%= code_partial("card/form", :erb) %>
|
36
32
|
<% end %>
|
37
33
|
|
38
34
|
<%= render_example %>
|
@@ -42,7 +38,7 @@
|
|
42
38
|
<% end %>
|
43
39
|
|
44
40
|
<% content_for :code, flush: true do %>
|
45
|
-
<%= code_partial("card/
|
41
|
+
<%= code_partial("card/notifications", :erb) %>
|
46
42
|
<% end %>
|
47
43
|
|
48
44
|
<%= render_example %>
|
@@ -2,11 +2,11 @@
|
|
2
2
|
description: "A control that allows the user to toggle between checked and not checked." %>
|
3
3
|
|
4
4
|
<%= content_for :preview, flush: true do %>
|
5
|
-
<%=
|
5
|
+
<%= render_code_preview('checkbox') %>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<% content_for :code, flush: true do %>
|
9
|
-
<%= code_partial("checkbox/
|
9
|
+
<%= code_partial("checkbox/preview", :erb) %>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<%= render_preview %>
|
@@ -17,6 +17,6 @@
|
|
17
17
|
<% end %>
|
18
18
|
|
19
19
|
<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>
|
20
|
-
<%= code_partial("checkbox/
|
20
|
+
<%= code_partial("checkbox/usage", :erb) %>
|
21
21
|
|
22
22
|
<%= render_usage("checkbox") %>
|
@@ -5,20 +5,12 @@
|
|
5
5
|
|
6
6
|
<%= content_for :preview, flush: true do %>
|
7
7
|
<div class="w-full flex justify-center">
|
8
|
-
<%=
|
9
|
-
<% collapsible_preview do %>
|
10
|
-
<div class="rounded-md border px-4 py-3 font-mono text-sm">@radix-ui/primitives</div>
|
11
|
-
<% end %>
|
12
|
-
<% collapsible_body do %>
|
13
|
-
<div class="rounded-md border px-4 py-3 font-mono text-sm">@radix-ui/colors</div>
|
14
|
-
<div class="rounded-md border px-4 py-3 font-mono text-sm">@stitches/react</div>
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
8
|
+
<%= render_code_preview('collapsible') %>
|
17
9
|
</div>
|
18
10
|
<% end %>
|
19
11
|
|
20
12
|
<% content_for :code, flush: true do %>
|
21
|
-
<%= code_partial("collapsible/
|
13
|
+
<%= code_partial("collapsible/preview", :erb) %>
|
22
14
|
<% end %>
|
23
15
|
|
24
16
|
<%= render_preview %>
|
@@ -29,6 +21,6 @@
|
|
29
21
|
<% end %>
|
30
22
|
|
31
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>
|
32
|
-
<%= code_partial("collapsible/
|
24
|
+
<%= code_partial("collapsible/usage", :erb) %>
|
33
25
|
|
34
26
|
<%= render_usage("collapsible") %>
|
@@ -3,21 +3,12 @@
|
|
3
3
|
|
4
4
|
<% content_for :preview, flush: true do %>
|
5
5
|
<div class="w-full flex justify-center">
|
6
|
-
<%=
|
7
|
-
<%= dialog_trigger do %>
|
8
|
-
<%= render_button("Open Typography", variant: :outline) %>
|
9
|
-
<% end %>
|
10
|
-
<%= dialog_content do %>
|
11
|
-
<h2 class="mt-10 scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0">The King's Plan</h2>
|
12
|
-
<p class="leading-7 [&:not(:first-child)]:mt-6">The king thought long and hard, and finally came up with <a href="#" class="font-medium text-primary underline underline-offset-4">a brilliant plan</a>: he would tax the jokes in the kingdom.</p>
|
13
|
-
<blockquote class="mt-6 border-l-2 pl-6 italic">"After all," he said, "everyone enjoys a good joke, so it's only fair that they should pay for the privilege."</blockquote>
|
14
|
-
<% end %>
|
15
|
-
<% end %>
|
6
|
+
<%= render_code_preview('dialog') %>
|
16
7
|
</div>
|
17
8
|
<% end %>
|
18
9
|
|
19
10
|
<% content_for :code, flush: true do %>
|
20
|
-
<%= code_partial("dialog/
|
11
|
+
<%= code_partial("dialog/preview", :erb) %>
|
21
12
|
<% end %>
|
22
13
|
|
23
14
|
<%= render_preview %>
|
@@ -30,7 +21,7 @@ rails generate shadcn_ui dialog
|
|
30
21
|
|
31
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"><a href="/docs/components/dialog#usage">Usage</a></h2>
|
32
23
|
|
33
|
-
<%= code_partial("dialog/
|
24
|
+
<%= code_partial("dialog/usage", :erb) %>
|
34
25
|
|
35
26
|
<%= render_usage("dialog") %>
|
36
27
|
|
@@ -81,7 +72,7 @@ rails generate shadcn_ui dialog
|
|
81
72
|
<% end %>
|
82
73
|
|
83
74
|
<% content_for :code, flush: true do %>
|
84
|
-
<%= code_partial("dialog/
|
75
|
+
<%= code_partial("dialog/notifications", :erb) %>
|
85
76
|
<% end %>
|
86
77
|
|
87
78
|
<%= render_example %>
|
@@ -139,7 +130,7 @@ rails generate shadcn_ui dialog
|
|
139
130
|
<% end %>
|
140
131
|
|
141
132
|
<% content_for :code, flush: true do %>
|
142
|
-
<%= code_partial("dialog/
|
133
|
+
<%= code_partial("dialog/form", :erb) %>
|
143
134
|
<% end %>
|
144
135
|
|
145
136
|
<%= render_example %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">The Dropdown Menu component introduces:</p>
|
2
|
+
|
3
|
+
<ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
|
4
|
+
<li><%= code("app/helpers/components/dropdown_menu_helper.rb") %></li>
|
5
|
+
<li><%= code("app/views/components/ui/_dropdown_menu.html.erb") %></li>
|
6
|
+
<li><%= code("app/javascript/controllers/ui/dropdown-menu_controller.js") %></li>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">
|
10
|
+
The method <%= code("render_dropdown_menu") %> defined in <%= code("app/helpers/components/dropdown_menu_helper.rb") %>
|
11
|
+
accepts a block for the two inner components, <%= code("dropdown_menu_trigger") %> and <%= code("dropdown_menu_content") %>. Each of those accepts a block for their respective content.</p>
|
12
|
+
|
13
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">
|
14
|
+
Within the <%= code("dropdown_menu_content") %> block, you can use the following methods:</p>
|
15
|
+
|
16
|
+
<ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
|
17
|
+
<li><%= code("dropdown_menu_label") %> - accepts an argument for the label section of the dropdown menu. This is optional.</li>
|
18
|
+
<li><%= code("dropdown_menu_item") %> - an arbitrary amount of these can be used for each menu item you want to include. This method either accepts a string or a block for the content you want.</li>
|
19
|
+
</ul>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% render_dropdown_menu do %>
|
2
|
+
<%= dropdown_menu_trigger do %>
|
3
|
+
<%= render_button "Open Dropdown", variant: :outline %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<%= dropdown_menu_content do %>
|
7
|
+
<%= dropdown_menu_label "My Account" %>
|
8
|
+
<%= render_separator class: "my-1" %>
|
9
|
+
<%= dropdown_menu_item "Profile" %>
|
10
|
+
<%= dropdown_menu_item do %>
|
11
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-2 h-4 w-4">
|
12
|
+
<rect width="20" height="14" x="2" y="5" rx="2"></rect><line x1="2" x2="22" y1="10" y2="10"></line>
|
13
|
+
</svg>
|
14
|
+
<span>Billing</span>
|
15
|
+
<span class="ml-auto text-xs tracking-widest opacity-60">⌘B</span>
|
16
|
+
<% end %>
|
17
|
+
<%= dropdown_menu_item "Settings" %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% render_dropdown_menu do %>
|
2
|
+
<%= dropdown_menu_trigger do %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%= dropdown_menu_content do %>
|
6
|
+
<%= dropdown_menu_label %>
|
7
|
+
|
8
|
+
<%= dropdown_menu_item %>
|
9
|
+
<%= dropdown_menu_item do %>
|
10
|
+
<% end %>
|
11
|
+
<%= dropdown_menu_item %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -3,24 +3,38 @@
|
|
3
3
|
|
4
4
|
<%= content_for :preview, flush: true do %>
|
5
5
|
<% render_dropdown_menu do %>
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<%= dropdown_menu_trigger do %>
|
7
|
+
<%= render_button "Open Dropdown", variant: :outline %>
|
8
|
+
<% end %>
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<% end %>
|
21
|
-
<%= dropdown_menu_item "Settings" %>
|
10
|
+
<%= dropdown_menu_content do %>
|
11
|
+
<%= dropdown_menu_label "My Account" %>
|
12
|
+
<%= render_separator class: "my-1" %>
|
13
|
+
<%= dropdown_menu_item "Profile" %>
|
14
|
+
<%= dropdown_menu_item do %>
|
15
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-2 h-4 w-4">
|
16
|
+
<rect width="20" height="14" x="2" y="5" rx="2"></rect><line x1="2" x2="22" y1="10" y2="10"></line>
|
17
|
+
</svg>
|
18
|
+
<span>Billing</span>
|
19
|
+
<span class="ml-auto text-xs tracking-widest opacity-60">⌘B</span>
|
22
20
|
<% end %>
|
21
|
+
<%= dropdown_menu_item "Settings" %>
|
23
22
|
<% end %>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% content_for :code, flush: true do %>
|
27
|
+
<%= code_partial("dropdown-menu/preview", :erb) %>
|
24
28
|
<% end %>
|
25
29
|
|
26
30
|
<%= render_preview %>
|
31
|
+
|
32
|
+
<h2 class="font-heading scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0" id="installation">Installation</h2>
|
33
|
+
<%= code_sample(language: "sh") do %>
|
34
|
+
rails generate shadcn-ui dropdown-menu
|
35
|
+
<% end %>
|
36
|
+
|
37
|
+
<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>
|
38
|
+
<%= code_partial("dropdown-menu/usage", :erb) %>
|
39
|
+
|
40
|
+
<%= render_usage("dropdown-menu") %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">The Filter component introduces:</p>
|
2
|
+
|
3
|
+
<ul class="my-6 ml-6 list-disc [&>li]:mt-2 text-sm">
|
4
|
+
<li><%= code("app/helpers/components/filter_helper.rb") %></li>
|
5
|
+
<li><%= code("app/views/components/ui/_filter.html.erb") %></li>
|
6
|
+
<li><%= code("app/javascript/controllers/ui/filter_controller.js") %></li>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">
|
10
|
+
The method <%= code("render_filter") %> method accepts one mandtory argument, an array of hashes that each have a <%= code("value") %> and name <%= code("name") %>.</p>
|
11
|
+
|
12
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">You can optionally also call <%= code("filter_icon") %> within a block passed to <%= code("render_filter") %> to render an icon to the left of the filter input.</p>
|
13
|
+
|
14
|
+
<p>This component gets used in the Combobox and Command components as well as potentially others.</p>
|