lookbook 1.0.0.beta.5 → 1.0.0.beta.6
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 +27 -254
- data/app/assets/lookbook/css/lookbook.css +1 -1
- data/app/assets/lookbook/css/themes/blue.css +57 -36
- data/app/assets/lookbook/css/themes/indigo.css +57 -36
- data/app/assets/lookbook/css/themes/zinc.css +57 -36
- data/app/assets/lookbook/css/tooltip.css +5 -5
- data/app/components/lookbook/button/component.html.erb +2 -2
- data/app/components/lookbook/embed/component.html.erb +5 -5
- data/app/components/lookbook/embed/component.rb +8 -0
- data/app/components/lookbook/filter/component.html.erb +1 -1
- data/app/components/lookbook/header/component.html.erb +1 -1
- data/app/components/lookbook/inspector_panel/component.html.erb +4 -0
- data/app/components/lookbook/inspector_panel/component.rb +36 -0
- data/app/components/lookbook/nav/item/component.html.erb +1 -1
- data/app/components/lookbook/prose/component.html.erb +1 -1
- data/app/components/lookbook/tabs/dropdown_tab/component.html.erb +1 -1
- data/app/components/lookbook/tabs/tab/component.html.erb +1 -1
- data/app/components/lookbook/toolbar/component.html.erb +1 -1
- data/app/components/lookbook/viewport/component.css +1 -1
- data/app/components/lookbook/viewport/component.html.erb +1 -1
- data/app/controllers/lookbook/pages_controller.rb +1 -0
- data/app/controllers/lookbook/previews_controller.rb +15 -3
- data/app/helpers/lookbook/application_helper.rb +0 -6
- data/app/helpers/lookbook/preview_helper.rb +2 -3
- data/app/views/layouts/lookbook/application.html.erb +1 -1
- data/app/views/layouts/lookbook/page.html.erb +2 -2
- data/app/views/layouts/lookbook/shell.html.erb +6 -0
- data/app/views/layouts/lookbook/skeleton.html.erb +0 -6
- data/app/views/lookbook/previews/panels/_content.html.erb +1 -1
- data/app/views/lookbook/previews/panels/_notes.html.erb +2 -2
- data/app/views/lookbook/previews/panels/_params.html.erb +1 -1
- data/app/views/lookbook/previews/show.html.erb +5 -3
- data/lib/lookbook/config.rb +56 -39
- data/lib/lookbook/engine.rb +8 -0
- data/lib/lookbook/params.rb +12 -0
- data/lib/lookbook/store.rb +8 -0
- data/lib/lookbook/version.rb +1 -1
- data/public/lookbook-assets/css/lookbook.css +302 -150
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/css/themes/blue.css +57 -36
- data/public/lookbook-assets/css/themes/blue.css.map +1 -1
- data/public/lookbook-assets/css/themes/indigo.css +57 -36
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
- data/public/lookbook-assets/css/themes/zinc.css +57 -36
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
- data/public/lookbook-assets/js/embed.js +193 -193
- data/public/lookbook-assets/js/lookbook.js +1169 -1326
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +6 -4
@@ -4,23 +4,23 @@
|
|
4
4
|
.tippy-box[data-theme~="tooltip"] {
|
5
5
|
@apply text-xs opacity-90;
|
6
6
|
|
7
|
-
background-color: var(--lookbook-tooltip);
|
7
|
+
background-color: var(--lookbook-tooltip-bg);
|
8
8
|
color: var(--lookbook-tooltip-text);
|
9
9
|
|
10
10
|
&[data-placement^="top"] > .tippy-arrow::before {
|
11
|
-
border-top-color: var(--lookbook-tooltip);
|
11
|
+
border-top-color: var(--lookbook-tooltip-bg);
|
12
12
|
}
|
13
13
|
|
14
14
|
&[data-placement^="bottom"] > .tippy-arrow::before {
|
15
|
-
border-bottom-color: var(--lookbook-tooltip);
|
15
|
+
border-bottom-color: var(--lookbook-tooltip-bg);
|
16
16
|
}
|
17
17
|
|
18
18
|
&[data-placement^="left"] > .tippy-arrow::before {
|
19
|
-
border-left-color: var(--lookbook-tooltip);
|
19
|
+
border-left-color: var(--lookbook-tooltip-bg);
|
20
20
|
}
|
21
21
|
|
22
22
|
&[data-placement^="right"] > .tippy-arrow::before {
|
23
|
-
border-right-color: var(--lookbook-tooltip);
|
23
|
+
border-right-color: var(--lookbook-tooltip-bg);
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%= render_component_tag tag_name,
|
2
2
|
href: @href,
|
3
3
|
class: [
|
4
|
-
"block text-lookbook-button-
|
4
|
+
"block text-lookbook-icon-button-stroke focus:outline-none focus-visible:outline-none #{padding}",
|
5
5
|
{
|
6
|
-
"hover:text-lookbook-button-
|
6
|
+
"hover:text-lookbook-icon-button-stroke-hover": !@disabled,
|
7
7
|
"cursor-[not-allowed] opacity-50": @disabled
|
8
8
|
}
|
9
9
|
],
|
@@ -7,13 +7,13 @@
|
|
7
7
|
<%= @example.preview.label %> (<%= @example.label %>)
|
8
8
|
</h3>
|
9
9
|
<% end %>
|
10
|
-
|
11
|
-
|
10
|
+
<% toolbar.section align: :right, divide: :left do %>
|
11
|
+
<%= render_component :button_group do |group| %>
|
12
12
|
<% group.button icon: :eye,
|
13
|
-
href:
|
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_inspect_path(@example.path, @params),
|
17
17
|
tooltip: "Open in new window",
|
18
18
|
target: "_blank" %>
|
19
19
|
<% end %>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
@viewport:resize-complete="resizeIframe"
|
29
29
|
@tabs:change.window="resizeIframe">
|
30
30
|
<%= render_component :viewport,
|
31
|
-
src:
|
31
|
+
src: lookbook_preview_path(@example.path, @params.merge(lookbook_embed: true)),
|
32
32
|
alpine_data: "store",
|
33
33
|
resize_height: false,
|
34
34
|
max_height: @max_height,
|
@@ -11,6 +11,14 @@ module Lookbook
|
|
11
11
|
|
12
12
|
protected
|
13
13
|
|
14
|
+
def lookbook_inspect_path(*args)
|
15
|
+
Lookbook::Engine.routes.url_helpers.lookbook_inspect_path(*args)
|
16
|
+
end
|
17
|
+
|
18
|
+
def lookbook_preview_path(*args)
|
19
|
+
Lookbook::Engine.routes.url_helpers.lookbook_preview_path(*args)
|
20
|
+
end
|
21
|
+
|
14
22
|
def alpine_data
|
15
23
|
[@id.to_json, "$store.pages.embeds"].join(",")
|
16
24
|
end
|
@@ -10,7 +10,7 @@
|
|
10
10
|
@keydown.esc.stop="clear"
|
11
11
|
@keydown.f.stop.prevent.window="focus"
|
12
12
|
@keydown.stop>
|
13
|
-
<button class="text-lookbook-button-
|
13
|
+
<button class="text-lookbook-icon-button-stroke hover:text-lookbook-icon-button-stroke-hover focus:ring-0 focus:outline-none absolute top-1/2 right-3 -translate-y-1/2" @click="clear" :class="{hidden: !active}">
|
14
14
|
<%= icon :x, size: 3 %>
|
15
15
|
</button>
|
16
16
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= render_component_tag :header do %>
|
2
|
-
<%= render_component :toolbar, class: "!bg-lookbook-header !text-lookbook-header-text !border-lookbook-header-border" do |toolbar| %>
|
2
|
+
<%= render_component :toolbar, class: "!bg-lookbook-header-bg !text-lookbook-header-text !border-lookbook-header-border" do |toolbar| %>
|
3
3
|
<% toolbar.section padded: true do %>
|
4
4
|
<% if branding.present? %>
|
5
5
|
<a
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "css_parser"
|
2
|
+
|
3
|
+
module Lookbook
|
4
|
+
class InspectorPanel::Component < Lookbook::BaseComponent
|
5
|
+
attr_reader :panel_styles, :panel_html, :id
|
6
|
+
|
7
|
+
def initialize(id:, name:, system: false, **html_attrs)
|
8
|
+
@id = id
|
9
|
+
@name = name
|
10
|
+
@system = system
|
11
|
+
@panel_html = nil
|
12
|
+
@panel_styles = nil
|
13
|
+
super(**html_attrs)
|
14
|
+
end
|
15
|
+
|
16
|
+
def before_render
|
17
|
+
if @system == false
|
18
|
+
panel_dom = ::Nokogiri::HTML::fragment(content)
|
19
|
+
style_tags = panel_dom.css('style')
|
20
|
+
if style_tags.any?
|
21
|
+
css_parser = ::CssParser::Parser.new
|
22
|
+
@panel_styles = ""
|
23
|
+
style_tags.each do |style_tag|
|
24
|
+
css_parser.load_string! style_tag.text
|
25
|
+
css_parser.each_selector do |selector, declarations, specificity|
|
26
|
+
@panel_styles += "##{id} #{selector} { #{declarations} }\n"
|
27
|
+
end
|
28
|
+
style_tag.unlink
|
29
|
+
end
|
30
|
+
@panel_html = panel_dom.to_html.html_safe
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@panel_html ||= content
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -16,7 +16,7 @@
|
|
16
16
|
size: 3,
|
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
|
-
<%= icon nav_icon, size: 3.5, class: "mr-1.5 text-lookbook-nav-icon" %>
|
19
|
+
<%= icon nav_icon, size: 3.5, class: "mr-1.5 text-lookbook-nav-icon-stroke" %>
|
20
20
|
<span><%= label %></span>
|
21
21
|
</div>
|
22
22
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= render_component_tag class: "prose #{size_class} text-lookbook-prose-text bg-lookbook-prose prose-a:text-lookbook-prose-link" do %>
|
1
|
+
<%= render_component_tag class: "prose #{size_class} text-lookbook-prose-text bg-lookbook-prose-bg prose-a:text-lookbook-prose-link" do %>
|
2
2
|
<%== rendered_content %>
|
3
3
|
<% end %>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
}
|
9
9
|
],
|
10
10
|
":class": "{
|
11
|
-
'border-lookbook-tabs-
|
11
|
+
'border-lookbook-tabs-border-active': isSelected($el),
|
12
12
|
'border-transparent text-lookbook-tabs-text hover:text-lookbook-tabs-text-hover': !isSelected($el),
|
13
13
|
'hidden': visibleTabsCount >= #{@position}
|
14
14
|
}",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
}
|
10
10
|
],
|
11
11
|
":class": "{
|
12
|
-
'border-lookbook-tabs-
|
12
|
+
'border-lookbook-tabs-border-active': isSelected($el),
|
13
13
|
'border-transparent text-lookbook-tabs-text hover:text-lookbook-tabs-text-hover': !isSelected($el),
|
14
14
|
'!text-lookbook-tabs-text-disabled': isDisabled($el),
|
15
15
|
'invisible pointer-events-none relative z-[-1]': visibleTabsCount < #{@position}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render_component_tag class: "h-10 border-b border-lookbook-divider w-full flex items-center text-sm flex-none bg-lookbook-toolbar" do %>
|
1
|
+
<%= render_component_tag class: "h-10 border-b border-lookbook-divider w-full flex items-center text-sm flex-none bg-lookbook-toolbar-bg" do %>
|
2
2
|
<div class="toolbar-sections flex items-stretch w-full">
|
3
3
|
<%= safe_join(sections) %>
|
4
4
|
</div>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
.resize-handle {
|
7
7
|
@apply flex items-center justify-center h-full w-full border-lookbook-divider bg-lookbook-viewport-handle hover:bg-indigo-100 hover:bg-opacity-20;
|
8
|
-
@apply text-lookbook-viewport-handle-icon hover:text-lookbook-viewport-handle-icon-hover transition select-none touch-none;
|
8
|
+
@apply text-lookbook-viewport-handle-icon-stroke hover:text-lookbook-viewport-handle-icon-stroke-hover transition select-none touch-none;
|
9
9
|
}
|
10
10
|
}
|
11
11
|
}
|
@@ -34,7 +34,7 @@
|
|
34
34
|
<% end %>
|
35
35
|
<% if @resize_height %>
|
36
36
|
<div
|
37
|
-
class="resize-handle border-b border-l border-lookbook-divider cursor-[
|
37
|
+
class="resize-handle border-b border-l border-lookbook-divider cursor-[row-resize] <%= "border-r" unless @resize_width %>"
|
38
38
|
@pointerdown="onResizeHeightStart"
|
39
39
|
@dblclick="toggleFullHeight">
|
40
40
|
<svg class="h-4 w-4 pointer-events-none rotate-90" fill="currentColor" viewBox="0 0 24 24" >
|
@@ -47,6 +47,16 @@ module Lookbook
|
|
47
47
|
redirect_to lookbook_inspect_path params[:path]
|
48
48
|
end
|
49
49
|
|
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
|
+
|
50
60
|
private
|
51
61
|
|
52
62
|
def lookup_entities
|
@@ -98,10 +108,11 @@ module Lookbook
|
|
98
108
|
preview_controller.params[param[:name]] = Lookbook::Params.cast(preview_controller.params[param[:name]], param[:type])
|
99
109
|
end
|
100
110
|
end
|
101
|
-
# set display params
|
111
|
+
# set display and data params
|
102
112
|
preview_controller.params.merge!({
|
103
113
|
lookbook: {
|
104
|
-
display: @example.display_params
|
114
|
+
display: @example.display_params,
|
115
|
+
data: Lookbook.data
|
105
116
|
}
|
106
117
|
})
|
107
118
|
end
|
@@ -145,7 +156,8 @@ module Lookbook
|
|
145
156
|
context: context_data,
|
146
157
|
preview: preview,
|
147
158
|
examples: examples,
|
148
|
-
|
159
|
+
example: example,
|
160
|
+
data: Lookbook.data,
|
149
161
|
app: Lookbook
|
150
162
|
})
|
151
163
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
alpine_data: "$store.layout.main",
|
5
5
|
":class": "$store.layout.mobile && '!block'" do |layout| %>
|
6
6
|
|
7
|
-
<% layout.pane id: "app-sidebar", class: "flex flex-col bg-lookbook-sidebar relative translate-x-0",
|
7
|
+
<% layout.pane id: "app-sidebar", class: "flex flex-col bg-lookbook-sidebar-bg relative translate-x-0",
|
8
8
|
":class": "{
|
9
9
|
'transition': $store.layout.mobile,
|
10
10
|
'translate-x-full': $store.layout.mobile && sidebarHidden,
|
@@ -4,11 +4,11 @@
|
|
4
4
|
x-data="{}"
|
5
5
|
@navigation:complete.window="$refs.scroller.scrollTop = 0">
|
6
6
|
|
7
|
-
<div class="h-full bg-lookbook-page relative">
|
7
|
+
<div class="h-full bg-lookbook-page-bg relative">
|
8
8
|
<% unless @error %>
|
9
9
|
|
10
10
|
<div class="absolute top-0 right-0 pt-1 pr-0 pl-1 pb-1 rounded-bl-md">
|
11
|
-
<div class="bg-lookbook-page opacity-90 absolute inset-0 w-full h-full z-0"></div>
|
11
|
+
<div class="bg-lookbook-page-bg opacity-90 absolute inset-0 w-full h-full z-0"></div>
|
12
12
|
<div class="relative z-10 flex items-center">
|
13
13
|
|
14
14
|
<% if @previous_page %>
|
@@ -7,6 +7,12 @@
|
|
7
7
|
@navigation:start="closeMobileSidebar"
|
8
8
|
class="w-screen h-screen grid grid-rows-[40px_1fr] relative">
|
9
9
|
|
10
|
+
<% if content_for? :panel_css %>
|
11
|
+
<style media="all" id="panel-styles">
|
12
|
+
<%= content_for :panel_css -%>
|
13
|
+
</style>
|
14
|
+
<% end %>
|
15
|
+
|
10
16
|
<%= render_component :header, id: "app-header", debug_menu: config.debug_menu do |header| %>
|
11
17
|
<% header.branding { config.project_name } %>
|
12
18
|
<% end %>
|
@@ -13,12 +13,6 @@
|
|
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
|
-
|
22
16
|
<% if config.ui_favicon != false %>
|
23
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>" %>">
|
24
18
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% items = examples.select { |example| example.notes.present? } %>
|
2
2
|
<% if items.many? %>
|
3
|
-
<div class="divide-y divide-dashed divide-lookbook-divider bg-lookbook-prose h-full w-full">
|
3
|
+
<div class="divide-y divide-dashed divide-lookbook-divider bg-lookbook-prose-bg h-full w-full">
|
4
4
|
<% items.each do |item| %>
|
5
5
|
<div class="px-4 py-6 relative">
|
6
6
|
<h6 class="italic font-mono mb-4 opacity-40">
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<% end %>
|
12
12
|
</div>
|
13
13
|
<% else %>
|
14
|
-
<div class="p-4 bg-lookbook-prose w-full h-full">
|
14
|
+
<div class="p-4 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 %>
|
@@ -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: lookbook_preview_path(@example.lookup_path),
|
41
|
+
href: lookbook_preview_path(@example.lookup_path, request.query_parameters),
|
42
42
|
tooltip: "Open preview in new window",
|
43
43
|
target: "_blank" %>
|
44
44
|
|
@@ -63,7 +63,7 @@
|
|
63
63
|
</div>
|
64
64
|
<% end %>
|
65
65
|
|
66
|
-
<%= layout.pane class: "flex flex-col h-full overflow-hidden bg-lookbook-drawer",
|
66
|
+
<%= layout.pane class: "flex flex-col h-full overflow-hidden bg-lookbook-drawer-bg",
|
67
67
|
"x-show": "!$store.inspector.drawer.hidden && #{@drawer_panels.any?}" do %>
|
68
68
|
|
69
69
|
<%= render_component :toolbar do |toolbar| %>
|
@@ -124,7 +124,9 @@
|
|
124
124
|
<%= render_component :tab_panels, alpine_data: "$store.inspector.drawer" do |tabs| %>
|
125
125
|
<% @drawer_panels.each do |panel| %>
|
126
126
|
<% tabs.panel id: panel.id, name: panel.name, class: [panel.panel_classes, { "p-4": panel.padded, "prose": panel.prose }] do %>
|
127
|
-
<%=
|
127
|
+
<%= render_component :inspector_panel, **panel.slice(:id, :name, :system) do %>
|
128
|
+
<%= render panel.partial, **@inspector_data, panel: panel, **panel.locals %>
|
129
|
+
<% end %>
|
128
130
|
<% end %>
|
129
131
|
<% end %>
|
130
132
|
<% end %>
|
data/lib/lookbook/config.rb
CHANGED
@@ -22,9 +22,8 @@ module Lookbook
|
|
22
22
|
|
23
23
|
preview_paths: [],
|
24
24
|
preview_display_params: {},
|
25
|
-
|
26
|
-
|
27
|
-
sort_examples: true,
|
25
|
+
preview_srcdoc: nil,
|
26
|
+
sort_examples: false,
|
28
27
|
|
29
28
|
listen: Rails.env.development?,
|
30
29
|
listen_paths: [],
|
@@ -57,7 +56,8 @@ module Lookbook
|
|
57
56
|
partial: "lookbook/previews/panels/preview",
|
58
57
|
hotkey: "v",
|
59
58
|
panel_classes: "overflow-hidden",
|
60
|
-
padded: false
|
59
|
+
padded: false,
|
60
|
+
system: true
|
61
61
|
},
|
62
62
|
output: {
|
63
63
|
pane: :main,
|
@@ -65,7 +65,8 @@ module Lookbook
|
|
65
65
|
partial: "lookbook/previews/panels/output",
|
66
66
|
label: "HTML",
|
67
67
|
hotkey: "h",
|
68
|
-
padded: false
|
68
|
+
padded: false,
|
69
|
+
system: true
|
69
70
|
},
|
70
71
|
source: {
|
71
72
|
pane: :drawer,
|
@@ -74,7 +75,8 @@ module Lookbook
|
|
74
75
|
label: "Source",
|
75
76
|
hotkey: "s",
|
76
77
|
copy: ->(data) { data.examples.map { |e| e.source }.join("\n") },
|
77
|
-
padded: false
|
78
|
+
padded: false,
|
79
|
+
system: true
|
78
80
|
},
|
79
81
|
notes: {
|
80
82
|
pane: :drawer,
|
@@ -83,7 +85,8 @@ module Lookbook
|
|
83
85
|
label: "Notes",
|
84
86
|
hotkey: "n",
|
85
87
|
disabled: ->(data) { data.examples.select { |e| e.notes.present? }.none? },
|
86
|
-
padded: false
|
88
|
+
padded: false,
|
89
|
+
system: true
|
87
90
|
},
|
88
91
|
params: {
|
89
92
|
pane: :drawer,
|
@@ -92,25 +95,10 @@ module Lookbook
|
|
92
95
|
label: "Params",
|
93
96
|
hotkey: "p",
|
94
97
|
disabled: ->(data) { data.preview.params.none? },
|
95
|
-
padded: false
|
98
|
+
padded: false,
|
99
|
+
system: true
|
96
100
|
}
|
97
101
|
},
|
98
|
-
|
99
|
-
inspector_panel_defaults: {
|
100
|
-
id: ->(data) { "inspector-panel-#{data.name}" },
|
101
|
-
partial: "lookbook/previews/panels/content",
|
102
|
-
content: nil,
|
103
|
-
label: ->(data) { data.name.titleize },
|
104
|
-
pane: :drawer,
|
105
|
-
position: ->(data) { data.index_position },
|
106
|
-
hotkey: nil,
|
107
|
-
disabled: false,
|
108
|
-
show: true,
|
109
|
-
copy: nil,
|
110
|
-
panel_classes: nil,
|
111
|
-
locals: {},
|
112
|
-
padded: true
|
113
|
-
},
|
114
102
|
})
|
115
103
|
end
|
116
104
|
|
@@ -122,22 +110,33 @@ module Lookbook
|
|
122
110
|
absolute_path(@options.components_path)
|
123
111
|
end
|
124
112
|
|
113
|
+
def page_paths=(paths = [])
|
114
|
+
@options.page_paths += paths if paths.is_a? Array
|
115
|
+
end
|
116
|
+
|
125
117
|
def page_paths
|
126
118
|
normalize_paths(@options.page_paths)
|
127
119
|
end
|
128
120
|
|
121
|
+
def preview_paths=(paths = [])
|
122
|
+
@options.preview_paths += paths if paths.is_a? Array
|
123
|
+
end
|
124
|
+
|
129
125
|
def preview_paths
|
130
126
|
normalize_paths(@options.preview_paths)
|
131
127
|
end
|
132
128
|
|
129
|
+
def preview_srcdoc=(enable)
|
130
|
+
Lookbook.logger.warn "The `preview_srcdoc` config option is deprecated and will be removed in v2.0"
|
131
|
+
end
|
132
|
+
|
133
133
|
def listen_paths
|
134
134
|
normalize_paths(@options.listen_paths)
|
135
135
|
end
|
136
136
|
|
137
|
-
def listen_extensions
|
138
|
-
@options.listen_extensions +=
|
137
|
+
def listen_extensions=(extensions = [])
|
138
|
+
@options.listen_extensions += extensions if extensions.is_a? Array
|
139
139
|
@options.listen_extensions.uniq!
|
140
|
-
@options.listen_extensions
|
141
140
|
end
|
142
141
|
|
143
142
|
def parser_registry_path
|
@@ -154,16 +153,13 @@ module Lookbook
|
|
154
153
|
end
|
155
154
|
|
156
155
|
def define_inspector_panel(name, opts = {})
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
if panel.position >= opts[:position]
|
165
|
-
panel.position += 1
|
166
|
-
end
|
156
|
+
pane = opts[:pane].presence || :drawer
|
157
|
+
siblings = inspector_panels.select { |key, panel| panel.pane == pane }
|
158
|
+
opts[:position] ||= siblings.size + 1
|
159
|
+
@options.inspector_panels[name] = opts
|
160
|
+
siblings.each do |key, panel|
|
161
|
+
if panel.position >= opts[:position]
|
162
|
+
panel.position += 1
|
167
163
|
end
|
168
164
|
end
|
169
165
|
end
|
@@ -180,6 +176,25 @@ module Lookbook
|
|
180
176
|
amend_inspector_panel(name, false)
|
181
177
|
end
|
182
178
|
|
179
|
+
def inspector_panel_defaults
|
180
|
+
{
|
181
|
+
id: ->(data) { "inspector-panel-#{data.name}" },
|
182
|
+
partial: "lookbook/previews/panels/content",
|
183
|
+
content: nil,
|
184
|
+
label: ->(data) { data.name.titleize },
|
185
|
+
pane: :drawer,
|
186
|
+
position: ->(data) { data.index_position },
|
187
|
+
hotkey: nil,
|
188
|
+
disabled: false,
|
189
|
+
show: true,
|
190
|
+
copy: nil,
|
191
|
+
panel_classes: nil,
|
192
|
+
locals: {},
|
193
|
+
padded: true,
|
194
|
+
system: false
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
183
198
|
def ui_theme=(name)
|
184
199
|
name = name.to_s
|
185
200
|
if Theme.valid_theme?(name)
|
@@ -225,8 +240,10 @@ module Lookbook
|
|
225
240
|
protected
|
226
241
|
|
227
242
|
def normalize_paths(paths)
|
228
|
-
paths.map!
|
229
|
-
|
243
|
+
paths.map! do |path|
|
244
|
+
full_path = absolute_path(path)
|
245
|
+
full_path if Dir.exist?(full_path)
|
246
|
+
end.compact!
|
230
247
|
paths
|
231
248
|
end
|
232
249
|
|
data/lib/lookbook/engine.rb
CHANGED
data/lib/lookbook/params.rb
CHANGED
@@ -63,6 +63,14 @@ module Lookbook
|
|
63
63
|
result = []
|
64
64
|
end
|
65
65
|
result
|
66
|
+
when "datetime"
|
67
|
+
begin
|
68
|
+
result = DateTime.parse(value)
|
69
|
+
rescue Date::Error
|
70
|
+
Lookbook.logger.debug "Failed to parse '#{value}' into a DateTime"
|
71
|
+
result = DateTime.now
|
72
|
+
end
|
73
|
+
result
|
66
74
|
else
|
67
75
|
begin
|
68
76
|
type_class = "ActiveModel::Type::#{type}".constantize
|
@@ -92,6 +100,8 @@ module Lookbook
|
|
92
100
|
"Boolean"
|
93
101
|
elsif default.is_a? Symbol
|
94
102
|
"Symbol"
|
103
|
+
elsif ["date", "datetime-local"].include?(input&.downcase) || default.is_a?(DateTime)
|
104
|
+
"DateTime"
|
95
105
|
else
|
96
106
|
"String"
|
97
107
|
end
|
@@ -99,6 +109,8 @@ module Lookbook
|
|
99
109
|
|
100
110
|
def input_text?(input)
|
101
111
|
[
|
112
|
+
"date",
|
113
|
+
"datetime-local",
|
102
114
|
"email",
|
103
115
|
"number",
|
104
116
|
"tel",
|
data/lib/lookbook/store.rb
CHANGED
@@ -21,6 +21,14 @@ module Lookbook
|
|
21
21
|
self
|
22
22
|
end
|
23
23
|
|
24
|
+
def get(key, fallback = nil)
|
25
|
+
if self.key?(normalize_key(key))
|
26
|
+
self[normalize_key(key)]
|
27
|
+
else
|
28
|
+
fallback
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
24
32
|
def method_missing(name, *args)
|
25
33
|
super(normalize_key(name), *args.map { |arg| normalize_value(arg) })
|
26
34
|
end
|
data/lib/lookbook/version.rb
CHANGED