UiKit

Adds UiKit for your Rails application
Icons/chart bar
Used 42 times
Created by
S Stas Syritsyn

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/V4Ys0W"
Template Source

Review the code before running this template on your machine.

run "yarn add uikit"

inject_into_file "app/javascript/packs/application.js" do <<~EOF
  import UIkit from 'uikit';
  import Icons from 'uikit/dist/js/uikit-icons';
  UIkit.use(Icons);
  window.UIkit = UIkit;
  EOF
end

run "touch app/assets/stylesheets/uikit.scss"

inject_into_file "app/assets/stylesheets/uikit.scss" do <<~EOF
  @import "uikit/src/scss/variables-theme";
  @import "uikit/src/scss/mixins-theme";
  @import "uikit/src/scss/uikit-theme";
  EOF
end

inject_into_file 'app/views/layouts/application.html.erb', before: '</head>' do <<~EOF
  <%= stylesheet_pack_tag 'uikit', media: 'all', 'data-turbolinks-track': 'reload' %>
  EOF
end

puts "Ok, UiKit is here! 👋"
Comments
Tadeu Granemann
Thanks for sharing this template =)