Skip to content
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

Support custom panel #11

Open
michael-yin opened this issue Jun 14, 2024 · 0 comments
Open

Support custom panel #11

michael-yin opened this issue Jun 14, 2024 · 0 comments

Comments

@michael-yin
Copy link
Member

# This is an simple example of creating a custom panel.
# This one is an assets panel that is used to display the
# contents of any CSS/JS assets for a component.
#
# It assumes that asset files are named the same as the component
# file but with a `.css/.js` file extesions.
Lookbook.add_panel("assets", "lookbook/panels/assets", {
  label: "Assets",
  locals: lambda do |data|
    assets = data.preview.render_targets.flat_map do |target|
      asset_files = Dir["#{target.directory_path}/#{target.file_name(true)}.{css,js}"]
      asset_files.map { |path| Pathname.new path }
    end.compact
    {assets: assets}
  end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant