Class: Odt::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#inject_stylesheets ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/odt/install_generator.rb', line 10

def inject_stylesheets
  css_candidates = [
    "app/assets/stylesheets/application.tailwind.css",
    "app/assets/stylesheets/application.css",
    "app/assets/stylesheets/application.scss"
  ]

  target_css = css_candidates.find { |file| File.exist?(file) }

  if target_css
    imports = %(\n/* ODT Design Tokens & Component Styles */\n@import "odt_ui.css";\n)
    append_to_file target_css, imports
    say "Added ODT CSS imports to #{target_css}", :green
  else
    say "Please add @import \"odt_ui.css\"; to your application stylesheet.", :yellow
  end
end