Skip to content

Migrate the themes components to align with Phlex conversions#170

Merged
stephannv merged 1 commit intoruby-ui:mainfrom
karinevieira:refactor/migrate_themes_components
Feb 19, 2025
Merged

Migrate the themes components to align with Phlex conversions#170
stephannv merged 1 commit intoruby-ui:mainfrom
karinevieira:refactor/migrate_themes_components

Conversation

@karinevieira
Copy link
Contributor

Phlex 2.0 follows a specific folder structure and naming convention for views and components.
For views, they should be placed in the app/views directory under the Views namespace, and must inherit from Views::Base.

# frozen_string_literal: true
class Views::Articles::Index < Views::Base
  def view_template
    h1 { "Articles" }
  end
end

For components, they should be placed in the app/components directory under the Components namespace, and must inherit from Components::Base.

class Components::Button < Components::Base
  def view_template
    button { "Click me" }
  end
end

This pull request continues the migration of the components that are currently in the app/views folder to app/components, in accordance with the Phlex conventions.

module Grid
class Card < Components::Base
def view_template
RubyUI::Card(class: "w-full") do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some cases, I needed to specify the module for the components because Zeitwerk was getting confused, causing the page to take too long to load. To resolve this, I added the RubyUI module to the necessary components.

@stephannv stephannv merged commit 634ba80 into ruby-ui:main Feb 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants