lookbook 1.0.0.beta.2 → 1.0.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +180 -40
- data/app/components/lookbook/{component.rb → base_component.rb} +7 -5
- 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 +3 -3
- 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 +34 -33
- 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 +8 -13
- data/app/components/lookbook/header/component.rb +6 -1
- data/app/components/lookbook/icon/component.rb +1 -1
- data/app/components/lookbook/nav/component.html.erb +4 -8
- data/app/components/lookbook/nav/component.rb +6 -8
- data/app/components/lookbook/nav/item/component.html.erb +12 -6
- data/app/components/lookbook/nav/item/component.rb +10 -3
- data/app/components/lookbook/page_tabs/component.html.erb +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.html.erb +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.html.erb +2 -2
- data/app/components/lookbook/tab_panels/panel/component.rb +2 -2
- data/app/components/lookbook/tabs/component.html.erb +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.html.erb +1 -1
- data/app/components/lookbook/tabs/dropdown_tab/component.rb +1 -1
- data/app/components/lookbook/tabs/tab/component.html.erb +1 -1
- data/app/components/lookbook/tabs/tab/component.rb +1 -1
- data/app/components/lookbook/tag_component.rb +5 -10
- 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/previews_controller.rb +24 -29
- data/app/helpers/lookbook/application_helper.rb +6 -0
- data/app/helpers/lookbook/component_helper.rb +4 -0
- data/app/helpers/lookbook/page_helper.rb +1 -1
- data/app/views/layouts/lookbook/application.html.erb +76 -58
- data/app/views/layouts/lookbook/page.html.erb +35 -35
- 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 +24 -11
- data/app/views/lookbook/pages/show.html.erb +7 -7
- data/app/views/lookbook/previews/panels/_notes.html.erb +1 -1
- data/app/views/lookbook/previews/show.html.erb +10 -10
- data/lib/lookbook/collection.rb +1 -1
- data/lib/lookbook/component.rb +31 -0
- data/lib/lookbook/config.rb +101 -40
- data/lib/lookbook/engine.rb +88 -18
- data/lib/lookbook/markdown.rb +3 -1
- data/lib/lookbook/page.rb +6 -2
- data/lib/lookbook/parser.rb +1 -4
- data/lib/lookbook/preview.rb +59 -12
- data/lib/lookbook/preview_example.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/lib/tasks/lookbook_tasks.rake +1 -1
- data/public/lookbook-assets/css/lookbook.css +34 -38
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +79 -78
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +4 -3
@@ -5,44 +5,44 @@
|
|
5
5
|
@navigation:complete.window="$refs.scroller.scrollTop = 0">
|
6
6
|
|
7
7
|
<div class="h-full bg-lookbook-page relative">
|
8
|
-
|
9
|
-
|
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>
|
12
|
-
<div class="relative z-10 flex items-center">
|
8
|
+
<% unless @error %>
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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>
|
12
|
+
<div class="relative z-10 flex items-center">
|
13
|
+
|
14
|
+
<% if @previous_page %>
|
15
|
+
<%= render_component :button,
|
16
|
+
size: :lg,
|
17
|
+
icon: :chevron_left,
|
18
|
+
tooltip: "Previous page",
|
19
|
+
href: lookbook_page_path(@previous_page.lookup_path),
|
20
|
+
class: "pr-0.5 bg-transparent" %>
|
21
|
+
<% else %>
|
22
|
+
<%= render_component :button,
|
23
|
+
size: :lg,
|
24
|
+
icon: :chevron_left,
|
25
|
+
disabled: true,
|
26
|
+
class: "opacity-50 !cursor-default pr-0.5 bg-transparent" %>
|
27
|
+
<% end %>
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
<% if @next_page %>
|
30
|
+
<%= render_component :button,
|
31
|
+
size: :lg,
|
32
|
+
icon: :chevron_right,
|
33
|
+
tooltip: "Next page",
|
34
|
+
href: lookbook_page_path(@next_page.lookup_path),
|
35
|
+
class: "pl-0.5 bg-transparent" %>
|
36
|
+
<% else %>
|
37
|
+
<%= render_component :button,
|
38
|
+
size: :lg,
|
39
|
+
icon: :chevron_right,
|
40
|
+
disabled: true,
|
41
|
+
class: "opacity-50 !cursor-default pl-0.5 bg-transparent" %>
|
42
|
+
<% end %>
|
43
|
+
</div>
|
43
44
|
</div>
|
44
|
-
|
45
|
-
<% end %>
|
45
|
+
<% end %>
|
46
46
|
|
47
47
|
<%= yield %>
|
48
48
|
</div>
|
@@ -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,14 +1,27 @@
|
|
1
|
-
<div id="
|
2
|
-
<div class="
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
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
11
|
</div>
|
12
|
-
|
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 %>
|
13
26
|
</div>
|
14
27
|
</div>
|
@@ -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
|
-
<div class="w-full max-w-
|
2
|
+
<div class="w-full max-w-screen-lg 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, class: "mt-6" 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,11 +21,11 @@
|
|
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
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 %>
|
@@ -34,7 +34,7 @@
|
|
34
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| %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
":class": "($store.inspector.drawer.hidden || #{@drawer_panels.none?}) && '!grid-rows-[1fr] !grid-cols-[1fr]'" do |layout| %>
|
4
4
|
|
5
5
|
<%= layout.pane class: "flex flex-col h-full overflow-hidden",
|
6
|
-
|
6
|
+
"x-effect": "forceOrientation = (layoutWidth < $store.inspector.minVerticalSplitWidth) ? 'horizontal' : null" do %>
|
7
7
|
|
8
8
|
<%= render_component :toolbar do |toolbar| %>
|
9
9
|
<% toolbar.section ":class": "layoutResizing && 'overflow-hidden'" do %>
|
@@ -46,7 +46,7 @@
|
|
46
46
|
tooltip: "Show drawer",
|
47
47
|
"@click": "$store.inspector.drawer.hidden = false",
|
48
48
|
class: "rotate-180",
|
49
|
-
|
49
|
+
"x-show": "$store.inspector.drawer.hidden",
|
50
50
|
cloak: true %>
|
51
51
|
<% end %>
|
52
52
|
<% 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 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 %>
|
@@ -64,7 +64,7 @@
|
|
64
64
|
<% end %>
|
65
65
|
|
66
66
|
<%= layout.pane class: "flex flex-col h-full overflow-hidden bg-lookbook-drawer",
|
67
|
-
|
67
|
+
"x-show": "!$store.inspector.drawer.hidden && #{@drawer_panels.any?}" do %>
|
68
68
|
|
69
69
|
<%= render_component :toolbar do |toolbar| %>
|
70
70
|
<% toolbar.section ":class": "layoutResizing && 'overflow-hidden'" do %>
|
@@ -80,11 +80,11 @@
|
|
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,
|
87
|
-
|
87
|
+
"x-show": "$store.inspector.drawer.activeTab === '#{panel.name}'",
|
88
88
|
cloak: true do %>
|
89
89
|
<%== panel.copy ? panel.copy : "" %>
|
90
90
|
<% end %>
|
@@ -98,18 +98,18 @@
|
|
98
98
|
<% group.button icon: :corner_up_right,
|
99
99
|
tooltip: "Move drawer to right",
|
100
100
|
"@click": "switchOrientation",
|
101
|
-
|
101
|
+
"x-show": "horizontal && layoutWidth > $store.inspector.minVerticalSplitWidth",
|
102
102
|
cloak: true %>
|
103
103
|
|
104
104
|
<% group.button icon: :corner_up_right,
|
105
|
-
|
105
|
+
"x-show": "horizontal && layoutWidth <= $store.inspector.minVerticalSplitWidth",
|
106
106
|
disabled: true,
|
107
107
|
cloak: true %>
|
108
108
|
|
109
109
|
<% group.button icon: :corner_left_down,
|
110
110
|
tooltip: "Move drawer to bottom",
|
111
111
|
"@click": "switchOrientation",
|
112
|
-
|
112
|
+
"x-show": "vertical",
|
113
113
|
cloak: true %>
|
114
114
|
|
115
115
|
<% group.button icon: :x_circle,
|
@@ -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/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
|
data/lib/lookbook/config.rb
CHANGED
@@ -6,11 +6,13 @@ module Lookbook
|
|
6
6
|
class Config
|
7
7
|
def initialize
|
8
8
|
@options = Store.new
|
9
|
-
|
9
|
+
|
10
10
|
@options.set({
|
11
11
|
project_name: "Lookbook",
|
12
12
|
log_level: 2,
|
13
13
|
auto_refresh: true,
|
14
|
+
|
15
|
+
components_path: "app/components",
|
14
16
|
|
15
17
|
page_controller: "Lookbook::PageController",
|
16
18
|
page_route: "pages",
|
@@ -26,6 +28,7 @@ module Lookbook
|
|
26
28
|
|
27
29
|
listen: Rails.env.development?,
|
28
30
|
listen_paths: [],
|
31
|
+
listen_extensions: ["rb", "html.*"],
|
29
32
|
listen_use_polling: false,
|
30
33
|
|
31
34
|
cable_mount_path: "/lookbook-cable",
|
@@ -37,13 +40,24 @@ module Lookbook
|
|
37
40
|
ui_theme: "indigo",
|
38
41
|
ui_theme_overrides: {},
|
39
42
|
|
43
|
+
hooks: {
|
44
|
+
after_initialize: [],
|
45
|
+
before_exit: [],
|
46
|
+
after_change: [],
|
47
|
+
},
|
48
|
+
|
49
|
+
debug_menu: Rails.env.development?,
|
50
|
+
|
51
|
+
experimental_features: false,
|
52
|
+
|
40
53
|
inspector_panels: {
|
41
54
|
preview: {
|
42
55
|
pane: :main,
|
43
56
|
position: 1,
|
44
57
|
partial: "lookbook/previews/panels/preview",
|
45
58
|
hotkey: "v",
|
46
|
-
panel_classes: "overflow-hidden"
|
59
|
+
panel_classes: "overflow-hidden",
|
60
|
+
padded: false
|
47
61
|
},
|
48
62
|
output: {
|
49
63
|
pane: :main,
|
@@ -51,6 +65,7 @@ module Lookbook
|
|
51
65
|
partial: "lookbook/previews/panels/output",
|
52
66
|
label: "HTML",
|
53
67
|
hotkey: "h",
|
68
|
+
padded: false
|
54
69
|
},
|
55
70
|
source: {
|
56
71
|
pane: :drawer,
|
@@ -58,7 +73,8 @@ module Lookbook
|
|
58
73
|
partial: "lookbook/previews/panels/source",
|
59
74
|
label: "Source",
|
60
75
|
hotkey: "s",
|
61
|
-
copy: ->(data) { data.examples.map { |e| e
|
76
|
+
copy: ->(data) { data.examples.map { |e| e.source }.join("\n") },
|
77
|
+
padded: false
|
62
78
|
},
|
63
79
|
notes: {
|
64
80
|
pane: :drawer,
|
@@ -66,7 +82,8 @@ module Lookbook
|
|
66
82
|
partial: "lookbook/previews/panels/notes",
|
67
83
|
label: "Notes",
|
68
84
|
hotkey: "n",
|
69
|
-
disabled: ->(data) { data.examples.
|
85
|
+
disabled: ->(data) { data.examples.select { |e| e.notes.present? }.none? },
|
86
|
+
padded: false
|
70
87
|
},
|
71
88
|
params: {
|
72
89
|
pane: :drawer,
|
@@ -74,7 +91,8 @@ module Lookbook
|
|
74
91
|
partial: "lookbook/previews/panels/params",
|
75
92
|
label: "Params",
|
76
93
|
hotkey: "p",
|
77
|
-
disabled: ->(data) { data.preview.params.none? }
|
94
|
+
disabled: ->(data) { data.preview.params.none? },
|
95
|
+
padded: false
|
78
96
|
}
|
79
97
|
},
|
80
98
|
|
@@ -90,25 +108,82 @@ module Lookbook
|
|
90
108
|
show: true,
|
91
109
|
copy: nil,
|
92
110
|
panel_classes: nil,
|
93
|
-
locals: {}
|
111
|
+
locals: {},
|
112
|
+
padded: true
|
94
113
|
},
|
95
|
-
|
96
|
-
experimental_features: false,
|
97
114
|
})
|
98
115
|
end
|
99
116
|
|
117
|
+
def project_name
|
118
|
+
@options.project_name == false ? nil : @options.project_name
|
119
|
+
end
|
120
|
+
|
121
|
+
def components_path
|
122
|
+
absolute_path(@options.components_path)
|
123
|
+
end
|
124
|
+
|
125
|
+
def page_paths
|
126
|
+
normalize_paths(@options.page_paths)
|
127
|
+
end
|
128
|
+
|
129
|
+
def preview_paths
|
130
|
+
normalize_paths(@options.preview_paths)
|
131
|
+
end
|
132
|
+
|
133
|
+
def listen_paths
|
134
|
+
normalize_paths(@options.listen_paths)
|
135
|
+
end
|
136
|
+
|
137
|
+
def listen_extensions
|
138
|
+
@options.listen_extensions += ["rb", "html.*"]
|
139
|
+
@options.listen_extensions.uniq!
|
140
|
+
@options.listen_extensions
|
141
|
+
end
|
142
|
+
|
143
|
+
def parser_registry_path
|
144
|
+
absolute_path(@options.parser_registry_path)
|
145
|
+
end
|
146
|
+
|
100
147
|
def inspector_panels(&block)
|
148
|
+
panels = Store.new(@options.inspector_panels.select { |key, panel| panel != false })
|
101
149
|
if block_given?
|
102
|
-
yield
|
150
|
+
yield panels
|
151
|
+
else
|
152
|
+
panels
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def define_inspector_panel(name, opts = {})
|
157
|
+
@options.inspector_panels[name] = opts
|
158
|
+
if opts[:position].present?
|
159
|
+
pane = inspector_panels[name].pane.presence || :drawer
|
160
|
+
siblings = inspector_panels.select do |key, panel|
|
161
|
+
panel.pane == pane && key != name.to_sym
|
162
|
+
end
|
163
|
+
siblings.each do |key, panel|
|
164
|
+
if panel.position >= opts[:position]
|
165
|
+
panel.position += 1
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def amend_inspector_panel(name, opts = {})
|
172
|
+
if opts == false
|
173
|
+
@options.inspector_panels[name] = false
|
103
174
|
else
|
104
|
-
|
175
|
+
@options.inspector_panels[name].merge!(opts)
|
105
176
|
end
|
106
177
|
end
|
107
178
|
|
179
|
+
def remove_inspector_panel(name)
|
180
|
+
amend_inspector_panel(name, false)
|
181
|
+
end
|
182
|
+
|
108
183
|
def ui_theme=(name)
|
109
184
|
name = name.to_s
|
110
185
|
if Theme.valid_theme?(name)
|
111
|
-
@options
|
186
|
+
@options.ui_theme = name
|
112
187
|
else
|
113
188
|
Lookbook.logger.warn "'#{name}' is not a valid Lookbook theme. Theme setting not changed."
|
114
189
|
end
|
@@ -116,18 +191,27 @@ module Lookbook
|
|
116
191
|
|
117
192
|
def ui_theme_overrides(&block)
|
118
193
|
if block_given?
|
119
|
-
yield
|
194
|
+
yield @options.ui_theme_overrides
|
120
195
|
else
|
121
|
-
|
196
|
+
@options.ui_theme_overrides
|
122
197
|
end
|
123
198
|
end
|
124
199
|
|
125
200
|
def [](key)
|
126
|
-
|
201
|
+
if respond_to? key.to_sym
|
202
|
+
public_send(key.to_sym)
|
203
|
+
else
|
204
|
+
@options[key.to_sym]
|
205
|
+
end
|
127
206
|
end
|
128
207
|
|
129
208
|
def []=(key, value)
|
130
|
-
|
209
|
+
setter_key = "#{key}=".to_sym
|
210
|
+
if respond_to? setter_key
|
211
|
+
public_send(setter_key, value)
|
212
|
+
else
|
213
|
+
@options[key.to_sym] = value
|
214
|
+
end
|
131
215
|
end
|
132
216
|
|
133
217
|
def to_h
|
@@ -140,18 +224,9 @@ module Lookbook
|
|
140
224
|
|
141
225
|
protected
|
142
226
|
|
143
|
-
def get_inspector_panels(panels)
|
144
|
-
panels.filter! { |key, panel| panel }
|
145
|
-
panels
|
146
|
-
end
|
147
|
-
|
148
|
-
def get_project_name(name)
|
149
|
-
name == false ? nil : name
|
150
|
-
end
|
151
|
-
|
152
227
|
def normalize_paths(paths)
|
153
228
|
paths.map! { |path| absolute_path(path) }
|
154
|
-
paths.
|
229
|
+
paths.select! { |path| Dir.exist?(path) }
|
155
230
|
paths
|
156
231
|
end
|
157
232
|
|
@@ -159,22 +234,8 @@ module Lookbook
|
|
159
234
|
File.absolute_path(path.to_s, Rails.root)
|
160
235
|
end
|
161
236
|
|
162
|
-
alias_method :get_page_paths, :normalize_paths
|
163
|
-
alias_method :get_preview_paths, :normalize_paths
|
164
|
-
alias_method :get_listen_paths, :normalize_paths
|
165
|
-
alias_method :get_parser_registry_path, :absolute_path
|
166
|
-
|
167
|
-
def get(name)
|
168
|
-
getter_name = "get_#{name}".to_sym
|
169
|
-
respond_to?(getter_name, true) ? send(getter_name, @options[name]) : @options[name]
|
170
|
-
end
|
171
|
-
|
172
|
-
def set(name, *args)
|
173
|
-
@options.send(name, *args)
|
174
|
-
end
|
175
|
-
|
176
237
|
def method_missing(name, *args)
|
177
|
-
|
238
|
+
@options.send(name, *args)
|
178
239
|
end
|
179
240
|
end
|
180
241
|
end
|