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.
- 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/components/lookbook/base_component.rb +0 -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/params_editor/field/component.rb +2 -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 -1
- data/app/controllers/lookbook/page_controller.rb +6 -1
- data/app/controllers/lookbook/previews_controller.rb +8 -16
- data/app/helpers/lookbook/application_helper.rb +9 -0
- data/app/helpers/lookbook/preview_helper.rb +7 -2
- data/app/views/layouts/lookbook/skeleton.html.erb +15 -8
- 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 +15 -10
- data/lib/lookbook/data.rb +11 -0
- data/lib/lookbook/engine.rb +70 -77
- data/lib/lookbook/entity.rb +1 -1
- data/lib/lookbook/hooks.rb +21 -0
- 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 +15 -0
- data/lib/lookbook/parser.rb +4 -1
- data/lib/lookbook/preview.rb +10 -12
- data/lib/lookbook/preview_example.rb +2 -2
- data/lib/lookbook/preview_group.rb +8 -0
- data/lib/lookbook/source_inspector.rb +23 -11
- data/lib/lookbook/store.rb +7 -3
- data/lib/lookbook/tag.rb +112 -0
- data/lib/lookbook/tags.rb +22 -0
- data/lib/lookbook/theme.rb +38 -9
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +1 -0
- 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 +48 -48
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74c62e76c265b02970bc86ad242fb43c347ccf0ad141b512148f3ef1e3eb2ae9
|
4
|
+
data.tar.gz: d389ed323fa6918a5919865414e6c4b17e23870a27d398ba92af055ffa958bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a64d8542e71251f52b36d88548dfe5fbd0347c1d6a52ff6e0f6bbe8e1e256d93a5761089f7594b95453c7865bf619822483efa229fe011474d2f2818d9bcd96c
|
7
|
+
data.tar.gz: 2360d8e4a06cf428dd10c7ea3d39d9d17b4bea377fa98861e9f3848026d3b9ed60da882df07005bd9547891fd63b88a8368da4a15dedc076de759a1418a06385
|
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
|
-
[![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
|
-
|
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
|
+
[![Lookbook UI](.github/assets/lookbook_screenshot_v1.0_beta.png)](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
|
+
}
|
@@ -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
|
@@ -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
|
-
|
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
|
@@ -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="/
|
9
|
-
<link href="/
|
10
|
-
|
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
|
17
|
-
<link
|
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="/
|
36
|
+
<script src="<%= asset_path("/js/lookbook.js") %>" defer></script>
|
29
37
|
<% if params[:lookbook_embed] %>
|
30
|
-
<script src="/
|
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="
|
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
|