shadcn-ui 0.0.12 → 0.0.14

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/shadcn.css +67 -83
  3. data/app/components/shadcn/form_builder.rb +12 -1
  4. data/app/helpers/components/badge_helper.rb +2 -2
  5. data/app/helpers/components/button_helper.rb +3 -3
  6. data/app/helpers/components/date_picker_helper.rb +10 -0
  7. data/app/helpers/components/filter_helper.rb +4 -0
  8. data/app/helpers/components/input_helper.rb +3 -2
  9. data/app/helpers/components/table_helper.rb +6 -6
  10. data/app/javascript/controllers/ui/date-picker_controller.js +766 -0
  11. data/app/javascript/controllers/ui/dialog_controller.js +3 -0
  12. data/app/javascript/controllers/ui/select_controller.js +129 -0
  13. data/app/javascript/utils/bodyScrollLock.js +289 -0
  14. data/app/javascript/utils/iso_date.js +198 -0
  15. data/app/views/components/ui/_card.html.erb +1 -1
  16. data/app/views/components/ui/_date_picker.html.erb +13 -0
  17. data/app/views/components/ui/_filter.html.erb +16 -13
  18. data/app/views/components/ui/_list.html.erb +4 -4
  19. data/app/views/components/ui/_textarea.html.erb +2 -2
  20. data/app/views/examples/components/accordion/code/_usage.erb +3 -3
  21. data/app/views/examples/components/date-picker/_usage.html.erb +19 -0
  22. data/app/views/examples/components/date-picker/code/_preview.erb +1 -0
  23. data/app/views/examples/components/date-picker/code/_usage.erb +1 -0
  24. data/app/views/examples/components/date-picker.html.erb +22 -0
  25. data/app/views/examples/components/dropdown-menu/code/_preview.erb +2 -2
  26. data/app/views/examples/components/dropdown-menu/code/_usage.erb +1 -1
  27. data/app/views/examples/components/dropdown-menu.html.erb +1 -1
  28. data/app/views/layouts/shared/_components.html.erb +1 -1
  29. data/lib/shadcn-ui/version.rb +1 -1
  30. data/shadcn-ui.gemspec +39 -0
  31. metadata +16 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d36b644105b526361e08e906fb9404b89f4099f4f860afdc229bebe36a4b1996
4
- data.tar.gz: ad0edad68914c4d1eee78f8b468b5f28cbead6ebd22fbd58f174ef7b5f00d77a
3
+ metadata.gz: a39d85928cde2116a4a0ffb5bf8790b0697474a1dff54e164a8817f3e1c02dc7
4
+ data.tar.gz: d79e0cd3ce519b91f2e4186ed7946c67bf50e3d9125a0ad3767f6326ef21662b
5
5
  SHA512:
6
- metadata.gz: d2d42f118d6048f572eab0597f8958be014e653ae2a0d020843308c96b2be4777798e91d54b648333caf67f516494b480edf7993639b64fbdaf5661ceb4389b6
7
- data.tar.gz: cd3967406dcf715fd6604bf25f20e2e7f1c719feefa27b239f982be71ecc811118f74fd7351d59f230f6a0e8269a1be378b9760ee6ebb82fb6f8d6609503eee8
6
+ metadata.gz: d0cb9bf3bb84df2d8a57c334fc43db494ab29a3b31d31ec5192aee725a3e321a207a56b86df94abc1d8b010c0728f1e718002edb6da371c0467cd4a63651ebdd
7
+ data.tar.gz: 11839c8a282b0497e8a2a33726818b7889bfd0299a60d41b6887f24f3b81b8189f2171e9dfb8e0749cf660b5b2e2a36ba502c6996c8491b90067459f8e18b59b
@@ -1,84 +1,64 @@
1
+ :root {
2
+ --font-sans: "Inter var";
3
+
4
+ --background: 0 0% 100%;
5
+ --foreground: 240 10% 3.9%;
6
+ --card: 0 0% 100%;
7
+ --card-foreground: 240 10% 3.9%;
8
+ --popover: 0 0% 100%;
9
+ --popover-foreground: 240 10% 3.9%;
10
+ --primary: 240 5.9% 10%;
11
+ --primary-foreground: 0 0% 98%;
12
+ --secondary: 240 4.8% 95.9%;
13
+ --secondary-foreground: 240 5.9% 10%;
14
+ --muted: 240 4.8% 95.9%;
15
+ --muted-foreground: 240 3.8% 46.1%;
16
+ --accent: 240 4.8% 95.9%;
17
+ --accent-foreground: 240 5.9% 10%;
18
+ --destructive: 0 84.2% 60.2%;
19
+ --destructive-foreground: 0 0% 98%;
20
+ --border: 240 5.9% 90%;
21
+ --input: 240 5.9% 90%;
22
+ --ring: 240 5% 64.9%;
23
+ --radius: 0.5rem;
24
+
25
+ --success: 132, 95.3%, 33.3%, 0.74;
26
+ --success-foreground: 109 55% 28%;
27
+
28
+ --info: 223 78% 42%;
29
+ --info-foreground: 225 100% 50%;
30
+
31
+ --attention: 45 90% 45%;
32
+ --attention-foreground: 60 98.4% 48.8% 0.82;
33
+ }
1
34
  @layer base {
2
- :root {
3
- --font-sans: "Inter var";
4
- --background: 0 0% 100%;
5
- --foreground: 222.2 47.4% 11.2%;
6
-
7
- --muted: 210 40% 96.1%;
8
- --muted-foreground: 215.4 16.3% 46.9%;
9
-
10
- --popover: 0 0% 100%;
11
- --popover-foreground: 222.2 47.4% 11.2%;
12
-
13
- --border: 214.3 31.8% 91.4%;
14
- --input: 214.3 31.8% 91.4%;
15
-
16
- --card: 0 0% 100%;
17
- --card-foreground: 222.2 47.4% 11.2%;
18
-
19
- --primary: 222.2 47.4% 11.2%;
20
- --primary-foreground: 210 40% 98%;
21
-
22
- --secondary: 210 40% 96.1%;
23
- --secondary-foreground: 222.2 47.4% 11.2%;
24
-
25
- --accent: 210 40% 96.1%;
26
- --accent-foreground: 222.2 47.4% 11.2%;
27
-
28
- --destructive: 0 100% 50%;
29
- --destructive-foreground: 210 40% 98%;
30
-
31
- --success: 132, 95.3%, 33.3%, 0.74;
32
- --success-foreground: 109 55% 28%;
33
-
34
- --info: 223 78% 42%;
35
- --info-foreground: 225 100% 50%;
36
-
37
- --attention: 45 90% 45%;
38
- --attention-foreground: 60 98.4% 48.8% 0.82;
39
-
40
- --ring: 215 20.2% 65.1%;
41
-
42
- --radius: 0.5rem;
43
- }
44
-
45
35
  .dark {
46
- --background: 224 71% 4%;
47
- --foreground: 213 31% 91%;
48
-
49
- --muted: 223 47% 11%;
50
- --muted-foreground: 215.4 16.3% 56.9%;
51
-
52
- --accent: 216 34% 17%;
53
- --accent-foreground: 210 40% 98%;
54
-
55
- --popover: 224 71% 4%;
56
- --popover-foreground: 215 20.2% 65.1%;
57
-
58
- --border: 216 34% 17%;
59
- --input: 216 34% 17%;
60
-
61
- --card: 224 71% 4%;
62
- --card-foreground: 213 31% 91%;
63
-
64
- --primary: 210 40% 98%;
65
- --primary-foreground: 222.2 47.4% 1.2%;
66
-
67
- --secondary: 222.2 47.4% 11.2%;
68
- --secondary-foreground: 210 40% 98%;
69
-
70
- --destructive: 0 63% 31%;
71
- --destructive-foreground: 210 40% 98%;
72
-
73
- --attention: 45, 90%, 45%, 0.8;
74
- --attention-foreground: 60 98.4% 48.8% 0.82;
36
+ --background: 240 10% 3.9%;
37
+ --foreground: 0 0% 98%;
38
+ --card: 240 10% 3.9%;
39
+ --card-foreground: 0 0% 98%;
40
+ --popover: 240 10% 3.9%;
41
+ --popover-foreground: 0 0% 98%;
42
+ --primary: 0 0% 98%;
43
+ --primary-foreground: 240 5.9% 10%;
44
+ --secondary: 240 3.7% 15.9%;
45
+ --secondary-foreground: 0 0% 98%;
46
+ --muted: 240 3.7% 15.9%;
47
+ --muted-foreground: 240 5% 64.9%;
48
+ --accent: 240 3.7% 15.9%;
49
+ --accent-foreground: 0 0% 98%;
50
+ --destructive: 0 62.8% 30.6%;
51
+ --destructive-foreground: 0 85.7% 97.3%;
52
+ --border: 240 3.7% 15.9%;
53
+ --input: 240 3.7% 15.9%;
54
+ --ring: 240 4.9% 83.9%;
55
+ --radius: 0.5rem;
75
56
 
76
57
  --success: 109 55% 28%;
77
58
  --success-foreground: 109 55% 28%;
78
59
 
79
- --ring: 216 34% 17%;
80
-
81
- --radius: 0.5rem;
60
+ --attention: 45, 90%, 45%, 0.8;
61
+ --attention-foreground: 60 98.4% 48.8% 0.82;
82
62
  }
83
63
  }
84
64
 
@@ -104,7 +84,19 @@
104
84
  .code-sample span {
105
85
  @apply bg-zinc-950;
106
86
  }
87
+ input.error {
88
+ @apply border-red-400;
89
+ }
90
+
91
+ label.error {
92
+ @apply text-destructive;
93
+ }
94
+
95
+ input.error:focus-visible {
96
+ @apply ring-destructive;
97
+ }
107
98
  }
99
+
108
100
  input[type="range"] {
109
101
  display: inline-block;
110
102
  vertical-align: middle;
@@ -214,11 +206,3 @@ input[type="range"]::-ms-track {
214
206
  overflow: hidden;
215
207
  transition: all 0.2s;
216
208
  }
217
-
218
- input.error {
219
- @apply border-red-400;
220
- }
221
-
222
- label.error {
223
- @apply text-destructive;
224
- }
@@ -37,7 +37,18 @@ class Shadcn::FormBuilder < ActionView::Helpers::FormBuilder
37
37
  type: "email", **options
38
38
  )
39
39
  end
40
-
40
+
41
+ def text_area(method, options = {})
42
+ error_class = @object.errors[method].any? ? "error" : ""
43
+ options[:class] = @template.tw("#{options[:class]} #{error_class}")
44
+ @template.render_textarea(
45
+ name: "#{object_name}[#{method}]",
46
+ id: "#{object_name}_#{method}",
47
+ value: @object.send(method),
48
+ type: "text", **options
49
+ )
50
+ end
51
+
41
52
  def submit(value = nil, options = {})
42
53
  @template.render_button(value, **options)
43
54
  end
@@ -1,7 +1,7 @@
1
1
  module Components::BadgeHelper
2
2
  def render_badge(label = "", data: "", text: "", variant: :default, **options)
3
3
  badge_classes = " inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 "
4
- varianet_classes = case variant.to_sym
4
+ variant_classes = case variant.to_sym
5
5
  when :default
6
6
  ComponentsHelper::PRIMARY_CLASSES
7
7
  when :secondary
@@ -13,7 +13,7 @@ module Components::BadgeHelper
13
13
  when :ghost
14
14
  ComponentsHelper::GHOST_CLASSES
15
15
  end
16
- badge_classes << " #{varianet_classes}"
16
+ badge_classes << " #{variant_classes}"
17
17
  text = label if label.present?
18
18
 
19
19
  content_tag :div, class: badge_classes do
@@ -1,7 +1,7 @@
1
1
  module Components::ButtonHelper
2
2
  def render_button(label = "", text: nil, variant: :default, as: :button, href: nil, data: {}, **options, &block)
3
3
  button_classes = " inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 "
4
- varianet_classes = case variant.to_sym
4
+ variant_classes = case variant.to_sym
5
5
  when :default
6
6
  " bg-primary text-primary-foreground hover:bg-primary/90 "
7
7
  when :secondary
@@ -13,8 +13,8 @@ module Components::ButtonHelper
13
13
  when :ghost
14
14
  " hover:bg-accent hover:text-accent-foreground "
15
15
  end
16
- button_classes << " #{varianet_classes} #{options[:class]}"
17
- button_classes = tw(button_classes)
16
+ button_classes = tw(button_classes, variant_classes, options[:class])
17
+
18
18
  text = label if label.present?
19
19
  text = capture(&block) if block
20
20
  render "components/ui/button", text:, button_classes:, as:, href:, data:, **options
@@ -0,0 +1,10 @@
1
+ module Components::DatePickerHelper
2
+ def render_date_picker(name:, id: nil, value: 'Pick a date', **options)
3
+ render partial: "components/ui/date_picker", locals: {
4
+ name:,
5
+ value:,
6
+ id:,
7
+ options: options
8
+ }
9
+ end
10
+ end
@@ -9,4 +9,8 @@ module Components::FilterHelper
9
9
  input_class = content_for?(:filter_icon) ? "pl-1" : ""
10
10
  render "components/ui/filter", items: items, options: options, input_class: input_class, content: content
11
11
  end
12
+
13
+ def list_item(value:, name:, selected:)
14
+ "#{name}"
15
+ end
12
16
  end
@@ -10,14 +10,15 @@ module Components::InputHelper
10
10
  options[:class] = tw(options[:class])
11
11
 
12
12
  options.reverse_merge!(
13
- label: (options[:lable] || false),
13
+ label: (options[:label] || false),
14
14
  required: (options[:required] || false),
15
15
  disabled: (options[:disabled] || false),
16
16
  readonly: (options[:readonly] || false),
17
17
  placeholder: (options[:placeholder] || ""),
18
18
  autocomplete: (options[:autocomplete] || ""),
19
19
  autocapitalize: (options[:autocapitalize] || nil),
20
- autocorrect: (options[:autocorrect] || nil)
20
+ autocorrect: (options[:autocorrect] || nil),
21
+ autofocus: (options[:autofocus] || nil)
21
22
  )
22
23
  render partial: "components/ui/input", locals: {
23
24
  type:,
@@ -1,6 +1,6 @@
1
1
  module Components::TableHelper
2
2
  def render_table(caption = nil, **options, &block)
3
- content_tag :table, options.reverse_merge(
3
+ content_tag :table, options.merge(
4
4
  class: tw("w-full text-sm border-b", options[:class])
5
5
  ) do
6
6
  if caption.present?
@@ -14,7 +14,7 @@ module Components::TableHelper
14
14
  end
15
15
 
16
16
  def table_head(**options, &block)
17
- content_tag :thead, options.reverse_merge(
17
+ content_tag :thead, options.merge(
18
18
  class: tw("[&_tr]:border-b", options[:class])
19
19
  ) do
20
20
  content_tag :tr, class: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted" do
@@ -24,7 +24,7 @@ module Components::TableHelper
24
24
  end
25
25
 
26
26
  def table_header(content = nil, **options, &block)
27
- content_tag :th, options.reverse_merge(
27
+ content_tag :th, options.merge(
28
28
  class: tw("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0", options[:class])
29
29
  ) do
30
30
  if block
@@ -36,19 +36,19 @@ module Components::TableHelper
36
36
  end
37
37
 
38
38
  def table_body(**options, &block)
39
- content_tag :tbody, class: options.reverse_merge(
39
+ content_tag :tbody, class: options.merge(
40
40
  class: tw("[&_tr:last-child]:border-0", options[:class])
41
41
  ), &block
42
42
  end
43
43
 
44
44
  def table_row(**options, &block)
45
- content_tag :tr, options.reverse_merge(
45
+ content_tag :tr, options.merge(
46
46
  class: tw("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", options[:class])
47
47
  ), &block
48
48
  end
49
49
 
50
50
  def table_column(content = nil, **options, &block)
51
- content_tag :td, options.reverse_merge(
51
+ content_tag :td, options.merge(
52
52
  class: tw("p-4 align-middle [&:has([role=checkbox])]:pr-0 font-medium", options[:class])
53
53
  ) do
54
54
  if block