lookbook 1.5.1 → 1.5.3
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 +4 -4
- data/app/controllers/concerns/lookbook/targetable_concern.rb +3 -2
- data/app/controllers/lookbook/previews_controller.rb +22 -4
- data/app/views/layouts/lookbook/application.html.erb +1 -1
- data/app/views/lookbook/preview.html.erb +1 -1
- data/lib/lookbook/engine.rb +10 -0
- data/lib/lookbook/entities/preview_example.rb +4 -0
- data/lib/lookbook/entities/preview_group.rb +4 -0
- data/lib/lookbook/version.rb +1 -1
- data/public/lookbook-assets/css/lookbook.css +357 -355
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/js/embed.js +32 -31
- data/public/lookbook-assets/js/embed.js.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +85 -84
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f540f127ea326803394a4fb256d8ec3f27a9f7564f003d075b5e3b70ccd0ff2
|
4
|
+
data.tar.gz: 7987f3e5caaeb9cc8ebd3e0a38fc3b2735ba3c894207320b612e15075441ac5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4984fbeb06a7ba811cb45a0253fb9391f238c1fbe48e8cb4d2f8b32166e5551c08a9df6116b737423af6ecdd90d13bd91317189d962fc174b32e16b848f21f26
|
7
|
+
data.tar.gz: aadc14cb2bc965a03fbed65fb6824b898449567fc09574974dd4edde3c317fe52ef5ba989b9039f291a34c6ad0673471f22c9b2ce5869567a3e684d78fbdfbbe
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<br>
|
2
|
-
<img src=".github/assets/lookbook_logo.svg" width="180">
|
2
|
+
<img alt="Lookbook Logo" src=".github/assets/lookbook_logo.svg" width="180">
|
3
3
|
|
4
4
|
A tool to help browse, develop, test & document [ViewComponents](https://viewcomponent.org/) in Ruby on Rails apps.
|
5
5
|
|
@@ -25,7 +25,7 @@ A tool to help browse, develop, test & document [ViewComponents](https://viewcom
|
|
25
25
|
|
26
26
|
## Development
|
27
27
|
|
28
|
-
Lookbook is implemented as an isolated [Rails Engine](https://guides.rubyonrails.org/engines.html) and uses [ViewComponent](https://viewcomponent.org), [Tailwind](https://tailwindcss.com/) and [Alpine](https://alpinejs.dev/) for
|
28
|
+
Lookbook is implemented as an isolated [Rails Engine](https://guides.rubyonrails.org/engines.html) and uses [ViewComponent](https://viewcomponent.org), [Tailwind](https://tailwindcss.com/) and [Alpine](https://alpinejs.dev/) for its UI.
|
29
29
|
|
30
30
|
This repository contains:
|
31
31
|
|
@@ -78,9 +78,9 @@ Lookbook was created by [Mark Perkins](https://github.com/allmarkedup) and conti
|
|
78
78
|
<br>
|
79
79
|
<br>
|
80
80
|
<a href="https://github.com/ViewComponent/lookbook/graphs/contributors">
|
81
|
-
<img src="https://contrib.rocks/image?repo=ViewComponent/lookbook&columns=14" width="800" />
|
81
|
+
<img alt="Lookbook contributors" src="https://contrib.rocks/image?repo=ViewComponent/lookbook&columns=14" width="800" />
|
82
82
|
</a>
|
83
83
|
|
84
84
|
## License
|
85
85
|
|
86
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -44,14 +44,15 @@ module Lookbook
|
|
44
44
|
display_params = SearchParamParser.call(params[:_display])
|
45
45
|
display_params.each do |name, value|
|
46
46
|
if @dynamic_display_options.key?(name)
|
47
|
-
cookies["lookbook-display-#{name}"] = value
|
47
|
+
cookies["lookbook-display-#{name}"] = value.is_a?(Array) ? value[1] : value
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
@dynamic_display_options.each do |name, opts|
|
53
53
|
choices = opts.is_a?(Hash) ? opts[:choices].to_a : opts
|
54
|
-
|
54
|
+
value = choices.first.is_a?(Array) ? choices.first[1] : choices.first
|
55
|
+
@static_display_options[name] ||= cookies.fetch("lookbook-display-#{name}", value)
|
55
56
|
end
|
56
57
|
|
57
58
|
unless params[:_display]
|
@@ -3,6 +3,8 @@ module Lookbook
|
|
3
3
|
include TargetableConcern
|
4
4
|
include WithPreviewControllerConcern
|
5
5
|
|
6
|
+
before_action { response.headers.delete("X-Frame-Options") }
|
7
|
+
|
6
8
|
layout "lookbook/inspector"
|
7
9
|
helper Lookbook::PreviewHelper
|
8
10
|
|
@@ -18,10 +20,15 @@ module Lookbook
|
|
18
20
|
{
|
19
21
|
name: preview.name,
|
20
22
|
examples: preview.examples.map { |example|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
case example
|
24
|
+
when Lookbook::PreviewExample
|
25
|
+
example_json(example)
|
26
|
+
when Lookbook::PreviewGroup
|
27
|
+
{
|
28
|
+
name: example.name,
|
29
|
+
examples: example.examples.map { |ex| example_json(ex) }
|
30
|
+
}
|
31
|
+
end
|
25
32
|
}
|
26
33
|
}
|
27
34
|
end
|
@@ -48,5 +55,16 @@ module Lookbook
|
|
48
55
|
show_404 layout: "lookbook/standalone"
|
49
56
|
end
|
50
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def example_json(example)
|
62
|
+
{
|
63
|
+
inspect_path: example.url_path,
|
64
|
+
name: example.name,
|
65
|
+
preview_path: example.preview_path,
|
66
|
+
lookup_path: example.lookup_path
|
67
|
+
}
|
68
|
+
end
|
51
69
|
end
|
52
70
|
end
|
@@ -13,7 +13,7 @@
|
|
13
13
|
}",
|
14
14
|
"@click.outside": "closeMobileSidebar",
|
15
15
|
cloak: true do %>
|
16
|
-
<% cache do %>
|
16
|
+
<% cache Lookbook::Engine.last_changed do %>
|
17
17
|
<%= lookbook_render :split_layout,
|
18
18
|
alpine_data: "$store.layout.#{@pages.any? && @previews.any? ? "sidebar" : "singleSectionSidebar"}",
|
19
19
|
style: "height: calc(100vh - 2.5rem);" do |layout| %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%# Render a group of examples %>
|
3
3
|
<% examples.each do |example| %>
|
4
4
|
<div style="margin-bottom: 30px !important; display: block !important;">
|
5
|
-
<h6 style="all: unset; display: block; color: #
|
5
|
+
<h6 style="all: unset; display: block; color: #555; font-family: sans-serif; font-size: 14px; margin-top: 0; margin-bottom: 10px;">
|
6
6
|
<%= example.label %>
|
7
7
|
</h6>
|
8
8
|
<%= example.output %>
|
data/lib/lookbook/engine.rb
CHANGED
@@ -43,6 +43,7 @@ module Lookbook
|
|
43
43
|
initializer "lookbook.file_watcher.pages" do
|
44
44
|
file_watcher.watch(opts.page_paths, opts.page_extensions) do |changes|
|
45
45
|
Engine.pages.load(Engine.page_paths)
|
46
|
+
Engine.mark_changed
|
46
47
|
Engine.websocket.broadcast(:reload)
|
47
48
|
run_hooks(:after_change, changes)
|
48
49
|
end
|
@@ -51,6 +52,7 @@ module Lookbook
|
|
51
52
|
initializer "lookbook.parser.previews_load_callback" do
|
52
53
|
parser.after_parse do |code_objects|
|
53
54
|
Engine.previews.load(code_objects.all(:class))
|
55
|
+
Engine.mark_changed
|
54
56
|
Engine.websocket.broadcast(:reload)
|
55
57
|
end
|
56
58
|
end
|
@@ -168,6 +170,14 @@ module Lookbook
|
|
168
170
|
@_previews ||= PreviewCollection.new
|
169
171
|
end
|
170
172
|
|
173
|
+
def mark_changed
|
174
|
+
@_last_changed = nil
|
175
|
+
end
|
176
|
+
|
177
|
+
def last_changed
|
178
|
+
@_last_changed ||= (Time.now.to_f * 1000).to_i
|
179
|
+
end
|
180
|
+
|
171
181
|
attr_reader :preview_controller
|
172
182
|
end
|
173
183
|
|
data/lib/lookbook/version.rb
CHANGED