Class: TailwindThemePicker::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/tailwind_theme_picker/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_themes_stylesheetObject



16
17
18
19
# File 'lib/generators/tailwind_theme_picker/install/install_generator.rb', line 16

def copy_themes_stylesheet
  copy_file "assets/stylesheets/tailwind_theme_picker/themes.css",
            "app/assets/tailwind/tailwind_theme_picker/themes.css"
end

#create_initializerObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/tailwind_theme_picker/install/install_generator.rb', line 21

def create_initializer
  return unless options[:initializer]
  create_file "config/initializers/tailwind_theme_picker.rb", <<~RUBY
    TailwindThemePicker.configure do |c|
      # c.themes  = %w[red blue green]   # subset / extend default 27
      # c.default = "sky"
      # c.theme_cookie   = "theme"
      # c.mode_cookie    = "mode"
      # c.cookie_max_age = 60 * 60 * 24 * 365
    end
  RUBY
end

#show_post_installObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/tailwind_theme_picker/install/install_generator.rb', line 34

def show_post_install
  say "\nTailwindThemePicker installed.", :green
  say ""
  say "Next steps:"
  say "  1. Add to your Tailwind input CSS (e.g. app/assets/tailwind/application.css):"
  say "       @import './tailwind_theme_picker/themes';", :cyan
  say "  2. Wire up your layout <html> tag and body:"
  say "       html lang=\"en\" *theme_picker_html_attrs", :cyan
  say "       = theme_picker_fouc_script   # in <head>"
  say "       = render_theme_picker        # in <body>"
  say ""
  say "After upgrading the gem, re-run this generator to pick up any new themes."
end