Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
unabris committed Oct 6, 2024
1 parent 1b5ceb5 commit ae42e66
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
*= require_tree .
*= require_self
*/

.wrapper {
padding: 1rem;
}
27 changes: 27 additions & 0 deletions site/app/views/layouts/lookbook.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= stylesheet_link_tag 'lookbook', 'data-turbo-track': 'reload' %>

<%= stylesheet_link_tag 'beyond_essence/application', 'data-turbo-track': 'reload' %>
<%= javascript_importmap_tags 'beyond_essence/application' %>

<%= yield :head %>
</head>

<body>
<div class="wrapper">
<% if params.dig(:lookbook, :display, :wrapper) == 'card' %>
<%= render BeyondEssence::CardComponent.new do %>
<%= yield %>
<% end %>
<% else %>
<%= yield %>
<% end %>
</div>
</body>
</html>
16 changes: 10 additions & 6 deletions site/app/views/lookbook/panels/_assets.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
</style>

<div class="lookbook-panel">
<% if assets.any? %>
<% if assets.any? %>
<div class="lookbook-panel">
<% assets.each do |asset| %>
<div class="asset-preview">
<header class="asset-header">
Expand All @@ -38,7 +38,11 @@
</div>
</div>
<% end %>
<% else %>
<p>No assets to display.</p>
<% end %>
</div>
</div>
<% else %>
<div class="p-4 w-full h-full bg-lookbook-prose-bg">
<%= lookbook_render :prose do %>
<em class='opacity-50'>No assets to display.</em>
<% end %>
</div>
<% end %>
26 changes: 19 additions & 7 deletions site/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,22 @@ class Application < Rails::Application
config.generators.system_tests = nil

if config.respond_to?(:lookbook)
def fetch_asset_files(data)
data.preview.components.flat_map do |component|
Dir[BeyondEssence::Engine.root.join('app/components',
"#{component.relative_file_path.to_s.chomp('.rb')}/*.{scss,js}")]
end
end

asset_panel_config = {
label: 'Assets',
partial: 'lookbook/panels/assets',
hotkey: 'a',
disabled: ->(data) { fetch_asset_files(data).empty? },
locals: lambda do |data|
assets = data.preview.components.flat_map do |component|
asset_files = Dir[BeyondEssence::Engine.root.join('app/components',
"#{component.relative_file_path.to_s.chomp('.rb')}/*.{scss,js}")]
asset_files.map do |path_str|
path = Pathname(path_str)
{ path:, language: path.extname.delete('.') }
end
assets = fetch_asset_files(data).map do |path_str|
path = Pathname(path_str)
{ path:, language: path.extname.delete('.') }
end

{ assets: }
Expand All @@ -67,6 +72,13 @@ class Application < Rails::Application
config.lookbook.preview_paths = [BeyondEssence::Engine.root.join('spec/components/previews')]
config.lookbook.preview_inspector.drawer_panels = [:params, :source, :assets]
config.lookbook.preview_embeds.policy = 'ALLOWALL'
config.view_component.default_preview_layout = 'lookbook'
config.lookbook.preview_display_options = {
wrapper: [
'background',
'card'
]
}
end
end
end

0 comments on commit ae42e66

Please sign in to comment.