Skip to content

Commit

Permalink
🛠️ Component: Set up view_component ComponentPreviews
Browse files Browse the repository at this point in the history
- #1187

This is an intermediary step before we look into `LookBook` or similar,
but it:

1. Makes it possible to define component previews in
   `spec/components/previews`
2. Creates a basic layout for showing Components
  • Loading branch information
zspencer committed Mar 6, 2023
1 parent e02407f commit 6c6fec4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/views/layouts/component_preview.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
</head>

<body>
<%= yield %>
</body>
</html>
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ class Application < Rails::Application

config.i18n.load_path += Dir[Rails.root.join("config", "locales", "**", "*.{rb,yml}")]
config.i18n.load_path += Dir[Rails.root.join("app", "furniture", "**", "locales", "**", "*.{rb,yml}")]

config.view_component.preview_paths << "#{Rails.root}/spec/components/previews"
config.view_component.default_preview_layout = "component_preview"
end
end

0 comments on commit 6c6fec4

Please sign in to comment.