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
View Components for /admin
#605
Merged
Merged
Conversation
This file contains 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
f0c6bef
to
df956ee
Compare
1e938c1
to
64df685
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is my first deep dive into generic, styled, reusable View Components. The codebase already has a fair amount of existing ones. But they weren't built in a way that makes them easily reusable.
The ones introduced in this PR are more generic to specific use-cases: styled tables in an admin context. I'm using this as a pressure test to see how I could add more components like these to the rest of the app.
Notes and thoughts
app/views/admin/users/index.html.erblooks real clean now!#calldirectly in the.rbfile of a component for simple layout cleans up the code quite a bit. There's no additional.html.erbfile!I'm not sold on passing "first" into components to style them differently. Ideally, that could be handled by the parent component. But I haven't figured out how to do that yet.I punted on anything related to Action View Form Helpers. There doesn't seem to be a good way to integrate these helpers with View Component (yet), so I opted to ignore them for now.formobject directly into the View Components. I understand that this tightly couples them, but it feels like an OK trade-off for now. I still get to use all the nice Rails helpers we all know and love.title || contentis a nice shortcut to be able to pass in a string or a block to render more custom content in a component.render TableComponent.new do |table|overrender TableComponent.new do |component|- makes it easier to understand which component you are chaining off of when nested.