ruby_ui 1.0.1 → 1.1.0

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 (122) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +6 -0
  4. data/lib/generators/ruby_ui/component/all_generator.rb +22 -0
  5. data/lib/generators/ruby_ui/component_generator.rb +4 -3
  6. data/lib/generators/ruby_ui/install/docs_generator.rb +33 -0
  7. data/lib/generators/ruby_ui/install/install_generator.rb +1 -7
  8. data/lib/generators/ruby_ui/install/templates/tailwind.css.erb +0 -3
  9. data/lib/generators/ruby_ui/javascript_utils.rb +4 -0
  10. data/lib/ruby_ui/accordion/accordion_docs.rb +53 -0
  11. data/lib/ruby_ui/alert/alert_docs.rb +135 -0
  12. data/lib/ruby_ui/alert_dialog/alert_dialog_content.rb +2 -3
  13. data/lib/ruby_ui/alert_dialog/alert_dialog_docs.rb +35 -0
  14. data/lib/ruby_ui/aspect_ratio/aspect_ratio_docs.rb +64 -0
  15. data/lib/ruby_ui/avatar/avatar_docs.rb +92 -0
  16. data/lib/ruby_ui/badge/badge_docs.rb +80 -0
  17. data/lib/ruby_ui/breadcrumb/breadcrumb_docs.rb +116 -0
  18. data/lib/ruby_ui/button/button.rb +32 -16
  19. data/lib/ruby_ui/button/button_docs.rb +143 -0
  20. data/lib/ruby_ui/calendar/calendar_docs.rb +34 -0
  21. data/lib/ruby_ui/card/card_docs.rb +114 -0
  22. data/lib/ruby_ui/carousel/carousel_docs.rb +104 -0
  23. data/lib/ruby_ui/chart/chart_docs.rb +115 -0
  24. data/lib/ruby_ui/checkbox/checkbox.rb +7 -1
  25. data/lib/ruby_ui/checkbox/checkbox_docs.rb +41 -0
  26. data/lib/ruby_ui/clipboard/clipboard_docs.rb +30 -0
  27. data/lib/ruby_ui/codeblock/codeblock_docs.rb +55 -0
  28. data/lib/ruby_ui/collapsible/collapsible_docs.rb +96 -0
  29. data/lib/ruby_ui/combobox/combobox.rb +3 -2
  30. data/lib/ruby_ui/combobox/combobox_checkbox.rb +4 -2
  31. data/lib/ruby_ui/combobox/combobox_controller.js +20 -5
  32. data/lib/ruby_ui/combobox/combobox_docs.rb +151 -0
  33. data/lib/ruby_ui/combobox/combobox_item.rb +2 -1
  34. data/lib/ruby_ui/combobox/combobox_popover.rb +2 -1
  35. data/lib/ruby_ui/combobox/combobox_radio.rb +8 -1
  36. data/lib/ruby_ui/combobox/combobox_search_input.rb +11 -5
  37. data/lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb +4 -2
  38. data/lib/ruby_ui/combobox/combobox_trigger.rb +8 -2
  39. data/lib/ruby_ui/command/command_controller.js +0 -1
  40. data/lib/ruby_ui/command/command_docs.rb +154 -0
  41. data/lib/ruby_ui/context_menu/context_menu.rb +1 -1
  42. data/lib/ruby_ui/context_menu/context_menu_docs.rb +85 -0
  43. data/lib/ruby_ui/dialog/dialog_content.rb +2 -3
  44. data/lib/ruby_ui/dialog/dialog_controller.js +1 -1
  45. data/lib/ruby_ui/dialog/dialog_docs.rb +102 -0
  46. data/lib/ruby_ui/docs/base.rb +90 -0
  47. data/lib/ruby_ui/docs/component_setup_tabs.rb +15 -0
  48. data/lib/ruby_ui/docs/components_table.rb +13 -0
  49. data/lib/ruby_ui/docs/header.rb +17 -0
  50. data/lib/ruby_ui/docs/sidebar_examples.rb +22 -0
  51. data/lib/ruby_ui/docs/visual_code_example.rb +22 -0
  52. data/lib/ruby_ui/dropdown_menu/dropdown_menu.rb +9 -0
  53. data/lib/ruby_ui/dropdown_menu/dropdown_menu_content.rb +17 -2
  54. data/lib/ruby_ui/dropdown_menu/dropdown_menu_controller.js +43 -14
  55. data/lib/ruby_ui/dropdown_menu/dropdown_menu_docs.rb +212 -0
  56. data/lib/ruby_ui/form/form_docs.rb +178 -0
  57. data/lib/ruby_ui/form/form_field.rb +1 -1
  58. data/lib/ruby_ui/form/form_field_error.rb +1 -1
  59. data/lib/ruby_ui/form/form_field_hint.rb +1 -1
  60. data/lib/ruby_ui/form/form_field_label.rb +7 -1
  61. data/lib/ruby_ui/hover_card/hover_card_docs.rb +71 -0
  62. data/lib/ruby_ui/input/input.rb +9 -1
  63. data/lib/ruby_ui/input/input_docs.rb +68 -0
  64. data/lib/ruby_ui/link/link.rb +32 -16
  65. data/lib/ruby_ui/link/link_docs.rb +106 -0
  66. data/lib/ruby_ui/masked_input/masked_input_docs.rb +47 -0
  67. data/lib/ruby_ui/pagination/pagination_docs.rb +127 -0
  68. data/lib/ruby_ui/popover/popover_docs.rb +971 -0
  69. data/lib/ruby_ui/progress/progress_docs.rb +27 -0
  70. data/lib/ruby_ui/radio_button/radio_button.rb +3 -1
  71. data/lib/ruby_ui/radio_button/radio_button_docs.rb +53 -0
  72. data/lib/ruby_ui/select/select_docs.rb +129 -0
  73. data/lib/ruby_ui/select/select_item.rb +14 -5
  74. data/lib/ruby_ui/select/select_trigger.rb +9 -4
  75. data/lib/ruby_ui/separator/separator_docs.rb +36 -0
  76. data/lib/ruby_ui/sheet/sheet_content.rb +1 -1
  77. data/lib/ruby_ui/sheet/sheet_docs.rb +76 -0
  78. data/lib/ruby_ui/shortcut_key/shortcut_key_docs.rb +29 -0
  79. data/lib/ruby_ui/sidebar/collapsible_sidebar.rb +99 -0
  80. data/lib/ruby_ui/sidebar/mobile_sidebar.rb +45 -0
  81. data/lib/ruby_ui/sidebar/non_collapsible_sidebar.rb +17 -0
  82. data/lib/ruby_ui/sidebar/sidebar.rb +29 -0
  83. data/lib/ruby_ui/sidebar/sidebar_content.rb +20 -0
  84. data/lib/ruby_ui/sidebar/sidebar_controller.js +67 -0
  85. data/lib/ruby_ui/sidebar/sidebar_docs.rb +176 -0
  86. data/lib/ruby_ui/sidebar/sidebar_footer.rb +20 -0
  87. data/lib/ruby_ui/sidebar/sidebar_group.rb +20 -0
  88. data/lib/ruby_ui/sidebar/sidebar_group_action.rb +33 -0
  89. data/lib/ruby_ui/sidebar/sidebar_group_content.rb +20 -0
  90. data/lib/ruby_ui/sidebar/sidebar_group_label.rb +26 -0
  91. data/lib/ruby_ui/sidebar/sidebar_header.rb +20 -0
  92. data/lib/ruby_ui/sidebar/sidebar_input.rb +20 -0
  93. data/lib/ruby_ui/sidebar/sidebar_inset.rb +23 -0
  94. data/lib/ruby_ui/sidebar/sidebar_menu.rb +20 -0
  95. data/lib/ruby_ui/sidebar/sidebar_menu_action.rb +48 -0
  96. data/lib/ruby_ui/sidebar/sidebar_menu_badge.rb +30 -0
  97. data/lib/ruby_ui/sidebar/sidebar_menu_button.rb +63 -0
  98. data/lib/ruby_ui/sidebar/sidebar_menu_item.rb +20 -0
  99. data/lib/ruby_ui/sidebar/sidebar_menu_skeleton.rb +36 -0
  100. data/lib/ruby_ui/sidebar/sidebar_menu_sub.rb +24 -0
  101. data/lib/ruby_ui/sidebar/sidebar_menu_sub_button.rb +50 -0
  102. data/lib/ruby_ui/sidebar/sidebar_menu_sub_item.rb +9 -0
  103. data/lib/ruby_ui/sidebar/sidebar_rail.rb +36 -0
  104. data/lib/ruby_ui/sidebar/sidebar_separator.rb +20 -0
  105. data/lib/ruby_ui/sidebar/sidebar_trigger.rb +42 -0
  106. data/lib/ruby_ui/sidebar/sidebar_wrapper.rb +24 -0
  107. data/lib/ruby_ui/skeleton/skeleton_docs.rb +29 -0
  108. data/lib/ruby_ui/switch/switch.rb +12 -2
  109. data/lib/ruby_ui/switch/switch_docs.rb +46 -0
  110. data/lib/ruby_ui/table/table_docs.rb +102 -0
  111. data/lib/ruby_ui/table/table_footer.rb +1 -1
  112. data/lib/ruby_ui/table/table_row.rb +1 -1
  113. data/lib/ruby_ui/tabs/tabs_docs.rb +211 -0
  114. data/lib/ruby_ui/tabs/tabs_trigger.rb +7 -1
  115. data/lib/ruby_ui/textarea/textarea.rb +8 -1
  116. data/lib/ruby_ui/textarea/textarea_docs.rb +54 -0
  117. data/lib/ruby_ui/theme_toggle/theme_toggle_docs.rb +71 -0
  118. data/lib/ruby_ui/tooltip/tooltip_controller.js +5 -4
  119. data/lib/ruby_ui/tooltip/tooltip_docs.rb +52 -0
  120. data/lib/ruby_ui/typography/typography_docs.rb +107 -0
  121. data/lib/ruby_ui.rb +1 -1
  122. metadata +81 -6
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Breadcrumb < Views::Base
4
+ def view_template
5
+ component = "Breadcrumb"
6
+
7
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8
+ render Docs::Header.new(title: "Breadcrumb", description: "Indicates the user's current location within a navigational hierarchy.")
9
+
10
+ Heading(level: 2) { "Usage" }
11
+
12
+ render Docs::VisualCodeExample.new(title: "Example", context: self) do
13
+ <<~RUBY
14
+ Breadcrumb do
15
+ BreadcrumbList do
16
+ BreadcrumbItem do
17
+ BreadcrumbLink(href: "/") { "Home" }
18
+ end
19
+ BreadcrumbSeparator()
20
+ BreadcrumbItem do
21
+ BreadcrumbLink(href: "/docs/accordion") { "Components" }
22
+ end
23
+ BreadcrumbSeparator()
24
+ BreadcrumbItem do
25
+ BreadcrumbPage { "Breadcrumb" }
26
+ end
27
+ end
28
+ end
29
+ RUBY
30
+ end
31
+
32
+ render Docs::VisualCodeExample.new(title: "With custom separator", context: self) do
33
+ <<~RUBY
34
+ Breadcrumb do
35
+ BreadcrumbList do
36
+ BreadcrumbItem do
37
+ BreadcrumbLink(href: "/") { "Home" }
38
+ end
39
+ BreadcrumbSeparator { slash_icon }
40
+ BreadcrumbItem do
41
+ BreadcrumbLink(href: "/docs/accordion") { "Components" }
42
+ end
43
+ BreadcrumbSeparator { slash_icon }
44
+ BreadcrumbItem do
45
+ BreadcrumbPage { "Breadcrumb" }
46
+ end
47
+ end
48
+ end
49
+ RUBY
50
+ end
51
+
52
+ render Docs::VisualCodeExample.new(title: "Collapsed", context: self) do
53
+ <<~RUBY
54
+ Breadcrumb do
55
+ BreadcrumbList do
56
+ BreadcrumbItem do
57
+ BreadcrumbLink(href: "/") { "Home" }
58
+ end
59
+ BreadcrumbSeparator()
60
+ BreadcrumbItem do
61
+ BreadcrumbEllipsis()
62
+ end
63
+ BreadcrumbSeparator()
64
+ BreadcrumbItem do
65
+ BreadcrumbLink(href: "/docs/accordion") { "Components" }
66
+ end
67
+ BreadcrumbSeparator()
68
+ BreadcrumbItem do
69
+ BreadcrumbPage { "Breadcrumb" }
70
+ end
71
+ end
72
+ end
73
+ RUBY
74
+ end
75
+
76
+ render Docs::VisualCodeExample.new(title: "With Link component", context: self) do
77
+ <<~RUBY
78
+ Breadcrumb do
79
+ BreadcrumbList do
80
+ BreadcrumbItem do
81
+ BreadcrumbLink(href: "/") { "Home" }
82
+ end
83
+ BreadcrumbSeparator()
84
+ BreadcrumbItem do
85
+ Link(href: "/docs/accordion", class: "px-0") { "Components" }
86
+ end
87
+ BreadcrumbSeparator()
88
+ BreadcrumbItem do
89
+ BreadcrumbPage { "Breadcrumb" }
90
+ end
91
+ end
92
+ end
93
+ RUBY
94
+ end
95
+
96
+ render Components::ComponentSetup::Tabs.new(component_name: component)
97
+
98
+ render Docs::ComponentsTable.new(component_files(component))
99
+ end
100
+ end
101
+
102
+ private
103
+
104
+ def slash_icon
105
+ svg(
106
+ xmlns: "http://www.w3.org/2000/svg",
107
+ class: "w-4 h-4",
108
+ viewbox: "0 0 24 24",
109
+ fill: "none",
110
+ stroke: "currentColor",
111
+ stroke_width: "2",
112
+ stroke_linecap: "round",
113
+ stroke_linejoin: "round"
114
+ ) { |s| s.path(d: "M22 2 2 22") }
115
+ end
116
+ end
@@ -2,6 +2,13 @@
2
2
 
3
3
  module RubyUI
4
4
  class Button < Base
5
+ BASE_CLASSES = [
6
+ "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors",
7
+ "disabled:pointer-events-none disabled:opacity-50",
8
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
9
+ "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
10
+ ].freeze
11
+
5
12
  def initialize(type: :button, variant: :primary, size: :md, icon: false, **attrs)
6
13
  @type = type
7
14
  @variant = variant.to_sym
@@ -36,43 +43,55 @@ module RubyUI
36
43
 
37
44
  def primary_classes
38
45
  [
39
- "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90",
40
- size_classes
46
+ BASE_CLASSES,
47
+ size_classes,
48
+ "bg-primary text-primary-foreground shadow",
49
+ "hover:bg-primary/90"
41
50
  ]
42
51
  end
43
52
 
44
53
  def link_classes
45
54
  [
46
- "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-primary underline-offset-4 hover:underline",
47
- size_classes
55
+ BASE_CLASSES,
56
+ size_classes,
57
+ "text-primary underline-offset-4",
58
+ "hover:underline"
48
59
  ]
49
60
  end
50
61
 
51
62
  def secondary_classes
52
63
  [
53
- "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-opacity-80",
54
- size_classes
64
+ BASE_CLASSES,
65
+ size_classes,
66
+ "bg-secondary text-secondary-foreground",
67
+ "hover:bg-opacity-80"
55
68
  ]
56
69
  end
57
70
 
58
71
  def destructive_classes
59
72
  [
60
- "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
61
- size_classes
73
+ BASE_CLASSES,
74
+ size_classes,
75
+ "bg-destructive text-white shadow-sm",
76
+ "[a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20",
77
+ "dark:focus-visible:ring-destructive/40 dark:bg-destructive/60"
62
78
  ]
63
79
  end
64
80
 
65
81
  def outline_classes
66
82
  [
67
- "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
68
- size_classes
83
+ BASE_CLASSES,
84
+ size_classes,
85
+ "border border-input bg-background shadow-sm",
86
+ "hover:bg-accent hover:text-accent-foreground"
69
87
  ]
70
88
  end
71
89
 
72
90
  def ghost_classes
73
91
  [
74
- "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground",
75
- size_classes
92
+ BASE_CLASSES,
93
+ size_classes,
94
+ "hover:bg-accent hover:text-accent-foreground"
76
95
  ]
77
96
  end
78
97
 
@@ -88,10 +107,7 @@ module RubyUI
88
107
  end
89
108
 
90
109
  def default_attrs
91
- {
92
- type: @type,
93
- class: default_classes
94
- }
110
+ {type: @type, class: default_classes}
95
111
  end
96
112
  end
97
113
  end
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Button < Views::Base
4
+ def view_template
5
+ component = "Button"
6
+
7
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8
+ render Docs::Header.new(title: "Button", description: "Displays a button or a component that looks like a button.")
9
+
10
+ Heading(level: 2) { "Usage" }
11
+
12
+ render Docs::VisualCodeExample.new(title: "Example", context: self) do
13
+ <<~RUBY
14
+ Button { "Button" }
15
+ RUBY
16
+ end
17
+
18
+ render Docs::VisualCodeExample.new(title: "Primary", context: self) do
19
+ <<~RUBY
20
+ Button(variant: :primary) { "Primary" }
21
+ RUBY
22
+ end
23
+
24
+ render Docs::VisualCodeExample.new(title: "Secondary", context: self) do
25
+ <<~RUBY
26
+ Button(variant: :secondary) { "Secondary" }
27
+ RUBY
28
+ end
29
+
30
+ render Docs::VisualCodeExample.new(title: "Destructive", context: self) do
31
+ <<~RUBY
32
+ Button(variant: :destructive) { "Destructive" }
33
+ RUBY
34
+ end
35
+
36
+ render Docs::VisualCodeExample.new(title: "Outline", context: self) do
37
+ <<~RUBY
38
+ Button(variant: :outline) { "Outline" }
39
+ RUBY
40
+ end
41
+
42
+ render Docs::VisualCodeExample.new(title: "Ghost", context: self) do
43
+ <<~RUBY
44
+ Button(variant: :ghost) { "Ghost" }
45
+ RUBY
46
+ end
47
+
48
+ render Docs::VisualCodeExample.new(title: "Link", context: self) do
49
+ <<~RUBY
50
+ Button(variant: :link) { "Link" }
51
+ RUBY
52
+ end
53
+
54
+ render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
55
+ <<~RUBY
56
+ Button(disabled: true) { "Disabled" }
57
+ RUBY
58
+ end
59
+
60
+ render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do
61
+ <<~RUBY
62
+ Button(aria: {disabled: "true"}) { "Aria Disabled" }
63
+ RUBY
64
+ end
65
+
66
+ render Docs::VisualCodeExample.new(title: "Icon", context: self) do
67
+ <<~RUBY
68
+ Button(variant: :outline, icon: true) do
69
+ svg(
70
+ xmlns: "http://www.w3.org/2000/svg",
71
+ viewbox: "0 0 20 20",
72
+ fill: "currentColor",
73
+ class: "w-5 h-5"
74
+ ) do |s|
75
+ s.path(
76
+ fill_rule: "evenodd",
77
+ d:
78
+ "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",
79
+ clip_rule: "evenodd"
80
+ )
81
+ end
82
+ end
83
+ RUBY
84
+ end
85
+
86
+ render Docs::VisualCodeExample.new(title: "With Icon", context: self) do
87
+ <<~RUBY
88
+ Button(variant: :primary) do
89
+ svg(
90
+ xmlns: "http://www.w3.org/2000/svg",
91
+ fill: "none",
92
+ viewbox: "0 0 24 24",
93
+ stroke_width: "1.5",
94
+ stroke: "currentColor",
95
+ class: "w-4 h-4 mr-2"
96
+ ) do |s|
97
+ s.path(
98
+ stroke_linecap: "round",
99
+ stroke_linejoin: "round",
100
+ d:
101
+ "M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"
102
+ )
103
+ end
104
+ span { "Login with Email" }
105
+ end
106
+ RUBY
107
+ end
108
+
109
+ render Docs::VisualCodeExample.new(title: "With Icon", context: self) do
110
+ <<~RUBY
111
+ Button(variant: :primary, disabled: true) do
112
+ svg(
113
+ xmlns: "http://www.w3.org/2000/svg",
114
+ viewbox: "0 0 20 20",
115
+ fill: "currentColor",
116
+ class: "w-4 h-4 mr-2 animate-spin"
117
+ ) do |s|
118
+ s.path(
119
+ fill_rule: "evenodd",
120
+ d:
121
+ "M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z",
122
+ clip_rule: "evenodd"
123
+ )
124
+ end
125
+ span { "Please wait" }
126
+ end
127
+ RUBY
128
+ end
129
+
130
+ render Docs::VisualCodeExample.new(title: "Submit", context: self) do
131
+ <<~RUBY
132
+ Button(variant: :primary, type: :submit) do
133
+ span { "Submit application" }
134
+ end
135
+ RUBY
136
+ end
137
+
138
+ render Components::ComponentSetup::Tabs.new(component_name: component)
139
+
140
+ render Docs::ComponentsTable.new(component_files(component))
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Calendar < Views::Base
4
+ def view_template
5
+ component = "Calendar"
6
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
7
+ render Docs::Header.new(title: "Calendar", description: "A date field component that allows users to enter and edit date.")
8
+
9
+ Heading(level: 2) { "Usage" }
10
+
11
+ render Docs::VisualCodeExample.new(title: "Connect to input", context: self) do
12
+ <<~RUBY
13
+ div(class: 'space-y-4') do
14
+ Input(type: 'string', placeholder: "Select a date", class: 'rounded-md border shadow', id: 'date', data_controller: 'ruby-ui--calendar-input')
15
+ Calendar(input_id: '#date', class: 'rounded-md border shadow')
16
+ end
17
+ RUBY
18
+ end
19
+
20
+ render Docs::VisualCodeExample.new(title: "Format date", description: "Format dates with date-fns", context: self) do
21
+ <<~RUBY
22
+ div(class: 'space-y-4') do
23
+ Input(type: 'string', placeholder: "Select a date", class: 'rounded-md border shadow', id: 'formatted-date', data_controller: 'ruby-ui--calendar-input')
24
+ Calendar(input_id: '#formatted-date', date_format: 'PPPP', class: 'rounded-md border shadow')
25
+ end
26
+ RUBY
27
+ end
28
+
29
+ render Components::ComponentSetup::Tabs.new(component_name: component)
30
+
31
+ render Docs::ComponentsTable.new(component_files(component))
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Card < Views::Base
4
+ def view_template
5
+ component = "Card"
6
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
7
+ render Docs::Header.new(title: "Card", description: "Displays a card with header, content, and footer.")
8
+
9
+ Heading(level: 2) { "Usage" }
10
+
11
+ render Docs::VisualCodeExample.new(title: "Card with image", context: self) do
12
+ <<~RUBY
13
+ Card(class: 'w-96') do
14
+ CardHeader do
15
+ CardTitle { 'You might like "RubyUI"' }
16
+ CardDescription { "@joeldrapper" }
17
+ end
18
+ CardContent do
19
+ AspectRatio(aspect_ratio: "16/9", class: "rounded-md overflow-hidden border") do
20
+ img(
21
+ alt: "Placeholder",
22
+ loading: "lazy",
23
+ src: image_url('pattern.jpg')
24
+ )
25
+ end
26
+ end
27
+ CardFooter(class: 'flex justify-end gap-x-2') do
28
+ Button(variant: :outline) { "See more" }
29
+ Button(variant: :primary) { "Buy now" }
30
+ end
31
+ end
32
+ RUBY
33
+ end
34
+
35
+ render Docs::VisualCodeExample.new(title: "Card with full-width image", context: self) do
36
+ <<~RUBY
37
+ Card(class: 'w-96 overflow-hidden') do
38
+ AspectRatio(aspect_ratio: "16/9", class: "border-b") do
39
+ img(
40
+ alt: "Placeholder",
41
+ loading: "lazy",
42
+ src: image_url('pattern.jpg')
43
+ )
44
+ end
45
+ CardHeader do
46
+ CardTitle { 'Introducing RubyUI' }
47
+ CardDescription { "Kickstart your project today!" }
48
+ end
49
+ CardFooter(class: 'flex justify-end') do
50
+ Button(variant: :outline) { "Get started" }
51
+ end
52
+ end
53
+ RUBY
54
+ end
55
+
56
+ render Docs::VisualCodeExample.new(title: "Account balance", context: self) do
57
+ <<~RUBY
58
+ Card(class: 'w-96 overflow-hidden') do
59
+ CardHeader do
60
+ div(class: 'w-10 h-10 rounded-xl flex items-center justify-center bg-violet-100 text-violet-700 -rotate-6') do
61
+ cash_icon
62
+ end
63
+ end
64
+ CardContent(class: 'space-y-1') do
65
+ CardDescription(class: 'font-medium') { "Current Balance" }
66
+ h5(class: 'font-semibold text-4xl') { '$2,602' }
67
+ end
68
+ CardFooter do
69
+ Text(size: "2", class: "text-muted-foreground") { "**** 4620" }
70
+ end
71
+ end
72
+ RUBY
73
+ end
74
+
75
+ render Components::ComponentSetup::Tabs.new(component_name: component)
76
+
77
+ render Docs::ComponentsTable.new(component_files(component))
78
+ end
79
+ end
80
+
81
+ def arrow_icon(classes: nil)
82
+ svg(
83
+ xmlns: "http://www.w3.org/2000/svg",
84
+ viewbox: "0 0 20 20",
85
+ fill: "currentColor",
86
+ class: ["w-4 h-4", classes]
87
+ ) do |s|
88
+ s.path(
89
+ fill_rule: "evenodd",
90
+ d:
91
+ "M3 10a.75.75 0 01.75-.75h10.638L10.23 5.29a.75.75 0 111.04-1.08l5.5 5.25a.75.75 0 010 1.08l-5.5 5.25a.75.75 0 11-1.04-1.08l4.158-3.96H3.75A.75.75 0 013 10z",
92
+ clip_rule: "evenodd"
93
+ )
94
+ end
95
+ end
96
+
97
+ def cash_icon(classes: nil)
98
+ svg(
99
+ xmlns: "http://www.w3.org/2000/svg",
100
+ fill: "none",
101
+ viewbox: "0 0 24 24",
102
+ stroke_width: "1.5",
103
+ stroke: "currentColor",
104
+ class: ["w-6 h-6", classes]
105
+ ) do |s|
106
+ s.path(
107
+ stroke_linecap: "round",
108
+ stroke_linejoin: "round",
109
+ d:
110
+ "M2.25 18.75a60.07 60.07 0 0115.797 2.101c.727.198 1.453-.342 1.453-1.096V18.75M3.75 4.5v.75A.75.75 0 013 6h-.75m0 0v-.375c0-.621.504-1.125 1.125-1.125H20.25M2.25 6v9m18-10.5v.75c0 .414.336.75.75.75h.75m-1.5-1.5h.375c.621 0 1.125.504 1.125 1.125v9.75c0 .621-.504 1.125-1.125 1.125h-.375m1.5-1.5H21a.75.75 0 00-.75.75v.75m0 0H3.75m0 0h-.375a1.125 1.125 0 01-1.125-1.125V15m1.5 1.5v-.75A.75.75 0 003 15h-.75M15 10.5a3 3 0 11-6 0 3 3 0 016 0zm3 0h.008v.008H18V10.5zm-12 0h.008v.008H6V10.5z"
111
+ )
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Carousel < Views::Base
4
+ def view_template
5
+ component = "Carousel"
6
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
7
+ render Docs::Header.new(title: "Carousel", description: "A carousel with motion and swipe built using Embla.")
8
+
9
+ Heading(level: 2) { "Usage" }
10
+
11
+ render Docs::VisualCodeExample.new(title: "Example", context: self) do
12
+ <<~RUBY
13
+ Carousel(options: {loop:false}, class: "w-full max-w-xs") do
14
+ CarouselContent do
15
+ 5.times do |index|
16
+ CarouselItem do
17
+ div(class: "p-1") do
18
+ Card do
19
+ CardContent(class: "flex aspect-square items-center justify-center p-6") do
20
+ span(class: "text-4xl font-semibold") { index + 1 }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ CarouselPrevious()
28
+ CarouselNext()
29
+ end
30
+ RUBY
31
+ end
32
+
33
+ render Docs::VisualCodeExample.new(title: "Sizes", context: self) do
34
+ <<~RUBY
35
+ Carousel(class: "w-full max-w-sm") do
36
+ CarouselContent do
37
+ 5.times do |index|
38
+ CarouselItem(class: "md:basis-1/2 lg:basis-1/3") do
39
+ div(class: "p-1") do
40
+ Card do
41
+ CardContent(class: "flex aspect-square items-center justify-center p-6") do
42
+ span(class: "text-3xl font-semibold") { index + 1 }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ CarouselPrevious()
50
+ CarouselNext()
51
+ end
52
+ RUBY
53
+ end
54
+
55
+ render Docs::VisualCodeExample.new(title: "Spacing", context: self) do
56
+ <<~RUBY
57
+ Carousel(class: "w-full max-w-sm") do
58
+ CarouselContent(class: "-ml-1") do
59
+ 5.times do |index|
60
+ CarouselItem(class: "pl-1 md:basis-1/2 lg:basis-1/3") do
61
+ div(class: "p-1") do
62
+ Card do
63
+ CardContent(class: "flex aspect-square items-center justify-center p-6") do
64
+ span(class: "text-2xl font-semibold") { index + 1 }
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ CarouselPrevious()
72
+ CarouselNext()
73
+ end
74
+ RUBY
75
+ end
76
+
77
+ render Docs::VisualCodeExample.new(title: "Orientation", context: self) do
78
+ <<~RUBY
79
+ Carousel(orientation: :vertical, options: {align: "start"}, class: "w-full max-w-xs") do
80
+ CarouselContent(class: "-mt-1 h-[200px]") do
81
+ 5.times do |index|
82
+ CarouselItem(class: "pt-1 md:basis-1/2") do
83
+ div(class: "p-1") do
84
+ Card do
85
+ CardContent(class: "flex items-center justify-center p-6") do
86
+ span(class: "text-3xl font-semibold") { index + 1 }
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+ CarouselPrevious()
94
+ CarouselNext()
95
+ end
96
+ RUBY
97
+ end
98
+
99
+ render Components::ComponentSetup::Tabs.new(component_name: component)
100
+
101
+ render Docs::ComponentsTable.new(component_files(component))
102
+ end
103
+ end
104
+ end