-
Notifications
You must be signed in to change notification settings - Fork 28
Update to phlex 2 beta #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
451deaf
step 1
sethhorsley f366b25
step 2
sethhorsley 88aa9cf
step 3
sethhorsley 785083e
last steps of doc components
sethhorsley 2ed01c4
update theme view
sethhorsley 0057afa
more updates
sethhorsley f01c286
tests should be passing!
sethhorsley b9fcad0
standard rb
sethhorsley b71a904
revert the local test packages
sethhorsley 2dca3a7
change branch to new phlex branch from rbui gem
sethhorsley 9db4284
Merge branch 'main' into update-to-phlex-2-beta
sethhorsley ccddb67
fix gemfile.lock
sethhorsley 1a0466b
😡
sethhorsley 44e943e
remove files_out
sethhorsley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,5 +38,4 @@ | |
| .env* | ||
|
|
||
| .tool-versions | ||
|
|
||
| config/credentials/production.key | ||
| /config/credentials/production.key | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,25 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Components::Base < Phlex::HTML | ||
| TAILWIND_MERGER = ::TailwindMerge::Merger.new.freeze unless defined?(TAILWIND_MERGER) | ||
| include RBUI | ||
| include ApplicationHelper | ||
|
|
||
| attr_reader :attrs | ||
| # Include any helpers you want to be available across all components | ||
| include Phlex::Rails::Helpers::Routes | ||
|
|
||
| def initialize(**user_attrs) | ||
| @attrs = mix(default_attrs, user_attrs) | ||
| @attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class] | ||
| end | ||
| GITHUB_REPO_URL = "https://github.com/ruby-ui/ruby_ui/" | ||
| GITHUB_FILE_URL = "#{GITHUB_REPO_URL}blob/main/" | ||
| end | ||
|
|
||
| if defined?(Rails) && Rails.env.development? | ||
| def before_template | ||
| comment { "Before #{self.class.name}" } | ||
| super | ||
| end | ||
| end | ||
| class MethodCallFinder < Prism::Visitor | ||
| attr_reader :calls | ||
|
|
||
| private | ||
| def initialize(calls) | ||
| @calls = calls | ||
| end | ||
|
|
||
| def default_attrs | ||
| {} | ||
| def visit_call_node(node) | ||
| super | ||
| calls << node.name | ||
| end | ||
| end |
2 changes: 1 addition & 1 deletion
2
...views/components/docs/components_table.rb → app/components/docs/components_table.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/components/docs/header.rb → app/components/docs/header.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/components/docs/tailwind_config.rb → app/components/docs/tailwind_config.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/components/docs/tailwind_css.rb → app/components/docs/tailwind_css.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
app/views/home_view/banner.rb → app/components/home/banner.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| class Components::Layouts::Base < Phlex::HTML | ||
| # include Components | ||
|
|
||
| if Rails.env.development? | ||
| def before_template | ||
| comment { "Before #{self.class.name}" } | ||
| super | ||
| end | ||
| end | ||
|
|
||
| PageInfo = Data.define(:title) | ||
|
|
||
| def around_template | ||
| doctype | ||
|
|
||
| html do | ||
| render Components::Shared::Head.new(page_info) | ||
|
|
||
| body do | ||
| render Components::Shared::Navbar.new | ||
| yield # This will render the content of child layouts/views | ||
| render Components::Shared::Flashes.new(notice: helpers.flash[:notice], alert: helpers.flash[:alert]) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def page_info | ||
| PageInfo.new( | ||
| title: page_title | ||
| ) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Components::Layouts::Docs < Components::Layouts::Base | ||
| include ApplicationHelper | ||
|
|
||
| def around_template | ||
| super do # Call the Base layout's template method | ||
| div(class: "flex-1") do | ||
| div(class: "border-b") do | ||
| div(class: "container px-4 flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] md:gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10") do | ||
| render Components::Shared::Sidebar.new | ||
| main(class: "relative py-6 lg:gap-10 lg:py-8 xl:grid xl:grid-cols-[1fr_300px]") do | ||
| yield # This will render the content of views using this layout | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| class Components::Layouts::Errors < Components::Base | ||
| include Components | ||
|
|
||
| PageInfo = Data.define(:title) | ||
|
|
||
| include Phlex::Rails::Layout | ||
|
|
||
| def view_template(&block) | ||
| doctype | ||
|
|
||
| html do | ||
| render Components::Shared::Head.new(page_info) | ||
|
|
||
| body do | ||
| main(class: "relative flex flex-col items-center justify-center gap-y-6 h-screen w-screen overflow-y-scroll") do | ||
| render Shared::GridPattern.new | ||
| ThemeToggle(class: "hidden") # In order for dark mode to work, we need to render the theme toggle somewhere in the DOM | ||
| render Shared::Logo.new | ||
| div(class: "container w-full max-w-md", &block) | ||
| end | ||
| render Shared::Flashes.new(notice: helpers.flash[:notice], alert: helpers.flash[:alert]) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def page_info | ||
| PageInfo.new( | ||
| title: page_title | ||
| ) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Components::Layouts::Pages < Components::Layouts::Base | ||
| def around_template | ||
| super do # Call the Base layout's template method | ||
| main(class: "relative") { yield } | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Components::RubyUiBase < Phlex::HTML | ||
| include RBUI | ||
| # include Components | ||
| include ApplicationHelper | ||
|
|
||
| # Include any helpers you want to be available across all components | ||
| include Phlex::Rails::Helpers::Routes | ||
|
|
||
| GITHUB_REPO_URL = "https://github.com/ruby-ui/ruby_ui/" | ||
| GITHUB_FILE_URL = "#{GITHUB_REPO_URL}blob/main/" | ||
|
|
||
| if Rails.env.development? | ||
| def before_template | ||
| comment { "Before #{self.class.name}" } | ||
| super | ||
| end | ||
| end | ||
| end | ||
|
|
||
| class MethodCallFinder < Prism::Visitor | ||
| attr_reader :calls | ||
|
|
||
| def initialize(calls) | ||
| @calls = calls | ||
| end | ||
|
|
||
| def visit_call_node(node) | ||
| super | ||
| calls << node.name | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/components/shared/flashes.rb → app/components/shared/flashes.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/components/shared/grid_pattern.rb → app/components/shared/grid_pattern.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
app/views/components/shared/head.rb → app/components/shared/head.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/views/components/shared/logo.rb → app/components/shared/logo.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you already are on Components directory, it means that you can use only Base make it less verbose
Components::Docs::ComponentsTable < Base
or even better: