2 |
--------------------------------------------------------------------------------
/app/jobs/rails_ui/application_job.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ApplicationJob < ActiveJob::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/test/dummy/Procfile.dev:
--------------------------------------------------------------------------------
1 | web: bin/rails server
2 | css: bin/rails tailwindcss:watch
3 | js: npm run build --watch
4 |
--------------------------------------------------------------------------------
/test/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | end
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michelson/rails-ui/HEAD/app/ui/components/rails_ui/.DS_Store
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/markdown/component.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= content %>
3 |
4 |
--------------------------------------------------------------------------------
/test/dummy/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative "../config/boot"
3 | require "rake"
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/lib/tasks/rails_ui_tasks.rake:
--------------------------------------------------------------------------------
1 | # desc "Explaining what the task does"
2 | # task :rails_ui do
3 | # # Task goes here
4 | # end
5 |
--------------------------------------------------------------------------------
/test/dummy/app/controllers/home_controller.rb:
--------------------------------------------------------------------------------
1 | class HomeController < ApplicationController
2 | layout "application"
3 | end
4 |
--------------------------------------------------------------------------------
/test/dummy/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | class ApplicationRecord < ActiveRecord::Base
2 | primary_abstract_class
3 | end
4 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/blocks_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class BlocksController < ApplicationController
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/charts_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ChartsController < ApplicationController
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/colors_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ColorsController < ApplicationController
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/themes_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ThemesController < ApplicationController
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/alert/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/badge/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/card/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/sheet/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/table/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/tabs/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toast/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/examples_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ExamplesController < ApplicationController
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/accordion/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/avatar/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/button/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/calendar/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/carousel/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/command/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dialog/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/input_otp/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/markdown/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/menubar/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/popover/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/progress/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/resizable/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/separator/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/skeleton/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toast_item/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/tooltip/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/lib/rails_ui.rb:
--------------------------------------------------------------------------------
1 | require "rails_ui/version"
2 | require "rails_ui/engine"
3 |
4 | module RailsUi
5 | # Your code goes here...
6 | end
7 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/accordion_item/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/alert_dialog/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/aspect_ratio/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb_item/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/collapsible/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/context_menu/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/separator/component.html.erb:
--------------------------------------------------------------------------------
1 | <%= tag.div role: "none", "data-orientation": @orientation, class: separator_class %>
2 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle_group/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/lib/generators/view_component/templates/index.css.tt:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/test/dummy/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/test/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | root to: "home#show"
3 |
4 | mount RailsUi::Engine => "/rails_ui"
5 | end
6 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu_item/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 |
--------------------------------------------------------------------------------
/test/dummy/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Connection < ActionCable::Connection::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/link/component.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%= link_to action, **button_attributes do %>
4 | <%= icon if icon %>
5 | <%= content %>
6 | <% end %>
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/markdown/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Markdown::Component < ApplicationViewComponent
4 | end
5 |
--------------------------------------------------------------------------------
/test/dummy/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: "from@example.com"
3 | layout "mailer"
4 | end
5 |
--------------------------------------------------------------------------------
/Procfile.dev:
--------------------------------------------------------------------------------
1 | web: cd test/dummy && bin/rails server -p $PORT -b 0.0.0.0
2 | css: cd test/dummy && bin/rails tailwindcss:watch
3 | js: cd test/dummy && npm run build_dev
--------------------------------------------------------------------------------
/app/models/rails_ui/application_record.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ApplicationRecord < ActiveRecord::Base
3 | self.abstract_class = true
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/ui/application_view_component_preview.rb:
--------------------------------------------------------------------------------
1 | class ApplicationViewComponentPreview < ViewComponentContrib::Preview::Base
2 | self.abstract_class = true
3 | end
4 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/application_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ApplicationController < ActionController::Base
3 | def ui
4 | end
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | // link_directory ../stylesheets .css
3 | //= link rails_ui_manifest.js
4 | //= link_tree ../builds
5 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/button/component.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <%= tag.button(**button_attributes) do
5 | concat(icon) if icon?
6 | concat(content)
7 | end
8 | %>
9 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | # Navigate to the dummy app and install npm packages
4 | npm --prefix ./test/dummy install
5 |
6 | # Install Ruby gems
7 | bundle install
--------------------------------------------------------------------------------
/test/dummy/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path("../config/application", __dir__)
3 | require_relative "../config/boot"
4 | require "rails/commands"
5 |
--------------------------------------------------------------------------------
/test/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative "application"
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/test/rails_ui_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class RailsUiTest < ActiveSupport::TestCase
4 | test "it has a version number" do
5 | assert RailsUi::VERSION
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/mailers/rails_ui/application_mailer.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class ApplicationMailer < ActionMailer::Base
3 | default from: "from@example.com"
4 | layout "mailer"
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/simple_editor/index.css:
--------------------------------------------------------------------------------
1 | /* Use component-local class names and add them to HTML via #class_for(name) helper */
2 |
3 | .ProseMirror:focus {
4 | outline: none;
5 | }
6 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle_group/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::ToggleGroup::Component < ApplicationViewComponent
4 | renders_many :toggles
5 | end
6 |
--------------------------------------------------------------------------------
/test/integration/navigation_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class NavigationTest < ActionDispatch::IntegrationTest
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/carousel/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Carousel::Component < ApplicationViewComponent
4 | option :items, default: -> { [] }
5 | end
6 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/link/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Link::Component < RailsUi::Button::Component
4 | option :action, default: -> { "#" }
5 |
6 | end
7 |
--------------------------------------------------------------------------------
/test/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative "config/environment"
4 |
5 | run Rails.application
6 | Rails.application.load_server
7 |
--------------------------------------------------------------------------------
/test/dummy/app/javascript/application.js:
--------------------------------------------------------------------------------
1 | // Entry point for the build script in your package.json
2 | import { Turbo } from '@hotwired/turbo-rails';
3 | window.Turbo = Turbo;
4 |
5 | import "./controllers"
6 |
--------------------------------------------------------------------------------
/test/dummy/test/controllers/home_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class HomeControllerTest < ActionDispatch::IntegrationTest
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle_group/component.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/context_menu/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::ContextMenu::Component < ApplicationViewComponent
4 | option :menu_items, default: -> { [] }
5 | option :side, default: -> { "right" }
6 | option :align, default: -> { "start" }
7 | end
8 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | RailsUi::Engine.routes.draw do
2 | root to: "playground#index"
3 | get "playground(/:section)", to: "playground#show", as: :playground
4 | resources :blocks
5 | resources :charts
6 | resources :themes
7 | resources :examples
8 | resources :colors
9 | end
10 |
--------------------------------------------------------------------------------
/bin/dev:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | if gem list --no-installed --exact --silent foreman; then
4 | echo "Installing foreman..."
5 | gem install foreman
6 | fi
7 |
8 | # Default to port 3000 if not specified
9 | export PORT="${PORT:-3000}"
10 |
11 | exec foreman start -f Procfile.dev "$@"
12 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/chart/component.erb:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/switch/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Switch::Component < ApplicationViewComponent
4 | option :id
5 | option :url, default: -> { "" }
6 | option :label
7 | option :checked
8 | option :disabled
9 | option :on_change
10 | end
11 |
--------------------------------------------------------------------------------
/test/controllers/rails_ui/blocks_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | module RailsUi
4 | class BlocksControllerTest < ActionDispatch::IntegrationTest
5 | include Engine.routes.url_helpers
6 |
7 | # test "the truth" do
8 | # assert true
9 | # end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/controllers/rails_ui/charts_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | module RailsUi
4 | class ChartsControllerTest < ActionDispatch::IntegrationTest
5 | include Engine.routes.url_helpers
6 |
7 | # test "the truth" do
8 | # assert true
9 | # end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/controllers/rails_ui/colors_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | module RailsUi
4 | class ColorsControllerTest < ActionDispatch::IntegrationTest
5 | include Engine.routes.url_helpers
6 |
7 | # test "the truth" do
8 | # assert true
9 | # end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/controllers/rails_ui/themes_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | module RailsUi
4 | class ThemesControllerTest < ActionDispatch::IntegrationTest
5 | include Engine.routes.url_helpers
6 |
7 | # test "the truth" do
8 | # assert true
9 | # end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/controllers/rails_ui/examples_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | module RailsUi
4 | class ExamplesControllerTest < ActionDispatch::IntegrationTest
5 | include Engine.routes.url_helpers
6 |
7 | # test "the truth" do
8 | # assert true
9 | # end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/test/dummy/app/javascript/controllers/application.js:
--------------------------------------------------------------------------------
1 | import { Application } from "@hotwired/stimulus"
2 |
3 | const application = Application.start()
4 |
5 | // Configure Stimulus development experience
6 | application.debug = false
7 | window.Stimulus = application
8 |
9 | export { application }
10 |
--------------------------------------------------------------------------------
/test/dummy/bin/dev:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | if gem list --no-installed --exact --silent foreman; then
4 | echo "Installing foreman..."
5 | gem install foreman
6 | fi
7 |
8 | # Default to port 3000 if not specified
9 | export PORT="${PORT:-3000}"
10 |
11 | exec foreman start -f Procfile.dev "$@"
12 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/accordion/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Accordion::Component < ApplicationViewComponent
4 | option :type, default: -> { "single" }
5 | option :collapsible, default: -> { true }
6 |
7 | renders_many :items, RailsUi::AccordionItem::Component
8 | end
9 |
--------------------------------------------------------------------------------
/test/controllers/rails_ui/playground_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | module RailsUi
4 | class PlaygroundControllerTest < ActionDispatch::IntegrationTest
5 | include Engine.routes.url_helpers
6 |
7 | # test "the truth" do
8 | # assert true
9 | # end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/alert/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Alert::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/badge/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Badge::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/card/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Card::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/sheet/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Sheet::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/table/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Table::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/tabs/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Tabs::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toast/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Toast::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/avatar/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Avatar::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/calendar/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Calendar::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/carousel/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Carousel::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/command/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Command::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dialog/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Dialog::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/markdown/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Markdown::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/menubar/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Menubar::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/popover/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Popover::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/progress/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Progress::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/skeleton/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Skeleton::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/switch/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Switch::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Toggle::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/tooltip/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Tooltip::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/test/dummy/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | # Automatically retry jobs that encountered a deadlock
3 | # retry_on ActiveRecord::Deadlocked
4 |
5 | # Most jobs are safe to ignore if the underlying records are no longer available
6 | # discard_on ActiveJob::DeserializationError
7 | end
8 |
--------------------------------------------------------------------------------
/test/dummy/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/accordion/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Accordion::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Breadcrumb::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/input_otp/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::InputOtp::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/resizable/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Resizable::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/separator/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Separator::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toast_item/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::ToastItem::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/lib/generators/view_component/templates/preview.rb.tt:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class <%= class_name %>::Preview < <%= preview_parent_class %>
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/alert_dialog/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::AlertDialog::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/aspect_ratio/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::AspectRatio::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/collapsible/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Collapsible::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/context_menu/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::ContextMenu::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::DropdownMenu::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/simple_editor/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::SimpleEditor::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle_group/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::ToggleGroup::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/accordion_item/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::AccordionItem::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb_item/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::BreadcrumbItem::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu_item/preview.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::DropdownMenuItem::Preview < ApplicationViewComponentPreview
4 | # You can specify the container class for the default template
5 | # self.container_class = "w-1/2 border border-gray-300"
6 |
7 | def default
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/simple_editor/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::SimpleEditor::Component < ApplicationViewComponent
4 | option :preview_id, default: -> {}
5 | option :variables, default: -> { {} }
6 | option :height, default: -> { "h-20" }
7 | option :data
8 | option :form
9 | option :field
10 | end
11 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/component_preview/component.rb:
--------------------------------------------------------------------------------
1 | class RailsUi::ComponentPreview::Component < ViewComponent::Base
2 | renders_one :example
3 | renders_one :code
4 |
5 | attr_reader :title
6 |
7 | def initialize(title:)
8 | @title = title
9 | end
10 |
11 | def render_code
12 | ERB::Util.html_escape_once code
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/controllers/rails_ui/playground_controller.rb:
--------------------------------------------------------------------------------
1 | module RailsUi
2 | class PlaygroundController < ApplicationController
3 | include RailsUi::ApplicationHelper
4 | def index
5 | @section = "accordion"
6 | render "show"
7 | end
8 |
9 | def show
10 | @section = params[:section]
11 | render "show"
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsUi
4 | module DropdownMenu
5 | class Component < ApplicationViewComponent
6 | renders_one :trigger
7 | renders_many :items, RailsUi::DropdownMenuItem::Component
8 | renders_many :separators # , SeparatorComponent
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.bundle/
2 | /doc/
3 | /log/*.log
4 | /pkg/
5 | /tmp/
6 | /test/dummy/db/*.sqlite3
7 | /test/dummy/db/*.sqlite3-*
8 | /test/dummy/log/*.log
9 | /test/dummy/node_modules
10 | /test/dummy/storage/
11 | /test/dummy/tmp/
12 | /test/dummy/public/assets/*
13 | !/test/dummy/public/assets/.keep
14 | /test/dummy/app/assets/builds/*
15 | !/test/dummy/app/assets/builds/.keep
16 |
--------------------------------------------------------------------------------
/app/ui/application_view_component.rb:
--------------------------------------------------------------------------------
1 | class ApplicationViewComponent < ViewComponentContrib::Base
2 | extend Dry::Initializer
3 |
4 | private
5 |
6 | def identifier
7 | @identifier ||= self.class.name.sub("::Component", "").underscore.split("/").join("--")
8 | end
9 |
10 | def class_for(name, from: identifier)
11 | "c-#{from}-#{name}"
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/card_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Card::Component do
6 | let(:options) { {} }
7 | let(:component) { Card::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/tabs_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Tabs::Component do
6 | let(:options) { {} }
7 | let(:component) { Tabs::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/index.js--:
--------------------------------------------------------------------------------
1 | import controllers from "./**/*index.js"
2 |
3 | controllers.forEach((controller) => {
4 | if(controller.module.default){
5 | const name = controller.name.replace("--index.js", "")
6 | console.log("ADDINDG CONTROLLER FROM RAILS UI", name)
7 | application.register(name, controller.module.default);
8 | }
9 | });
10 |
11 | console.log(application)
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/alert_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Alert::Component do
6 | let(:options) { {} }
7 | let(:component) { Alert::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/avatar_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Avatar::Component do
6 | let(:options) { {} }
7 | let(:component) { Avatar::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/badge_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Badge::Component do
6 | let(:options) { {} }
7 | let(:component) { Badge::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/button_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Button::Component do
6 | let(:options) { {} }
7 | let(:component) { Button::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/dialog_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Dialog::Component do
6 | let(:options) { {} }
7 | let(:component) { Dialog::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/sheet_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Sheet::Component do
6 | let(:options) { {} }
7 | let(:component) { Sheet::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/table_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Table::Component do
6 | let(:options) { {} }
7 | let(:component) { Table::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/toast_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Toast::Component do
6 | let(:options) { {} }
7 | let(:component) { Toast::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/toggle_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Toggle::Component do
6 | let(:options) { {} }
7 | let(:component) { Toggle::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu_item/component.html.erb:
--------------------------------------------------------------------------------
1 | <%= tag.send(tag_name, **html_options) do %>
2 | <% if icon.present? %>
3 | <%= icon %>
4 | <% # inline_svg_tag icon, class: "mr-2 h-4 w-4" %>
5 | <% end %>
6 | <%= content %>
7 | <% if shortcut.present? %>
8 | <%= shortcut %>
9 | <% end %>
10 | <% end %>
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/command_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Command::Component do
6 | let(:options) { {} }
7 | let(:component) { Command::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/menubar_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Menubar::Component do
6 | let(:options) { {} }
7 | let(:component) { Menubar::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/popover_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Popover::Component do
6 | let(:options) { {} }
7 | let(:component) { Popover::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/tooltip_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Tooltip::Component do
6 | let(:options) { {} }
7 | let(:component) { Tooltip::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/frontend/components/rails_ui/button_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Button::Component do
6 | let(:options) { {} }
7 | let(:component) { Button::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/accordion_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Accordion::Component do
6 | let(:options) { {} }
7 | let(:component) { Accordion::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/calendar_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Calendar::Component do
6 | let(:options) { {} }
7 | let(:component) { Calendar::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/carousel_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Carousel::Component do
6 | let(:options) { {} }
7 | let(:component) { Carousel::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/input_otp_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe InputOtp::Component do
6 | let(:options) { {} }
7 | let(:component) { InputOtp::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/markdown_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Markdown::Component do
6 | let(:options) { {} }
7 | let(:component) { Markdown::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/progress_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Progress::Component do
6 | let(:options) { {} }
7 | let(:component) { Progress::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/resizable_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Resizable::Component do
6 | let(:options) { {} }
7 | let(:component) { Resizable::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/skeleton_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Skeleton::Component do
6 | let(:options) { {} }
7 | let(:component) { Skeleton::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/toast_item_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe ToastItem::Component do
6 | let(:options) { {} }
7 | let(:component) { ToastItem::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/breadcrumb_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Breadcrumb::Component do
6 | let(:options) { {} }
7 | let(:component) { Breadcrumb::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/collapsible_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Collapsible::Component do
6 | let(:options) { {} }
7 | let(:component) { Collapsible::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/test/dummy/spec/ui/components/separator_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe Separator::Component do
6 | let(:options) { {} }
7 | let(:component) { Separator::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/avatar/component.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% if src %>
3 | <%= image_tag src, class: "aspect-square h-full w-full", alt: alt %>
4 | <% else %>
5 |
6 | <%= fallback_initials %>
7 |
8 | <% end %>
9 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/chart/component.rb:
--------------------------------------------------------------------------------
1 | # app/components/rails_ui/alert_dialog/component.rb
2 | module RailsUi
3 | module Chart
4 | class Component < ApplicationViewComponent
5 | #option :id, default: -> { SecureRandom.hex(6) }
6 | option :type, default: -> { 'line' }
7 | option :config, default: -> { {} }
8 | option :data, default: -> { {} }
9 |
10 | end
11 | end
12 | end
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/alert_dialog_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe AlertDialog::Component do
6 | let(:options) { {} }
7 | let(:component) { AlertDialog::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/aspect_ratio_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe AspectRatio::Component do
6 | let(:options) { {} }
7 | let(:component) { AspectRatio::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/context_menu_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe ContextMenu::Component do
6 | let(:options) { {} }
7 | let(:component) { ContextMenu::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/dropdown_menu_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe DropdownMenu::Component do
6 | let(:options) { {} }
7 | let(:component) { DropdownMenu::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/simple_editor_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe SimpleEditor::Component do
6 | let(:options) { {} }
7 | let(:component) { SimpleEditor::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/toggle_group_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe ToggleGroup::Component do
6 | let(:options) { {} }
7 | let(:component) { ToggleGroup::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/skeleton/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Skeleton::Component < ApplicationViewComponent
4 | option :variant, default: -> { :avatar }
5 | option :avatar_size, default: -> { "h-12 w-12" }
6 | option :card_size, default: -> { "h-[125px] w-[250px]" }
7 | option :lines, default: -> { 2 }
8 | option :line_widths, default: -> { ["250px", "200px"] }
9 | end
10 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/accordion_demo_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe AccordionDemo::Component do
6 | let(:options) { {} }
7 | let(:component) { AccordionDemo::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/accordion_item_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe AccordionItem::Component do
6 | let(:options) { {} }
7 | let(:component) { AccordionItem::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/breadcrumb_item_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe BreadcrumbItem::Component do
6 | let(:options) { {} }
7 | let(:component) { BreadcrumbItem::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/test/dummy/spec/ui/components/simple_editor_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe SimpleEditor::Component do
6 | let(:options) { {} }
7 | let(:component) { SimpleEditor::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/accordion_content_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe AccordionContent::Component do
6 | let(:options) { {} }
7 | let(:component) { AccordionContent::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/accordion_trigger_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe AccordionTrigger::Component do
6 | let(:options) { {} }
7 | let(:component) { AccordionTrigger::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/spec/ui/components/rails_ui/dropdown_menu_item_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe DropdownMenuItem::Component do
6 | let(:options) { {} }
7 | let(:component) { DropdownMenuItem::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/command/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # app/components/rails_ui/command/component.rb
4 | module RailsUi
5 | module Command
6 | class Component < ApplicationViewComponent
7 | option :id, default: -> { SecureRandom.hex(6) }
8 | option :placeholder, default: -> { "Type a command or search..." }
9 | option :sections, default: -> { [] }
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/generators/view_component/templates/component_spec.rb.tt:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require "rails_helper"
4 |
5 | describe <%= class_name %>::Component do
6 | let(:options) { {} }
7 | let(:component) { <%= class_name %>::Component.new(**options) }
8 |
9 | subject { rendered_component }
10 |
11 | it "renders" do
12 | render_inline(component)
13 |
14 | is_expected.to have_css "div"
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/views/rails_ui/playground/sections/_figma.html.erb:
--------------------------------------------------------------------------------
1 | <%= render RailsUi::Markdown::Component.new do %>
2 |
3 |
4 | Every component recreated in Figma. With customizable props, typography and icons.
5 | The Figma UI Kit is open sourced by Pietro Schirano.
6 |
7 | [Grab a copy](https://www.figma.com/community/file/1203061493325953101)
8 |
9 |
10 | <% end %>
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/resizable/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsUi
4 | module Resizable
5 | class Component < ApplicationViewComponent
6 | option :id, default: -> { SecureRandom.hex(6) }
7 | option :direction, default: -> { "horizontal" }
8 | option :panels, default: -> { [] }
9 | option :class_name, default: -> { "min-h-[200px] rounded-lg border" }
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/card/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/skeleton/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | export default class Controller extends BaseController {
10 | connect() {
11 | }
12 | disconnect() {
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/tabs/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/alert/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/avatar/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/badge/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/button/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/progress/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/table/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/accordion_item/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb_item/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "stimulus";
8 | //
9 | // export class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | //
13 | // disconnect() {
14 | // }
15 | // }
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/separator/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | // export default class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | // disconnect() {
13 | // }
14 | // }
15 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/aspect_ratio/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | // export default class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | // disconnect() {
13 | // }
14 | // }
15 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toast_item/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | // export default class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | // disconnect() {
13 | // }
14 | // }
15 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/toggle_group/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | // export default class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | // disconnect() {
13 | // }
14 | // }
15 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/dropdown_menu_item/index.js:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | // export default class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | // disconnect() {
13 | // }
14 | // }
15 |
--------------------------------------------------------------------------------
/lib/generators/view_component/templates/index.js.tt:
--------------------------------------------------------------------------------
1 | import "./index.css"
2 |
3 | // Add a Stimulus controller for this component.
4 | // It will automatically registered and its name will be available
5 | // via #component_name in the component class.
6 | //
7 | // import { Controller as BaseController } from "@hotwired/stimulus";
8 | //
9 | // export default class Controller extends BaseController {
10 | // connect() {
11 | // }
12 | // disconnect() {
13 | // }
14 | // }
15 |
--------------------------------------------------------------------------------
/test/dummy/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
4 | # Use this to limit dissemination of sensitive information.
5 | # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
6 | Rails.application.config.filter_parameters += [
7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8 | ]
9 |
--------------------------------------------------------------------------------
/app/views/layouts/rails_ui/preview.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Rails ui
5 | <%= csrf_meta_tags %>
6 | <%= csp_meta_tag %>
7 |
8 | <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
9 | <%= stylesheet_link_tag "application", media: "all" %>
10 | <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
11 |
12 |
13 |
14 |
15 | <%= yield %>
16 |
17 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/breadcrumb/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Breadcrumb::Component < ApplicationViewComponent
4 | renders_many :items, RailsUi::BreadcrumbItem::Component
5 |
6 | def separator
7 | ''.html_safe
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/alert/component.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% if icon %>
3 | <%= icon_svg.html_safe %>
4 | <% end %>
5 | <% if title? %>
6 |
5 | <% lines.times do |i| %>
6 |
7 | <% end %>
8 |
9 |
10 | <% else %>
11 |
12 |
13 |
14 | <% lines.times do |i| %>
15 |
16 | <% end %>
17 |
18 |
19 | <% end %>
--------------------------------------------------------------------------------
/lib/generators/view_component/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | ============
3 | Creates a new view component, test and preview files.
4 | Pass the component name, either CamelCased or under_scored, and an optional list of attributes as arguments.
5 |
6 | Example:
7 | ========
8 | bin/rails generate view_component Profile name age
9 |
10 | creates a Profile component and test:
11 | Component: app/frontend/components/profile/component.rb
12 | Template: app/frontend/components/profile/component.html.erb
13 | Test: spec/frontend/components/profile_component_spec.rb
14 | Preview: app/frontend/components/profile/component_preview.rb
15 | JS: app/frontend/components/profile/component.js
16 | CSS: app/frontend/components/profile/component.css
17 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 |
4 | # Specify your gem's dependencies in rails_ui.gemspec.
5 | gemspec
6 |
7 | gem "puma"
8 |
9 | # gem "sqlite3", "2.0.2"
10 | gem "pg"
11 | gem "pry"
12 |
13 | gem "sprockets-rails"
14 |
15 | gem "view_components"
16 | gem "view_component-contrib"
17 |
18 | gem "tailwindcss-rails"
19 | gem "turbo-rails", github: "hotwired/turbo-rails", branch: "main"
20 |
21 | group :development do
22 | gem "web-console", ">= 3.3.0"
23 | gem "standard"
24 | end
25 |
26 | # Start debugger with binding.b [https://github.com/ruby/debug]
27 | # gem "debug", ">= 1.0.0"
28 |
29 | gem "dry-initializer", "~> 3.1"
30 |
31 | gem "method_source", "~> 1.1"
32 |
33 | gem "jsbundling-rails", "~> 1.3"
34 |
35 | gem "stimulus-rails", "~> 1.3"
36 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/rails_ui/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/test/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/app/ui/components/rails_ui/separator/component.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RailsUi::Separator::Component < ApplicationViewComponent
4 | # Available orientations for the separator
5 | ORIENTATIONS = %w[horizontal vertical].freeze
6 |
7 | # Define initializer to accept orientation and class_name as parameters
8 | def initialize(orientation: "horizontal", class_name: "")
9 | @orientation = ORIENTATIONS.include?(orientation) ? orientation : "horizontal"
10 | @class_name = class_name
11 | end
12 |
13 | # Provides the CSS class for the separator
14 | def separator_class
15 | base_class = "shrink-0 bg-border"
16 | orientation_class = (@orientation == "vertical") ? "h-full w-[1px]" : "h-[1px] w-full my-4"
17 | [base_class, orientation_class, @class_name].compact.join(" ")
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/app/views/rails_ui/playground/_nav.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% rails_ui_nav_items.each do |item| %>
4 |
5 | <% if item[:type] == "link"%>
6 |