Skip to content

Commit 3a068ff

Browse files
authored
Add component setup instruction with CLI (#141)
1 parent ad3584f commit 3a068ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+180
-7
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module Components
2+
module ComponentSetup
3+
class CLISteps < Components::Base
4+
def initialize(component_name:)
5+
@component_name = component_name
6+
end
7+
8+
private
9+
10+
attr_reader :component_name
11+
12+
def view_template
13+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-6") do
14+
Heading(level: 4, class: "pb-4 border-b") { "Using RubyUI CLI" }
15+
Text do
16+
"We provide a Ruby gem with useful generators to help you to setup RubyUI components in your apps."
17+
end
18+
19+
render Steps::Builder.new do |steps|
20+
steps.add_step do
21+
render Steps::Container do
22+
Text(size: "4", weight: "semibold") do
23+
plain "Add RubyUI gem to your Gemfile if you don't have it yet"
24+
end
25+
26+
code = <<~CODE
27+
bundle add ruby_ui --group development --require false
28+
CODE
29+
div(class: "w-full") do
30+
Codeblock(code, syntax: :javascript)
31+
end
32+
end
33+
end
34+
steps.add_step do
35+
render Steps::Container do
36+
Text(size: "4", weight: "semibold") do
37+
"Run the install command"
38+
end
39+
40+
code = <<~CODE
41+
rails g ruby_ui:component #{component_name.camelcase}
42+
CODE
43+
div(class: "w-full") do
44+
Codeblock(code, syntax: :javascript)
45+
end
46+
end
47+
end
48+
end
49+
end
50+
end
51+
end
52+
end
53+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module Components
2+
module ComponentSetup
3+
class Tabs < Components::Base
4+
def initialize(component_name:)
5+
@component_name = component_name
6+
end
7+
8+
private
9+
10+
attr_reader :component_name
11+
12+
def view_template
13+
Heading(level: 2) { "Installation" }
14+
15+
Tabs(default_value: "cli", class: "w-full") do
16+
TabsList do
17+
TabsTrigger(value: "cli") { "CLI" }
18+
TabsTrigger(value: "manual") { "Manual" }
19+
end
20+
21+
TabsContent(value: "cli") do
22+
render CLISteps.new(component_name:)
23+
end
24+
25+
TabsContent(value: "manual") do
26+
Text { "Coming soon" }
27+
end
28+
end
29+
end
30+
end
31+
end
32+
end

app/views/components/shared/menu.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def components
6868
{name: "Avatar", path: helpers.docs_avatar_path},
6969
{name: "Badge", path: helpers.docs_badge_path},
7070
{name: "Button", path: helpers.docs_button_path},
71-
{name: "Card", path: helpers.docs_card_path},
7271
{name: "Calendar", path: helpers.docs_calendar_path},
72+
{name: "Card", path: helpers.docs_card_path},
7373
# { name: "Chart", path: helpers.docs_chart_path, badge: "New" },
7474
{name: "Checkbox", path: helpers.docs_checkbox_path},
7575
{name: "Checkbox Group", path: helpers.docs_checkbox_group_path},
@@ -83,8 +83,8 @@ def components
8383
{name: "Dialog / Modal", path: helpers.docs_dialog_path},
8484
{name: "Dropdown Menu", path: helpers.docs_dropdown_menu_path},
8585
{name: "Form", path: helpers.docs_form_path},
86-
{name: "Input", path: helpers.docs_input_path},
8786
{name: "Hover Card", path: helpers.docs_hover_card_path},
87+
{name: "Input", path: helpers.docs_input_path},
8888
{name: "Link", path: helpers.docs_link_path},
8989
{name: "Masked Input", path: helpers.masked_input_path},
9090
{name: "Pagination", path: helpers.docs_pagination_path, badge: "New"},
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module Steps
4+
class Container < ApplicationComponent
5+
def view_template(&)
6+
div(class: "space-y-4", &)
7+
end
8+
end
9+
end

app/views/docs/accordion_view.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def view_template
4545
RUBY
4646
end
4747

48+
render Components::ComponentSetup::Tabs.new(component_name: component)
49+
4850
render Docs::ComponentsTable.new(component_files(component))
4951
end
5052
end

app/views/docs/alert_dialog_view.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def view_template
2727
RUBY
2828
end
2929

30+
render Components::ComponentSetup::Tabs.new(component_name: component)
31+
3032
render Docs::ComponentsTable.new(component_files(component))
3133
end
3234
end

app/views/docs/alert_view.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def view_template
5757
RUBY
5858
end
5959

60+
render Components::ComponentSetup::Tabs.new(component_name: component)
61+
6062
render Docs::ComponentsTable.new(component_files(component))
6163
end
6264
end

app/views/docs/aspect_ratio_view.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def view_template
6060
RUBY
6161
end
6262

63+
render Components::ComponentSetup::Tabs.new(component_name: component)
64+
6365
render Docs::ComponentsTable.new(component_files(component))
6466
end
6567
end

app/views/docs/avatar_view.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def view_template
8484
RUBY
8585
end
8686

87+
render Components::ComponentSetup::Tabs.new(component_name: component)
88+
8789
render Docs::ComponentsTable.new(component_files(component))
8890
end
8991
end

app/views/docs/badge_view.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
class Docs::BadgeView < ApplicationView
44
def view_template
5+
component = "Badge"
6+
57
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
68
render Docs::Header.new(title: "Badge", description: "Displays a badge or a component that looks like a badge.")
79

@@ -69,8 +71,10 @@ def view_template
6971
RUBY
7072
end
7173

74+
render Components::ComponentSetup::Tabs.new(component_name: component)
75+
7276
# components
73-
render Docs::ComponentsTable.new(component_files("Badge"))
77+
render Docs::ComponentsTable.new(component_files(component))
7478
end
7579
end
7680
end

0 commit comments

Comments
 (0)