Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2024 RBUI
Copyright (c) 2024 RubyUI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# RBUI (former PhlexUI) 🚀
# RubyUI (former PhlexUI) 🚀

A UI component library, crafted precisely for Ruby devs who want to stay organized and build modern apps, fast. ✨
**Use this to build your own component library** 🛠️

## About RBUI 📚
## About RubyUI 📚

RBUI is a UI component library designed to let Ruby developers create modern, fast, and organized applications. 💎
RubyUI is a UI component library designed to let Ruby developers create modern, fast, and organized applications. 💎

### Key Features:

- **Built for Speed** ⚡: RBUI leverages Phlex, which is up to 12x faster than traditional Rails ERB templates.
- **Built for Speed** ⚡: RubyUI leverages Phlex, which is up to 12x faster than traditional Rails ERB templates.
- **Stunning UI** 🎨: Design beautiful, streamlined, and customizable UIs that sell your app effortlessly.
- **Stay Organized** 📁: Keep your UI components well-organized and easy to manage.
- **Customer-Centric UX** 🧑‍💼: Create memorable app experiences for your users.
Expand All @@ -28,26 +28,26 @@ RBUI is a UI component library designed to let Ruby developers create modern, fa
### 1. Install the gem

```bash
bundle add rbui
bundle add ruby_ui
```

or add it to your Gemfile:

```ruby
gem "rbui"
gem "ruby_ui"
```

### 2. Run the installer:

```bash
bin/rails g rbui:install
bin/rails g ruby_ui:install
```

### 3. Done! 🎉

## Documentation 📖

Visit https://rbui.dev/docs/introduction to view the full documentation, including:
Visit https://ruby_ui.dev/docs/introduction to view the full documentation, including:

- Detailed component guides
- Themes
Expand All @@ -56,7 +56,7 @@ Visit https://rbui.dev/docs/introduction to view the full documentation, includi

## Speed Comparison 🏎️

RBUI, powered by Phlex, outperforms traditional methods:
RubyUI, powered by Phlex, outperforms traditional methods:

- Phlex: Baseline 🏁
- ViewComponent: 5.57x slower 🐢
Expand All @@ -75,4 +75,4 @@ Licensed under the [MIT license](https://github.com/shadcn/ui/blob/main/LICENSE.

---

© 2024 RBUI. All rights reserved. 🔒
© 2024 RubyUI. All rights reserved. 🔒
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "rbui"
require "ruby_ui"

Bundler.require(:development)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "rails/generators"

module RBUI
module RubyUI
module Generators
class BaseGenerator < defined?(Rails::Generators::Base) ? Rails::Generators::Base : Object
namespace "rbui:base"
namespace "ruby_ui:base"

source_root File.join(__dir__, "templates")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module RBUI
module RubyUI
module Generators
class ComponentGenerator < RBUI::Generators::BaseGenerator
namespace "rbui:component"
class ComponentGenerator < RubyUI::Generators::BaseGenerator
namespace "ruby_ui:component"

source_root File.expand_path("../../..", __dir__)
argument :component_name, type: :string, required: true
Expand All @@ -21,7 +21,7 @@ def copy_common_files
end

def copy_component_files
puts "Component #{component} not found in rbui gem" if component_source.empty?
puts "Component #{component} not found in ruby_ui gem" if component_source.empty?

component_files = Dir.glob("#{component_source}/*")

Expand All @@ -32,22 +32,22 @@ def copy_component_files
end

def update_index_file
index_path = File.join(destination_root, "app/components/rbui/index.js")
index_path = File.join(destination_root, "app/components/ruby_ui/index.js")

rbui_index_content = File.read(index_path)
ruby_ui_index_content = File.read(index_path)

updated_rbui_index_content = add_controller_registration(rbui_index_content)
updated_ruby_ui_index_content = add_controller_registration(ruby_ui_index_content)

File.write(index_path, updated_rbui_index_content)
File.write(index_path, updated_ruby_ui_index_content)
end

def add_controller_registration(rbui_index_content)
def add_controller_registration(ruby_ui_index_content)
valid_controllers = get_valid_controllers

rbui_index_content = update_imports(rbui_index_content, valid_controllers)
update_registrations(rbui_index_content, valid_controllers)
ruby_ui_index_content = update_imports(ruby_ui_index_content, valid_controllers)
update_registrations(ruby_ui_index_content, valid_controllers)
# Uncomment the following line if you want to update exports
# rbui_index_content = update_exports(rbui_index_content, valid_controllers)
# ruby_ui_index_content = update_exports(ruby_ui_index_content, valid_controllers)
end

def get_valid_controllers
Expand All @@ -74,8 +74,8 @@ def controller_info(controller_file)
# Build the new import path
new_import_path = new_import_path("./#{relative_path.dirname}/#{file_name}")

# Create the registration name by dasherizing the component name and prefixing with 'rbui--'
registration_name = "rbui--#{component_name.dasherize}"
# Create the registration name by dasherizing the component name and prefixing with 'ruby_ui--'
registration_name = "ruby_ui--#{component_name.dasherize}"
Comment on lines +77 to +78
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think rbui--something should be replaced with ruby-ui--something instead of ruby_ui--something

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sethhorsley , I do agree with @pierry01 here. It will be violating stimulus conventions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good catch. I can fix it in another pr.


# Return a hash with import, registration, and export statements
{
Expand All @@ -92,7 +92,7 @@ def controller_info(controller_file)

def new_import_path(relative_path)
if using_importmap?
"rbui/#{relative_path.sub(/^\.\//, "")}"
"ruby_ui/#{relative_path.sub(/^\.\//, "")}"
else
relative_path
end
Expand All @@ -118,11 +118,11 @@ def component
end

def source_path
@source_path ||= "lib/rbui"
@source_path ||= "lib/ruby_ui"
end

def destination_path
@destination_path ||= "app/components/rbui"
@destination_path ||= "app/components/ruby_ui"
end

def component_source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
require_relative "../base_generator"

# TODO: make ejctectec components work without the gem
module RBUI
module RubyUI
module Generators
class InstallGenerator < RBUI::Generators::BaseGenerator
namespace "rbui:install"
class InstallGenerator < RubyUI::Generators::BaseGenerator
namespace "ruby_ui:install"

if defined?(Rails::Generators::Base)
source_root File.expand_path("templates", __dir__)
Expand All @@ -22,7 +22,7 @@ def add_phlex_rails
say "Phlex Rails is already installed", :green
else
say "Adding Phlex Rails"
run "bundle add phlex-rails --version=\"~> 1.2.1\""
run "bundle add phlex-rails --version=\"~> 2.0.0.beta2\""
end

say "Adding tailwind_merge"
Expand Down Expand Up @@ -59,11 +59,11 @@ def install_stuff

tailwind_config_path = Rails.root.join("config/tailwind.config.js")
if !File.exist?(tailwind_config_path)
say "Tailwind CSS is required for RBUI", :red
say "Tailwind CSS is required for RubyUI", :red
end

say "Add rbui initializer"
template "base_store_initializer.rb", "config/initializers/rbui.rb"
say "Add ruby_ui initializer"
template "base_store_initializer.rb", "config/initializers/ruby_ui.rb"

if using_importmap?
say "Using importmaps, adding tailwind-animate"
Expand All @@ -90,16 +90,16 @@ def install_stuff
template "application.tailwind.css", "app/assets/stylesheets/application.tailwind.css", force: true
end

def pin_rbui_js
def pin_ruby_ui_js
stimulus_path = Rails.root.join("app/javascript/application.js")
package_name = "rbui-js"
package_name = "ruby_ui-js"

say "Add RBUI Stimulus controllers"
# run "mkdir -p app/javascript/controllers/rbui-js"
template "index.js", "app/components/rbui/index.js"
say "Add RubyUI Stimulus controllers"
# run "mkdir -p app/javascript/controllers/ruby_ui-js"
template "index.js", "app/components/ruby_ui/index.js"

if using_importmap?
gsub_file "app/components/rbui/index.js", /^import { application }.*$/ do
gsub_file "app/components/ruby_ui/index.js", /^import { application }.*$/ do
'import { application } from "controllers/application";'
end

Expand All @@ -109,34 +109,34 @@ def pin_rbui_js

say "Pin #{package_name}"
append_to_file Rails.root.join("config/importmap.rb") do
"pin_all_from \"app/components/rbui\", under: \"rbui\"\n"
"pin_all_from \"app/components/ruby_ui\", under: \"ruby_ui\"\n"
end

run "bin/importmap pin #{package_name}"
append_to_file stimulus_path, "\nimport \"rbui\";\n"
append_to_file stimulus_path, "\nimport \"ruby_ui\";\n"

manifest_path = Rails.root.join("app/assets/config/manifest.js")
if File.exist?(manifest_path)
append_to_file manifest_path, "\n//= link rbui/index.js\n"
append_to_file manifest_path, "\n//= link ruby_ui/index.js\n"
end

fix_import_maps!
else
say "Add rbui-js package"
say "Add ruby_ui-js package"
run "yarn add #{package_name}"

append_to_file stimulus_path, "\nimport \"../components/rbui\";\n"
append_to_file stimulus_path, "\nimport \"../components/ruby_ui\";\n"

run "yarn build"
end
end

def include_rbui
message = "Include RBUI in your global component layout?\n This allows to call RBUI.Button {\"button\"} / RBUI::Button.new {\"button\"} with Button {\"button\"} (y/n)"
def include_ruby_ui
message = "Include RubyUI in your global component layout?\n This allows to call RubyUI.Button {\"button\"} / RubyUI::Button.new {\"button\"} with Button {\"button\"} (y/n)"
if yes?(message)
say "Add RBUI to your global component layout"
say "Add RubyUI to your global component layout"
insert_into_file "app/views/application_view.rb", after: "class ApplicationView < ApplicationComponent\n" do
" include RBUI\n"
" include RubyUI\n"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
--ring: 240 5.9% 10%;
--radius: 0.5rem;

/* rbui especific */
/* ruby_ui especific */
--warning: 38 92% 50%;
--warning-foreground: 0 0% 100%;
--success: 87 100% 37%;
Expand Down Expand Up @@ -53,7 +53,7 @@
--input: 240 3.7% 15.9%;
--ring: 240 4.9% 83.9%;

/* rbui especific */
/* ruby_ui especific */
--warning: 38 92% 50%;
--warning-foreground: 0 0% 100%;
--success: 84 81% 44%;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#RubyUI.setup do |config|

# Setting a namespace allows you to access RubyUI components through this namespace.
# For example, with namespace set to "UI", you can use:
# UI::Button.new instead of RubyUI::Button.new
# UI::Card.new instead of RubyUI::Card.new
# This can help avoid naming conflicts and allows for cleaner, more concise code.
# If you prefer to use RubyUI components directly, you can leave this unset.
# config.namespace = "UI"
#end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { application } from "../../../app/javascript/controllers/application";
// import ComboboxController from "./combobox/combobox_controller";

// Register all controllers
// application.register("rbui--combobox", ComboboxController);
// application.register("ruby_ui--combobox", ComboboxController);

import RBUI from "rbui-js";
RBUI.initialize(application);
import RubyUI from "ruby_ui-js";
RubyUI.initialize(application);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Static::IndexView < ApplicationView
def template
render RBUI::Button.new { "click me" }
render RubyUI::Button.new { "click me" }
br {}

# UI.Button { "click me" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// For importing tailwind styles from rbui gem
// For importing tailwind styles from ruby_ui gem
const execSync = require('child_process').execSync;

// Import rbui gem path
const outputRBUI = execSync('bundle show rbui', { encoding: 'utf-8' });
const rbui_path = outputRBUI.trim() + '/**/*.rb';
// Import ruby_ui gem path
const outputRubyUI = execSync('bundle show ruby_ui', { encoding: 'utf-8' });
const ruby_ui_path = outputRubyUI.trim() + '/**/*.rb';

const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
darkMode: ["class"],
content: [
'./app/views/**/*.{erb,haml,html,slim,rb}',
'./app/components/rbui/**/*.rb',
'./app/components/ruby_ui/**/*.rb',
'./app/helpers/**/*.rb',
'./app/assets/stylesheets/**/*.css',
'./app/javascript/**/*.js',
rbui_path
ruby_ui_path
],
theme: {
container: {
Expand Down Expand Up @@ -60,7 +60,7 @@ module.exports = {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
/* rbui especific */
/* ruby_ui especific */
warning: {
DEFAULT: "hsl(var(--warning))",
foreground: "hsl(var(--warning-foreground))",
Expand Down
Loading