lookbook 1.0.0.beta.6 → 1.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -30
  3. data/app/assets/lookbook/css/themes/blue.css +2 -1
  4. data/app/assets/lookbook/css/themes/indigo.css +2 -1
  5. data/app/assets/lookbook/css/themes/zinc.css +2 -1
  6. data/app/components/lookbook/base_component.rb +0 -1
  7. data/app/components/lookbook/inspector_panel/component.css +5 -0
  8. data/app/components/lookbook/inspector_panel/component.html.erb +6 -4
  9. data/app/components/lookbook/inspector_panel/component.rb +3 -3
  10. data/app/components/lookbook/nav/component.rb +1 -2
  11. data/app/components/lookbook/nav/item/component.html.erb +1 -1
  12. data/app/components/lookbook/params_editor/field/component.rb +2 -1
  13. data/app/components/lookbook/tab_panels/component.rb +1 -1
  14. data/app/components/lookbook/tab_panels/panel/component.rb +2 -2
  15. data/app/components/lookbook/tag_component.rb +3 -3
  16. data/app/controllers/lookbook/application_controller.rb +1 -1
  17. data/app/controllers/lookbook/page_controller.rb +6 -1
  18. data/app/controllers/lookbook/previews_controller.rb +8 -16
  19. data/app/helpers/lookbook/application_helper.rb +9 -0
  20. data/app/helpers/lookbook/preview_helper.rb +7 -2
  21. data/app/views/layouts/lookbook/skeleton.html.erb +15 -8
  22. data/app/views/lookbook/index.html.erb +11 -24
  23. data/app/views/lookbook/previews/panels/_notes.html.erb +1 -1
  24. data/app/views/lookbook/previews/show.html.erb +2 -2
  25. data/lib/lookbook/code_formatter.rb +1 -1
  26. data/lib/lookbook/collection.rb +8 -3
  27. data/lib/lookbook/component.rb +2 -3
  28. data/lib/lookbook/config.rb +15 -10
  29. data/lib/lookbook/data.rb +11 -0
  30. data/lib/lookbook/engine.rb +70 -77
  31. data/lib/lookbook/entity.rb +1 -1
  32. data/lib/lookbook/hooks.rb +21 -0
  33. data/lib/lookbook/markdown.rb +1 -1
  34. data/lib/lookbook/page.rb +4 -5
  35. data/lib/lookbook/page_section.rb +2 -4
  36. data/lib/lookbook/panels.rb +15 -0
  37. data/lib/lookbook/parser.rb +4 -1
  38. data/lib/lookbook/preview.rb +10 -12
  39. data/lib/lookbook/preview_example.rb +2 -2
  40. data/lib/lookbook/preview_group.rb +8 -0
  41. data/lib/lookbook/source_inspector.rb +23 -11
  42. data/lib/lookbook/store.rb +7 -3
  43. data/lib/lookbook/tag.rb +112 -0
  44. data/lib/lookbook/tags.rb +22 -0
  45. data/lib/lookbook/theme.rb +38 -9
  46. data/lib/lookbook/version.rb +1 -1
  47. data/lib/lookbook.rb +1 -0
  48. data/lib/tasks/lookbook_tasks.rake +1 -2
  49. data/public/lookbook-assets/css/lookbook.css +19 -10
  50. data/public/lookbook-assets/css/lookbook.css.map +1 -1
  51. data/public/lookbook-assets/css/themes/blue.css +1 -0
  52. data/public/lookbook-assets/css/themes/blue.css.map +1 -1
  53. data/public/lookbook-assets/css/themes/indigo.css +1 -0
  54. data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
  55. data/public/lookbook-assets/css/themes/zinc.css +1 -0
  56. data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
  57. data/public/lookbook-assets/js/lookbook.js +48 -48
  58. data/public/lookbook-assets/js/lookbook.js.map +1 -1
  59. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0be6f1f0dc2e74e64585f664af67c7a3b05b8de3cd875cfa4732d2cecb37465
4
- data.tar.gz: a315fa37ed07664a06096709b8bc88b81011e0f8f54b438362b8e6803eee6e3d
3
+ metadata.gz: 74c62e76c265b02970bc86ad242fb43c347ccf0ad141b512148f3ef1e3eb2ae9
4
+ data.tar.gz: d389ed323fa6918a5919865414e6c4b17e23870a27d398ba92af055ffa958bf4
5
5
  SHA512:
6
- metadata.gz: 87214ff5e7f0292276b5ddbd3ff4b1b41f8ae685e9fa28de92043af5f6a5736c51b8729a5432e3fe2c0ff7fe75dd6f7ee145796d36c0d08528d20c37e6886d06
7
- data.tar.gz: c615b04dd5ee26613fd3ea804473727114cd8acc97aa6b0aeb4f280255adf56cd645228e45dd40e0e864915a328eb8c2a1adde198256bdf4b7923dbb4009a714
6
+ metadata.gz: a64d8542e71251f52b36d88548dfe5fbd0347c1d6a52ff6e0f6bbe8e1e256d93a5761089f7594b95453c7865bf619822483efa229fe011474d2f2818d9bcd96c
7
+ data.tar.gz: 2360d8e4a06cf428dd10c7ea3d39d9d17b4bea377fa98861e9f3848026d3b9ed60da882df07005bd9547891fd63b88a8368da4a15dedc076de759a1418a06385
data/README.md CHANGED
@@ -1,53 +1,61 @@
1
- # Lookbook v1.0 [beta]
1
+ # Lookbook v1.0
2
2
 
3
- **This is the development branch for Lookbook v1.0.**
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
- _For code and documentation for the current stable release see the [main branch](https://github.com/allmarkedup/lookbook/tree/main)._
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
- 📣 **This v1.0 beta is still under active development.** However no breaking changes are envisaged to the current implementation and it should now be stable enough to be used for day-to-day development. Give it a try! 🎉
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
- The new (work-in-progress) **documentation site** for Lookbook v1.0 is available here:
17
+ ```ruby
18
+ gem "lookbook", ">= 1.0.0.beta.8"
19
+ ```
16
20
 
17
- 👉 **https://lookbook-docs-v1-beta.netlify.app/** 👈
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
- ## 🚀 Demo app
24
+ <h4>Useful Resources</h4>
22
25
 
23
- There is a demo of the latest v1.0 beta here:
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
- [![Lookbook UI](.github/assets/lookbook_screenshot_v1.0_beta.png)](https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook/)
28
30
 
31
+ ## Changes and new features in v1.0
29
32
 
30
- ## 🔎 Release focus
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
- The main goals of the v1.0 release are:
35
+ ### Frontend changes:
33
36
 
34
- - [x] Rebuild app UI using ViewComponent components
35
- - [x] Improve usability of the small screen/mobile layout
36
- - [x] Add support for basic UI color theme customisation
37
- - [x] Allow users to extend Lookbook with custom panels and by hooking into lifecycle events
38
- - [x] Remove the `experimental` flag from the [Pages](https://github.com/allmarkedup/lookbook#pages)
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
- **No breaking changes** are planned for user-facing features, although the app UI will include some minor visual updates and usability improvements.
43
+ ### New options for extending Lookbook:
43
44
 
44
- ## 👋 Testing and feedback - help wanted!
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
- The bulk of the v1.0 'new feature' development work is now mostly complete, although testing and bug fixing is ongoing.
49
+ ### Other changes
47
50
 
48
- **If you are an existing Lookbook user** I'd greatly appreciate if you can kick the tyres on the v1.0 beta and open an issue with any bug reports, suggestions or feedback you might have, either about Lookbook itself or the [new docs site](https://lookbook-docs-v1-beta.netlify.app/).
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
+ [![Lookbook UI](.github/assets/lookbook_screenshot_v1.0_beta.png)](https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook/)
49
57
 
50
- ## 🛠 Workbench
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
- ## 🚦 Running tests
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
+ }
@@ -12,7 +12,6 @@ module Lookbook
12
12
  merged_classes = class_names(attrs[:class], @html_attrs[:class])
13
13
  merged_attrs = @html_attrs.except(:class).deep_merge(attrs.except(:class))
14
14
 
15
-
16
15
  render Lookbook::TagComponent.new(tag: tag,
17
16
  name: component_name,
18
17
  **merged_attrs,
@@ -0,0 +1,5 @@
1
+ @layer components {
2
+ .lookbook-panel {
3
+ @apply p-4 min-h-full;
4
+ }
5
+ }
@@ -1,4 +1,6 @@
1
- <% if panel_styles %>
2
- <% content_for :panel_css do %><%= panel_styles %><% end %>
3
- <% end %>
4
- <%= panel_html %>
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::fragment(content)
19
- style_tags = panel_dom.css('style')
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
@@ -4,8 +4,7 @@ module Lookbook
4
4
  renders_one :toolbar, Lookbook::Toolbar::Component
5
5
 
6
6
  def initialize(
7
- id: nil,
8
- collection:,
7
+ collection:, id: nil,
9
8
  collapse_singles: false,
10
9
  **attrs
11
10
  )
@@ -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><%= label %></span>
20
+ <span <% if @item.type == :preview %>class="font-bold"<% end %>><%= label %></span>
21
21
  </div>
22
22
  <% end %>
23
23
 
@@ -31,7 +31,8 @@ module Lookbook
31
31
  protected
32
32
 
33
33
  def alpine_data
34
- "{name: '#{@name}', value: #{value.to_json}}"
34
+ escaped_value = value.is_a?(String) ? helpers.j(value) : value
35
+ "{name: '#{@name}', value: '#{escaped_value}'}"
35
36
  end
36
37
 
37
38
  def alpine_component
@@ -3,7 +3,7 @@ module Lookbook
3
3
  renders_many :panels, ->(**attrs) do
4
4
  @panel_counter += 1
5
5
  attrs[:name] ||= "tab-#{@panel_counter}"
6
- Lookbook::TabPanels::Panel::Component.new **attrs
6
+ Lookbook::TabPanels::Panel::Component.new(**attrs)
7
7
  end
8
8
 
9
9
  def initialize(**html_attrs)
@@ -1,8 +1,8 @@
1
1
  module Lookbook
2
2
  class TabPanels::Panel::Component < Lookbook::BaseComponent
3
3
  def initialize(name:, id: nil, **html_attrs)
4
- @name = name
5
- @id = "#{id || "panel-#{name}"}"
4
+ @name = name
5
+ @id = (id || "panel-#{name}").to_s
6
6
  super(**html_attrs)
7
7
  end
8
8
  end
@@ -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('6.1.5.1') ? :escape_attributes : :escape
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
@@ -24,7 +24,7 @@ module Lookbook
24
24
  protected
25
25
 
26
26
  def generate_theme_overrides
27
- @theme_overrides ||= Lookbook::Theme.new(Lookbook.config.ui_theme_overrides).to_css
27
+ @theme_overrides ||= Lookbook.theme.to_css
28
28
  end
29
29
 
30
30
  def feature_enabled?(feature)
@@ -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.select { |p| p.pane == config.pane }.size + 1),
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.class == Proc ? value.call(Lookbook::Store.new(callable_data)) : 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
@@ -4,6 +4,15 @@ module Lookbook
4
4
  Lookbook::Engine.config.lookbook
5
5
  end
6
6
 
7
+ def theme
8
+ Lookbook.theme
9
+ end
10
+
11
+ def asset_path(file, version: true)
12
+ path = "/lookbook-assets/#{file}".gsub("//", "/")
13
+ version ? "#{path}?v=#{Lookbook::VERSION}" : path
14
+ end
15
+
7
16
  def feature_enabled?(name)
8
17
  Lookbook::Features.enabled?(name)
9
18
  end
@@ -1,6 +1,11 @@
1
1
  module Lookbook
2
2
  module PreviewHelper
3
- # Left intentionally empty.
4
- # Included for backwards compatability.
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
@@ -5,16 +5,24 @@
5
5
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
7
7
 
8
- <link href="/lookbook-assets/css/lookbook.css?v=<%= Lookbook::VERSION %>" rel="stylesheet">
9
- <link href="/lookbook-assets/css/themes/<%= config.ui_theme %>.css?v=<%= Lookbook::VERSION %>" rel="stylesheet">
10
- <% if @theme_overrides.present? %>
8
+ <link href="<%= asset_path("/css/lookbook.css") %>" rel="stylesheet">
9
+ <link href="<%= asset_path("/css/themes/#{config.ui_theme}.css") %>" rel="stylesheet">
10
+
11
+ <%- if @theme_overrides.present? %>
11
12
  <style media="all">
12
13
  <%== @theme_overrides %>
13
14
  </style>
14
15
  <% end %>
15
16
 
16
- <% if config.ui_favicon != false %>
17
- <link rel="icon" href="<%= config.ui_favicon || "data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>👀</text></svg>" %>">
17
+ <% if config.ui_favicon == true %>
18
+ <link
19
+ rel="icon"
20
+ href="data:image/svg+xml,%3Csvg width='96' height='84' viewBox='0 0 96 84' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3CclipPath id='a'%3E%3Cpath d='M96 0v84H0V0h96Z'/%3E%3C/clipPath%3E%3CclipPath id='b'%3E%3Cpath d='M71.897 0a1.5 1.5 0 0 1 1.31.769l22.605 40.5a1.5 1.5 0 0 1 0 1.462l-22.605 40.5a1.5 1.5 0 0 1-1.31.769H49.481a1 1 0 0 1-.873-1.487L70.812 42.73a1.5 1.5 0 0 0 0-1.462L48.608 1.487A1 1 0 0 1 49.481 0ZM24.655.564l22.72 40.705a1.5 1.5 0 0 1 0 1.462l-22.72 40.705a1 1 0 0 1-1.746 0L.19 42.73a1.5 1.5 0 0 1 0-1.462L22.91.564a1 1 0 0 1 1.746 0Z'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg clip-path='url(%23a)'%3E%3Cg clip-path='url(%23b)'%3E%3Cpath fill='<%= url_encode theme.favicon_dark_mode %>' d='M0 0h96v84H0V0z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
21
+ media="(prefers-color-scheme: dark)">
22
+ <link
23
+ rel="icon"
24
+ href="data:image/svg+xml,%3Csvg width='96' height='84' viewBox='0 0 96 84' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3CclipPath id='a'%3E%3Cpath d='M96 0v84H0V0h96Z'/%3E%3C/clipPath%3E%3CclipPath id='b'%3E%3Cpath d='M71.897 0a1.5 1.5 0 0 1 1.31.769l22.605 40.5a1.5 1.5 0 0 1 0 1.462l-22.605 40.5a1.5 1.5 0 0 1-1.31.769H49.481a1 1 0 0 1-.873-1.487L70.812 42.73a1.5 1.5 0 0 0 0-1.462L48.608 1.487A1 1 0 0 1 49.481 0ZM24.655.564l22.72 40.705a1.5 1.5 0 0 1 0 1.462l-22.72 40.705a1 1 0 0 1-1.746 0L.19 42.73a1.5 1.5 0 0 1 0-1.462L22.91.564a1 1 0 0 1 1.746 0Z'/%3E%3C/clipPath%3E%3C/defs%3E%3Cg clip-path='url(%23a)'%3E%3Cg clip-path='url(%23b)'%3E%3Cpath fill='<%= url_encode theme.favicon_light_mode %>' d='M0 0h96v84H0V0z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
25
+ media="(prefers-color-scheme: light)">
18
26
  <% end %>
19
27
 
20
28
  <script>
@@ -25,15 +33,14 @@
25
33
  <% end %>
26
34
  </script>
27
35
 
28
- <script src="/lookbook-assets/js/lookbook.js?v=<%= Lookbook::VERSION %>" defer></script>
36
+ <script src="<%= asset_path("/js/lookbook.js") %>" defer></script>
29
37
  <% if params[:lookbook_embed] %>
30
- <script src="/lookbook-assets/js/embed.js?v=<%= Lookbook::VERSION %>" defer></script>
38
+ <script src="<%= asset_path("/js/embed.js") %>" defer></script>
31
39
  <% end %>
32
40
 
33
41
  <title><%= [@title, config.project_name || "Lookbook"].compact.join(" :: ") %></title>
34
42
  </head>
35
43
  <body>
36
-
37
44
  <%= yield :body %>
38
45
 
39
46
  <% if Rails.env.development? %>
@@ -1,27 +1,14 @@
1
1
  <div id="landing" class="flex flex-col items-center justify-center h-full w-full">
2
- <div class="p-4 text-center mx-auto">
3
- <% if Lookbook.previews? %>
4
- <div id="landing-with-content">
5
- <h5 class="text-lg opacity-50"><%= config.project_name %></h5>
6
- <div class="mt-2 italic opacity-30 max-w-[400px]">
7
- <p>
8
- Select a preview from the nav to get started.
9
- </p>
10
- </div>
11
- </div>
12
- <% else %>
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="p-4 bg-lookbook-prose-bg w-full h-full">
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: [panel.panel_classes, { "p-4": panel.padded, "prose": panel.prose }] do %>
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: [panel.panel_classes, { "p-4": panel.padded, "prose": panel.prose }] do %>
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 %>
@@ -1,6 +1,6 @@
1
1
  require "rouge"
2
2
  require "htmlbeautifier"
3
- require 'htmlentities'
3
+ require "htmlentities"
4
4
 
5
5
  module Lookbook
6
6
  module CodeFormatter
@@ -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.to_s.tr("_", "-")) : find_by_path(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
- items.find { |i| i.id == id }
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)
@@ -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