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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +4 -0
- data/lib/generators/ruby_ui/install/docs_generator.rb +33 -0
- data/lib/ruby_ui/accordion/accordion_docs.rb +53 -0
- data/lib/ruby_ui/alert/alert_docs.rb +135 -0
- data/lib/ruby_ui/alert_dialog/alert_dialog_docs.rb +35 -0
- data/lib/ruby_ui/aspect_ratio/aspect_ratio_docs.rb +64 -0
- data/lib/ruby_ui/avatar/avatar_docs.rb +92 -0
- data/lib/ruby_ui/badge/badge_docs.rb +80 -0
- data/lib/ruby_ui/breadcrumb/breadcrumb_docs.rb +116 -0
- data/lib/ruby_ui/button/button_docs.rb +143 -0
- data/lib/ruby_ui/calendar/calendar_docs.rb +34 -0
- data/lib/ruby_ui/card/card_docs.rb +114 -0
- data/lib/ruby_ui/carousel/carousel_docs.rb +104 -0
- data/lib/ruby_ui/chart/chart_docs.rb +115 -0
- data/lib/ruby_ui/checkbox/checkbox.rb +2 -2
- data/lib/ruby_ui/checkbox/checkbox_docs.rb +41 -0
- data/lib/ruby_ui/clipboard/clipboard_docs.rb +30 -0
- data/lib/ruby_ui/codeblock/codeblock_docs.rb +55 -0
- data/lib/ruby_ui/collapsible/collapsible_docs.rb +96 -0
- data/lib/ruby_ui/combobox/combobox_controller.js +16 -1
- data/lib/ruby_ui/combobox/combobox_docs.rb +151 -0
- data/lib/ruby_ui/combobox/combobox_popover.rb +2 -1
- data/lib/ruby_ui/combobox/combobox_toggle_all_checkbox.rb +3 -2
- data/lib/ruby_ui/combobox/combobox_trigger.rb +1 -1
- data/lib/ruby_ui/command/command_docs.rb +154 -0
- data/lib/ruby_ui/context_menu/context_menu.rb +1 -1
- data/lib/ruby_ui/context_menu/context_menu_docs.rb +85 -0
- data/lib/ruby_ui/dialog/dialog_docs.rb +102 -0
- data/lib/ruby_ui/docs/base.rb +90 -0
- data/lib/ruby_ui/docs/component_setup_tabs.rb +15 -0
- data/lib/ruby_ui/docs/components_table.rb +13 -0
- data/lib/ruby_ui/docs/header.rb +17 -0
- data/lib/ruby_ui/docs/sidebar_examples.rb +22 -0
- data/lib/ruby_ui/docs/visual_code_example.rb +22 -0
- data/lib/ruby_ui/dropdown_menu/dropdown_menu_docs.rb +212 -0
- data/lib/ruby_ui/form/form_docs.rb +178 -0
- data/lib/ruby_ui/form/form_field.rb +1 -1
- data/lib/ruby_ui/form/form_field_error.rb +1 -1
- data/lib/ruby_ui/form/form_field_hint.rb +1 -1
- data/lib/ruby_ui/form/form_field_label.rb +1 -1
- data/lib/ruby_ui/hover_card/hover_card_docs.rb +71 -0
- data/lib/ruby_ui/input/input.rb +4 -3
- data/lib/ruby_ui/input/input_docs.rb +68 -0
- data/lib/ruby_ui/link/link_docs.rb +106 -0
- data/lib/ruby_ui/masked_input/masked_input_docs.rb +47 -0
- data/lib/ruby_ui/pagination/pagination_docs.rb +127 -0
- data/lib/ruby_ui/popover/popover_docs.rb +971 -0
- data/lib/ruby_ui/progress/progress_docs.rb +27 -0
- data/lib/ruby_ui/radio_button/radio_button.rb +1 -1
- data/lib/ruby_ui/radio_button/radio_button_docs.rb +53 -0
- data/lib/ruby_ui/select/select_docs.rb +129 -0
- data/lib/ruby_ui/separator/separator_docs.rb +36 -0
- data/lib/ruby_ui/sheet/sheet_content.rb +1 -1
- data/lib/ruby_ui/sheet/sheet_docs.rb +76 -0
- data/lib/ruby_ui/shortcut_key/shortcut_key_docs.rb +29 -0
- data/lib/ruby_ui/sidebar/sidebar_docs.rb +176 -0
- data/lib/ruby_ui/skeleton/skeleton_docs.rb +29 -0
- data/lib/ruby_ui/switch/switch_docs.rb +46 -0
- data/lib/ruby_ui/table/table_docs.rb +102 -0
- data/lib/ruby_ui/tabs/tabs_docs.rb +211 -0
- data/lib/ruby_ui/textarea/textarea_docs.rb +54 -0
- data/lib/ruby_ui/theme_toggle/theme_toggle_docs.rb +71 -0
- data/lib/ruby_ui/tooltip/tooltip_docs.rb +52 -0
- data/lib/ruby_ui/typography/typography_docs.rb +107 -0
- data/lib/ruby_ui.rb +1 -1
- metadata +53 -6
|
@@ -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
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Views::Docs::Chart < Views::Base
|
|
4
|
+
def view_template
|
|
5
|
+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
|
|
6
|
+
render Docs::Header.new(title: "Chart", description: "Displays information in a visual way.")
|
|
7
|
+
|
|
8
|
+
Heading(level: 2) { "Introduction" }
|
|
9
|
+
|
|
10
|
+
Text do
|
|
11
|
+
plain "RubyUI uses "
|
|
12
|
+
InlineLink(href: "https://www.chartjs.org/") { "Chart.js" }
|
|
13
|
+
plain " to render charts. Chart.js is a free open-source JavaScript library for data visualization, which supports 8 chart types: bar, line, area, pie, bubble, radar, polar, and scatter. If you're unfamiliar with Chart.js. We recommend the "
|
|
14
|
+
InlineLink(href: "https://www.chartjs.org/docs/latest/getting-started/") { "Getting Started guide" }
|
|
15
|
+
plain ". "
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Heading(level: 2) { "Usage" }
|
|
19
|
+
|
|
20
|
+
render Docs::VisualCodeExample.new(title: "Bar Chart", context: self) do
|
|
21
|
+
<<~RUBY
|
|
22
|
+
options = {
|
|
23
|
+
type: 'bar',
|
|
24
|
+
data: {
|
|
25
|
+
labels: ['Phlex', 'VC', 'ERB'],
|
|
26
|
+
datasets: [{
|
|
27
|
+
label: 'render time (ms)',
|
|
28
|
+
data: [100, 520, 1200],
|
|
29
|
+
}]
|
|
30
|
+
},
|
|
31
|
+
options: {
|
|
32
|
+
indexAxis: 'y',
|
|
33
|
+
scales: {
|
|
34
|
+
y: {
|
|
35
|
+
beginAtZero: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Chart(options: options)
|
|
42
|
+
RUBY
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
render Docs::VisualCodeExample.new(title: "Line Graph", context: self) do
|
|
46
|
+
<<~RUBY
|
|
47
|
+
options = {
|
|
48
|
+
type: 'line',
|
|
49
|
+
data: {
|
|
50
|
+
labels: ['Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
|
|
51
|
+
datasets: [{
|
|
52
|
+
label: 'Github Stars',
|
|
53
|
+
data: [40, 30, 79, 140, 290, 550],
|
|
54
|
+
}]
|
|
55
|
+
},
|
|
56
|
+
options: {
|
|
57
|
+
scales: {
|
|
58
|
+
y: {
|
|
59
|
+
beginAtZero: true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
plugins: {
|
|
63
|
+
legend: {
|
|
64
|
+
display: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Chart(options: options)
|
|
71
|
+
RUBY
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
render Docs::VisualCodeExample.new(title: "Pie Chart", description: "Setting custom background color", context: self) do
|
|
75
|
+
<<~RUBY
|
|
76
|
+
options = {
|
|
77
|
+
type: 'pie',
|
|
78
|
+
data: {
|
|
79
|
+
labels: [
|
|
80
|
+
'Red',
|
|
81
|
+
'Blue',
|
|
82
|
+
'Yellow'
|
|
83
|
+
],
|
|
84
|
+
datasets: [{
|
|
85
|
+
label: 'My First Dataset',
|
|
86
|
+
data: [300, 50, 100],
|
|
87
|
+
backgroundColor: [
|
|
88
|
+
'rgb(255, 99, 132)',
|
|
89
|
+
'rgb(54, 162, 235)',
|
|
90
|
+
'rgb(255, 205, 86)'
|
|
91
|
+
],
|
|
92
|
+
hoverOffset: 4
|
|
93
|
+
}]
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Chart(options: options)
|
|
98
|
+
RUBY
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
render Components::ComponentSetup::Tabs.new(component_name: "Chart")
|
|
102
|
+
|
|
103
|
+
render Docs::ComponentsTable.new(components)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
|
|
109
|
+
def components
|
|
110
|
+
[
|
|
111
|
+
::Docs::ComponentStruct.new(name: "ChartController", source: "https://github.com/PhlexUI/phlex_ui_stimulus/blob/main/controllers/chart_controller.js", built_using: :stimulus),
|
|
112
|
+
::Docs::ComponentStruct.new(name: "Chart", source: "https://github.com/PhlexUI/phlex_ui/blob/main/lib/phlex_ui/chart.rb", built_using: :phlex)
|
|
113
|
+
]
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -17,9 +17,9 @@ module RubyUI
|
|
|
17
17
|
action: "change->ruby-ui--checkbox-group#onChange change->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
|
|
18
18
|
},
|
|
19
19
|
class: [
|
|
20
|
-
"peer h-4 w-4 shrink-0 rounded-sm border
|
|
20
|
+
"peer h-4 w-4 shrink-0 rounded-sm border-input ring-offset-background accent-primary",
|
|
21
21
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
22
|
-
"checked:bg-primary checked:text-primary-foreground",
|
|
22
|
+
"checked:bg-primary checked:text-primary-foreground dark:checked:bg-secondary checked:text-primary checked:border-primary",
|
|
23
23
|
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none",
|
|
24
24
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
25
25
|
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Views::Docs::Checkbox < Views::Base
|
|
4
|
+
def view_template
|
|
5
|
+
component = "Checkbox"
|
|
6
|
+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
|
|
7
|
+
render Docs::Header.new(title: "Checkbox", description: "A control that allows the user to toggle between checked and not checked.")
|
|
8
|
+
|
|
9
|
+
Heading(level: 2) { "Usage" }
|
|
10
|
+
|
|
11
|
+
render Docs::VisualCodeExample.new(title: "Example", context: self) do
|
|
12
|
+
<<~RUBY
|
|
13
|
+
div(class: 'flex items-center space-x-3') do
|
|
14
|
+
Checkbox(id: 'terms')
|
|
15
|
+
label(for: 'terms', class: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70') { "Accept terms and conditions" }
|
|
16
|
+
end
|
|
17
|
+
RUBY
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
render Docs::VisualCodeExample.new(title: "Checked", context: self) do
|
|
21
|
+
<<~RUBY
|
|
22
|
+
div(class: "items-top flex space-x-3") do
|
|
23
|
+
Checkbox(id: 'terms1', checked: true)
|
|
24
|
+
div(class: "grid gap-1.5 leading-none") do
|
|
25
|
+
label(
|
|
26
|
+
for: "terms1",
|
|
27
|
+
class:
|
|
28
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
29
|
+
) { " Accept terms and conditions " }
|
|
30
|
+
p(class: "text-sm text-muted-foreground") { " You agree to our Terms of Service and Privacy Policy." }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
RUBY
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
render Components::ComponentSetup::Tabs.new(component_name: component)
|
|
37
|
+
|
|
38
|
+
render Docs::ComponentsTable.new(component_files(component))
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Views::Docs::Clipboard < Views::Base
|
|
4
|
+
def view_template
|
|
5
|
+
component = "Clipboard"
|
|
6
|
+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
|
|
7
|
+
render Docs::Header.new(title: "Clipboard", description: "A control to allow you to copy content to the clipboard.")
|
|
8
|
+
|
|
9
|
+
Heading(level: 2) { "Usage" }
|
|
10
|
+
|
|
11
|
+
render Docs::VisualCodeExample.new(title: "Example", context: self) do
|
|
12
|
+
<<~RUBY
|
|
13
|
+
Clipboard(success: "Copied!", error: "Copy failed!", class: "relative", options: {placement: "top"}) do
|
|
14
|
+
ClipboardSource(class: "hidden") { span { "Born rich!!!" } }
|
|
15
|
+
|
|
16
|
+
ClipboardTrigger do
|
|
17
|
+
Link(href: "#", class: "gap-1") do
|
|
18
|
+
Text(size: :small, class: "text-primary") { "Copy the secret of success!!!" }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
RUBY
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
render Components::ComponentSetup::Tabs.new(component_name: component)
|
|
26
|
+
|
|
27
|
+
render Docs::ComponentsTable.new(component_files(component))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Views::Docs::Codeblock < Views::Base
|
|
4
|
+
def view_template
|
|
5
|
+
component = "Codeblock"
|
|
6
|
+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
|
|
7
|
+
render Docs::Header.new(title: "Codeblock", description: "A component for displaying highlighted code.")
|
|
8
|
+
|
|
9
|
+
Heading(level: 2) { "Usage" }
|
|
10
|
+
|
|
11
|
+
render Docs::VisualCodeExample.new(title: "With clipboard", context: self) do
|
|
12
|
+
<<~RUBY
|
|
13
|
+
code = <<~CODE
|
|
14
|
+
def hello_world
|
|
15
|
+
puts "Hello, world!"
|
|
16
|
+
end
|
|
17
|
+
CODE
|
|
18
|
+
div(class: 'w-full') do
|
|
19
|
+
Codeblock(code, syntax: :ruby)
|
|
20
|
+
end
|
|
21
|
+
RUBY
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
render Docs::VisualCodeExample.new(title: "Without clipboard", context: self) do
|
|
25
|
+
<<~RUBY
|
|
26
|
+
code = <<~CODE
|
|
27
|
+
def hello_world
|
|
28
|
+
puts "Hello, world!"
|
|
29
|
+
end
|
|
30
|
+
CODE
|
|
31
|
+
div(class: 'w-full') do
|
|
32
|
+
Codeblock(code, syntax: :ruby, clipboard: false)
|
|
33
|
+
end
|
|
34
|
+
RUBY
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
render Docs::VisualCodeExample.new(title: "Custom message", description: "Copy the code to see the message", context: self) do
|
|
38
|
+
<<~RUBY
|
|
39
|
+
code = <<~CODE
|
|
40
|
+
def hello_world
|
|
41
|
+
puts "Hello, world!"
|
|
42
|
+
end
|
|
43
|
+
CODE
|
|
44
|
+
div(class: 'w-full') do
|
|
45
|
+
Codeblock(code, syntax: :ruby, clipboard_success: "Nice one!")
|
|
46
|
+
end
|
|
47
|
+
RUBY
|
|
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
|
|
55
|
+
end
|