palkan / view_component-contrib

A collection of extension and developer tools for ViewComponent
MIT License
369 stars 22 forks source link

Previews page is blank #4

Closed brandoncordell closed 2 years ago

brandoncordell commented 3 years ago

What did you do?

Installed view_component-contrib using the template and choosing the sidecar option. Creating some components that have component_name > preview.rb files.

What did you expect to happen?

When going to /rails/view_components I expected to see a list of components that had preview.rb files.

What actually happened?

The page was blank.

Additional context

Environment

Ruby Version: 3.0.1

Framework Version (Rails, whatever): Rails 6.1.4

View Component Contrib Version: 0.1.0

palkan commented 3 years ago

Could you please share the file structure of your project related to components and also the changes (as a diff) introduced after applying the template?

brandoncordell commented 3 years ago

I was able to get the preview page working by starting from scratch and re-doing the configuration steps. I'm still having an issue with previews though. The server needs to be restarted for a preview to be picked up and when I change a Preview class ViewComponent can no longer find the preview and I need to restart the server. I'm not sure if that's a view_component issue or view_component-contrib.

liaden commented 3 years ago

For what it is worth, I had

config.view_component.preview_paths << Rails.root.join("/app/components")

and that caused it to search /app/components only which obviously had no components.

liaden commented 3 years ago

I was able to get the preview page working by starting from scratch and re-doing the configuration steps. I'm still having an issue with previews though. The server needs to be restarted for a preview to be picked up and when I change a Preview class ViewComponent can no longer find the preview and I need to restart the server. I'm not sure if that's a view_component issue or view_component-contrib.

That is because the monkey patch runs load_previews if descendants.empty?. Having to reload is definitely a PITA.