lookbook 2.0.0.beta.3 → 2.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/app/assets/lookbook/css/lookbook.css +6 -0
- data/app/assets/lookbook/css/themes/blue.css +4 -1
- data/app/assets/lookbook/css/themes/green.css +4 -1
- data/app/assets/lookbook/css/themes/indigo.css +4 -1
- data/app/assets/lookbook/css/themes/rose.css +4 -1
- data/app/assets/lookbook/css/themes/zinc.css +4 -1
- data/app/assets/lookbook/img/lucide-sprite.svg +869 -869
- data/app/components/lookbook/code/highlight_github.css +16 -17
- data/app/components/lookbook/dimensions_display/component.js +4 -7
- data/app/components/lookbook/file_source/component.html.erb +9 -0
- data/app/components/lookbook/file_source/component.rb +73 -0
- data/app/components/lookbook/header/component.html.erb +11 -8
- data/app/components/lookbook/icon/component.css +1 -1
- data/app/components/lookbook/icon/component.html.erb +1 -1
- data/app/components/lookbook/icon/component.rb +4 -1
- data/app/components/lookbook/logo/component.html.erb +6 -0
- data/app/components/lookbook/logo/component.rb +15 -0
- data/app/components/lookbook/message/component.css +33 -0
- data/app/components/lookbook/message/component.html.erb +26 -0
- data/app/components/lookbook/message/component.rb +13 -0
- data/app/components/lookbook/nav/entity/component.html.erb +1 -1
- data/app/components/lookbook/nav/entity/component.rb +1 -1
- data/app/components/lookbook/params/field/component.css +3 -3
- data/app/components/lookbook/prose/component.css +8 -1
- data/app/components/lookbook/prose/component.html.erb +6 -1
- data/app/components/lookbook/prose/component.rb +2 -2
- data/app/controllers/concerns/lookbook/targetable_concern.rb +2 -16
- data/app/controllers/lookbook/application_controller.rb +38 -14
- data/app/controllers/lookbook/embeds_controller.rb +3 -4
- data/app/controllers/lookbook/inspector_controller.rb +4 -12
- data/app/controllers/lookbook/pages_controller.rb +15 -27
- data/app/controllers/lookbook/preview_controller.rb +30 -2
- data/app/controllers/lookbook/previews_controller.rb +13 -15
- data/app/views/layouts/lookbook/application.html.erb +1 -0
- data/app/views/layouts/lookbook/skeleton.html.erb +2 -2
- data/app/views/lookbook/errors/default.html.erb +40 -0
- data/app/views/lookbook/errors/not_found.html.erb +10 -0
- data/app/views/lookbook/index.html.erb +29 -24
- data/app/views/lookbook/pages/show.html.erb +6 -5
- data/app/views/lookbook/partials/_blank_slate.html.erb +7 -0
- data/config/app.yml +8 -0
- data/config/routes.rb +2 -0
- data/lib/lookbook/engine.rb +6 -3
- data/lib/lookbook/entities/concerns/annotatable_entity.rb +26 -1
- data/lib/lookbook/entities/concerns/inspectable_entity.rb +17 -2
- data/lib/lookbook/entities/concerns/locatable_entity.rb +51 -7
- data/lib/lookbook/entities/concerns/navigable_entity.rb +14 -1
- data/lib/lookbook/entities/entity.rb +34 -12
- data/lib/lookbook/entities/page_entity.rb +68 -10
- data/lib/lookbook/entities/page_section_entity.rb +4 -0
- data/lib/lookbook/entities/preview_entity.rb +107 -17
- data/lib/lookbook/entities/renderable_entity.rb +47 -9
- data/lib/lookbook/entities/rendered_scenario_entity.rb +17 -6
- data/lib/lookbook/entities/scenario_entity.rb +77 -16
- data/lib/lookbook/entities/scenario_group_entity.rb +82 -9
- data/lib/lookbook/helpers/page_helper.rb +26 -1
- data/lib/lookbook/helpers/ui_elements_helper.rb +0 -24
- data/lib/lookbook/param.rb +1 -1
- data/lib/lookbook/stores/config_store.rb +0 -12
- data/lib/lookbook/support/errors/config_error.rb +1 -1
- data/lib/lookbook/support/errors/error.rb +64 -0
- data/lib/lookbook/support/errors/parser_error.rb +1 -1
- data/lib/lookbook/support/errors/preview_template_error.rb +1 -1
- data/lib/lookbook/support/errors/routing_error.rb +7 -0
- data/lib/lookbook/support/errors/template_error.rb +7 -0
- data/lib/lookbook/version.rb +1 -1
- data/public/lookbook-assets/css/lookbook.css +374 -53
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/css/themes/blue.css +4 -1
- data/public/lookbook-assets/css/themes/blue.css.map +1 -1
- data/public/lookbook-assets/css/themes/green.css +4 -1
- data/public/lookbook-assets/css/themes/green.css.map +1 -1
- data/public/lookbook-assets/css/themes/indigo.css +4 -1
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
- data/public/lookbook-assets/css/themes/rose.css +4 -1
- data/public/lookbook-assets/css/themes/rose.css.map +1 -1
- data/public/lookbook-assets/css/themes/zinc.css +4 -1
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
- data/public/lookbook-assets/img/lucide-sprite.svg +869 -869
- data/public/lookbook-assets/js/index.js +125 -125
- data/public/lookbook-assets/js/index.js.map +1 -1
- metadata +15 -7
- data/app/views/layouts/lookbook/shell.html.erb +0 -25
- data/app/views/lookbook/404.html.erb +0 -15
- data/app/views/lookbook/error.html.erb +0 -46
- data/lib/lookbook/error.rb +0 -120
- data/lib/lookbook/support/errors/lookbook_error.rb +0 -21
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lookbook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.beta.
|
|
4
|
+
version: 2.0.0.beta.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Perkins
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: css_parser
|
|
@@ -236,6 +236,8 @@ files:
|
|
|
236
236
|
- app/components/lookbook/embed_code_dropdown/component.html.erb
|
|
237
237
|
- app/components/lookbook/embed_code_dropdown/component.js
|
|
238
238
|
- app/components/lookbook/embed_code_dropdown/component.rb
|
|
239
|
+
- app/components/lookbook/file_source/component.html.erb
|
|
240
|
+
- app/components/lookbook/file_source/component.rb
|
|
239
241
|
- app/components/lookbook/filter/component.html.erb
|
|
240
242
|
- app/components/lookbook/filter/component.js
|
|
241
243
|
- app/components/lookbook/filter/component.rb
|
|
@@ -250,6 +252,11 @@ files:
|
|
|
250
252
|
- app/components/lookbook/inspector_panel/component.css
|
|
251
253
|
- app/components/lookbook/inspector_panel/component.html.erb
|
|
252
254
|
- app/components/lookbook/inspector_panel/component.rb
|
|
255
|
+
- app/components/lookbook/logo/component.html.erb
|
|
256
|
+
- app/components/lookbook/logo/component.rb
|
|
257
|
+
- app/components/lookbook/message/component.css
|
|
258
|
+
- app/components/lookbook/message/component.html.erb
|
|
259
|
+
- app/components/lookbook/message/component.rb
|
|
253
260
|
- app/components/lookbook/nav/component.html.erb
|
|
254
261
|
- app/components/lookbook/nav/component.js
|
|
255
262
|
- app/components/lookbook/nav/component.rb
|
|
@@ -311,11 +318,10 @@ files:
|
|
|
311
318
|
- app/helpers/lookbook/application_helper.rb
|
|
312
319
|
- app/views/layouts/lookbook/application.html.erb
|
|
313
320
|
- app/views/layouts/lookbook/embed.html.erb
|
|
314
|
-
- app/views/layouts/lookbook/shell.html.erb
|
|
315
321
|
- app/views/layouts/lookbook/skeleton.html.erb
|
|
316
|
-
- app/views/lookbook/404.html.erb
|
|
317
322
|
- app/views/lookbook/embeds/show.html.erb
|
|
318
|
-
- app/views/lookbook/
|
|
323
|
+
- app/views/lookbook/errors/default.html.erb
|
|
324
|
+
- app/views/lookbook/errors/not_found.html.erb
|
|
319
325
|
- app/views/lookbook/index.html.erb
|
|
320
326
|
- app/views/lookbook/inspector/inputs/_color.html.erb
|
|
321
327
|
- app/views/lookbook/inspector/inputs/_range.html.erb
|
|
@@ -331,6 +337,7 @@ files:
|
|
|
331
337
|
- app/views/lookbook/inspector/panels/_source.html.erb
|
|
332
338
|
- app/views/lookbook/inspector/show.html.erb
|
|
333
339
|
- app/views/lookbook/pages/show.html.erb
|
|
340
|
+
- app/views/lookbook/partials/_blank_slate.html.erb
|
|
334
341
|
- app/views/lookbook/partials/_iframe_content_scripts.html.erb
|
|
335
342
|
- app/views/lookbook/partials/_user_styles.html.erb
|
|
336
343
|
- app/views/lookbook/previews/group.html.erb
|
|
@@ -366,7 +373,6 @@ files:
|
|
|
366
373
|
- lib/lookbook/entities/rendered_scenario_entity.rb
|
|
367
374
|
- lib/lookbook/entities/scenario_entity.rb
|
|
368
375
|
- lib/lookbook/entities/scenario_group_entity.rb
|
|
369
|
-
- lib/lookbook/error.rb
|
|
370
376
|
- lib/lookbook/features.rb
|
|
371
377
|
- lib/lookbook/file_watcher.rb
|
|
372
378
|
- lib/lookbook/helpers/class_names_helper.rb
|
|
@@ -412,9 +418,11 @@ files:
|
|
|
412
418
|
- lib/lookbook/stores/tag_store.rb
|
|
413
419
|
- lib/lookbook/support/deprecation.rb
|
|
414
420
|
- lib/lookbook/support/errors/config_error.rb
|
|
415
|
-
- lib/lookbook/support/errors/
|
|
421
|
+
- lib/lookbook/support/errors/error.rb
|
|
416
422
|
- lib/lookbook/support/errors/parser_error.rb
|
|
417
423
|
- lib/lookbook/support/errors/preview_template_error.rb
|
|
424
|
+
- lib/lookbook/support/errors/routing_error.rb
|
|
425
|
+
- lib/lookbook/support/errors/template_error.rb
|
|
418
426
|
- lib/lookbook/support/evented_file_update_checker.rb
|
|
419
427
|
- lib/lookbook/support/null_object.rb
|
|
420
428
|
- lib/lookbook/support/null_websocket.rb
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<%= content_for :body do %>
|
|
2
|
-
<div
|
|
3
|
-
id="app"
|
|
4
|
-
x-data="app"
|
|
5
|
-
x-cloak
|
|
6
|
-
@popstate.window="handleNavigation"
|
|
7
|
-
@click.document="hijax"
|
|
8
|
-
@navigation:start="closeMobileSidebar"
|
|
9
|
-
class="w-screen h-screen grid grid-rows-[40px_1fr] relative">
|
|
10
|
-
|
|
11
|
-
<% if content_for? :user_styles %>
|
|
12
|
-
<style media="all" id="user-styles">
|
|
13
|
-
<%= content_for :user_styles -%>
|
|
14
|
-
</style>
|
|
15
|
-
<% end %>
|
|
16
|
-
|
|
17
|
-
<%= lookbook_render :header, id: "app-header", debug_menu: @config.debug_menu do |header| %>
|
|
18
|
-
<% header.branding { @config.project_name } %>
|
|
19
|
-
<% end %>
|
|
20
|
-
|
|
21
|
-
<%= content_for?(:shell) ? yield(:shell) : yield %>
|
|
22
|
-
</div>
|
|
23
|
-
<% end %>
|
|
24
|
-
|
|
25
|
-
<%= render template: "layouts/lookbook/skeleton" %>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<div class="bg-white flex flex-col items-center justify-center h-screen w-full">
|
|
2
|
-
<div class="px-4 text-center max-w-sm">
|
|
3
|
-
<%= icon :alert_triangle, size: 10, class: "text-red-300 mx-auto" %>
|
|
4
|
-
<div class="mt-3">
|
|
5
|
-
<h5 class="text-base">
|
|
6
|
-
<%== message %>
|
|
7
|
-
</h5>
|
|
8
|
-
<% if defined?(description) %>
|
|
9
|
-
<p class="mt-2 opacity-50 text-sm">
|
|
10
|
-
<%== description %>
|
|
11
|
-
</p>
|
|
12
|
-
<% end %>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
</div>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
error = error.is_a?(Lookbook::Error) ? error : Lookbook::Error.new(error)
|
|
3
|
-
@title = error.title
|
|
4
|
-
%>
|
|
5
|
-
|
|
6
|
-
<div class="flex flex-col h-screen">
|
|
7
|
-
<div class="h-full bg-red-50 overflow-y-auto">
|
|
8
|
-
<header class="mx-8 py-6">
|
|
9
|
-
<h2 class="text-xl font-bold text-red-700"><%= error.title %></h2>
|
|
10
|
-
</header>
|
|
11
|
-
|
|
12
|
-
<div class="flex-none px-8 py-6 mb-8 border-t border-b border-red-200 bg-red-100 text-base font-mono leading-relaxed">
|
|
13
|
-
<pre class="whitespace-pre-wrap font-sans leading-tight text-red-900"><%= error.message %></pre>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<% if error.file_name %>
|
|
17
|
-
<div class="text-sm mx-8 mb-2 font-mono">
|
|
18
|
-
<span><%= error.file_name %></span>
|
|
19
|
-
<% if error.line_number %>
|
|
20
|
-
<span>[line <strong><%= error.line_number %></strong>]</span>
|
|
21
|
-
<% end %>
|
|
22
|
-
</div>
|
|
23
|
-
<% end %>
|
|
24
|
-
|
|
25
|
-
<% if error.source_code %>
|
|
26
|
-
<div class="mx-8 border border-red-200 max-w-screen-lg">
|
|
27
|
-
<%= lookbook_render :code,
|
|
28
|
-
language: error.file_lang,
|
|
29
|
-
highlight_lines: [error.source_code[:highlighted_line]],
|
|
30
|
-
start_line: error.source_code[:start_line],
|
|
31
|
-
line_numbers: true do %><%= h(error.source_code[:code]) %><% end %>
|
|
32
|
-
</div>
|
|
33
|
-
<% end %>
|
|
34
|
-
|
|
35
|
-
<h3 class="font-bold mb-2 px-8 py-2 mt-8 sticky top-0 bg-red-50">Full stack trace:</h3>
|
|
36
|
-
<div class="text-xs font-mono">
|
|
37
|
-
<div class="px-8 pb-10 text-gray-400 leading-relaxed">
|
|
38
|
-
<% error.backtrace.each do |line| %>
|
|
39
|
-
<div class="hover:text-gray-900 transition-colors duration-100">
|
|
40
|
-
<%= line %>
|
|
41
|
-
</div>
|
|
42
|
-
<% end %>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
data/lib/lookbook/error.rb
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
module Lookbook
|
|
2
|
-
class Error < StandardError
|
|
3
|
-
delegate :full_message, :backtrace, :to_s, to: :original
|
|
4
|
-
|
|
5
|
-
LINES_AROUND = 3
|
|
6
|
-
|
|
7
|
-
def initialize(original = nil, title: nil, message: nil, file_path: nil, file_name: nil, line_number: nil, source_code: nil)
|
|
8
|
-
@original = original
|
|
9
|
-
@title = title
|
|
10
|
-
@message = message
|
|
11
|
-
@file_path = file_path
|
|
12
|
-
@file_name = file_name
|
|
13
|
-
@line_number = line_number
|
|
14
|
-
@source_code = source_code
|
|
15
|
-
super()
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def source_code
|
|
19
|
-
lines = source_code_lines
|
|
20
|
-
|
|
21
|
-
if lines.present? && line_number.is_a?(Integer)
|
|
22
|
-
start_line = source_code_start_line(lines)
|
|
23
|
-
end_line = source_code_end_line(lines)
|
|
24
|
-
highlighted_line = source_code_highlighted_line(lines)
|
|
25
|
-
|
|
26
|
-
line_count = end_line - start_line
|
|
27
|
-
relevant_lines = lines.slice(start_line - 1, line_count + 1)
|
|
28
|
-
if relevant_lines.present?
|
|
29
|
-
empty_start_lines = 0
|
|
30
|
-
relevant_lines.each do |line|
|
|
31
|
-
break unless line.strip.empty?
|
|
32
|
-
empty_start_lines += 1
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
code: relevant_lines.join("\n").lstrip,
|
|
37
|
-
start_line: start_line,
|
|
38
|
-
highlighted_line: highlighted_line - empty_start_lines
|
|
39
|
-
}
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def source_code_lines
|
|
46
|
-
if file_path || @source_code
|
|
47
|
-
if @source_code
|
|
48
|
-
@source_code.split("\n")
|
|
49
|
-
else
|
|
50
|
-
full_path = Rails.root.join(file_path)
|
|
51
|
-
File.read(full_path).split("\n") if File.exist? full_path
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def file_lang
|
|
57
|
-
lang = Lookbook::Lang.guess(file_path)
|
|
58
|
-
lang.present? ? lang[:name] : "plaintext"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def title
|
|
62
|
-
@title || original.class.to_s
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def message
|
|
66
|
-
(@message || original.message).gsub("(<unknown>):", "").strip.upcase_first
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def file_name
|
|
70
|
-
if @file_name == false
|
|
71
|
-
nil
|
|
72
|
-
else
|
|
73
|
-
@file_name || file_path
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def file_path
|
|
78
|
-
path = if @file_path.nil?
|
|
79
|
-
parsed_backtrace[0][0] if parsed_backtrace.any?
|
|
80
|
-
else
|
|
81
|
-
@file_path.presence || nil
|
|
82
|
-
end
|
|
83
|
-
path&.to_s&.delete_prefix("#{Rails.root}/")
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def line_number
|
|
87
|
-
number = if @line_number.nil?
|
|
88
|
-
parsed_backtrace[0][1] if parsed_backtrace.any?
|
|
89
|
-
else
|
|
90
|
-
@line_number.presence || nil
|
|
91
|
-
end
|
|
92
|
-
number.present? ? number.to_i : number
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def parsed_backtrace
|
|
96
|
-
backtrace.map do |x|
|
|
97
|
-
x =~ /^(.+?):(\d+)(|:in `(.+)')$/
|
|
98
|
-
[$1, $2, $4]
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
protected
|
|
103
|
-
|
|
104
|
-
def original
|
|
105
|
-
@original.presence || self
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def source_code_start_line(lines)
|
|
109
|
-
[(line_number - LINES_AROUND), 1].max unless line_number.nil?
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def source_code_end_line(lines)
|
|
113
|
-
[line_number + LINES_AROUND, lines&.size || Infinity].min
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def source_code_highlighted_line(lines)
|
|
117
|
-
[line_number - source_code_start_line(lines) + 1, 1].max unless line_number.nil?
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Lookbook
|
|
2
|
-
class LookbookError < StandardError
|
|
3
|
-
attr_reader :scope, :original, :message
|
|
4
|
-
|
|
5
|
-
def initialize(msg = nil, scope: nil, original: nil)
|
|
6
|
-
@scope = scope
|
|
7
|
-
@original = original
|
|
8
|
-
@message = msg
|
|
9
|
-
super(msg)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def full_message
|
|
13
|
-
if msg.nil?
|
|
14
|
-
message
|
|
15
|
-
else
|
|
16
|
-
scope_str = scope.nil? ? "[#{scope}]" : ""
|
|
17
|
-
"#{scope_str} #{message}".strip
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|