lookbook 1.0.0.beta.1 → 1.0.0.beta.4
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 +180 -40
- data/app/components/lookbook/{component.rb → base_component.rb} +1 -1
- data/app/components/lookbook/button/component.rb +1 -1
- data/app/components/lookbook/button_group/component.rb +1 -1
- data/app/components/lookbook/code/component.rb +1 -1
- data/app/components/lookbook/copy_button/component.html.erb +1 -1
- data/app/components/lookbook/copy_button/component.rb +1 -1
- data/app/components/lookbook/dimensions_display/component.rb +1 -1
- data/app/components/lookbook/embed/component.html.erb +6 -5
- data/app/components/lookbook/embed/component.rb +1 -1
- data/app/components/lookbook/filter/component.html.erb +1 -1
- data/app/components/lookbook/filter/component.rb +1 -1
- data/app/components/lookbook/header/component.html.erb +6 -11
- data/app/components/lookbook/header/component.rb +6 -1
- data/app/components/lookbook/icon/component.rb +1 -1
- data/app/components/lookbook/nav/component.rb +1 -1
- data/app/components/lookbook/nav/item/component.html.erb +2 -2
- data/app/components/lookbook/nav/item/component.rb +1 -1
- data/app/components/lookbook/page_tabs/component.rb +1 -1
- data/app/components/lookbook/params_editor/component.rb +1 -1
- data/app/components/lookbook/params_editor/field/component.rb +1 -1
- data/app/components/lookbook/prose/component.rb +1 -1
- data/app/components/lookbook/split_layout/component.rb +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/tabs/component.js +6 -6
- data/app/components/lookbook/tabs/component.rb +1 -1
- data/app/components/lookbook/tabs/dropdown_tab/component.rb +1 -1
- data/app/components/lookbook/tabs/tab/component.rb +1 -1
- data/app/components/lookbook/toolbar/component.rb +1 -1
- data/app/components/lookbook/viewport/component.rb +1 -1
- data/app/controllers/lookbook/application_controller.rb +1 -1
- data/app/controllers/lookbook/pages_controller.rb +1 -1
- data/app/controllers/lookbook/previews_controller.rb +27 -32
- data/app/helpers/lookbook/application_helper.rb +8 -2
- data/app/helpers/lookbook/component_helper.rb +4 -0
- data/app/helpers/lookbook/page_helper.rb +2 -2
- data/app/views/layouts/lookbook/application.html.erb +5 -3
- data/app/views/layouts/lookbook/page.html.erb +2 -2
- data/app/views/layouts/lookbook/shell.html.erb +2 -48
- data/app/views/layouts/lookbook/skeleton.html.erb +7 -1
- data/app/views/lookbook/404.html.erb +1 -1
- data/app/views/lookbook/index.html.erb +1 -1
- data/app/views/lookbook/pages/show.html.erb +8 -8
- data/app/views/lookbook/previews/panels/_notes.html.erb +1 -1
- data/app/views/lookbook/previews/panels/_preview.html.erb +1 -1
- data/app/views/lookbook/previews/show.html.erb +4 -4
- data/config/routes.rb +6 -6
- data/lib/lookbook/collection.rb +1 -1
- data/lib/lookbook/component.rb +31 -0
- data/lib/lookbook/config.rb +94 -41
- data/lib/lookbook/engine.rb +72 -12
- data/lib/lookbook/page.rb +3 -3
- data/lib/lookbook/parser.rb +1 -4
- data/lib/lookbook/preview.rb +25 -8
- data/lib/lookbook/preview_example.rb +2 -2
- data/lib/lookbook/preview_group.rb +1 -1
- data/lib/lookbook/source_inspector.rb +10 -0
- data/lib/lookbook/utils.rb +2 -2
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +1 -12
- data/public/lookbook-assets/css/lookbook.css +24 -28
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +50 -49
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +3 -2
@@ -15,7 +15,7 @@ module Lookbook
|
|
15
15
|
def index
|
16
16
|
landing = Lookbook.pages.find(&:landing) || Lookbook.pages.first
|
17
17
|
if landing.present?
|
18
|
-
redirect_to
|
18
|
+
redirect_to lookbook_page_path(landing.lookup_path)
|
19
19
|
else
|
20
20
|
render "lookbook/index", layout: Lookbook.previews.any? ? "lookbook/application" : "lookbook/shell"
|
21
21
|
end
|
@@ -44,7 +44,7 @@ module Lookbook
|
|
44
44
|
|
45
45
|
def show_legacy
|
46
46
|
Lookbook.logger.warn("Legacy URL path detected. These paths are deprecated and will be removed in a future version")
|
47
|
-
redirect_to
|
47
|
+
redirect_to lookbook_inspect_path params[:path]
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
@@ -54,13 +54,13 @@ module Lookbook
|
|
54
54
|
if @example.present?
|
55
55
|
@preview = @example.preview
|
56
56
|
if params[:path] == @preview&.lookup_path
|
57
|
-
redirect_to
|
57
|
+
redirect_to lookbook_inspect_path "#{params[:path]}/#{@preview.default_example.name}"
|
58
58
|
end
|
59
59
|
else
|
60
60
|
@preview = Lookbook.previews.find(params[:path])
|
61
61
|
if @preview.present?
|
62
62
|
first_example = @preview.examples.first
|
63
|
-
redirect_to
|
63
|
+
redirect_to lookbook_inspect_path(first_example.lookup_path) if first_example
|
64
64
|
else
|
65
65
|
@preview = Lookbook.previews.find(path_segments.slice(0, path_segments.size - 1).join("/"))
|
66
66
|
end
|
@@ -117,41 +117,36 @@ module Lookbook
|
|
117
117
|
def inspector_data
|
118
118
|
return @inspector_data if @inspector_data.present?
|
119
119
|
|
120
|
-
|
120
|
+
context_data = {
|
121
121
|
preview_params: preview_params,
|
122
122
|
path: params[:path],
|
123
|
-
query_parameters: request.query_parameters,
|
124
|
-
original: request
|
125
123
|
}
|
126
124
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
}
|
133
|
-
[:id, :label, :notes, :lookup_path, :full_path].each do |prop|
|
134
|
-
preview_data[prop] = @preview.public_send(prop)
|
135
|
-
end
|
125
|
+
example = @example
|
126
|
+
preview = @preview
|
127
|
+
preview.define_singleton_method(:params, proc {
|
128
|
+
example.params
|
129
|
+
})
|
136
130
|
|
137
|
-
|
131
|
+
examples = target_examples.map do |example|
|
138
132
|
render_args = @preview.render_args(example.name, params: preview_controller.params)
|
139
133
|
has_template = render_args[:template] != "view_components/preview"
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
})
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
example_data
|
134
|
+
output = preview_controller.process(:render_example_to_string, @preview, example.name)
|
135
|
+
source = has_template ? example.template_source(render_args[:template]) : example.method_source
|
136
|
+
source_lang = has_template ? example.template_lang(render_args[:template]) : example.lang
|
137
|
+
|
138
|
+
example.define_singleton_method(:output, proc { output })
|
139
|
+
example.define_singleton_method(:source, proc { source })
|
140
|
+
example.define_singleton_method(:source_lang, proc { source_lang })
|
141
|
+
example
|
149
142
|
end
|
150
143
|
|
151
144
|
@inspector_data ||= Lookbook::Store.new({
|
152
|
-
|
153
|
-
preview:
|
154
|
-
examples:
|
145
|
+
context: context_data,
|
146
|
+
preview: preview,
|
147
|
+
examples: examples,
|
148
|
+
components: preview.components,
|
149
|
+
app: Lookbook
|
155
150
|
})
|
156
151
|
end
|
157
152
|
|
@@ -163,7 +158,7 @@ module Lookbook
|
|
163
158
|
|
164
159
|
callable_data = {
|
165
160
|
name: name.to_s,
|
166
|
-
index_position: (@panels.
|
161
|
+
index_position: (@panels.select { |p| p.pane == config.pane }.size + 1),
|
167
162
|
**inspector_data
|
168
163
|
}
|
169
164
|
|
@@ -175,15 +170,15 @@ module Lookbook
|
|
175
170
|
@panels << Lookbook::Store.new(resolved_config, deep: false)
|
176
171
|
end
|
177
172
|
|
178
|
-
@panels.
|
173
|
+
@panels = @panels.select(&:show).sort_by { |p| [p.position, p.label] }
|
179
174
|
end
|
180
175
|
|
181
176
|
def main_panels
|
182
|
-
panels.
|
177
|
+
panels.select { |panel| panel.pane == :main }
|
183
178
|
end
|
184
179
|
|
185
180
|
def drawer_panels
|
186
|
-
panels.
|
181
|
+
panels.select { |panel| panel.pane == :drawer }
|
187
182
|
end
|
188
183
|
|
189
184
|
def preview_controller
|
@@ -11,14 +11,20 @@ module Lookbook
|
|
11
11
|
def landing_path
|
12
12
|
landing = Lookbook.pages.find(&:landing) || Lookbook.pages.first
|
13
13
|
if landing.present?
|
14
|
-
|
14
|
+
lookbook_page_path landing.lookup_path
|
15
15
|
else
|
16
|
-
|
16
|
+
lookbook_home_path
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def generate_id(*args)
|
21
21
|
args.map { |args| args.delete_prefix("/").tr("&?=/_\-", "-") }.join("-")
|
22
22
|
end
|
23
|
+
|
24
|
+
def append_styles(&block)
|
25
|
+
content_for :styles do
|
26
|
+
capture(&block)
|
27
|
+
end
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
@@ -2,6 +2,10 @@ module Lookbook
|
|
2
2
|
module ComponentHelper
|
3
3
|
COMPONENT_CLASSES = {} # cache for constantized references
|
4
4
|
|
5
|
+
def icon(name, **attrs)
|
6
|
+
render Lookbook::Icon::Component.new(name: name, **attrs)
|
7
|
+
end
|
8
|
+
|
5
9
|
def render_component(ref, **attrs, &block)
|
6
10
|
klass = component_class(ref)
|
7
11
|
comp = attrs.key?(:content) ? klass.new(**attrs.except(:content)).with_content(attrs[:content]) : klass.new(**attrs)
|
@@ -5,7 +5,7 @@ module Lookbook
|
|
5
5
|
def page_path(id)
|
6
6
|
page = id.is_a?(Page) ? id : Lookbook.pages.find(id)
|
7
7
|
if page.present?
|
8
|
-
|
8
|
+
lookbook_page_path page.lookup_path
|
9
9
|
else
|
10
10
|
Lookbook.logger.warn "Could not find page with id ':#{id}'"
|
11
11
|
end
|
@@ -16,7 +16,7 @@ module Lookbook
|
|
16
16
|
|
17
17
|
@embed_counter ||= 0
|
18
18
|
|
19
|
-
preview_lookup = args.first.is_a?(Symbol) ? args.first :
|
19
|
+
preview_lookup = args.first.is_a?(Symbol) ? args.first : preview_class_path(args.first)
|
20
20
|
preview = Lookbook.previews.find(preview_lookup)
|
21
21
|
example = args[1] ? preview&.example(args[1]) : preview&.default_example
|
22
22
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
alpine_data: "$store.layout.main",
|
4
4
|
":class": "$store.layout.mobile && '!block'" do |layout| %>
|
5
5
|
|
6
|
-
<% layout.pane class: "flex flex-col bg-lookbook-sidebar relative translate-x-0",
|
6
|
+
<% layout.pane id: "app-sidebar", class: "flex flex-col bg-lookbook-sidebar relative translate-x-0",
|
7
7
|
":class": "{
|
8
8
|
'transition': $store.layout.mobile,
|
9
9
|
'translate-x-full': $store.layout.mobile && sidebarHidden,
|
@@ -17,6 +17,7 @@
|
|
17
17
|
style: "height: calc(100vh - 2.5rem);" do |layout| %>
|
18
18
|
<% layout.pane class: "overflow-hidden" do %>
|
19
19
|
<%= render_component :nav,
|
20
|
+
id: "previews-nav",
|
20
21
|
collection: Lookbook.previews,
|
21
22
|
alpine_data: "$store.nav.previews",
|
22
23
|
label: "Previews",
|
@@ -28,6 +29,7 @@
|
|
28
29
|
<% if Lookbook.pages.any? %>
|
29
30
|
<% layout.pane class: "overflow-hidden" do %>
|
30
31
|
<%= render_component :nav,
|
32
|
+
id: "pages-nav",
|
31
33
|
collection: Lookbook.pages,
|
32
34
|
alpine_data: "$store.nav.pages",
|
33
35
|
label: "Pages" %>
|
@@ -40,7 +42,7 @@
|
|
40
42
|
<div x-data="{hidden: false}" class="flex-none border-t border-lookbook-divider absolute bottom-0 left-0 right-0" x-show="!hidden">
|
41
43
|
<%= render_component :toolbar do |toolbar| %>
|
42
44
|
<% toolbar.section padded: true, class: "flex items-center" do %>
|
43
|
-
<%=
|
45
|
+
<%= icon :alert_triangle, size: 4, class: "text-red-700" %>
|
44
46
|
<span class="ml-2">Preview load errors</span>
|
45
47
|
<% end %>
|
46
48
|
<% toolbar.section align: :right do %>
|
@@ -67,7 +69,7 @@
|
|
67
69
|
<% end %>
|
68
70
|
<% end %>
|
69
71
|
|
70
|
-
<% layout.pane class: "overflow-hidden", ":class": "$store.layout.mobile && 'w-screen'" do %>
|
72
|
+
<% layout.pane id: "app-main", class: "overflow-hidden", ":class": "$store.layout.mobile && 'w-screen'" do %>
|
71
73
|
<%= content_for?(:main) ? yield(:main) : yield %>
|
72
74
|
<% end %>
|
73
75
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
size: :lg,
|
17
17
|
icon: :chevron_left,
|
18
18
|
tooltip: "Previous page",
|
19
|
-
href:
|
19
|
+
href: lookbook_page_path(@previous_page.lookup_path),
|
20
20
|
class: "pr-0.5 bg-transparent" %>
|
21
21
|
<% else %>
|
22
22
|
<%= render_component :button,
|
@@ -31,7 +31,7 @@
|
|
31
31
|
size: :lg,
|
32
32
|
icon: :chevron_right,
|
33
33
|
tooltip: "Next page",
|
34
|
-
href:
|
34
|
+
href: lookbook_page_path(@next_page.lookup_path),
|
35
35
|
class: "pl-0.5 bg-transparent" %>
|
36
36
|
<% else %>
|
37
37
|
<%= render_component :button,
|
@@ -7,58 +7,12 @@
|
|
7
7
|
@navigation:start="closeMobileSidebar"
|
8
8
|
class="w-screen h-screen grid grid-rows-[40px_1fr] relative">
|
9
9
|
|
10
|
-
<%= render_component :header do |header| %>
|
10
|
+
<%= render_component :header, id: "app-header", debug_menu: config.debug_menu do |header| %>
|
11
11
|
<% header.branding { config.project_name } %>
|
12
12
|
<% end %>
|
13
13
|
|
14
|
-
<% if false %>
|
15
|
-
<%= render_component :toolbar, class: "group !bg-lookbook-header !text-lookbook-header-text" do |toolbar| %>
|
16
|
-
<% toolbar.section padded: true do %>
|
17
|
-
<%= render_component :branding,
|
18
|
-
text: config.project_name,
|
19
|
-
href: landing_path if config.project_name %>
|
20
|
-
<% end %>
|
21
|
-
<% toolbar.section padded: false, align: :right, class: "flex items-center" do %>
|
22
|
-
<%= render_component :button_group, class: "relative -top-px" do |group| %>
|
23
|
-
<% if Rails.env == "development" %>
|
24
|
-
<% group.button icon: :help_circle, class: "opacity-50 hover:opacity-100 transition !text-lookbook-header-text" do |button| %>
|
25
|
-
<% button.dropdown do %>
|
26
|
-
<%= tag.div class: "divide-y divide-lookbook-divider" do %>
|
27
|
-
<div class="flex items-center text-xs px-3 py-2">
|
28
|
-
<span class="opacity-60 mr-1">Lookbook</span>
|
29
|
-
<span class="mr-6">v<%= Lookbook::VERSION %></span>
|
30
|
-
<a href="https://github.com/allmarkedup/lookbook" target="_blank" class="ml-auto opacity-70">
|
31
|
-
<%= render_component :icon, name: :github, size: 3 %>
|
32
|
-
</a>
|
33
|
-
</div>
|
34
|
-
<div class="px-3 py-2">
|
35
|
-
<a href="#"
|
36
|
-
class="text-xs underline"
|
37
|
-
@click.stop="localStorage.clear(); window.location.reload();">
|
38
|
-
Clear local storage
|
39
|
-
</a>
|
40
|
-
</div>
|
41
|
-
<% end %>
|
42
|
-
<% end %>
|
43
|
-
<% end %>
|
44
|
-
<% end %>
|
45
|
-
<% group.button icon: :menu,
|
46
|
-
"@click.stop": "toggleSidebar",
|
47
|
-
x_show: "$store.layout.mobile && sidebarHidden",
|
48
|
-
class: "!text-lookbook-header-text" %>
|
49
|
-
<% group.button icon: :x,
|
50
|
-
"@click.stop": "toggleSidebar",
|
51
|
-
x_show: "$store.layout.mobile && !sidebarHidden",
|
52
|
-
"@keydown.esc.window": "closeMobileSidebar",
|
53
|
-
class: "!text-lookbook-header-text" %>
|
54
|
-
<% end %>
|
55
|
-
<% end %>
|
56
|
-
<% end %>
|
57
|
-
<% end %>
|
58
|
-
|
59
14
|
<%= content_for?(:shell) ? yield(:shell) : yield %>
|
60
15
|
</div>
|
61
16
|
<% end %>
|
62
17
|
|
63
|
-
<%= render template: "layouts/lookbook/skeleton" %>
|
64
|
-
0
|
18
|
+
<%= render template: "layouts/lookbook/skeleton" %>
|
@@ -8,11 +8,17 @@
|
|
8
8
|
<link href="/lookbook-assets/css/lookbook.css?v=<%= Lookbook::VERSION %>" rel="stylesheet">
|
9
9
|
<link href="/lookbook-assets/css/themes/<%= config.ui_theme %>.css?v=<%= Lookbook::VERSION %>" rel="stylesheet">
|
10
10
|
<% if @theme_overrides.present? %>
|
11
|
-
<style>
|
11
|
+
<style media="all">
|
12
12
|
<%== @theme_overrides %>
|
13
13
|
</style>
|
14
14
|
<% end %>
|
15
15
|
|
16
|
+
<% if content_for? :styles %>
|
17
|
+
<style media="all">
|
18
|
+
<%= content_for :styles %>
|
19
|
+
</style>
|
20
|
+
<% end %>
|
21
|
+
|
16
22
|
<% if config.ui_favicon != false %>
|
17
23
|
<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>" %>">
|
18
24
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="bg-white flex flex-col items-center justify-center h-screen w-full">
|
2
2
|
<div class="px-4 text-center max-w-sm">
|
3
|
-
<%=
|
3
|
+
<%= icon :alert_triangle, size: 10, class: "text-red-300 mx-auto" %>
|
4
4
|
<div class="mt-3">
|
5
5
|
<h5 class="text-base">
|
6
6
|
<%== message %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div id="welcome-message" class="flex flex-col h-full w-full">
|
2
2
|
<div class="flex flex-col items-center justify-center h-full">
|
3
3
|
<div class="p-4 text-center mx-auto">
|
4
|
-
<%=
|
4
|
+
<%= icon :layers, size: 10, class: "opacity-30 mx-auto" %>
|
5
5
|
<div class="mt-6 text-base opacity-40">
|
6
6
|
<% if Lookbook.previews.any? %>
|
7
7
|
<h5>Select a preview to get started</h5>
|
@@ -1,17 +1,17 @@
|
|
1
1
|
<div class="px-4 md:px-10 pt-8 md:pt-10 overflow-auto scroll-smooth w-full max-h-full pb-12" x-ref="scroller">
|
2
2
|
<div class="w-full max-w-3xl mx-auto h-full flex flex-col">
|
3
3
|
<% if @page.header? %>
|
4
|
-
<header class="mb-8 prose max-w-none flex-none">
|
4
|
+
<header id="page-header" class="mb-8 prose max-w-none flex-none">
|
5
5
|
<h1><%= @page.title %></h1>
|
6
6
|
</header>
|
7
7
|
<% end %>
|
8
8
|
|
9
|
-
<%= render_component :prose, markdown: false, class: "max-w-none flex-none" do %>
|
9
|
+
<%= render_component :prose, id: "page-content", markdown: false, class: "max-w-none flex-none" do %>
|
10
10
|
<%= @page_content %>
|
11
11
|
<% end %>
|
12
12
|
|
13
13
|
<% if @page.sections.any? %>
|
14
|
-
<%= render_component :page_tabs, markdown: false do |page_tabs| %>
|
14
|
+
<%= render_component :page_tabs, id: "page-tabbed-sections", markdown: false, class: "mt-6" do |page_tabs| %>
|
15
15
|
<% @page.sections.each do |section| %>
|
16
16
|
<% page_tabs.tab name: "page-section-#{section.name}", label: section.label do %>
|
17
17
|
<%= page_controller.render_page(section) %>
|
@@ -21,20 +21,20 @@
|
|
21
21
|
<% end %>
|
22
22
|
|
23
23
|
<% if @page.footer? && @pages.many? %>
|
24
|
-
<footer class="flex items-center justify-between border-t border-gray-300 mt-12 pt-8 pb-10 ">
|
24
|
+
<footer id="page-footer" class="flex items-center justify-between border-t border-gray-300 mt-12 pt-8 pb-10 ">
|
25
25
|
<% if @previous_page %>
|
26
|
-
<a href="<%=
|
26
|
+
<a href="<%= lookbook_page_path @previous_page.lookup_path %>"
|
27
27
|
class="flex items-center flex-none">
|
28
|
-
<%=
|
28
|
+
<%= icon :arrow_left, size: 4, class: "hover:text-indigo-800" %>
|
29
29
|
<span class="ml-2 underline"><%= @previous_page.title %></span>
|
30
30
|
</a>
|
31
31
|
<% end %>
|
32
32
|
|
33
33
|
<% if @next_page %>
|
34
|
-
<a href="<%=
|
34
|
+
<a href="<%= lookbook_page_path @next_page.lookup_path %>"
|
35
35
|
class="flex items-center flex-none ml-auto">
|
36
36
|
<span class="mr-2 underline"><%= @next_page.title %></span>
|
37
|
-
<%=
|
37
|
+
<%= icon :arrow_right, size: 4, class: "hover:text-indigo-800" %>
|
38
38
|
</a>
|
39
39
|
<% end %>
|
40
40
|
</footer>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% items = examples.
|
1
|
+
<% items = examples.select { |example| example.notes.present? } %>
|
2
2
|
<% if items.many? %>
|
3
3
|
<div class="divide-y divide-dashed divide-lookbook-divider bg-lookbook-prose h-full w-full">
|
4
4
|
<% items.each do |item| %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= render_component :viewport,
|
2
|
-
src:
|
2
|
+
src: lookbook_preview_path(request.query_parameters.merge(lookbook_timestamp: Time.now)),
|
3
3
|
alpine_data: "$store.inspector.main",
|
4
4
|
class: "-inset-px relative",
|
5
5
|
style: "width: calc(100% + 2px); height: calc(100% + 2px)"
|
@@ -38,7 +38,7 @@
|
|
38
38
|
"@click.stop": "startSpin(); $dispatch('viewport:reload'); stopSpin(500);" %>
|
39
39
|
|
40
40
|
<% group.button icon: :external_link,
|
41
|
-
href:
|
41
|
+
href: lookbook_preview_path(@example.lookup_path),
|
42
42
|
tooltip: "Open preview in new window",
|
43
43
|
target: "_blank" %>
|
44
44
|
|
@@ -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 name: panel.name, class: panel.panel_classes do %>
|
58
|
+
<% tabs.panel id: panel.id, name: panel.name, class: [panel.panel_classes, { "p-4": panel.padded, "prose": panel.prose }] do %>
|
59
59
|
<%= render panel.partial, **@inspector_data, panel: panel, **panel.locals %>
|
60
60
|
<% end %>
|
61
61
|
<% end %>
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
<% toolbar.section align: :right, class: "flex-none relative z-10" do %>
|
82
82
|
<%= render_component :button_group do |group| %>
|
83
|
-
<%= @drawer_panels.
|
83
|
+
<%= @drawer_panels.select { |p| !p.disabled && p.copy }.each do |panel| %>
|
84
84
|
<% group.button icon: :copy,
|
85
85
|
tooltip: "Copy panel contents",
|
86
86
|
copy: !!panel.copy,
|
@@ -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 name: panel.name do %>
|
126
|
+
<% tabs.panel id: panel.id, name: panel.name, class: [panel.panel_classes, { "p-4": panel.padded, "prose": panel.prose }] do %>
|
127
127
|
<%= render panel.partial, **@inspector_data, panel: panel, **panel.locals %>
|
128
128
|
<% end %>
|
129
129
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -3,13 +3,13 @@ Lookbook::Engine.routes.draw do
|
|
3
3
|
mount Lookbook::Engine.websocket => Lookbook.config.cable_mount_path
|
4
4
|
end
|
5
5
|
|
6
|
-
root to: "application#index", as: :
|
6
|
+
root to: "application#index", as: :lookbook_home
|
7
7
|
|
8
|
-
get "/#{Lookbook.config.page_route}", to: "pages#index", as: :
|
9
|
-
get "/#{Lookbook.config.page_route}/*path", to: "pages#show", as: :
|
8
|
+
get "/#{Lookbook.config.page_route}", to: "pages#index", as: :lookbook_page_index
|
9
|
+
get "/#{Lookbook.config.page_route}/*path", to: "pages#show", as: :lookbook_page
|
10
10
|
|
11
|
-
get "/preview/*path", to: "previews#preview", as: :
|
12
|
-
get "/inspect/*path", to: "previews#show", as: :
|
11
|
+
get "/preview/*path", to: "previews#preview", as: :lookbook_preview
|
12
|
+
get "/inspect/*path", to: "previews#show", as: :lookbook_inspect
|
13
13
|
|
14
|
-
get "/*path", to: "previews#show_legacy", as: :
|
14
|
+
get "/*path", to: "previews#show_legacy", as: :lookbook_inspect_legacy
|
15
15
|
end
|
data/lib/lookbook/collection.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class Component < Entity
|
3
|
+
|
4
|
+
attr_accessor :name
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
@name = name
|
8
|
+
super(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
name.underscore
|
13
|
+
end
|
14
|
+
|
15
|
+
def full_path
|
16
|
+
Pathname.new("#{Lookbook.config.components_path}/#{path}.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
def dir_path
|
20
|
+
full_path.dirname
|
21
|
+
end
|
22
|
+
|
23
|
+
def template_path
|
24
|
+
Dir.glob("#{Lookbook.config.components_path}/#{path}.*.erb").first
|
25
|
+
end
|
26
|
+
|
27
|
+
def inline?
|
28
|
+
template_path.present?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|