ruby_ui 1.0.2 → 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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +4 -0
  4. data/lib/generators/ruby_ui/install/docs_generator.rb +33 -0
  5. data/lib/ruby_ui/accordion/accordion_docs.rb +53 -0
  6. data/lib/ruby_ui/alert/alert_docs.rb +135 -0
  7. data/lib/ruby_ui/alert_dialog/alert_dialog_docs.rb +35 -0
  8. data/lib/ruby_ui/aspect_ratio/aspect_ratio_docs.rb +64 -0
  9. data/lib/ruby_ui/avatar/avatar_docs.rb +92 -0
  10. data/lib/ruby_ui/badge/badge_docs.rb +80 -0
  11. data/lib/ruby_ui/breadcrumb/breadcrumb_docs.rb +116 -0
  12. data/lib/ruby_ui/button/button_docs.rb +143 -0
  13. data/lib/ruby_ui/calendar/calendar_docs.rb +34 -0
  14. data/lib/ruby_ui/card/card_docs.rb +114 -0
  15. data/lib/ruby_ui/carousel/carousel_docs.rb +104 -0
  16. data/lib/ruby_ui/chart/chart_docs.rb +115 -0
  17. data/lib/ruby_ui/checkbox/checkbox.rb +2 -2
  18. data/lib/ruby_ui/checkbox/checkbox_docs.rb +41 -0
  19. data/lib/ruby_ui/clipboard/clipboard_docs.rb +30 -0
  20. data/lib/ruby_ui/codeblock/codeblock_docs.rb +55 -0
  21. data/lib/ruby_ui/collapsible/collapsible_docs.rb +96 -0
  22. data/lib/ruby_ui/combobox/combobox_controller.js +16 -1
  23. data/lib/ruby_ui/combobox/combobox_docs.rb +151 -0
  24. data/lib/ruby_ui/combobox/combobox_popover.rb +2 -1
  25. data/lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb +3 -2
  26. data/lib/ruby_ui/combobox/combobox_trigger.rb +1 -1
  27. data/lib/ruby_ui/command/command_docs.rb +154 -0
  28. data/lib/ruby_ui/context_menu/context_menu.rb +1 -1
  29. data/lib/ruby_ui/context_menu/context_menu_docs.rb +85 -0
  30. data/lib/ruby_ui/dialog/dialog_docs.rb +102 -0
  31. data/lib/ruby_ui/docs/base.rb +90 -0
  32. data/lib/ruby_ui/docs/component_setup_tabs.rb +15 -0
  33. data/lib/ruby_ui/docs/components_table.rb +13 -0
  34. data/lib/ruby_ui/docs/header.rb +17 -0
  35. data/lib/ruby_ui/docs/sidebar_examples.rb +22 -0
  36. data/lib/ruby_ui/docs/visual_code_example.rb +22 -0
  37. data/lib/ruby_ui/dropdown_menu/dropdown_menu_docs.rb +212 -0
  38. data/lib/ruby_ui/form/form_docs.rb +178 -0
  39. data/lib/ruby_ui/form/form_field.rb +1 -1
  40. data/lib/ruby_ui/form/form_field_error.rb +1 -1
  41. data/lib/ruby_ui/form/form_field_hint.rb +1 -1
  42. data/lib/ruby_ui/form/form_field_label.rb +1 -1
  43. data/lib/ruby_ui/hover_card/hover_card_docs.rb +71 -0
  44. data/lib/ruby_ui/input/input.rb +4 -3
  45. data/lib/ruby_ui/input/input_docs.rb +68 -0
  46. data/lib/ruby_ui/link/link_docs.rb +106 -0
  47. data/lib/ruby_ui/masked_input/masked_input_docs.rb +47 -0
  48. data/lib/ruby_ui/pagination/pagination_docs.rb +127 -0
  49. data/lib/ruby_ui/popover/popover_docs.rb +971 -0
  50. data/lib/ruby_ui/progress/progress_docs.rb +27 -0
  51. data/lib/ruby_ui/radio_button/radio_button.rb +1 -1
  52. data/lib/ruby_ui/radio_button/radio_button_docs.rb +53 -0
  53. data/lib/ruby_ui/select/select_docs.rb +129 -0
  54. data/lib/ruby_ui/separator/separator_docs.rb +36 -0
  55. data/lib/ruby_ui/sheet/sheet_content.rb +1 -1
  56. data/lib/ruby_ui/sheet/sheet_docs.rb +76 -0
  57. data/lib/ruby_ui/shortcut_key/shortcut_key_docs.rb +29 -0
  58. data/lib/ruby_ui/sidebar/sidebar_docs.rb +176 -0
  59. data/lib/ruby_ui/skeleton/skeleton_docs.rb +29 -0
  60. data/lib/ruby_ui/switch/switch_docs.rb +46 -0
  61. data/lib/ruby_ui/table/table_docs.rb +102 -0
  62. data/lib/ruby_ui/tabs/tabs_docs.rb +211 -0
  63. data/lib/ruby_ui/textarea/textarea_docs.rb +54 -0
  64. data/lib/ruby_ui/theme_toggle/theme_toggle_docs.rb +71 -0
  65. data/lib/ruby_ui/tooltip/tooltip_docs.rb +52 -0
  66. data/lib/ruby_ui/typography/typography_docs.rb +107 -0
  67. data/lib/ruby_ui.rb +1 -1
  68. metadata +53 -6
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Table < Views::Base
4
+ Invoice = Struct.new(:identifier, :status, :method, :amount, keyword_init: true)
5
+ User = Struct.new(:avatar_url, :name, :username, :commits, :github_url, keyword_init: true)
6
+
7
+ def view_template
8
+ component = "Table"
9
+
10
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-8") do
11
+ render Docs::Header.new(title: "Table", description: "A responsive table component.")
12
+
13
+ Heading(level: 2) { "Usage" }
14
+
15
+ render Docs::VisualCodeExample.new(title: "Without builder", context: self) do
16
+ <<~RUBY
17
+ Table do
18
+ TableCaption { "Employees at Acme inc." }
19
+ TableHeader do
20
+ TableRow do
21
+ TableHead { "Name" }
22
+ TableHead { "Email" }
23
+ TableHead { "Status" }
24
+ TableHead(class: "text-right") { "Role" }
25
+ end
26
+ end
27
+ TableBody do
28
+ invoices.each do |invoice|
29
+ TableRow do
30
+ TableCell(class: 'font-medium') { invoice.identifier }
31
+ TableCell { render_status_badge(invoice.status) }
32
+ TableCell { invoice.method }
33
+ TableCell(class: "text-right") { format_amount(invoice.amount) }
34
+ end
35
+ end
36
+ end
37
+ TableFooter do
38
+ TableRow do
39
+ TableHead(class: "font-medium", colspan: 3) { "Total" }
40
+ TableHead(class: "font-medium text-right") { format_amount(invoices.sum(&:amount)) }
41
+ end
42
+ end
43
+ end
44
+ RUBY
45
+ end
46
+
47
+ render Components::ComponentSetup::Tabs.new(component_name: component)
48
+
49
+ render Docs::ComponentsTable.new(component_files(component))
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def invoices
56
+ [
57
+ Invoice.new(identifier: "INV-0001", status: "Active", method: "Credit Card", amount: 100),
58
+ Invoice.new(identifier: "INV-0002", status: "Active", method: "Bank Transfer", amount: 230),
59
+ Invoice.new(identifier: "INV-0003", status: "Pending", method: "PayPal", amount: 350),
60
+ Invoice.new(identifier: "INV-0004", status: "Inactive", method: "Credit Card", amount: 100)
61
+ ]
62
+ end
63
+
64
+ def users
65
+ [
66
+ User.new(avatar_url: "https://avatars.githubusercontent.com/u/246692?v=4", name: "Joel Drapper", username: "joeldrapper", commits: 404),
67
+ User.new(avatar_url: "https://avatars.githubusercontent.com/u/33979976?v=4", name: "Alexandre Ruban", username: "alexandreruban", commits: 16),
68
+ User.new(avatar_url: "https://avatars.githubusercontent.com/u/77887?v=4", name: "Will Cosgrove", username: "willcosgrove", commits: 12),
69
+ User.new(avatar_url: "https://avatars.githubusercontent.com/u/3025661?v=4", name: "Stephann V.", username: "stephannv", commits: 8),
70
+ User.new(avatar_url: "https://avatars.githubusercontent.com/u/6411752?v=4", name: "Marco Roth", username: "marcoroth", commits: 8)
71
+ ]
72
+ end
73
+
74
+ def github_link(user)
75
+ "https://github.com/#{user.username}"
76
+ end
77
+
78
+ def github_icon
79
+ svg(viewbox: "0 0 438.549 438.549", class: "h-4 w-4") do |s|
80
+ s.path(
81
+ fill: "currentColor",
82
+ d:
83
+ "M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"
84
+ )
85
+ end
86
+ end
87
+
88
+ def format_amount(amount)
89
+ "$#{amount}.00"
90
+ end
91
+
92
+ def render_status_badge(status)
93
+ case status.downcase
94
+ when "active"
95
+ Badge(variant: :success, size: :sm) { status }
96
+ when "inactive"
97
+ Badge(variant: :destructive, size: :sm) { status }
98
+ when "pending"
99
+ Badge(variant: :warning, size: :sm) { status }
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,211 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Tabs < Views::Base
4
+ Repo = Struct.new(:github_url, :name, :stars, :version, keyword_init: true)
5
+
6
+ def view_template
7
+ component = "Tabs"
8
+
9
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
10
+ render Docs::Header.new(title: "Tabs", description: "A set of layered sections of content—known as tab panels—that are displayed one at a time.")
11
+
12
+ Heading(level: 2) { "Usage" }
13
+
14
+ render Docs::VisualCodeExample.new(title: "Example", context: self) do
15
+ <<~RUBY
16
+ Tabs(default_value: "account", class: 'w-96') do
17
+ TabsList do
18
+ TabsTrigger(value: "account") { "Account" }
19
+ TabsTrigger(value: "password") { "Password" }
20
+ end
21
+ TabsContent(value: "account") do
22
+ div(class: "rounded-lg border p-6 space-y-4 bg-background text-foreground") do
23
+ div(class: "space-y-0") do
24
+ Text(size: "4", weight: "semibold") { "Account" }
25
+ Text(size: "2", class: "text-muted-foreground") { "Update your account details." }
26
+ end
27
+ end
28
+ end
29
+ TabsContent(value: "password") do
30
+ div(class: "rounded-lg border p-6 space-y-4 bg-background text-foreground") do
31
+ div do
32
+ Text(size: "4", weight: "semibold") { "Password" }
33
+ Text(size: "2", class: "text-muted-foreground") { "Change your password here. After saving, you'll be logged out." }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ RUBY
39
+ end
40
+
41
+ render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
42
+ <<~RUBY
43
+ Tabs(default_value: "account", class: 'w-96') do
44
+ TabsList do
45
+ TabsTrigger(disabled: true, value: "account") { "Account" }
46
+ TabsTrigger(disabled: true, value: "password") { "Password" }
47
+ end
48
+ end
49
+ RUBY
50
+ end
51
+
52
+ render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do
53
+ <<~RUBY
54
+ Tabs(default_value: "account", class: 'w-96') do
55
+ TabsList do
56
+ TabsTrigger(aria: {disabled: "true"}, value: "account") { "Account" }
57
+ TabsTrigger(aria: {disabled: "true"}, value: "password") { "Password" }
58
+ end
59
+ end
60
+ RUBY
61
+ end
62
+
63
+ render Docs::VisualCodeExample.new(title: "Full width", context: self) do
64
+ <<~RUBY
65
+ Tabs(default_value: "overview", class: 'w-96') do
66
+ TabsList(class: 'w-full grid grid-cols-2') do
67
+ TabsTrigger(value: "overview") do
68
+ book_icon
69
+ span(class: 'ml-2') { "Overview" }
70
+ end
71
+ TabsTrigger(value: "repositories") do
72
+ repo_icon
73
+ span(class: 'ml-2') { "Repositories" }
74
+ end
75
+ end
76
+ TabsContent(value: "overview") do
77
+ div(class: "rounded-lg border p-6 bg-background text-foreground flex justify-between space-x-4") do
78
+ Avatar do
79
+ AvatarImage(src: "https://avatars.githubusercontent.com/u/246692?v=4", alt: "joeldrapper")
80
+ AvatarFallback { "JD" }
81
+ end
82
+ div(class: "space-y-4") do
83
+ div do
84
+ Text(size: "4", weight: "semibold") { "Joel Drapper" }
85
+ Text(size: "2", class: "text-muted-foreground") { "Creator of Phlex Components. Ruby on Rails developer." }
86
+ end
87
+ Link(href: "https://github.com/joeldrapper", variant: :outline, size: :sm) do
88
+ github_icon
89
+ span(class: 'ml-2') { "View profile" }
90
+ end
91
+ end
92
+ end
93
+ end
94
+ TabsContent(value: "repositories") do
95
+ div(class: "rounded-lg border p-6 space-y-4 bg-background text-foreground") do
96
+ repo = repositories.first
97
+ Link(href: repo.github_url, variant: :link, class: "pl-0") { repo.name }
98
+ Badge { repo.version }
99
+ end
100
+ end
101
+ end
102
+ RUBY
103
+ end
104
+
105
+ render Docs::VisualCodeExample.new(title: "Change default value", context: self) do
106
+ <<~RUBY
107
+ Tabs(default: "password", class: 'w-96') do
108
+ TabsList do
109
+ TabsTrigger(value: "account") { "Account" }
110
+ TabsTrigger(value: "password") { "Password" }
111
+ end
112
+ TabsContent(value: "account") do
113
+ div(class: "rounded-lg border p-6 space-y-4 bg-background text-foreground") do
114
+ div(class: "space-y-0") do
115
+ Text(size: "4", weight: "semibold") { "Account" }
116
+ Text(size: "2", class: "text-muted-foreground") { "Update your account details." }
117
+ end
118
+ end
119
+ end
120
+ TabsContent(value: "password") do
121
+ div(class: "rounded-lg border p-6 space-y-4 bg-background text-foreground") do
122
+ div do
123
+ Text(size: "4", weight: "semibold") { "Password" }
124
+ Text(size: "2", class: "text-muted-foreground") { "Change your password here. After saving, you'll be logged out." }
125
+ end
126
+ end
127
+ end
128
+ end
129
+ RUBY
130
+ end
131
+
132
+ render Components::ComponentSetup::Tabs.new(component_name: component)
133
+
134
+ render Docs::ComponentsTable.new(component_files(component))
135
+ end
136
+ end
137
+
138
+ private
139
+
140
+ def book_icon
141
+ svg(
142
+ xmlns: "http://www.w3.org/2000/svg",
143
+ fill: "none",
144
+ viewbox: "0 0 24 24",
145
+ stroke_width: "2",
146
+ stroke: "currentColor",
147
+ class: "w-4 h-4 text-muted-foreground"
148
+ ) do |s|
149
+ s.path(
150
+ stroke_linecap: "round",
151
+ stroke_linejoin: "round",
152
+ d:
153
+ "M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"
154
+ )
155
+ end
156
+ end
157
+
158
+ def repo_icon
159
+ svg(
160
+ xmlns: "http://www.w3.org/2000/svg",
161
+ fill: "none",
162
+ viewbox: "0 0 24 24",
163
+ stroke_width: "2",
164
+ stroke: "currentColor",
165
+ class: "w-4 h-4 text-muted-foreground"
166
+ ) do |s|
167
+ s.path(
168
+ stroke_linecap: "round",
169
+ stroke_linejoin: "round",
170
+ d:
171
+ "M16.5 3.75V16.5L12 14.25 7.5 16.5V3.75m9 0H18A2.25 2.25 0 0120.25 6v12A2.25 2.25 0 0118 20.25H6A2.25 2.25 0 013.75 18V6A2.25 2.25 0 016 3.75h1.5m9 0h-9"
172
+ )
173
+ end
174
+ end
175
+
176
+ def github_icon
177
+ svg(viewbox: "0 0 438.549 438.549", class: "h-4 w-4") do |s|
178
+ s.path(
179
+ fill: "currentColor",
180
+ d:
181
+ "M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"
182
+ )
183
+ end
184
+ end
185
+
186
+ def star_icon
187
+ svg(
188
+ xmlns: "http://www.w3.org/2000/svg",
189
+ fill: "none",
190
+ viewbox: "0 0 24 24",
191
+ stroke_width: "2",
192
+ stroke: "currentColor",
193
+ class: "w-4 h-4 text-amber-500"
194
+ ) do |s|
195
+ s.path(
196
+ stroke_linecap: "round",
197
+ stroke_linejoin: "round",
198
+ d:
199
+ "M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"
200
+ )
201
+ end
202
+ end
203
+
204
+ def repositories
205
+ [
206
+ Repo.new(github_url: "https://github.com/phlex-ruby/phlex", name: "phlex", stars: 961, version: "v1.8.1"),
207
+ Repo.new(github_url: "https://github.com/joeldrapper/green_dots", name: "green_dots", stars: 40, version: "1.0"),
208
+ Repo.new(github_url: "https://github.com/joeldrapper/literal", name: "literal", stars: 96, version: "v0.1.0")
209
+ ]
210
+ end
211
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Textarea < Views::Base
4
+ def view_template
5
+ component = "Textarea"
6
+
7
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8
+ render Docs::Header.new(title: "Textarea", description: "Displays a textarea field.")
9
+
10
+ Heading(level: 2) { "Usage" }
11
+
12
+ render Docs::VisualCodeExample.new(title: "Textarea", context: self) do
13
+ <<~RUBY
14
+ div(class: "grid w-full max-w-sm items-center gap-1.5") do
15
+ Textarea(placeholder: "Textarea")
16
+ end
17
+ RUBY
18
+ end
19
+
20
+ render Docs::VisualCodeExample.new(title: "Disabled", context: self) do
21
+ <<~RUBY
22
+ div(class: "grid w-full max-w-sm items-center gap-1.5") do
23
+ Textarea(disabled: true, placeholder: "Disabled")
24
+ end
25
+ RUBY
26
+ end
27
+
28
+ render Docs::VisualCodeExample.new(title: "Aria Disabled", context: self) do
29
+ <<~RUBY
30
+ div(class: "grid w-full max-w-sm items-center gap-1.5") do
31
+ Textarea(aria: {disabled: "true"}, placeholder: "Aria Disabled")
32
+ end
33
+ RUBY
34
+ end
35
+
36
+ render Docs::VisualCodeExample.new(title: "With FormField", context: self) do
37
+ <<~RUBY
38
+ div(class: "grid w-full max-w-sm items-center gap-1.5") do
39
+ FormField do
40
+ FormFieldLabel(for: "textarea") { "Textarea" }
41
+ FormFieldHint { "This is a textarea" }
42
+ Textarea(placeholder: "Textarea", id: "textarea")
43
+ FormFieldError()
44
+ end
45
+ end
46
+ RUBY
47
+ end
48
+ end
49
+
50
+ render Components::ComponentSetup::Tabs.new(component_name: component)
51
+
52
+ render Docs::ComponentsTable.new(component_files(component))
53
+ end
54
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::ThemeToggle < Views::Base
4
+ def view_template
5
+ component = "ThemeToggle"
6
+
7
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8
+ render Docs::Header.new(title: "Theme Toggle", description: "Toggle between dark/light theme.")
9
+
10
+ Heading(level: 2) { "Usage" }
11
+
12
+ render Docs::VisualCodeExample.new(title: "With icon", context: self) do
13
+ <<~RUBY
14
+ ThemeToggle do |toggle|
15
+ SetLightMode do
16
+ Button(variant: :ghost, icon: true) do
17
+ svg(
18
+ xmlns: "http://www.w3.org/2000/svg",
19
+ viewbox: "0 0 24 24",
20
+ fill: "currentColor",
21
+ class: "w-4 h-4"
22
+ ) do |s|
23
+ s.path(
24
+ d:
25
+ "M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-2.25A.75.75 0 0112 18zM7.758 17.303a.75.75 0 00-1.061-1.06l-1.591 1.59a.75.75 0 001.06 1.061l1.591-1.59zM6 12a.75.75 0 01-.75.75H3a.75.75 0 010-1.5h2.25A.75.75 0 016 12zM6.697 7.757a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 00-1.061 1.06l1.59 1.591z"
26
+ )
27
+ end
28
+ end
29
+ end
30
+
31
+ SetDarkMode do
32
+ Button(variant: :ghost, icon: true) do
33
+ svg(
34
+ xmlns: "http://www.w3.org/2000/svg",
35
+ viewbox: "0 0 24 24",
36
+ fill: "currentColor",
37
+ class: "w-4 h-4"
38
+ ) do |s|
39
+ s.path(
40
+ fill_rule: "evenodd",
41
+ d:
42
+ "M9.528 1.718a.75.75 0 01.162.819A8.97 8.97 0 009 6a9 9 0 009 9 8.97 8.97 0 003.463-.69.75.75 0 01.981.98 10.503 10.503 0 01-9.694 6.46c-5.799 0-10.5-4.701-10.5-10.5 0-4.368 2.667-8.112 6.46-9.694a.75.75 0 01.818.162z",
43
+ clip_rule: "evenodd"
44
+ )
45
+ end
46
+ end
47
+ end
48
+ end
49
+ RUBY
50
+ end
51
+
52
+ render Docs::VisualCodeExample.new(title: "With text", context: self) do
53
+ <<~RUBY
54
+ ThemeToggle do |toggle|
55
+ SetLightMode do
56
+ Button(variant: :primary) { "Light" }
57
+ end
58
+
59
+ SetDarkMode do
60
+ Button(variant: :primary) { "Dark" }
61
+ end
62
+ end
63
+ RUBY
64
+ end
65
+
66
+ render Components::ComponentSetup::Tabs.new(component_name: component)
67
+
68
+ render Docs::ComponentsTable.new(component_files(component))
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Tooltip < Views::Base
4
+ def view_template
5
+ component = "Tooltip"
6
+
7
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8
+ render Docs::Header.new(title: "Tooltip", description: "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.")
9
+
10
+ Heading(level: 2) { "Usage" }
11
+
12
+ render Docs::VisualCodeExample.new(title: "Example", context: self) do
13
+ <<~RUBY
14
+ Tooltip do
15
+ TooltipTrigger do
16
+ Button(variant: :outline, icon: true) do
17
+ bookmark_icon
18
+ end
19
+ end
20
+ TooltipContent do
21
+ Text { "Add to library" }
22
+ end
23
+ end
24
+ RUBY
25
+ end
26
+
27
+ render Components::ComponentSetup::Tabs.new(component_name: component)
28
+
29
+ render Docs::ComponentsTable.new(component_files(component))
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def bookmark_icon
36
+ svg(
37
+ xmlns: "http://www.w3.org/2000/svg",
38
+ fill: "none",
39
+ viewbox: "0 0 24 24",
40
+ stroke_width: "1.5",
41
+ stroke: "currentColor",
42
+ class: "w-4 h-4"
43
+ ) do |s|
44
+ s.path(
45
+ stroke_linecap: "round",
46
+ stroke_linejoin: "round",
47
+ d:
48
+ "M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0111.186 0z"
49
+ )
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Views::Docs::Typography < Views::Base
4
+ def view_template
5
+ component = "Typography"
6
+
7
+ div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8
+ render Docs::Header.new(title: "Typography", description: "Sensible defaults to use for text.")
9
+
10
+ Components.Heading(level: 2) { "Usage" }
11
+
12
+ render Docs::VisualCodeExample.new(title: "h1", context: self) do
13
+ <<~RUBY
14
+ Heading(level: 1) { "This is an H1 title" }
15
+ RUBY
16
+ end
17
+
18
+ render Docs::VisualCodeExample.new(title: "h2", context: self) do
19
+ <<~RUBY
20
+ Heading(level: 2) { "This is an H2 title" }
21
+ RUBY
22
+ end
23
+
24
+ render Docs::VisualCodeExample.new(title: "h3", context: self) do
25
+ <<~RUBY
26
+ Heading(level: 3) { "This is an H3 title" }
27
+ RUBY
28
+ end
29
+
30
+ render Docs::VisualCodeExample.new(title: "h4", context: self) do
31
+ <<~RUBY
32
+ Heading(level: 4) { "This is an H4 title" }
33
+ RUBY
34
+ end
35
+
36
+ render Docs::VisualCodeExample.new(title: "p", context: self) do
37
+ <<~RUBY
38
+ Text { "This is an P tag" }
39
+ RUBY
40
+ end
41
+
42
+ render Docs::VisualCodeExample.new(title: "Inline Link", context: self) do
43
+ <<~RUBY
44
+ Text(class: 'text-center') do
45
+ plain "Checkout our "
46
+ InlineLink(href: docs_installation_path) { "installation instructions" }
47
+ plain " to get started."
48
+ end
49
+ RUBY
50
+ end
51
+
52
+ render Docs::VisualCodeExample.new(title: "List", context: self) do
53
+ <<~RUBY
54
+ Components.TypographyList(items: [
55
+ 'Phlex is fast',
56
+ 'Phlex is easy to use',
57
+ 'Phlex is awesome',
58
+ ])
59
+ RUBY
60
+ end
61
+
62
+ render Docs::VisualCodeExample.new(title: "Numbered List", context: self) do
63
+ <<~RUBY
64
+ Components.TypographyList(items: [
65
+ 'Copy',
66
+ 'Paste',
67
+ 'Customize',
68
+ ], numbered: true)
69
+ RUBY
70
+ end
71
+
72
+ render Docs::VisualCodeExample.new(title: "Inline Code", context: self) do
73
+ <<~RUBY
74
+ InlineCode { "This is an inline code block" }
75
+ RUBY
76
+ end
77
+
78
+ render Docs::VisualCodeExample.new(title: "Lead", context: self) do
79
+ <<~RUBY
80
+ Text(as: "p", size: "5", weight: "muted") { "A modal dialog that interrupts the user with important content and expects a response." }
81
+ RUBY
82
+ end
83
+
84
+ render Docs::VisualCodeExample.new(title: "Large", context: self) do
85
+ <<~RUBY
86
+ Text(size: "4", weight: "semibold") { "Are you sure absolutely sure?" }
87
+ RUBY
88
+ end
89
+
90
+ render Docs::VisualCodeExample.new(title: "Small", context: self) do
91
+ <<~RUBY
92
+ Text(size: "sm") { "Email address" }
93
+ RUBY
94
+ end
95
+
96
+ render Docs::VisualCodeExample.new(title: "Muted", context: self) do
97
+ <<~RUBY
98
+ Text(size: "2", class: "text-muted-foreground") { "Enter your email address." }
99
+ RUBY
100
+ end
101
+
102
+ render Components::ComponentSetup::Tabs.new(component_name: component)
103
+
104
+ render Docs::ComponentsTable.new(component_files(component))
105
+ end
106
+ end
107
+ end
data/lib/ruby_ui.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyUI
4
- VERSION = "1.0.2"
4
+ VERSION = "1.1.0"
5
5
  end