Skip to content

Commit

Permalink
README updates and change static->page
Browse files Browse the repository at this point in the history
  • Loading branch information
justalever committed Mar 31, 2023
1 parent 5356c08 commit 3e87f27
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 52 deletions.
108 changes: 90 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Rails UI

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/railsui`. To experiment with that code, run `bin/console` for an interactive prompt.
Welcome to Rails UI—a plug-and-play solution for Ruby on Rails developers needing product design support.

TODO: Delete this and the text above, and describe your gem
Rails UI ships with components and views wrapped up in theme form. Each theme utilizes a CSS framework of your choice. Leverage a bundled design system to scale your apps faster and more consistently.

### Links

- [Website](https://railsui.com)
- [Documentation](https://railsui.com/docs)
- Community - Coming soon
- [Twitter](https://twitter.com/railsui_)

## Installation

Expand All @@ -26,9 +33,28 @@ Install base configuration and Rails UI engine:
$ rails railsui:install
```

After installing Rails UI run your server using the `bin/dev` command.
After installing Rails UI, run your server using the `bin/dev` command and proceed to the configuration screen.

## Configuration

Use Rails UI for brand **new** Ruby on Rails applications for best results.

Configuration is a simple process that first prompts you for an application name and preferred CSS framework—following install of a CSS framework; you can choose a theme. Rails UI currently ships with support for Bootstrap and Tailwind CSS.

### Selecting a theme

After configuring your Rails UI install, you will see a series of themes. Choose your preferred theme and click "Save changes." Rails UI installs any assets, dependencies, and code related to the theme.

Note: The theme list will grow as Rails UI does.


### Adding pages

## Usage
Because we take a theme-first approach to design with Rails UI, you can install pre-designed one-off pages. Pages are a work in progress, and each theme will have multiple available for install in the future.

## Design system

After you configure Rails UI, you can preview the design system. There you will find a collection of components and best practices for real-world usage of your Rails UI theme. Use this as a guide to add a new design to your application, but please don't take it as gosple. Design is less rigid than programming and often needs a little tweaking as you go. My goal is to give you a hell of a good head start.



Expand All @@ -40,7 +66,6 @@ After installing Rails UI run your server using the `bin/dev` command.
[Rails UI](https://railsui.com) is plug-and-play UI for Ruby on Rails applications. It takes a theme-based approach to product design and offers a suite of pre-designed components and pages for rails developer looking to move fast but look good doing so.
</details>


<details>
<summary>
What happens during installation?
Expand Down Expand Up @@ -78,40 +103,87 @@ If you select Bootstrap as your CSS framework that comes with [Bootstrap Icons](

It's recommended to stick with one library of icons and one variant for better consistency.

### Installation steps
### Installation detail

#### Install and configure Devise
#### Install, configure, and customize Devise

[Devise](https://github.com/heartcombo/devise) is one of the more popular gems for authentication with Ruby on Rails. Rails UI ships with initial support for Devise and assumes there is a `User` model in your app. On top of the default columns we add an `first_name`, `last_name`, and `admin`.
[Devise](https://github.com/heartcombo/devise) is one of the more popular gems for authentication with Ruby on Rails. Rails UI ships with initial Devise support and assumes a `User` model exists in your app. On top of the default columns, we add a `first_name,` `last_name,` and `admin.`

Even if you use something other than `User` you can go back after install and change this since it's easy to do so early in the app's lifecycle.
Even if you use something other than `User,` you can go back after installation and change this since it's easy to do so early in the app's lifecycle.

#### Adds name_of_person and avatar
Devise allows you to install independent views for customization. We took care of this with themed authentication templates ready to use. Check out the Authentication section of the design system to preview the experience.

Rails UI themes often leverage avatars for user accounts so we bundled that logic into a `User` model.
#### Add name_of_person and avatar

A `first_name` and `last_name` attribute was also added for use with the handy [name_of_person](https://github.com/basecamp/name_of_person) gem. This gem allows you to refer to users' in different ways throughout your app with ease.
Rails UI themes often leverage avatars for user accounts, so we bundled that logic into a `User` model.

#### Remove importmaps as a default
We added the `first_name` and `last_name` attributes for use with the handy [name_of_person](https://github.com/basecamp/name_of_person) gem. This gem allows you to refer to users in different ways throughout your app quickly.

Rails UI has some opinionated defaults when it comes to assets and JavaScript. We leverage both the [cssbundling-rails](https://github.com/rails/cssbundling-rails) and [jsbundling-rails](https://github.com/rails/jsbundling-rails). Importmaps aren't our preference so we opt to using these gems to compensate.
#### Remove importmaps as a default

esbuild is the default JavaScript build engine. Depending on your chosen CSS framework we included those dependencies as well. Rails UI currently supports Bootstrap and Tailwind CSS.
Rails UI has some opinionated defaults when it comes to assets and JavaScript. We leverage both the [cssbundling-rails](https://github.com/rails/cssbundling-rails) and [jsbundling-rails](https://github.com/rails/jsbundling-rails). Importmaps aren't our preference, so we use these gems to compensate.

esbuild is the default JavaScript build engine. Depending on your chosen CSS framework, we included those dependencies as well. Rails UI currently supports Bootstrap and Tailwind CSS.

#### Add ActiveStorage and ActionText support

Adding ActiveStorage and ActionText to Rails is quite simple but requires an additional step or two from the get go. This handles that for you so you needn't worry about it.
Adding ActiveStorage and ActionText to Rails is simple but requires an additional step. Rails UI handles that for you, so you needn't worry about it.

#### Add esbuild + Stimulus.js

While there are many JavaScript solutions out there, the default with Rails is [Stimulus.js](https://stimulus.hotwired.dev/), so we've used the same tools to keep things simple.

</details>
#### Custom scaffolds and generators

Rails UI installs a custom template engine configured when installed. The engine hooks into the Rails generator logic and spits out themed scaffold templates when you generate a new resource. We found this saves loads of time that you can put better use elsewhere.

#### Custom mailer layout and mailer helpers

Designing a proper e-mail template takes a lot of work, and Rails UI takes out the guesswork of supporting many e-mail clients.

Bundled with your theme is a customized `mailer.html.erb` layout file and a few helpers to make coding additional e-mails easier. We've bundled a few templates to get you started, including a minimal, promotional, and transactional template. All Devise e-mails come ready to use too.
</details>

<details>
<summary>Is this an application template for Rails?</summary>

No. This is an engine that mounts to a pre-existing Rails application but not like other engines you've probably used. You can think of Rails UI as a source of truth for design elements, components, and views that play a big role in what your end users see when interacting with your app.
No. Well, kind of, but mostly this is a hybrid Rails engine not like other engines you've probably used. You can think of Rails UI as a source of truth for design elements, components, and views that significantly influence what your end users see when interacting with your app. It takes the guesswork out of the design problem.

**Rails UI is meant for brand new Rails applications.** You'll want to use it on the "first run" so you can establish the foundation for assets and design patterns early on. To use Rails UI you need to choose a theme (more themes coming soon) that will act as the basis for future design elements.
</details>

<details>
<summary>What happens when I configure Rails UI? </summary>

Once configured Rails UI will:

- Generate a custom configuration yaml file railsui.yml that's required to theme your new app.
- Install dependencies and any necessary assets.
- Generate a custom tailored design system for repeatable web elements. Think of this as a system for providing design direction when creating new features. This includes typography, font elements, and SVG icons.
- Optionally install one-off templates (i.e. About us, Pricing, etc...). Use these as a starting point.
- Install scaffold templates that follow the theme and CSS framework you chose.
- After installing the Rails UI gem and running the installer, you may configure your application preferences.
</details>

<details>
<summary>Where are all the Turbo goodies?</summary>

We're just hitting ground with Rails UI so expect to see additional components and solutions in the future. We have loads of ideas but would always love to hear yours as well.
</details>

<details>
<summary>Is this code open-sourced?</summary>

While we are kicking the tires with an alpha version of Rails UI it is free and clear to try out but not redistribute.

Our _evenutal_ license model will be a non-exclusive one in which essentially means you don't have permission to modify or share Rails UI but you can use it freely in your projects.

Eventually, when the official first release drops, an ongoing subscription is required in order to ship new themes and updates in an ongoing fashion.
</details>


## Updates

Rails UI ships as a gem. Future releases are available to clone/pull from a private git-hosted group of which you will have access to with an active subscription.

If you subscription lapses you can still use Rails UI but you lose access to ongoing updates and additional themes to choose from.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_dependency "railsui/application_controller"

module Railsui
class StaticController < ApplicationController
class PageController < ApplicationController
layout "railsui/landing"
def index
end
Expand Down
8 changes: 0 additions & 8 deletions app/helpers/railsui/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ def heading(options={})
}
end

def about_page_exists?
Rails.root.join("app/views/static/about.html.erb").exist? && Railsui.config.about?
end

def pricing_page_exists?
Rails.root.join("app/views/static/pricing.html.erb").exist? && Railsui.config.pricing?
end

def email_viewer(subject="A sample subject", &block)
render "railsui/shared/rui_email_preview", subject: subject, block: block, flush: true
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/railsui/admin/fields/_pages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</div>
<div>
<%= link_to "View page", Rails.application.routes.url_for(action: details[:title].downcase, controller: "static", only_path: true), target: :_blank, class: "px-3 py-2 bg-white border border-slate-300 text-slate-600 shadow-sm rounded text-center text-sm font-medium hover:text-slate-700 hover:border-slate-400 dark:bg-slate-700 dark:text-slate-100 dark:border-slate-700 dark:hover:text-slate-100 dark:hover:border-slate-500" %>
<%= link_to "View page", Rails.application.routes.url_for(action: details[:title].downcase, controller: "page", only_path: true), target: :_blank, class: "px-3 py-2 bg-white border border-slate-300 text-slate-600 shadow-sm rounded text-center text-sm font-medium hover:text-slate-700 hover:border-slate-400 dark:bg-slate-700 dark:text-slate-100 dark:border-slate-700 dark:hover:text-slate-100 dark:hover:border-slate-500" %>
</div>
<% else %>
<div class="flex-1">
Expand Down
2 changes: 1 addition & 1 deletion app/views/railsui/admin/fields/_theme_setup.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3 class="font-bold text-2xl mb-3 font-rui">Select a theme</h3>
<div class="prose dark:prose-invert mb-6 max-w-full">
<p>Each theme provides pre-designed static pages, scaffolded resources, UI components, layout patterns, partials, and more. <%= link_to "Read more about themes", docs_themes_path, target: :_blank %>.</p>
<p>Each theme provides pre-designed pages, scaffolded resources, UI components, layout patterns, partials, and more. <%= link_to "Read more about themes", docs_themes_path, target: :_blank %>.</p>
</div>

<% Railsui::Default::THEMES.each do |framework, themes| %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/railsui/docs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<p>Starting with a theme as a source of truth and general aesthetic, I compile all the components that make up a successful web application and present those in a design system for atomic use cases.</p>

<p> The final form includes everything from static pages to integrated components like flash messages, mailer templates, scaffold templates, helpers, and more. This list will keep growing as the number of themes and Rails UI as a whole scale.</p>
<p> The final form includes everything from pages to integrated components like flash messages, mailer templates, scaffold templates, helpers, and more. This list will keep growing as the number of themes and Rails UI as a whole scale.</p>

<% if Railsui.framework? %>
<p>Check out your current <%= link_to "design system", systems_path %> to get a glimpse these aspects.</p>
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions app/views/railsui/page/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- root path setup by client -->
<%= render "railsui/page/launchpad" %>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!-- fallback start at railsui/start which is accessible in the dev environment -->
<%= render "railsui/static/launchpad" %>
<%= render "railsui/page/launchpad" %>
3 changes: 3 additions & 0 deletions app/views/railsui/shared/_launcher.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<li>
<%= link_to "Documentation", railsui.docs_path, data: { turbo: false } %>
</li>
<li>
<%= link_to "Routes", railsui.routes_path, data: { turbo: false } %>
</li>
</ul>
</nav>
</div>
Expand Down
2 changes: 0 additions & 2 deletions app/views/railsui/static/index.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
get :faqs
end

scope controller: :static do
scope controller: :page do
get :index
get :start
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
require 'generators/railsui/generator_helpers'
module Railsui
module Generators
class StaticGenerator < Rails::Generators::NamedBase
class PageGenerator < Rails::Generators::NamedBase
include Rails::Generators::ResourceHelpers
include Rails.application.routes.url_helpers
include Railsui::Generators::GeneratorHelpers
hook_for :test_framework, as: :controller
source_root File.expand_path('../templates', __FILE__)
class_option :css, type: :string, default: nil, desc: "Pass CSS framework of choice"

desc "Adds StaticController, additional routing and associated pages for views"
desc "Adds additional routing and associated pages for views"

def copy_controller_action
append_to_file "app/controllers/static_controller.rb", after: "class StaticController < ApplicationController\n" do
append_to_file "app/controllers/page_controller.rb", after: "class PageController < ApplicationController\n" do
"\tdef #{display_name}\n\tend\n\n"
end
end
Expand All @@ -26,7 +25,7 @@ def display_name
def copy_view_files
# only return active Rails UI pages
return unless Railsui.config.pages.include?(display_name)
template "#{Railsui.config.css_framework}/#{Railsui.config.theme}/#{display_name}.html.erb.tt", File.join("app/views/static", "#{display_name}.html.erb")
template "#{Railsui.config.css_framework}/#{Railsui.config.theme}/#{display_name}.html.erb.tt", File.join("app/views/page", "#{display_name}.html.erb")
end

def add_to_navigation
Expand All @@ -39,7 +38,7 @@ def add_to_navigation
end

def add_routes
insert_into_file "#{Rails.root}/config/routes.rb", "\t\tget #{display_name.prepend(':')}\n", after: "scope controller: :static do\n"
insert_into_file "#{Rails.root}/config/routes.rb", "\t\tget #{display_name.prepend(':')}\n", after: "scope controller: :page do\n"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/install/bootstrap/install.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if Rails.root.join("app/assets/stylesheets/application.bootstrap.scss").exist?
say "🛑 Bootstrap is already installed. For best results uninstall it and re-run the Rails UI installer."
say "🥾 Bootstrap is already installed."
else

def swap_sprockets_to_builds
Expand Down
16 changes: 8 additions & 8 deletions lib/install/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ def setup_routes
mount Railsui::Engine, at: "/railsui"
end
scope controller: :static do
scope controller: :page do
end
# Inherits from Railsui::StaticController#index
# To overide, add your own static#index view or change to a new root
# Inherits from Railsui::PageController#index
# To overide, add your own page#index view or change to a new root
# Visit the start page for Rails UI any time at /railsui/start
root action: :index, controller: "railsui/static"
root action: :index, controller: "railsui/page"
RUBY

insert_into_file "#{Rails.root}/config/routes.rb", "#{content}\n", after: "Rails.application.routes.draw do\n"
end

def add_static_controller
generate "controller", "static --skip-test-framework --skip-assets --skip-helper --skip-routes --skip-template-engine"
def add_page_controller
generate "controller", "page --skip-test-framework --skip-assets --skip-helper --skip-routes --skip-template-engine"
end


Expand Down Expand Up @@ -271,8 +271,8 @@ def configure_permitted_parameters
say "⚡️ Setup routes"
setup_routes

say "⚡️ Generate StaticController"
add_static_controller
say "⚡️ Generate PageController"
add_page_controller

# Make sure it's before the extend_layout_and_views method
say "⚡️ Add devise layout and customizations..."
Expand Down
2 changes: 1 addition & 1 deletion lib/install/tailwind/install.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# General FYI: Tailwind requires more finesse to have ability to make use of more advanced PostCSS features. We're borrowing from the cssbundling-rails gem install pattern here to accomodate.
# General FYI: Tailwind requires more finesse to have ability to make use of more advanced PostCSS features. I'm borrowing from the cssbundling-rails gem install.rb file here to accomodate.

if Railsui.config.pages.any? && Railsui.config.theme.present?
say "🔔 #{Railsui.config.theme.humanize} theme already installed and configured"
Expand Down
2 changes: 1 addition & 1 deletion lib/railsui/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def save
def create_pages
Railsui::Pages.all_pages.each do | page, details |
if Railsui::Pages.page_enabled?(page) && !Railsui::Pages.page_exists?(page)
Railsui.run_command "rails g railsui:static #{page}"
Railsui.run_command "rails g railsui:page #{page}"
Railsui.run_command "rails css:build"
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/railsui/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.page_enabled?(page)
end

def self.page_exists?(page)
Rails.root.join("app/views/static/#{page}.html.erb").exist?
Rails.root.join("app/views/page/#{page}.html.erb").exist?
end
end
end

0 comments on commit 3e87f27

Please sign in to comment.