shadcn-ui 0.0.3 → 0.0.5
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/Procfile.dev +0 -1
- data/README.md +13 -314
- data/app/assets/stylesheets/shadcn.css +8 -0
- data/app/controllers/components_controller.rb +1 -0
- data/app/controllers/documentation_controller.rb +0 -1
- data/app/controllers/users_controller.rb +19 -0
- data/app/form_builders/shadcn_form_builder.rb +43 -0
- data/app/helpers/components/alert_dialog_helper.rb +19 -3
- data/app/helpers/components/forms_helper.rb +13 -0
- data/app/helpers/components/input_helper.rb +15 -5
- data/app/helpers/components/slider_helper.rb +1 -1
- data/app/helpers/components/toast_helper.rb +4 -1
- data/app/helpers/components_helper.rb +4 -0
- data/app/helpers/examples_helper.rb +6 -1
- data/app/javascript/controllers/highlight_controller.js +0 -1
- data/app/javascript/controllers/ui/dialog_controller.js +1 -1
- data/app/javascript/controllers/ui/dropdown_controller.js +1 -1
- data/app/javascript/controllers/ui/hover-card_controller.js +2 -3
- data/app/javascript/controllers/ui/popover_controller.js +7 -3
- data/app/javascript/controllers/ui/sheet_controller.js +1 -1
- data/app/javascript/controllers/ui/toast_controller.js +50 -23
- data/app/javascript/controllers/ui/transition_controller.js +1 -1
- data/app/models/user.rb +9 -0
- data/app/views/application/index.html.erb +625 -17
- data/app/views/components/ui/_alert_dialog.html.erb +10 -6
- data/app/views/components/ui/_card.html.erb +7 -1
- data/app/views/components/ui/_dialog.html.erb +0 -26
- data/app/views/components/ui/_filter.html.erb +3 -2
- data/app/views/components/ui/_input.html.erb +3 -0
- data/app/views/components/ui/_label.html.erb +1 -1
- data/app/views/components/ui/_toast.html.erb +8 -4
- data/app/views/documentation/generators.html.md +20 -0
- data/app/views/documentation/helpers.html.md +54 -0
- data/app/views/documentation/installation.html.md +1 -1
- 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/_usage.html.erb +24 -0
- data/app/views/examples/components/alert-dialog/code/_preview.erb +22 -0
- data/app/views/examples/components/alert-dialog/code/_usage.erb +13 -0
- data/app/views/examples/components/alert-dialog.html.erb +14 -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/code/_usage.erb +3 -0
- 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/forms/_usage.html.erb +28 -0
- data/app/views/examples/components/forms/code/_preview.erb +13 -0
- data/app/views/examples/components/forms/code/_usage.erb +6 -0
- data/app/views/examples/components/forms.html.erb +23 -0
- 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/_destructive.erb +6 -0
- data/app/views/examples/components/toast/code/_preview.erb +4 -0
- data/app/views/examples/components/toast/code/_usage.erb +2 -0
- data/app/views/examples/components/toast.html.erb +28 -5
- 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/config/routes.rb +3 -0
- data/lib/components.json +13 -1
- data/lib/generators/shadcn-ui_generator.rb +1 -1
- data/lib/shadcn-ui/version.rb +1 -1
- metadata +84 -20
- data/app/views/examples/components/card/code/usage.erb +0 -3
- 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/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
@@ -1,7 +1,7 @@
|
|
1
1
|
<div data-controller="ui--dialog">
|
2
|
+
<div data-action="click->ui--dialog#open"><%= content_for(:alert_dialog_trigger) %></div>
|
2
3
|
<%= render "components/ui/shared/backdrop", as: "backdrop" %>
|
3
4
|
|
4
|
-
<%= trigger %>
|
5
5
|
<div
|
6
6
|
role="alertdialog"
|
7
7
|
data-state="closed"
|
@@ -9,12 +9,16 @@
|
|
9
9
|
tabindex="-1"
|
10
10
|
style="pointer-events: auto"
|
11
11
|
data-ui--dialog-target="dialog">
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
</div>
|
12
|
+
<div>
|
13
|
+
<%= content_for(:alert_dialog_content) %>
|
14
|
+
</div>
|
16
15
|
<div class="flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2">
|
17
|
-
|
16
|
+
<div data-action="click->ui--dialog#close">
|
17
|
+
<%= content_for(:alert_dialog_cancel) %>
|
18
|
+
</div>
|
19
|
+
<div data-action="click->ui--dialog#close">
|
20
|
+
<%= content_for(:alert_dialog_continue) %>
|
21
|
+
</div>
|
18
22
|
</div>
|
19
23
|
</div>
|
20
24
|
</div>
|
@@ -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>
|
@@ -41,29 +41,3 @@
|
|
41
41
|
</button>
|
42
42
|
</div>
|
43
43
|
</div>
|
44
|
-
<!-- <div data-controller="ui--dialog">
|
45
|
-
<div
|
46
|
-
data-ui--dialog-target="modal"
|
47
|
-
data-state="closed"
|
48
|
-
class="hidden fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
|
49
|
-
style="pointer-events: auto"
|
50
|
-
data-aria-hidden="true"
|
51
|
-
aria-hidden="true"></div>
|
52
|
-
|
53
|
-
<%#= trigger %>
|
54
|
-
<div
|
55
|
-
role="alertdialog"
|
56
|
-
data-state="closed"
|
57
|
-
class="hidden fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full"
|
58
|
-
tabindex="-1"
|
59
|
-
style="pointer-events: auto"
|
60
|
-
data-ui--dialog-target="dialog">
|
61
|
-
<div class="flex flex-col space-y-2 text-center sm:text-left">
|
62
|
-
<h2 class="text-lg font-semibold"><%#= label %></h2>
|
63
|
-
<p class="text-sm text-muted-foreground"><%#= description %></p>
|
64
|
-
</div>
|
65
|
-
<div class="flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2">
|
66
|
-
<%#= cancel %> <%#= continue %>
|
67
|
-
</div>
|
68
|
-
</div>
|
69
|
-
</div> -->
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<div data-controller="ui--filter">
|
2
2
|
<%= render_card do %>
|
3
3
|
<div class="flex items-center">
|
4
|
-
|
5
|
-
<%= render_input name: "filter", placeholder: "Filter items...",
|
4
|
+
<%= content_for :filter_icon %>
|
5
|
+
<%= render_input name: "filter", placeholder: "Filter items...", variant: :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] %>">
|
8
8
|
<%= content_tag :div, role: "group" do
|
@@ -12,3 +12,4 @@
|
|
12
12
|
end %>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
15
|
+
</div>
|
@@ -2,6 +2,9 @@
|
|
2
2
|
<%= text_field_tag name, value, type: type, id: id,
|
3
3
|
class: options[:class],
|
4
4
|
placeholder: options[:placeholder],
|
5
|
+
autocomplete: options[:autocomplete],
|
6
|
+
autocapitalize: options[:autocapitalize],
|
7
|
+
autocorrect: options[:autocorrect],
|
5
8
|
disabled: options[:disabled],
|
6
9
|
required: options[:required],
|
7
10
|
readonly: options[:readonly],
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<%= label_tag name, label,
|
2
2
|
data: options[:data],
|
3
|
-
class: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 #{options[:class]}" %>
|
3
|
+
class: tw("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 #{options[:class]}") %>
|
@@ -1,4 +1,8 @@
|
|
1
|
-
<div role="region" aria-label="Notifications (F8)" tabindex="-1" style=""
|
1
|
+
<div role="region" aria-label="Notifications (F8)" tabindex="-1" style=""
|
2
|
+
id="<%= options[:id] %>"
|
3
|
+
data-controller="ui--toast <%= data[:controller] %>"
|
4
|
+
data-auto="<%= options[:auto] %>"
|
5
|
+
class="hidden">
|
2
6
|
<span aria-hidden="true" tabindex="0" style="position: fixed; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;"></span>
|
3
7
|
<ol tabindex="-1" class="fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]">
|
4
8
|
<li role="status"
|
@@ -9,7 +13,7 @@
|
|
9
13
|
data-ui--toast-target="item"
|
10
14
|
data-swipe-direction="right"
|
11
15
|
data-duration="5000"
|
12
|
-
class="toast-item hidden group pointer-events-auto relative flex w-full items-center
|
16
|
+
class="<%= tw("toast-item hidden group pointer-events-auto relative flex w-full items-center
|
13
17
|
justify-between space-x-4 overflow-hidden rounded-md p-6 pr-8 shadow-lg
|
14
18
|
transition-all
|
15
19
|
data-[swipe=cancel]:translate-x-0
|
@@ -20,14 +24,14 @@
|
|
20
24
|
data-[state=closed]:fade-out-80
|
21
25
|
data-[state=open]:slide-in-from-top-full
|
22
26
|
data-[state=open]:sm:slide-in-from-bottom-full
|
23
|
-
border bg-background"
|
27
|
+
border bg-background #{options[:class]}") %>"
|
24
28
|
style="user-select: none; touch-action: none;">
|
25
29
|
<div class="grid gap-1">
|
26
30
|
<div class="text-sm font-semibold"><%= header %></div>
|
27
31
|
<div class="text-sm opacity-90"><%= description %></div>
|
28
32
|
</div>
|
29
33
|
<%= action %>
|
30
|
-
<button data-action="ui--toast#
|
34
|
+
<button data-action="ui--toast#close" type="button" class="absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600" toast-close="" data-radix-toast-announce-exclude=""><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="h-4 w-4"><line x1="18" x2="6" y1="6" y2="18"></line><line x1="6" x2="18" y1="6" y2="18"></line></svg></button>
|
31
35
|
</li>
|
32
36
|
</ol>
|
33
37
|
<span aria-hidden="true" tabindex="0" style="position: fixed; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;"></span>
|
@@ -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.
|
@@ -32,7 +32,7 @@ The components need a few things in order to render and function properly
|
|
32
32
|
package.json if you need via `echo '{}' >> package.json`.
|
33
33
|
|
34
34
|
```
|
35
|
-
npm install -D
|
35
|
+
npm install -D tailwindcss-animate
|
36
36
|
```
|
37
37
|
|
38
38
|
These are the requirements if you want to add them individually:
|
@@ -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,24 @@
|
|
1
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">The Alert Dialog 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_dialog_helper.rb") %></li>
|
5
|
+
<li><%= code("app/views/components/ui/_alert_dialog.html.erb") %></li>
|
6
|
+
</ul>
|
7
|
+
|
8
|
+
And relies on <%= code("app/javascript/controllers/ui/dialog_controller.js") %>.
|
9
|
+
|
10
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">
|
11
|
+
The method <%= code("render_alert_dialog") %> defined in <%= code("app/helpers/components/alert_dialog_helper.rb") %>
|
12
|
+
accepts a block for the inner components of the dialog. It renders the partial
|
13
|
+
<%= code("app/views/components/ui/_alert_dialog.html.erb") %> which contains the model structure and
|
14
|
+
and the 2 actions buttons of continue and cancel.
|
15
|
+
</p>
|
16
|
+
|
17
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">
|
18
|
+
The modal is composed of 4 components with corresponding helper methods, <%= code("alert_dialog_trigger") %>,
|
19
|
+
which accepts a block for the element that will trigger the modal, and <%= code("alert_dialog_content") %>,
|
20
|
+
which accepts a block for the body of the modal and the two actions for the modal, <%= code("alert_dialog_cancel") %> for the element that you would like to cancel the dialog interaction, for example a button, and <%= code("alert_dialog_continue") %> for the element you would like to use to continue to interaction. Note, you should feel free to bind your own data actions to these buttons as they are enclosed in an element that will handle closing the modal on click.
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p class="leading-7 [&:not(:first-child)]:mt-6">
|
24
|
+
See <a href="/docs/components/dialog">Dialog</a> for more context as this component inherits functionality from that one.</p>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= render_alert_dialog do %>
|
2
|
+
<%= alert_dialog_trigger do %>
|
3
|
+
<%= render_button("Open Dialog", variant: :outline) %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<%= alert_dialog_content do %>
|
7
|
+
<div class="flex flex-col space-y-2 text-center sm:text-left">
|
8
|
+
<h2 class="text-lg font-semibold">Are you absolutely sure?</h2>
|
9
|
+
<p class="text-sm text-muted-foreground">
|
10
|
+
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
|
11
|
+
</p>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= alert_dialog_cancel do %>
|
16
|
+
<%= render_button("Cancel", variant: :outline) %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= alert_dialog_continue do %>
|
20
|
+
<%= render_button("Continue") %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
@@ -3,22 +3,25 @@
|
|
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
|
|
22
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-dialog
|
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>
|
24
|
+
|
25
|
+
<%= code_partial("alert-dialog/usage", :erb) %>
|
26
|
+
|
27
|
+
<%= render_usage("alert-dialog") %>
|
@@ -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") %>
|