lookbook 1.0.0.beta.7 → 1.0.0.rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +38 -30
- data/app/assets/lookbook/css/themes/blue.css +2 -1
- data/app/assets/lookbook/css/themes/indigo.css +2 -1
- data/app/assets/lookbook/css/themes/zinc.css +2 -1
- data/app/assets/lookbook/js/components/clipboard.js +1 -1
- data/app/components/lookbook/base_component.rb +0 -1
- data/app/components/lookbook/embed/component.html.erb +1 -1
- data/app/components/lookbook/inspector_panel/component.css +5 -0
- data/app/components/lookbook/inspector_panel/component.html.erb +6 -4
- data/app/components/lookbook/inspector_panel/component.rb +3 -3
- data/app/components/lookbook/nav/component.rb +1 -2
- data/app/components/lookbook/nav/item/component.html.erb +1 -1
- data/app/components/lookbook/tab_panels/component.rb +1 -1
- data/app/components/lookbook/tab_panels/panel/component.rb +2 -2
- data/app/components/lookbook/tag_component.rb +3 -3
- data/app/controllers/lookbook/application_controller.rb +1 -0
- data/app/controllers/lookbook/page_controller.rb +6 -1
- data/app/controllers/lookbook/previews_controller.rb +8 -16
- data/app/helpers/lookbook/preview_helper.rb +7 -2
- data/app/views/lookbook/index.html.erb +11 -24
- data/app/views/lookbook/previews/panels/_notes.html.erb +1 -1
- data/app/views/lookbook/previews/show.html.erb +2 -2
- data/lib/lookbook/code_formatter.rb +1 -1
- data/lib/lookbook/collection.rb +8 -3
- data/lib/lookbook/component.rb +2 -3
- data/lib/lookbook/config.rb +13 -10
- data/lib/lookbook/data.rb +1 -1
- data/lib/lookbook/engine.rb +13 -10
- data/lib/lookbook/entity.rb +1 -1
- data/lib/lookbook/hooks.rb +1 -1
- data/lib/lookbook/markdown.rb +1 -1
- data/lib/lookbook/page.rb +4 -5
- data/lib/lookbook/page_section.rb +2 -4
- data/lib/lookbook/panels.rb +1 -1
- data/lib/lookbook/preview.rb +9 -11
- data/lib/lookbook/preview_controller.rb +1 -1
- data/lib/lookbook/preview_example.rb +1 -1
- data/lib/lookbook/source_inspector.rb +14 -11
- data/lib/lookbook/store.rb +7 -3
- data/lib/lookbook/tag.rb +5 -1
- data/lib/lookbook/tags.rb +3 -3
- data/lib/lookbook/theme.rb +2 -2
- data/lib/lookbook/version.rb +1 -1
- data/lib/tasks/lookbook_tasks.rake +1 -2
- data/public/lookbook-assets/css/lookbook.css +19 -10
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/css/themes/blue.css +1 -0
- data/public/lookbook-assets/css/themes/blue.css.map +1 -1
- data/public/lookbook-assets/css/themes/indigo.css +1 -0
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
- data/public/lookbook-assets/css/themes/zinc.css +1 -0
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +84 -84
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 03c7bc590a271bc1db49e9636c5c6a274ec45f9a449aaf811695e74c4de52aaa
         | 
| 4 | 
            +
              data.tar.gz: a23446857053cf0789adf7ac0644ea3fe8968a8a7fee7c25e2f688ff5e15b7b5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b1eac6af6a1e73ef6c44aa637ca1552bba495d3f07a402ff2bb60d79606c391aaa4a54eeed8e44896273007cb9261cffe57d40b135951b94ea57919be9581d44
         | 
| 7 | 
            +
              data.tar.gz: 70fd860db9aa315acd81b182188f3b7f53a38098f33a57bd7b4d8839437de932bc93462a5d00acd30195790157f8af70e7f8313778663bf784ffb3d8fb9437a1
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,53 +1,61 @@ | |
| 1 | 
            -
            # Lookbook v1.0 | 
| 1 | 
            +
            # Lookbook v1.0
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            <div>
         | 
| 4 | 
            +
            <a href="https://rubygems.org/gems/lookbook"><img src="https://img.shields.io/gem/v/lookbook?include_prereleases" alt="Gem version"></a>
         | 
| 5 | 
            +
            <img src="https://github.com/allmarkedup/lookbook/actions/workflows/ci.yml/badge.svg?branch=v1.0-beta" alt="CI status">
         | 
| 6 | 
            +
            </div>
         | 
| 7 | 
            +
            <br>
         | 
| 4 8 |  | 
| 5 | 
            -
             | 
| 9 | 
            +
            > **This is the Lookbook v1.0 BETA development branch.**<br>
         | 
| 10 | 
            +
            >_For code and documentation for the current stable release see the [main branch](https://github.com/allmarkedup/lookbook/tree/main)._
         | 
| 6 11 |  | 
| 7 | 
            -
            ---
         | 
| 8 12 |  | 
| 9 | 
            -
             | 
| 13 | 
            +
            ## Get started
         | 
| 10 14 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             
         | 
| 13 | 
            -
            ## 📚 Documentation
         | 
| 15 | 
            +
            If you are already using Lookbook in your project, just update the Lookbook gem to the latest beta release and then head over to the [beta documentation site](https://beta.lookbook.build/) to read more about the new features.
         | 
| 14 16 |  | 
| 15 | 
            -
             | 
| 17 | 
            +
            ```ruby
         | 
| 18 | 
            +
            gem "lookbook", ">= 1.0.0.beta.8"
         | 
| 19 | 
            +
            ```
         | 
| 16 20 |  | 
| 17 | 
            -
             | 
| 21 | 
            +
            If you are **new to Lookbook** then check out the <a href="https://beta.lookbook.build/guide/quick-start/">v1.0 quick start guide</a> for more detailed instructions on installing Lookbook in your project
         | 
| 18 22 |  | 
| 19 | 
            -
            > Documentation source files are located in the `/docs` directory within this repository. The docs are built using [Bridgetown](https://www.bridgetownrb.com/).
         | 
| 20 23 |  | 
| 21 | 
            -
             | 
| 24 | 
            +
            <h4>Useful Resources</h4>
         | 
| 22 25 |  | 
| 23 | 
            -
             | 
| 26 | 
            +
            * 👉 <a href="https://beta.lookbook.build/">v1.0 docs</a>
         | 
| 27 | 
            +
            * 👉 <a href="https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook">v1.0 demo app</a> <em>(The repo for the demo <a href="https://github.com/allmarkedup/lookbook-demo/tree/v1.0-beta">is here</a> if you want to dig in further)</em>
         | 
| 24 28 |  | 
| 25 | 
            -
            👉 **https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook/** 👈
         | 
| 26 29 |  | 
| 27 | 
            -
            [](https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook/)
         | 
| 28 30 |  | 
| 31 | 
            +
            ## Changes and new features in v1.0
         | 
| 29 32 |  | 
| 30 | 
            -
             | 
| 33 | 
            +
            Lookbook v1.0 includes a completely re-written UI, many under-the hood improvements and a some exciting new customisation options.
         | 
| 31 34 |  | 
| 32 | 
            -
             | 
| 35 | 
            +
            ### Frontend changes:
         | 
| 33 36 |  | 
| 34 | 
            -
            -  | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
            - [x] Improve the development/debugging setup
         | 
| 40 | 
            -
            - [ ] Improve the test setup and test coverage, switch to RSpec **[in progress]**
         | 
| 37 | 
            +
            * Completely re-written UI - now built with ViewComponents
         | 
| 38 | 
            +
            * New [UI themes and customisation options](https://beta.lookbook.build/guide/themes/)
         | 
| 39 | 
            +
            * Improved small-screen/mobile view
         | 
| 40 | 
            +
            * Debug menu
         | 
| 41 | 
            +
            * ...and many other small visual and usability improvements
         | 
| 41 42 |  | 
| 42 | 
            -
             | 
| 43 | 
            +
            ### New options for extending Lookbook:
         | 
| 43 44 |  | 
| 44 | 
            -
             | 
| 45 | 
            +
            * Define [custom tags](https://beta.lookbook.build/guide/extend/tags/) for preview file annotations
         | 
| 46 | 
            +
            * Create [your own tab panels](https://beta.lookbook.build/guide/extend/panels/) - with complete control over content/layout and access to all Lookbook data
         | 
| 47 | 
            +
            * Use [lifecycle hooks](https://beta.lookbook.build/guide/extend/hooks/) to run your own code when Lookbook starts up, when files change or at shutdown
         | 
| 45 48 |  | 
| 46 | 
            -
             | 
| 49 | 
            +
            ### Other changes
         | 
| 47 50 |  | 
| 48 | 
            -
             | 
| 51 | 
            +
            * 'Workbench' app for developing Lookbook's UI components in Lookbook
         | 
| 52 | 
            +
            * New Rspec-based test suite and dummy app
         | 
| 53 | 
            +
            * All new documentation site built using [Bridgetown](https://www.bridgetownrb.com/)
         | 
| 54 | 
            +
             | 
| 55 | 
            +
             | 
| 56 | 
            +
            [](https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook/)
         | 
| 49 57 |  | 
| 50 | 
            -
            ##  | 
| 58 | 
            +
            ## Workbench
         | 
| 51 59 |  | 
| 52 60 | 
             
            As of this release, Lookbook's UI is itself built using ViewComponent components. To help with development it is possible to preview these components (in a Lookbook instance!) by running the included 'Workbench" app, as follows:
         | 
| 53 61 |  | 
| @@ -59,7 +67,7 @@ As of this release, Lookbook's UI is itself built using ViewComponent components | |
| 59 67 | 
             
            This will start the Workbench app in development mode and any changes to Lookbooks views or assets will immediately be visible in the UI.
         | 
| 60 68 |  | 
| 61 69 |  | 
| 62 | 
            -
            ##  | 
| 70 | 
            +
            ## Running tests
         | 
| 63 71 |  | 
| 64 72 | 
             
            The test suite is in the process of being completely overhauled.
         | 
| 65 73 |  | 
| @@ -58,6 +58,7 @@ | |
| 58 58 | 
             
              --lookbook-header-bg: var(--lookbook-accent-600);
         | 
| 59 59 | 
             
              --lookbook-header-text: var(--lookbook-white);
         | 
| 60 60 | 
             
              --lookbook-header-border: var(--lookbook-accent-700);
         | 
| 61 | 
            +
              --lookbook-blank-slate-title: var(--lookbook-accent-600);
         | 
| 61 62 | 
             
              --lookbook-branding-text: var(--lookbook-header-text);
         | 
| 62 63 | 
             
              --lookbook-draggable-hint: rgb(224 231 255 / 0.2);
         | 
| 63 | 
            -
            }
         | 
| 64 | 
            +
            }
         | 
| @@ -58,6 +58,7 @@ | |
| 58 58 | 
             
              --lookbook-header-bg: var(--lookbook-accent-600);
         | 
| 59 59 | 
             
              --lookbook-header-text: var(--lookbook-white);
         | 
| 60 60 | 
             
              --lookbook-header-border: var(--lookbook-accent-700);
         | 
| 61 | 
            +
              --lookbook-blank-slate-title: var(--lookbook-accent-600);
         | 
| 61 62 | 
             
              --lookbook-branding-text: var(--lookbook-header-text);
         | 
| 62 63 | 
             
              --lookbook-draggable-hint: rgb(224 231 255 / 0.2);
         | 
| 63 | 
            -
            }
         | 
| 64 | 
            +
            }
         | 
| @@ -58,6 +58,7 @@ | |
| 58 58 | 
             
              --lookbook-header-bg: var(--lookbook-accent-600);
         | 
| 59 59 | 
             
              --lookbook-header-text: var(--lookbook-white);
         | 
| 60 60 | 
             
              --lookbook-header-border: var(--lookbook-accent-700);
         | 
| 61 | 
            +
              --lookbook-blank-slate-title: var(--lookbook-accent-600);
         | 
| 61 62 | 
             
              --lookbook-branding-text: var(--lookbook-header-text);
         | 
| 62 63 | 
             
              --lookbook-draggable-hint: rgb(224 231 255 / 0.2);
         | 
| 63 | 
            -
            }
         | 
| 64 | 
            +
            }
         | 
| @@ -19,7 +19,7 @@ function initClipboard(context = {}) { | |
| 19 19 | 
             
                    return false;
         | 
| 20 20 | 
             
                  }
         | 
| 21 21 |  | 
| 22 | 
            -
                  const content = decodeEntities(targetEl. | 
| 22 | 
            +
                  const content = decodeEntities(targetEl.innerHTML.trim());
         | 
| 23 23 |  | 
| 24 24 | 
             
                  await window.navigator.clipboard.writeText(content);
         | 
| 25 25 | 
             
                  this.copied = true;
         | 
| @@ -13,7 +13,7 @@ | |
| 13 13 | 
             
                      href: lookbook_inspect_path(@example.path, @params),
         | 
| 14 14 | 
             
                      tooltip: "View in Inspector" %>
         | 
| 15 15 | 
             
                    <% group.button icon: :external_link,
         | 
| 16 | 
            -
                      href:  | 
| 16 | 
            +
                      href: lookbook_preview_path(@example.path, @params),
         | 
| 17 17 | 
             
                      tooltip: "Open in new window",
         | 
| 18 18 | 
             
                      target: "_blank" %>
         | 
| 19 19 | 
             
                  <% end %>
         | 
| @@ -1,4 +1,6 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
              <%  | 
| 3 | 
            -
            <% end %>
         | 
| 4 | 
            -
             | 
| 1 | 
            +
            <%= render_component_tag :div, class: "h-full" do %>
         | 
| 2 | 
            +
              <% if panel_styles %>
         | 
| 3 | 
            +
                <% content_for :panel_css do %><%= panel_styles %><% end %>
         | 
| 4 | 
            +
              <% end %>
         | 
| 5 | 
            +
              <%= panel_html %>
         | 
| 6 | 
            +
            <% end %>
         | 
| @@ -15,8 +15,8 @@ module Lookbook | |
| 15 15 |  | 
| 16 16 | 
             
                def before_render
         | 
| 17 17 | 
             
                  if @system == false
         | 
| 18 | 
            -
                    panel_dom = ::Nokogiri::HTML | 
| 19 | 
            -
                    style_tags = panel_dom.css( | 
| 18 | 
            +
                    panel_dom = ::Nokogiri::HTML.fragment(content)
         | 
| 19 | 
            +
                    style_tags = panel_dom.css("style")
         | 
| 20 20 | 
             
                    if style_tags.any?
         | 
| 21 21 | 
             
                      css_parser = ::CssParser::Parser.new
         | 
| 22 22 | 
             
                      @panel_styles = ""
         | 
| @@ -27,7 +27,7 @@ module Lookbook | |
| 27 27 | 
             
                        end
         | 
| 28 28 | 
             
                        style_tag.unlink
         | 
| 29 29 | 
             
                      end
         | 
| 30 | 
            -
                      @panel_html = panel_dom.to_html.html_safe | 
| 30 | 
            +
                      @panel_html = panel_dom.to_html.html_safe
         | 
| 31 31 | 
             
                    end
         | 
| 32 32 | 
             
                  end
         | 
| 33 33 | 
             
                  @panel_html ||= content
         | 
| @@ -17,7 +17,7 @@ | |
| 17 17 | 
             
                    class: "mr-1 text-lookbook-nav-toggle absolute -left-4",
         | 
| 18 18 | 
             
                    "x-effect": "iconName = open ? 'chevron-down' : 'chevron-right'" if children? %>
         | 
| 19 19 | 
             
                  <%= icon nav_icon, size: 3.5, class: "mr-1.5 text-lookbook-nav-icon-stroke" %>
         | 
| 20 | 
            -
                  <span | 
| 20 | 
            +
                  <span <% if @item.type == :preview %>class="font-bold"<% end %>><%= label %></span>
         | 
| 21 21 | 
             
                </div>
         | 
| 22 22 | 
             
              <% end %>
         | 
| 23 23 |  | 
| @@ -6,19 +6,19 @@ module Lookbook | |
| 6 6 | 
             
                  @tag = tag
         | 
| 7 7 | 
             
                  html_attrs[:data] ||= {}
         | 
| 8 8 | 
             
                  html_attrs[:data][:component] = name if name.present?
         | 
| 9 | 
            -
                  html_attrs["x-cloak"] = true if cloak == true
         | 
| 9 | 
            +
                  html_attrs[:"x-cloak"] = true if cloak == true
         | 
| 10 10 | 
             
                  html_attrs[self.class.escape_attribute_key] = false
         | 
| 11 11 | 
             
                  @html_attrs = html_attrs
         | 
| 12 12 | 
             
                end
         | 
| 13 13 |  | 
| 14 14 | 
             
                def call
         | 
| 15 | 
            -
                  tag.public_send(@tag, **@html_attrs) do
         | 
| 15 | 
            +
                  tag.public_send(@tag.to_sym, **@html_attrs) do
         | 
| 16 16 | 
             
                    content
         | 
| 17 17 | 
             
                  end
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 20 | 
             
                def self.escape_attribute_key
         | 
| 21 | 
            -
                  @escape_attribute_key ||= Gem::Version.new(Rails.version) < Gem::Version.new( | 
| 21 | 
            +
                  @escape_attribute_key ||= Gem::Version.new(Rails.version) < Gem::Version.new("6.1.5.1") ? :escape_attributes : :escape
         | 
| 22 22 | 
             
                end
         | 
| 23 23 | 
             
              end
         | 
| 24 24 | 
             
            end
         | 
| @@ -13,7 +13,12 @@ module Lookbook | |
| 13 13 | 
             
                  @pages = Lookbook.pages
         | 
| 14 14 | 
             
                  @next_page = @pages.find_next(@page)
         | 
| 15 15 | 
             
                  @previous_page = @pages.find_previous(@page)
         | 
| 16 | 
            -
                  content = render_to_string inline: @page.content
         | 
| 16 | 
            +
                  content = render_to_string inline: @page.content, locals: {
         | 
| 17 | 
            +
                    page: @page,
         | 
| 18 | 
            +
                    next_page: @next_page,
         | 
| 19 | 
            +
                    previous_page: @previous_page,
         | 
| 20 | 
            +
                    pages: @pages
         | 
| 21 | 
            +
                  }
         | 
| 17 22 | 
             
                  @page.markdown? ? Lookbook::Markdown.render(content) : content
         | 
| 18 23 | 
             
                end
         | 
| 19 24 | 
             
              end
         | 
| @@ -2,6 +2,8 @@ module Lookbook | |
| 2 2 | 
             
              class PreviewsController < ApplicationController
         | 
| 3 3 | 
             
                layout "lookbook/inspector"
         | 
| 4 4 |  | 
| 5 | 
            +
                helper Lookbook::PreviewHelper
         | 
| 6 | 
            +
             | 
| 5 7 | 
             
                def self.controller_path
         | 
| 6 8 | 
             
                  "lookbook/previews"
         | 
| 7 9 | 
             
                end
         | 
| @@ -47,16 +49,6 @@ module Lookbook | |
| 47 49 | 
             
                  redirect_to lookbook_inspect_path params[:path]
         | 
| 48 50 | 
             
                end
         | 
| 49 51 |  | 
| 50 | 
            -
                # Namespaced preview helpers
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                def lookbook_display(key, fallback = nil)
         | 
| 53 | 
            -
                  params.dig(:lookbook, :display, key.to_sym) || fallback
         | 
| 54 | 
            -
                end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                def lookbook_data(key, fallback = nil)
         | 
| 57 | 
            -
                  Lookbook.data.get(key, fallback)
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 52 | 
             
                private
         | 
| 61 53 |  | 
| 62 54 | 
             
                def lookup_entities
         | 
| @@ -130,7 +122,7 @@ module Lookbook | |
| 130 122 |  | 
| 131 123 | 
             
                  context_data = {
         | 
| 132 124 | 
             
                    preview_params: preview_params,
         | 
| 133 | 
            -
                    path: params[:path] | 
| 125 | 
            +
                    path: params[:path]
         | 
| 134 126 | 
             
                  }
         | 
| 135 127 |  | 
| 136 128 | 
             
                  example = @example
         | 
| @@ -145,7 +137,7 @@ module Lookbook | |
| 145 137 | 
             
                    output = preview_controller.process(:render_example_to_string, @preview, example.name)
         | 
| 146 138 | 
             
                    source = has_template ? example.template_source(render_args[:template]) : example.method_source
         | 
| 147 139 | 
             
                    source_lang = has_template ? example.template_lang(render_args[:template]) : example.lang
         | 
| 148 | 
            -
             | 
| 140 | 
            +
             | 
| 149 141 | 
             
                    example.define_singleton_method(:output, proc { output })
         | 
| 150 142 | 
             
                    example.define_singleton_method(:source, proc { source })
         | 
| 151 143 | 
             
                    example.define_singleton_method(:source_lang, proc { source_lang })
         | 
| @@ -170,21 +162,21 @@ module Lookbook | |
| 170 162 |  | 
| 171 163 | 
             
                    callable_data = {
         | 
| 172 164 | 
             
                      name: name.to_s,
         | 
| 173 | 
            -
                      index_position: (@panels. | 
| 165 | 
            +
                      index_position: (@panels.count { |p| p.pane == config.pane } + 1),
         | 
| 174 166 | 
             
                      **inspector_data
         | 
| 175 167 | 
             
                    }
         | 
| 176 168 |  | 
| 177 169 | 
             
                    resolved_config = config_with_defaults.transform_values do |value|
         | 
| 178 | 
            -
                      value. | 
| 170 | 
            +
                      value.instance_of?(Proc) ? value.call(Lookbook::Store.new(callable_data)) : value
         | 
| 179 171 | 
             
                    end
         | 
| 180 172 | 
             
                    resolved_config[:name] = name.to_s
         | 
| 181 | 
            -
             | 
| 173 | 
            +
             | 
| 182 174 | 
             
                    @panels << Lookbook::Store.new(resolved_config, deep: false)
         | 
| 183 175 | 
             
                  end
         | 
| 184 176 |  | 
| 185 177 | 
             
                  @panels = @panels.select(&:show).sort_by { |p| [p.position, p.label] }
         | 
| 186 178 | 
             
                end
         | 
| 187 | 
            -
             | 
| 179 | 
            +
             | 
| 188 180 | 
             
                def main_panels
         | 
| 189 181 | 
             
                  panels.select { |panel| panel.pane == :main }
         | 
| 190 182 | 
             
                end
         | 
| @@ -1,6 +1,11 @@ | |
| 1 1 | 
             
            module Lookbook
         | 
| 2 2 | 
             
              module PreviewHelper
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 3 | 
            +
                def lookbook_display(key, fallback = nil)
         | 
| 4 | 
            +
                  params.dig(:lookbook, :display, key.to_sym) || fallback
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def lookbook_data(key, fallback = nil)
         | 
| 8 | 
            +
                  Lookbook.data.get(key, fallback)
         | 
| 9 | 
            +
                end
         | 
| 5 10 | 
             
              end
         | 
| 6 11 | 
             
            end
         | 
| @@ -1,27 +1,14 @@ | |
| 1 1 | 
             
            <div id="landing" class="flex flex-col items-center justify-center h-full w-full">
         | 
| 2 | 
            -
              <div class=" | 
| 3 | 
            -
                 | 
| 4 | 
            -
                   | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
                    </ | 
| 11 | 
            -
                   | 
| 12 | 
            -
                 | 
| 13 | 
            -
                  <div id="landing-no-content">
         | 
| 14 | 
            -
                    <h5 class="text-lg font-bold opacity-80"><%= config.project_name %></h5>
         | 
| 15 | 
            -
                    <div class="mt-3 italic opacity-40 max-w-[400px]">
         | 
| 16 | 
            -
                      <p>
         | 
| 17 | 
            -
                        Nothing here yet! 
         | 
| 18 | 
            -
                        <a class="underline" href="https://viewcomponent.org/guide/previews.html" target="_blank">
         | 
| 19 | 
            -
                          Create a preview
         | 
| 20 | 
            -
                        </a>
         | 
| 21 | 
            -
                        to get started.
         | 
| 22 | 
            -
                      </p>
         | 
| 23 | 
            -
                    </div>
         | 
| 24 | 
            -
                  </div>
         | 
| 25 | 
            -
                <% end %>
         | 
| 2 | 
            +
              <div class="text-center" id="landing-<%= Lookbook.previews? ? "with" : "no" %>-content">
         | 
| 3 | 
            +
                <h5 class="text-base text-lookbook-blank-slate-title truncate uppercase font-black tracking-wider mb-2">
         | 
| 4 | 
            +
                  <%= config.project_name %>
         | 
| 5 | 
            +
                </h5>
         | 
| 6 | 
            +
                <div class="opacity-60">
         | 
| 7 | 
            +
                  <% if Lookbook.previews? %>
         | 
| 8 | 
            +
                    <p>Select a preview from the nav to get started.</p>
         | 
| 9 | 
            +
                  <% else %>
         | 
| 10 | 
            +
                    <p><a class="underline" href="https://beta.lookbook.build/guide/previews" target="_blank">Create a preview</a> to get started.</p>
         | 
| 11 | 
            +
                  <% end %>
         | 
| 12 | 
            +
                </div>
         | 
| 26 13 | 
             
              </div>
         | 
| 27 14 | 
             
            </div>
         | 
| @@ -11,7 +11,7 @@ | |
| 11 11 | 
             
                <% end %>
         | 
| 12 12 | 
             
              </div>
         | 
| 13 13 | 
             
            <% else %>
         | 
| 14 | 
            -
              <div class=" | 
| 14 | 
            +
              <div class="px-4 py-6 bg-lookbook-prose-bg w-full h-full">
         | 
| 15 15 | 
             
                <%= render_component :prose do %>
         | 
| 16 16 | 
             
                  <%== items.any? ? items.first.notes : "<em class='opacity-50'>No notes provided.</em>" %>
         | 
| 17 17 | 
             
                <% end %>
         | 
| @@ -55,7 +55,7 @@ | |
| 55 55 | 
             
                <div class="h-full relative overflow-auto">
         | 
| 56 56 | 
             
                  <%= render_component :tab_panels, alpine_data: "$store.inspector.main" do |tabs| %>
         | 
| 57 57 | 
             
                    <% @main_panels.each do |panel| %>
         | 
| 58 | 
            -
                      <% tabs.panel id: panel.id, name: panel.name, class:  | 
| 58 | 
            +
                      <% tabs.panel id: panel.id, name: panel.name, class: panel.panel_classes do %>
         | 
| 59 59 | 
             
                        <%= render panel.partial, **@inspector_data, panel: panel, **panel.locals %>
         | 
| 60 60 | 
             
                      <% end %>
         | 
| 61 61 | 
             
                    <% end %>
         | 
| @@ -123,7 +123,7 @@ | |
| 123 123 | 
             
                <div class="h-full overflow-auto">
         | 
| 124 124 | 
             
                  <%= render_component :tab_panels, alpine_data: "$store.inspector.drawer" do |tabs| %>
         | 
| 125 125 | 
             
                    <% @drawer_panels.each do |panel| %>
         | 
| 126 | 
            -
                      <% tabs.panel id: panel.id, name: panel.name, class:  | 
| 126 | 
            +
                      <% tabs.panel id: panel.id, name: panel.name, class: panel.panel_classes  do %>
         | 
| 127 127 | 
             
                        <%= render_component :inspector_panel, **panel.slice(:id, :name, :system) do %>
         | 
| 128 128 | 
             
                          <%= render panel.partial, **@inspector_data, panel: panel, **panel.locals %>
         | 
| 129 129 | 
             
                        <% end %>
         | 
    
        data/lib/lookbook/collection.rb
    CHANGED
    
    | @@ -10,7 +10,7 @@ module Lookbook | |
| 10 10 | 
             
                    items = path
         | 
| 11 11 | 
             
                    path = ""
         | 
| 12 12 | 
             
                  end
         | 
| 13 | 
            -
             | 
| 13 | 
            +
             | 
| 14 14 | 
             
                  @path = path.delete_prefix("/").delete_suffix("/")
         | 
| 15 15 | 
             
                  super(@path)
         | 
| 16 16 |  | 
| @@ -37,6 +37,10 @@ module Lookbook | |
| 37 37 | 
             
                  @items.sort_by { |item| [item.hierarchy_depth, item&.position, item.label] }
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            +
                def clear
         | 
| 41 | 
            +
                  @items = []
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 40 44 | 
             
                def visible_items
         | 
| 41 45 | 
             
                  reject { |i| i.hidden? }
         | 
| 42 46 | 
             
                end
         | 
| @@ -68,14 +72,15 @@ module Lookbook | |
| 68 72 |  | 
| 69 73 | 
             
                def find(lookup = nil, &block)
         | 
| 70 74 | 
             
                  if lookup
         | 
| 71 | 
            -
                    lookup.is_a?(Symbol) ? find_by_id(lookup | 
| 75 | 
            +
                    lookup.is_a?(Symbol) ? find_by_id(lookup) : find_by_path(lookup)
         | 
| 72 76 | 
             
                  elsif block
         | 
| 73 77 | 
             
                    items.find(&block)
         | 
| 74 78 | 
             
                  end
         | 
| 75 79 | 
             
                end
         | 
| 76 80 |  | 
| 77 81 | 
             
                def find_by_id(id)
         | 
| 78 | 
            -
                   | 
| 82 | 
            +
                  id = id.to_s.tr("_", "-")
         | 
| 83 | 
            +
                  items.find { |i| i.id.to_s == id }
         | 
| 79 84 | 
             
                end
         | 
| 80 85 |  | 
| 81 86 | 
             
                def find_by_path(path)
         | 
    
        data/lib/lookbook/component.rb
    CHANGED
    
    | @@ -1,13 +1,12 @@ | |
| 1 1 | 
             
            module Lookbook
         | 
| 2 2 | 
             
              class Component < Entity
         | 
| 3 | 
            -
             | 
| 4 3 | 
             
                attr_accessor :name
         | 
| 5 4 |  | 
| 6 5 | 
             
                def initialize(name)
         | 
| 7 6 | 
             
                  @name = name
         | 
| 8 7 | 
             
                  super(path)
         | 
| 9 8 | 
             
                end
         | 
| 10 | 
            -
             | 
| 9 | 
            +
             | 
| 11 10 | 
             
                def path
         | 
| 12 11 | 
             
                  name.underscore
         | 
| 13 12 | 
             
                end
         | 
| @@ -28,4 +27,4 @@ module Lookbook | |
| 28 27 | 
             
                  template_path.present?
         | 
| 29 28 | 
             
                end
         | 
| 30 29 | 
             
              end
         | 
| 31 | 
            -
            end
         | 
| 30 | 
            +
            end
         | 
    
        data/lib/lookbook/config.rb
    CHANGED
    
    | @@ -6,14 +6,14 @@ module Lookbook | |
| 6 6 | 
             
              class Config
         | 
| 7 7 | 
             
                def initialize
         | 
| 8 8 | 
             
                  @options = Store.new
         | 
| 9 | 
            -
             | 
| 9 | 
            +
             | 
| 10 10 | 
             
                  @options.set({
         | 
| 11 11 | 
             
                    project_name: "Lookbook",
         | 
| 12 12 | 
             
                    log_level: 2,
         | 
| 13 13 | 
             
                    auto_refresh: true,
         | 
| 14 14 |  | 
| 15 15 | 
             
                    components_path: "app/components",
         | 
| 16 | 
            -
             | 
| 16 | 
            +
             | 
| 17 17 | 
             
                    page_controller: "Lookbook::PageController",
         | 
| 18 18 | 
             
                    page_route: "pages",
         | 
| 19 19 | 
             
                    page_paths: ["test/components/docs"],
         | 
| @@ -44,7 +44,7 @@ module Lookbook | |
| 44 44 | 
             
                    hooks: {
         | 
| 45 45 | 
             
                      after_initialize: [],
         | 
| 46 46 | 
             
                      before_exit: [],
         | 
| 47 | 
            -
                      after_change: [] | 
| 47 | 
            +
                      after_change: []
         | 
| 48 48 | 
             
                    },
         | 
| 49 49 |  | 
| 50 50 | 
             
                    debug_menu: Rails.env.development?,
         | 
| @@ -100,7 +100,7 @@ module Lookbook | |
| 100 100 | 
             
                        padded: false,
         | 
| 101 101 | 
             
                        system: true
         | 
| 102 102 | 
             
                      }
         | 
| 103 | 
            -
                    } | 
| 103 | 
            +
                    }
         | 
| 104 104 | 
             
                  })
         | 
| 105 105 | 
             
                end
         | 
| 106 106 |  | 
| @@ -147,7 +147,7 @@ module Lookbook | |
| 147 147 |  | 
| 148 148 | 
             
                def inspector_panels(&block)
         | 
| 149 149 | 
             
                  panels = Store.new(@options.inspector_panels.select { |key, panel| panel != false })
         | 
| 150 | 
            -
                  if  | 
| 150 | 
            +
                  if block
         | 
| 151 151 | 
             
                    yield panels
         | 
| 152 152 | 
             
                  else
         | 
| 153 153 | 
             
                    panels
         | 
| @@ -158,7 +158,7 @@ module Lookbook | |
| 158 158 | 
             
                  pane = opts[:pane].presence || :drawer
         | 
| 159 159 | 
             
                  siblings = inspector_panels.select { |key, panel| panel.pane == pane }
         | 
| 160 160 | 
             
                  opts[:position] ||= siblings.size + 1
         | 
| 161 | 
            -
                  @options.inspector_panels[name] = opts | 
| 161 | 
            +
                  @options.inspector_panels[name] = opts
         | 
| 162 162 | 
             
                  siblings.each do |key, panel|
         | 
| 163 163 | 
             
                    if panel.position >= opts[:position]
         | 
| 164 164 | 
             
                      panel.position += 1
         | 
| @@ -192,7 +192,6 @@ module Lookbook | |
| 192 192 | 
             
                    copy: nil,
         | 
| 193 193 | 
             
                    panel_classes: nil,
         | 
| 194 194 | 
             
                    locals: {},
         | 
| 195 | 
            -
                    padded: true,
         | 
| 196 195 | 
             
                    system: false
         | 
| 197 196 | 
             
                  }
         | 
| 198 197 | 
             
                end
         | 
| @@ -207,7 +206,7 @@ module Lookbook | |
| 207 206 | 
             
                end
         | 
| 208 207 |  | 
| 209 208 | 
             
                def ui_theme_overrides(&block)
         | 
| 210 | 
            -
                  if  | 
| 209 | 
            +
                  if block
         | 
| 211 210 | 
             
                    yield @options.ui_theme_overrides
         | 
| 212 211 | 
             
                  else
         | 
| 213 212 | 
             
                    @options.ui_theme_overrides
         | 
| @@ -238,7 +237,7 @@ module Lookbook | |
| 238 237 | 
             
                def to_json(*a)
         | 
| 239 238 | 
             
                  to_h.to_json(*a)
         | 
| 240 239 | 
             
                end
         | 
| 241 | 
            -
             | 
| 240 | 
            +
             | 
| 242 241 | 
             
                protected
         | 
| 243 242 |  | 
| 244 243 | 
             
                def normalize_paths(paths)
         | 
| @@ -256,5 +255,9 @@ module Lookbook | |
| 256 255 | 
             
                def method_missing(name, *args)
         | 
| 257 256 | 
             
                  @options.send(name, *args)
         | 
| 258 257 | 
             
                end
         | 
| 258 | 
            +
             | 
| 259 | 
            +
                def respond_to_missing?(name, *)
         | 
| 260 | 
            +
                  to_h.key? name
         | 
| 261 | 
            +
                end
         | 
| 259 262 | 
             
              end
         | 
| 260 | 
            -
            end
         | 
| 263 | 
            +
            end
         | 
    
        data/lib/lookbook/data.rb
    CHANGED