Class: Solrengine::Ui::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Solrengine::Ui::InstallGenerator
- Defined in:
- lib/generators/solrengine/ui/install_generator.rb
Instance Method Summary collapse
- #add_dark_mode_variant ⇒ Object
- #add_lookbook_preview_layout ⇒ Object
- #add_lookbook_preview_path ⇒ Object
- #add_lookbook_route ⇒ Object
- #add_tailwind_source ⇒ Object
- #configure_lookbook_preview_layout ⇒ Object
- #show_post_install ⇒ Object
Instance Method Details
#add_dark_mode_variant ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 21 def add_dark_mode_variant css_file = "app/assets/stylesheets/application.tailwind.css" return unless File.exist?(css_file) content = File.read(css_file) return if content.include?("@custom-variant dark") append_to_file css_file, "\n/* Class-based dark mode for SolRengine UI */\n@custom-variant dark (&:where(.dark, .dark *));\n" end |
#add_lookbook_preview_layout ⇒ Object
55 56 57 58 59 60 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 55 def add_lookbook_preview_layout layout_path = "app/views/layouts/lookbook_preview.html.erb" return if File.exist?(layout_path) copy_file "lookbook_preview.html.erb", layout_path end |
#add_lookbook_preview_path ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 41 def add_lookbook_preview_path app_file = "config/application.rb" content = File.read(app_file) return if content.include?("lookbook.preview_paths") inject_into_file app_file, before: /^ end/ do <<~RUBY # SolRengine UI Lookbook previews config.lookbook.preview_paths << File.join(Gem.loaded_specs["solrengine-ui"].full_gem_path, "previews") if defined?(Lookbook) RUBY end end |
#add_lookbook_route ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 31 def add_lookbook_route route_file = "config/routes.rb" content = File.read(route_file) return if content.include?("Lookbook") inject_into_file route_file, after: "Rails.application.routes.draw do\n" do " mount Lookbook::Engine, at: \"/lookbook\" if Rails.env.development?\n\n" end end |
#add_tailwind_source ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 8 def add_tailwind_source css_file = "app/assets/stylesheets/application.tailwind.css" return unless File.exist?(css_file) content = File.read(css_file) return if content.include?("solrengine-ui") gem_path = Gem.loaded_specs["solrengine-ui"]&.full_gem_path return unless gem_path append_to_file css_file, "\n/* SolRengine UI components */\n@source \"#{gem_path}/app\";\n" end |
#configure_lookbook_preview_layout ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 62 def configure_lookbook_preview_layout app_file = "config/application.rb" content = File.read(app_file) return if content.include?("lookbook.preview_layout") inject_into_file app_file, before: /^ end/ do <<~RUBY # SolRengine UI Lookbook preview layout (loads Tailwind + dark mode) config.lookbook.preview_layout = "lookbook_preview" if defined?(Lookbook) RUBY end end |
#show_post_install ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/generators/solrengine/ui/install_generator.rb', line 76 def show_post_install say "\n SolRengine UI installed!", :green say "" say " Next steps:" say " 1. Add gem 'lookbook' to your Gemfile (development group) if not already added" say " 2. yarn add @solrengine/ui (for Stimulus controllers)" say " 3. bin/dev and visit /lookbook to see all components" say "" end |