Skip to content

Commit

Permalink
Add component setup instruction with CLI (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv authored Nov 21, 2024
1 parent ad3584f commit 3a068ff
Show file tree
Hide file tree
Showing 42 changed files with 180 additions and 7 deletions.
53 changes: 53 additions & 0 deletions app/components/component_setup/cli_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module Components
module ComponentSetup
class CLISteps < Components::Base
def initialize(component_name:)
@component_name = component_name
end

private

attr_reader :component_name

def view_template
div(class: "max-w-2xl mx-auto w-full py-10 space-y-6") do
Heading(level: 4, class: "pb-4 border-b") { "Using RubyUI CLI" }
Text do
"We provide a Ruby gem with useful generators to help you to setup RubyUI components in your apps."
end

render Steps::Builder.new do |steps|
steps.add_step do
render Steps::Container do
Text(size: "4", weight: "semibold") do
plain "Add RubyUI gem to your Gemfile if you don't have it yet"
end

code = <<~CODE
bundle add ruby_ui --group development --require false
CODE
div(class: "w-full") do
Codeblock(code, syntax: :javascript)
end
end
end
steps.add_step do
render Steps::Container do
Text(size: "4", weight: "semibold") do
"Run the install command"
end

code = <<~CODE
rails g ruby_ui:component #{component_name.camelcase}
CODE
div(class: "w-full") do
Codeblock(code, syntax: :javascript)
end
end
end
end
end
end
end
end
end
32 changes: 32 additions & 0 deletions app/components/component_setup/tabs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Components
module ComponentSetup
class Tabs < Components::Base
def initialize(component_name:)
@component_name = component_name
end

private

attr_reader :component_name

def view_template
Heading(level: 2) { "Installation" }

Tabs(default_value: "cli", class: "w-full") do
TabsList do
TabsTrigger(value: "cli") { "CLI" }
TabsTrigger(value: "manual") { "Manual" }
end

TabsContent(value: "cli") do
render CLISteps.new(component_name:)
end

TabsContent(value: "manual") do
Text { "Coming soon" }
end
end
end
end
end
end
4 changes: 2 additions & 2 deletions app/views/components/shared/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def components
{name: "Avatar", path: helpers.docs_avatar_path},
{name: "Badge", path: helpers.docs_badge_path},
{name: "Button", path: helpers.docs_button_path},
{name: "Card", path: helpers.docs_card_path},
{name: "Calendar", path: helpers.docs_calendar_path},
{name: "Card", path: helpers.docs_card_path},
# { name: "Chart", path: helpers.docs_chart_path, badge: "New" },
{name: "Checkbox", path: helpers.docs_checkbox_path},
{name: "Checkbox Group", path: helpers.docs_checkbox_group_path},
Expand All @@ -83,8 +83,8 @@ def components
{name: "Dialog / Modal", path: helpers.docs_dialog_path},
{name: "Dropdown Menu", path: helpers.docs_dropdown_menu_path},
{name: "Form", path: helpers.docs_form_path},
{name: "Input", path: helpers.docs_input_path},
{name: "Hover Card", path: helpers.docs_hover_card_path},
{name: "Input", path: helpers.docs_input_path},
{name: "Link", path: helpers.docs_link_path},
{name: "Masked Input", path: helpers.masked_input_path},
{name: "Pagination", path: helpers.docs_pagination_path, badge: "New"},
Expand Down
9 changes: 9 additions & 0 deletions app/views/components/steps/container.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module Steps
class Container < ApplicationComponent
def view_template(&)
div(class: "space-y-4", &)
end
end
end
2 changes: 2 additions & 0 deletions app/views/docs/accordion_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/alert_dialog_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/alert_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/aspect_ratio_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/avatar_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/views/docs/badge_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class Docs::BadgeView < ApplicationView
def view_template
component = "Badge"

div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
render Docs::Header.new(title: "Badge", description: "Displays a badge or a component that looks like a badge.")

Expand Down Expand Up @@ -69,8 +71,10 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

# components
render Docs::ComponentsTable.new(component_files("Badge"))
render Docs::ComponentsTable.new(component_files(component))
end
end
end
6 changes: 5 additions & 1 deletion app/views/docs/button_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class Docs::ButtonView < ApplicationView
def view_template
component = "Button"

div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
render Docs::Header.new(title: "Button", description: "Displays a button or a component that looks like a button.")

Expand Down Expand Up @@ -121,7 +123,9 @@ def view_template
RUBY
end

render Docs::ComponentsTable.new(component_files("Button"))
render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
end
2 changes: 2 additions & 0 deletions app/views/docs/calendar_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/card_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/chart_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: "Chart")

render Docs::ComponentsTable.new(components)
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/checkbox_group_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/checkbox_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/clipboard_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/codeblock_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def hello_world
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/collapsible_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
3 changes: 3 additions & 0 deletions app/views/docs/combobox_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def view_template
end
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: "Combobox")

render Docs::ComponentsTable.new(component_files("Combobox"))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/command_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/context_menu_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/date_picker_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/dialog_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/dropdown_menu_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/form_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/hover_card_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/input_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/link_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/masked_input_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/pagination_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/docs/popover_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,8 @@ def view_template
RUBY
end

render Components::ComponentSetup::Tabs.new(component_name: component)

render Docs::ComponentsTable.new(component_files(component))
end
end
Expand Down
Loading

0 comments on commit 3a068ff

Please sign in to comment.