lookbook 2.0.0.beta.2 → 2.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/lookbook/css/fonts.css +33 -0
- data/app/assets/lookbook/css/lookbook.css +7 -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/fonts/Inter-italic.var.woff2 +0 -0
- data/app/assets/lookbook/fonts/Inter-roman.var.woff2 +0 -0
- data/app/assets/lookbook/fonts/SourceCodeVariable-Italic.ttf.woff2 +0 -0
- data/app/assets/lookbook/fonts/SourceCodeVariable-Roman.ttf.woff2 +0 -0
- data/app/assets/lookbook/img/lucide-sprite.svg +869 -869
- data/app/assets/lookbook/js/lib/lookbook.js +12 -2
- 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 +2 -2
- data/app/components/lookbook/nav/entity/component.rb +1 -1
- data/app/components/lookbook/page_tabs/component.html.erb +2 -2
- 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 +9 -8
- 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 +12 -5
- 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/services/markdown_renderer.rb +2 -4
- 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/Inter-italic.var.69eb0fe1.woff2 +0 -0
- data/public/lookbook-assets/Inter-italic.var.736a7044.woff2 +0 -0
- data/public/lookbook-assets/Inter-roman.var.b695afbe.woff2 +0 -0
- data/public/lookbook-assets/Inter-roman.var.fbdd51d0.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Italic.cad97b83.otf +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Italic.ttf.09b4354a.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Italic.ttf.fcd7e9f4.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Roman.185ddb17.otf +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Roman.ttf.118e9f22.woff2 +0 -0
- data/public/lookbook-assets/SourceCodeVariable-Roman.ttf.91043609.woff2 +0 -0
- data/public/lookbook-assets/css/lookbook.css +417 -58
- 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 +173 -173
- data/public/lookbook-assets/js/index.js.map +1 -1
- data/public/lookbook-assets/js/lookbook-core.js +4 -2
- data/public/lookbook-assets/js/lookbook.js +4 -2
- metadata +31 -26
- 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
- data/lib/tasks/lookbook_tasks.rake +0 -10
- data/public/lookbook-assets/css/app.css +0 -2341
- data/public/lookbook-assets/css/app.css.map +0 -11
- data/public/lookbook-assets/css/themes/zinc.css.map.91837.5 +0 -1
- data/public/lookbook-assets/feather-sprite.svg +0 -1
- data/public/lookbook-assets/js/app.js +0 -10862
- data/public/lookbook-assets/js/app.js.map +0 -2571
- data/public/lookbook-assets/js/embed.js +0 -1427
- data/public/lookbook-assets/js/embed.js.91837.6 +0 -0
- data/public/lookbook-assets/js/embed.js.map +0 -1
- data/public/lookbook-assets/js/lookbook-core.js.map +0 -1
- data/public/lookbook-assets/js/lookbook.js.map +0 -1
- data/public/lookbook-assets/lookbook-esm.js +0 -1427
- data/public/lookbook-assets/lookbook-esm.js.map +0 -1
- data/public/lookbook-assets/lookbook-global.js +0 -1427
- data/public/lookbook-assets/lookbook-global.js.map +0 -1
- data/public/lookbook-assets/lookbook.js +0 -1427
- data/public/lookbook-assets/lookbook.js.map +0 -1
@@ -10,7 +10,7 @@ const whiteListedAttributes = [
|
|
10
10
|
"param-*",
|
11
11
|
];
|
12
12
|
|
13
|
-
function initEmbeds() {
|
13
|
+
function initEmbeds(root = document) {
|
14
14
|
if (typeof window.iFrameResize !== "function") {
|
15
15
|
console.error(
|
16
16
|
"Lookbook embeds require the 'iframe-resizer' library to be available. Skipping embed instantiation."
|
@@ -18,7 +18,17 @@ function initEmbeds() {
|
|
18
18
|
return;
|
19
19
|
}
|
20
20
|
|
21
|
-
|
21
|
+
if (typeof root === "string") {
|
22
|
+
root = document.querySelector(root);
|
23
|
+
}
|
24
|
+
|
25
|
+
if (!root) {
|
26
|
+
return console.error(
|
27
|
+
"Could not initialize Lookbook embeds. Root node not found."
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
31
|
+
const embeds = Array.from(root.querySelectorAll("lookbook-embed"));
|
22
32
|
|
23
33
|
embeds.forEach((embed) => {
|
24
34
|
const attrs = Array.from(embed.attributes);
|
@@ -162,14 +162,13 @@
|
|
162
162
|
} /* Comment */
|
163
163
|
.err {
|
164
164
|
color: var(--hl-error-fg);
|
165
|
-
background-color: var(--hl-error-bg);
|
166
165
|
} /* Error */
|
167
166
|
.g {
|
168
167
|
color: var(--hl-subtle-fg);
|
169
168
|
} /* Generic */
|
170
169
|
.k {
|
171
170
|
color: var(--hl-keyword);
|
172
|
-
font-weight:
|
171
|
+
font-weight: 600;
|
173
172
|
} /* Keyword; catches prefixes and css3 */
|
174
173
|
.l {
|
175
174
|
color: var(--hl-subtle-fg);
|
@@ -180,7 +179,7 @@
|
|
180
179
|
} /* Name */
|
181
180
|
.o {
|
182
181
|
color: var(--hl-operator);
|
183
|
-
font-weight:
|
182
|
+
font-weight: 600;
|
184
183
|
} /* Operator */
|
185
184
|
.x {
|
186
185
|
color: var(--hl-subtle-fg);
|
@@ -194,7 +193,7 @@
|
|
194
193
|
} /* Comment.Multiline */
|
195
194
|
.cp {
|
196
195
|
color: var(--hl-comment-preproc);
|
197
|
-
font-weight:
|
196
|
+
font-weight: 600;
|
198
197
|
} /* Comment.Preproc */
|
199
198
|
.c1 {
|
200
199
|
color: var(--hl-comment);
|
@@ -203,7 +202,7 @@
|
|
203
202
|
.cs {
|
204
203
|
color: var(--hl-comment-special-fg);
|
205
204
|
background-color: var(--hl-comment-special-bg);
|
206
|
-
font-weight:
|
205
|
+
font-weight: 600;
|
207
206
|
font-style: italic;
|
208
207
|
} /* Comment.Special */
|
209
208
|
.gd {
|
@@ -232,38 +231,38 @@
|
|
232
231
|
} /* Generic.Prompt */
|
233
232
|
.gs {
|
234
233
|
color: var(--hl-subtle-fg);
|
235
|
-
font-weight:
|
234
|
+
font-weight: 600;
|
236
235
|
} /* Generic.Strong */
|
237
236
|
.gu {
|
238
237
|
color: var(--hl-subheading);
|
239
|
-
font-weight:
|
238
|
+
font-weight: 600;
|
240
239
|
} /* Generic.Subheading */
|
241
240
|
.gt {
|
242
241
|
color: var(--hl-danger);
|
243
242
|
} /* Generic.Traceback */
|
244
243
|
.kc {
|
245
244
|
color: var(--hl-keyword-crude);
|
246
|
-
font-weight:
|
245
|
+
font-weight: 600;
|
247
246
|
} /* Keyword.Constant */
|
248
247
|
.kd {
|
249
248
|
color: var(--hl-keyword-crude);
|
250
|
-
font-weight:
|
249
|
+
font-weight: 600;
|
251
250
|
} /* Keyword.Declaration */
|
252
251
|
.kn {
|
253
252
|
color: var(--hl-keyword-crude);
|
254
|
-
font-weight:
|
253
|
+
font-weight: 600;
|
255
254
|
} /* Keyword.Namespace */
|
256
255
|
.kp {
|
257
256
|
color: var(--hl-keyword-crude);
|
258
|
-
font-weight:
|
257
|
+
font-weight: 600;
|
259
258
|
} /* Keyword.Pseudo */
|
260
259
|
.kr {
|
261
260
|
color: var(--hl-keyword-crude);
|
262
|
-
font-weight:
|
261
|
+
font-weight: 600;
|
263
262
|
} /* Keyword.Reserved */
|
264
263
|
.kt {
|
265
264
|
color: var(--hl-keyword-subtle);
|
266
|
-
font-weight:
|
265
|
+
font-weight: 600;
|
267
266
|
} /* Keyword.Type */
|
268
267
|
.ld {
|
269
268
|
color: var(--hl-subtle-fg);
|
@@ -282,7 +281,7 @@
|
|
282
281
|
} /* Name.Builtin */
|
283
282
|
.nc {
|
284
283
|
color: var(--hl-class);
|
285
|
-
font-weight:
|
284
|
+
font-weight: 600;
|
286
285
|
} /* Name.Class */
|
287
286
|
.no {
|
288
287
|
color: var(--hl-variable);
|
@@ -295,11 +294,11 @@
|
|
295
294
|
} /* Name.Entity */
|
296
295
|
.ne {
|
297
296
|
color: var(--hl-exception);
|
298
|
-
font-weight:
|
297
|
+
font-weight: 600;
|
299
298
|
} /* Name.Exception */
|
300
299
|
.nf {
|
301
300
|
color: var(--hl-function);
|
302
|
-
font-weight:
|
301
|
+
font-weight: 600;
|
303
302
|
} /* Name.Function */
|
304
303
|
.nl {
|
305
304
|
color: var(--hl-subtle-fg);
|
@@ -321,7 +320,7 @@
|
|
321
320
|
} /* Name.Variable */
|
322
321
|
.ow {
|
323
322
|
color: var(--hl-word);
|
324
|
-
font-weight:
|
323
|
+
font-weight: 600;
|
325
324
|
} /* Operator.Word */
|
326
325
|
.w {
|
327
326
|
color: var(--hl-whitespace);
|
@@ -18,13 +18,10 @@ export default function dimensionsDisplayComponent(targetSelector) {
|
|
18
18
|
|
19
19
|
createObserver() {
|
20
20
|
if (this.target) {
|
21
|
-
this.observer = observeSize(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
this.height = height;
|
26
|
-
}
|
27
|
-
);
|
21
|
+
this.observer = observeSize(this.target, ({ width, height }) => {
|
22
|
+
this.width = width;
|
23
|
+
this.height = height;
|
24
|
+
});
|
28
25
|
}
|
29
26
|
},
|
30
27
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class FileSource::Component < Lookbook::BaseComponent
|
3
|
+
attr_reader :file_path, :lines_around_highlight
|
4
|
+
|
5
|
+
def initialize(file_path:, source: nil, highlight_lines: [], lines_around_highlight: nil,
|
6
|
+
start_line: 1, end_line: nil, start_line_number: nil, **html_attrs)
|
7
|
+
@file_path = file_path
|
8
|
+
@source = source
|
9
|
+
@highlight_lines = highlight_lines.map(&:to_i)
|
10
|
+
@start_line = start_line
|
11
|
+
@end_line = end_line
|
12
|
+
@start_line_number = start_line_number
|
13
|
+
@lines_around_highlight = lines_around_highlight
|
14
|
+
super(**html_attrs)
|
15
|
+
end
|
16
|
+
|
17
|
+
def render?
|
18
|
+
source.present?
|
19
|
+
end
|
20
|
+
|
21
|
+
def trimmed_source
|
22
|
+
return unless source.present?
|
23
|
+
|
24
|
+
from = start_line - 1
|
25
|
+
to = end_line - 1
|
26
|
+
source_lines[from..to].join("\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
def source
|
30
|
+
return @source if @source.present?
|
31
|
+
|
32
|
+
@_source ||= File.read(file_path)
|
33
|
+
rescue
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def source_lang
|
38
|
+
lang = Lang.guess(file_path)
|
39
|
+
lang.present? ? lang[:name] : "plaintext"
|
40
|
+
end
|
41
|
+
|
42
|
+
def highlight_lines
|
43
|
+
@highlight_lines.map { |num| num - start_line + 1 }
|
44
|
+
end
|
45
|
+
|
46
|
+
def source_lines
|
47
|
+
@_source_lines ||= source&.split("\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
def start_line
|
51
|
+
if lines_around_highlight && @highlight_lines.any?
|
52
|
+
start = @highlight_lines.first - lines_around_highlight
|
53
|
+
(start > 0) ? start : 1
|
54
|
+
else
|
55
|
+
@start_line
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def start_line_number
|
60
|
+
@start_line_number || start_line
|
61
|
+
end
|
62
|
+
|
63
|
+
def end_line
|
64
|
+
line_count = source_lines.size
|
65
|
+
if lines_around_highlight && @highlight_lines.any?
|
66
|
+
last = @highlight_lines.last + lines_around_highlight
|
67
|
+
(last <= line_count) ? last : line_count
|
68
|
+
else
|
69
|
+
(@end_line && (@end_line <= line_count)) ? @end_line : line_count
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
<%= render_component_tag :header do %>
|
2
2
|
<%= lookbook_render :toolbar, class: "!bg-lookbook-header-bg !text-lookbook-header-text !border-lookbook-header-border" do |toolbar| %>
|
3
3
|
<% toolbar.with_section padded: true do %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
<div class="flex items-center space-x-3">
|
5
|
+
<%= lookbook_render :logo, size: 4 %>
|
6
|
+
<% if branding.present? %>
|
7
|
+
<a
|
8
|
+
<% if landing_path %>href="<%= landing_path %>"<% end %>
|
9
|
+
class="text-sm truncate uppercase font-black tracking-wider text-lookbook-branding-text">
|
10
|
+
<%= branding %>
|
11
|
+
</a>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
11
14
|
<% end %>
|
12
15
|
|
13
16
|
<% toolbar.with_section padded: false, align: :right, class: "flex items-center -mt-px" do %>
|
@@ -22,7 +25,7 @@
|
|
22
25
|
<% if @debug_menu %>
|
23
26
|
<% group.with_button id: "debug-menu-button",
|
24
27
|
icon: :help_circle,
|
25
|
-
class: "
|
28
|
+
class: "!text-lookbook-header-text", "x-show": "!loading" do |button| %>
|
26
29
|
<% menu = lookbook_render :debug_menu,
|
27
30
|
version: Lookbook::VERSION,
|
28
31
|
docs_url: "https://lookbook.build/guide",
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module Lookbook
|
2
2
|
class Icon::Component < Lookbook::BaseComponent
|
3
|
-
|
3
|
+
attr_reader :stroke
|
4
|
+
|
5
|
+
def initialize(name:, size: 4, stroke: 2, **html_attrs)
|
4
6
|
@alpine_data = name.is_a?(Symbol) ? alpine_encode(name.to_s.tr("_", "-")) : name
|
5
7
|
@size = size || 4
|
8
|
+
@stroke = stroke
|
6
9
|
super(**html_attrs)
|
7
10
|
end
|
8
11
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<svg width="<%= size_rems %>" viewBox="0 0 18 22" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<g stroke="currentColor" stroke-width="<%= stroke %>" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
|
3
|
+
<path d="M3.5 1H17v20H3.5A2.5 2.5 0 0 1 1 18.5v-15A2.5 2.5 0 0 1 3.5 1Z"/>
|
4
|
+
<path d="M1.153 19.36c0-.737.261-1.188.596-1.57.417-.475.985-.79 1.751-.79H17M6.801 5.1v7.554L6.8 12.7h5.57"/>
|
5
|
+
</g>
|
6
|
+
</svg>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class Logo::Component < Lookbook::BaseComponent
|
3
|
+
attr_reader :stroke
|
4
|
+
|
5
|
+
def initialize(size: 4, stroke: 2, **html_attrs)
|
6
|
+
@size = size || 4
|
7
|
+
@stroke = stroke
|
8
|
+
super(**html_attrs)
|
9
|
+
end
|
10
|
+
|
11
|
+
def size_rems
|
12
|
+
"#{@size * 0.25}rem"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
@layer components {
|
2
|
+
[data-component="message"] {
|
3
|
+
@apply bg-lookbook-message-bg p-4 xs:p-6 shadow border border-lookbook-divider rounded flex gap-6 w-full;
|
4
|
+
|
5
|
+
&.icon-right {
|
6
|
+
@apply flex-row-reverse items-center;
|
7
|
+
}
|
8
|
+
|
9
|
+
&.icon-left {
|
10
|
+
@apply items-start;
|
11
|
+
}
|
12
|
+
|
13
|
+
& .message-title {
|
14
|
+
@apply text-base text-lookbook-message-title truncate uppercase font-bold tracking-wide mb-2;
|
15
|
+
}
|
16
|
+
|
17
|
+
& .message-icon {
|
18
|
+
@apply flex-none opacity-30 hidden xs:block;
|
19
|
+
}
|
20
|
+
|
21
|
+
&.theme-error {
|
22
|
+
@apply border-red-200;
|
23
|
+
|
24
|
+
& .message-title {
|
25
|
+
@apply text-red-700;
|
26
|
+
}
|
27
|
+
|
28
|
+
& .message-icon {
|
29
|
+
@apply text-red-600 opacity-50;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= render_component_tag class: {
|
2
|
+
"icon-left": (icon_position == :left),
|
3
|
+
"icon-right": (icon_position == :right),
|
4
|
+
"theme-info": (theme == :info),
|
5
|
+
"theme-error": (theme == :error),
|
6
|
+
} do %>
|
7
|
+
<% if icon_name %>
|
8
|
+
<div class="message-icon">
|
9
|
+
<% if icon_name == :logo %>
|
10
|
+
<%= lookbook_render :logo, stroke: 1, size: 10 %>
|
11
|
+
<% else %>
|
12
|
+
<%= icon icon_name, stroke: 1, size: 10 %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
<div class="flex-grow">
|
17
|
+
<% if title %>
|
18
|
+
<h4 class="message-title">
|
19
|
+
<%= title %>
|
20
|
+
</h4>
|
21
|
+
<% end %>
|
22
|
+
<div class="opacity-70">
|
23
|
+
<%= lookbook_render :prose, size: :sm, content: content %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Lookbook
|
2
|
+
class Message::Component < Lookbook::BaseComponent
|
3
|
+
attr_reader :title, :icon_name, :icon_position, :theme
|
4
|
+
|
5
|
+
def initialize(title: nil, icon: nil, icon_position: :left, theme: :info, **html_attrs)
|
6
|
+
@title = title
|
7
|
+
@icon_name = icon
|
8
|
+
@icon_position = icon_position
|
9
|
+
@theme = theme
|
10
|
+
super(**html_attrs)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
key: "#{id}-entity-#{type}",
|
4
4
|
class: "list-none",
|
5
5
|
"x-show": "!filteredOut",
|
6
|
-
data: { "entity-type": type },
|
6
|
+
data: { "entity-type": type.to_s.tr("_","-") },
|
7
7
|
cloak: true do %>
|
8
8
|
<%= lookbook_tag href.present? ? :a : :button,
|
9
9
|
href: href,
|
@@ -17,7 +17,7 @@
|
|
17
17
|
class: "nav-toggle-icon",
|
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 class="truncate <% if node.type == :preview %>font-
|
20
|
+
<span class="truncate <% if node.type == :preview %>font-semibold<% end %>"><%= label %></span>
|
21
21
|
</div>
|
22
22
|
<% end %>
|
23
23
|
|
@@ -2,13 +2,13 @@
|
|
2
2
|
<div class="flex w-full border-b border-lookbook-divider mb-6">
|
3
3
|
<%= lookbook_render :tabs, theme: :page do |t| %>
|
4
4
|
<% @tabs.each do |props| %>
|
5
|
-
<%= t.
|
5
|
+
<%= t.with_tab **props %>
|
6
6
|
<% end %>
|
7
7
|
<% end %>
|
8
8
|
</div>
|
9
9
|
<%= lookbook_render :tab_panels do |t| %>
|
10
10
|
<% @tabs.each do |props| %>
|
11
|
-
<% t.
|
11
|
+
<% t.with_panel name: props[:name] do %>
|
12
12
|
<%= lookbook_render :prose, markdown: props[:markdown], class: "max-w-none flex-none" do %>
|
13
13
|
<%== props[:tab_content] %>
|
14
14
|
<% end %>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
}
|
8
8
|
|
9
9
|
th {
|
10
|
-
@apply font-
|
10
|
+
@apply font-semibold py-4 px-4 align-middle text-left;
|
11
11
|
}
|
12
12
|
|
13
13
|
th.param-label {
|
@@ -29,7 +29,7 @@
|
|
29
29
|
}
|
30
30
|
|
31
31
|
td.param-label {
|
32
|
-
@apply font-
|
32
|
+
@apply font-semibold;
|
33
33
|
}
|
34
34
|
|
35
35
|
.param-input-wrapper {
|
@@ -65,7 +65,7 @@
|
|
65
65
|
}
|
66
66
|
|
67
67
|
td.param-label {
|
68
|
-
@apply font-
|
68
|
+
@apply font-semibold;
|
69
69
|
}
|
70
70
|
|
71
71
|
td.param-description-empty {
|
@@ -1,12 +1,19 @@
|
|
1
1
|
@layer components {
|
2
2
|
[data-component="prose"] {
|
3
|
+
letter-spacing: -0.015em !important;
|
4
|
+
|
3
5
|
[data-component="code"] {
|
4
6
|
@apply border border-lookbook-divider rounded-md;
|
5
7
|
}
|
6
8
|
|
7
9
|
[data-component="embed"],
|
8
|
-
[data-component="code"]
|
10
|
+
[data-component="code"],
|
11
|
+
[data-lookbook-embed] {
|
9
12
|
@apply my-8;
|
10
13
|
}
|
14
|
+
|
15
|
+
[data-lookbook-embed] {
|
16
|
+
@apply rounded-md;
|
17
|
+
}
|
11
18
|
}
|
12
19
|
}
|
@@ -1,3 +1,8 @@
|
|
1
|
-
<%= render_component_tag class: "
|
1
|
+
<%= render_component_tag class: "
|
2
|
+
prose #{size_class}
|
3
|
+
text-lookbook-prose-text bg-lookbook-prose-bg prose-a:text-lookbook-prose-link
|
4
|
+
prose-headings:font-semibold
|
5
|
+
prose-h1:font-bold
|
6
|
+
" do %>
|
2
7
|
<%== rendered_content %>
|
3
8
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Lookbook
|
2
2
|
class Prose::Component < Lookbook::BaseComponent
|
3
|
-
def initialize(size: :
|
3
|
+
def initialize(size: :sm, markdown: true, **html_attrs)
|
4
4
|
@size = size
|
5
5
|
@markdown = markdown
|
6
6
|
super(**html_attrs)
|
@@ -17,7 +17,7 @@ module Lookbook
|
|
17
17
|
when :lg
|
18
18
|
"prose-lg"
|
19
19
|
else
|
20
|
-
""
|
20
|
+
"prose-sm lg:prose-base"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -66,7 +66,8 @@ module Lookbook
|
|
66
66
|
@params = []
|
67
67
|
|
68
68
|
if @target
|
69
|
-
|
69
|
+
param_tags = @target.tags("param").uniq(&:name)
|
70
|
+
@params = param_tags.map do |param_tag|
|
70
71
|
Param.from_tag(
|
71
72
|
param_tag,
|
72
73
|
value: preview_controller.params[param_tag.name]
|
@@ -115,21 +116,6 @@ module Lookbook
|
|
115
116
|
})
|
116
117
|
end
|
117
118
|
|
118
|
-
def show_404(layout: nil)
|
119
|
-
locals = if @preview
|
120
|
-
{
|
121
|
-
message: "Example not found",
|
122
|
-
description: "The '#{@preview.label}' preview does not have an scenario named '#{path_segments.last}'."
|
123
|
-
}
|
124
|
-
else
|
125
|
-
{
|
126
|
-
message: "Not found",
|
127
|
-
description: "Looked for '#{params[:path]}'.<br>The preview may have been renamed or deleted."
|
128
|
-
}
|
129
|
-
end
|
130
|
-
render_in_layout "lookbook/404", layout: layout, **locals, status: 404
|
131
|
-
end
|
132
|
-
|
133
119
|
def path_segments
|
134
120
|
params[:path].split("/")
|
135
121
|
end
|
@@ -4,13 +4,20 @@ module Lookbook
|
|
4
4
|
|
5
5
|
protect_from_forgery with: :exception
|
6
6
|
|
7
|
+
layout "lookbook/application"
|
8
|
+
|
7
9
|
helper Lookbook::ClassNamesHelper if Engine.runtime_context.rails_older_than?("6.1.0")
|
8
10
|
helper Lookbook::ApplicationHelper
|
9
11
|
helper Lookbook::UiElementsHelper
|
10
12
|
|
11
|
-
before_action :
|
13
|
+
before_action :assign_theme_overrides
|
12
14
|
before_action :assign_instance_vars
|
13
15
|
|
16
|
+
rescue_from ActionController::RoutingError do |err|
|
17
|
+
raise Lookbook::RoutingError, err.message, original: err
|
18
|
+
end
|
19
|
+
rescue_from StandardError, with: :handle_error
|
20
|
+
|
14
21
|
def self.controller_path
|
15
22
|
"lookbook"
|
16
23
|
end
|
@@ -24,9 +31,13 @@ module Lookbook
|
|
24
31
|
end
|
25
32
|
end
|
26
33
|
|
34
|
+
def not_found
|
35
|
+
raise_not_found
|
36
|
+
end
|
37
|
+
|
27
38
|
protected
|
28
39
|
|
29
|
-
def
|
40
|
+
def assign_theme_overrides
|
30
41
|
@theme_overrides ||= Engine.theme.to_css
|
31
42
|
end
|
32
43
|
|
@@ -37,23 +48,36 @@ module Lookbook
|
|
37
48
|
@config = Lookbook.config
|
38
49
|
@engine = Lookbook.engine
|
39
50
|
@embed = !!params[:lookbook_embed]
|
51
|
+
@blank_slate = Engine.pages.none? && Engine.previews.none?
|
40
52
|
end
|
41
53
|
|
42
|
-
def
|
43
|
-
|
44
|
-
render path, layout: layout.presence || (params[:lookbook_embed] ? "lookbook/basic" : "lookbook/application"), locals: locals
|
54
|
+
def raise_not_found(message = "Page not found")
|
55
|
+
raise Lookbook::RoutingError, message
|
45
56
|
end
|
46
57
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
def handle_error(err)
|
59
|
+
@error = err.is_a?(Lookbook::Error) ? err : Lookbook::Error.new(original: err)
|
60
|
+
@status_code = get_status_code(err)
|
61
|
+
|
62
|
+
view = (@status_code == :not_found) ? "not_found" : "default"
|
63
|
+
layout = current_layout || "lookbook/skeleton"
|
64
|
+
|
65
|
+
render "lookbook/errors/#{view}", layout: layout, status: @status_code
|
66
|
+
end
|
67
|
+
|
68
|
+
def current_layout
|
69
|
+
self.class.send(:_layout)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def get_status_code(err)
|
75
|
+
if err.respond_to?(:status)
|
76
|
+
err.status
|
77
|
+
else
|
78
|
+
status_map = ActionDispatch::ExceptionWrapper.rescue_responses
|
79
|
+
status_map.fetch(err.class.name, :internal_server_error)
|
55
80
|
end
|
56
|
-
Lookbook::Error.new(exception, **error_params)
|
57
81
|
end
|
58
82
|
end
|
59
83
|
end
|