lookbook 3.0.0.alpha.1 → 3.0.0.alpha.2
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 +8 -261
- data/app/components/lookbook/ui/app/router/router.html.erb +1 -0
- data/app/components/lookbook/ui/app/router/router.js +29 -3
- data/app/components/lookbook/ui/elements/nav/nav_item/nav_item.js +2 -4
- data/app/components/lookbook/ui/elements/viewport/viewport.css +1 -0
- data/app/components/lookbook/ui/elements/viewport/viewport.html.erb +0 -1
- data/app/components/lookbook/ui/elements/viewport/viewport.rb +1 -6
- data/app/components/lookbook/ui/previews/preview_embed/preview_embed.html.erb +1 -2
- data/app/components/lookbook/ui/previews/preview_embed/preview_embed.rb +5 -4
- data/app/components/lookbook/ui/previews/preview_inspector/preview_inspector.html.erb +2 -2
- data/app/components/lookbook/ui/previews/preview_inspector/preview_inspector.rb +3 -2
- data/app/controllers/lookbook/events_controller.rb +4 -0
- data/app/controllers/lookbook/previews_controller.rb +1 -1
- data/app/views/layouts/lookbook/embed.html.erb +1 -1
- data/app/views/lookbook/inspector/panels/_preview.html.erb +1 -2
- data/app/views/lookbook/previews/embed.html.erb +1 -1
- data/app/views/lookbook/previews/inspect.html.erb +1 -0
- data/app/views/lookbook/previews/scenario.html.erb +5 -1
- data/config/initializers/05_autoload_previews.rb +2 -2
- data/config/routes.rb +2 -1
- data/lib/lookbook/concerns/feature_checks.rb +17 -0
- data/lib/lookbook/config.rb +2 -3
- data/lib/lookbook/directory_entity.rb +72 -0
- data/lib/lookbook/engine.rb +1 -1
- data/lib/lookbook/entity.rb +4 -2
- data/lib/lookbook/entity_tree.rb +17 -2
- data/lib/lookbook/pages/page_directories.rb +20 -0
- data/lib/lookbook/pages/page_directory_entity.rb +9 -40
- data/lib/lookbook/pages/page_entity.rb +4 -2
- data/lib/lookbook/pages/pages.rb +5 -14
- data/lib/lookbook/previews/preview_directories.rb +20 -0
- data/lib/lookbook/previews/preview_directory_entity.rb +8 -35
- data/lib/lookbook/previews/preview_entity.rb +7 -8
- data/lib/lookbook/previews/previews.rb +14 -15
- data/lib/lookbook/previews/scenario_entity.rb +1 -1
- data/lib/lookbook/reloader.rb +3 -6
- data/lib/lookbook/services/list_resolver.rb +13 -2
- data/lib/lookbook/services/styles_extractor.rb +1 -1
- data/lib/lookbook/utils.rb +4 -0
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +0 -1
- data/public/lookbook-assets/app.css +2 -0
- data/public/lookbook-assets/app.js +48 -8
- metadata +6 -17
- data/lib/lookbook/previews/tags/priority_tag.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e001a0495be9b2addbeb92aaf82dfa6152b19e3f038c9cb4846ef9cccbc938e3
|
4
|
+
data.tar.gz: b59f9ddfd438cd2e38d7a99d0196f0a8e98aa2355a50db0ba7e34e253b4cd1e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4175c9a8b770a18d9b873e94a607f52666cb66be489f9c7e6abf57c5edbc6249a3c54bccc2820efbf2f06a9dd70fd63e8c429eb51d102d905895336eaaf924c5
|
7
|
+
data.tar.gz: d4e4ad273d84d352f765cb7398e4e6b927fa094fd6b4ae9831855b90386c9df91cd6357cf1a98e90ad2de02ae62f1f066f41620e3d83641f5aa9ef3c1e501f97
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
This branch contains a work-in-progress, exploratory, from-scratch rebuild of Lookbook, intended to form the basis of a future v3.0 release.
|
8
8
|
|
9
|
-
[Demo](#demo-site) ・ [
|
9
|
+
[Demo](#demo-site) ・ [Documentation](#documentation) ・ [Development](#development)
|
10
10
|
|
11
11
|

|
12
12
|
|
@@ -16,53 +16,15 @@ You can find a hosted version of the [demo/test app](#demo-app) here: https://v3
|
|
16
16
|
|
17
17
|
This pulls directly from the `v3` development branch and so may occasionally be broken.
|
18
18
|
|
19
|
-
##
|
19
|
+
## Documentation
|
20
20
|
|
21
|
-
|
21
|
+
v3-specific documentation is still very much a work in progress. The pages below should provide enough information if you wish to install the latest alpha release and test out some of the new features.
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
* Ruby >= 3.0.0
|
30
|
-
* Rails >= 6.1.0
|
31
|
-
|
32
|
-
### Installation
|
33
|
-
|
34
|
-
Add Lookbook to the `development` group in your Gemfile:
|
35
|
-
|
36
|
-
```rb
|
37
|
-
group :development do
|
38
|
-
gem "lookbook", github: "lookbook-hq/lookbook", branch: "v3"
|
39
|
-
gem "listen" # Required for 'live' UI updates when file changes are detected
|
40
|
-
end
|
41
|
-
```
|
42
|
-
|
43
|
-
Lookbook will automatically be mounted at `/lookbook` within your app when the server is started.
|
44
|
-
|
45
|
-
> 🚨 Previously Lookbook required manual mounting in your app. This is **no longer the case**, so if trialing v3 in a project with an existing Lookbook install you must remove [the mounting code](https://lookbook.build/guide/installation#step-2) from your routes.rb file first.
|
46
|
-
|
47
|
-
### Configuration
|
48
|
-
|
49
|
-
The currently implemented v3 configuration options are not yet documented, but can be seen in the [config.rb](lib/lookbook/config.rb) file.
|
50
|
-
|
51
|
-
> 🚨 If testing out the v3 branch on an existing Lookbook install you may see errors if setting v2.x config options that have not yet been re-implemented in v3.
|
52
|
-
|
53
|
-
### Breaking changes
|
54
|
-
|
55
|
-
Lookbook v3.0 will contain a number of breaking changes from the v2.x releases.
|
56
|
-
|
57
|
-
The majority of these changes will be in the _extending_, _theming_ and _API_ areas, so heavily customised Lookbook installations may find upgrading a more involved process. As yet there is no documentation on the exact scope of these changes.
|
58
|
-
|
59
|
-
In addition, until v3 development reaches beta release stage there are likely to be _unintentional breaking changes_ due to missing or partly-implemented features.
|
60
|
-
|
61
|
-
For these reasons, it is recommended that anyone who wants to kick the tyres on the pre-alpha v3 codebase do so **on new projects** or **existing projects with simple, 'vanilla' Lookbook installs** to minimise the chance of running into issues.
|
62
|
-
|
63
|
-
### Running in production
|
64
|
-
|
65
|
-
Please don't do this. It's really not ready yet.
|
23
|
+
* [Installing/Upgrading](./docs/alpha/01_usage.md)
|
24
|
+
* [New features](./docs/alpha/02_new_features.md)
|
25
|
+
* [Background and motivation](./docs/alpha/03_motivation.md)
|
26
|
+
* [Development status](./docs/alpha/08_status.md)
|
27
|
+
* [Troubleshooting/Known issues](./docs/alpha/09_troubleshooting.md)
|
66
28
|
|
67
29
|
## Development
|
68
30
|
|
@@ -141,221 +103,6 @@ If you want to disable `Lookbook` logging, set
|
|
141
103
|
Lookbook.logger = ::Logger.new('/dev/null')
|
142
104
|
```
|
143
105
|
|
144
|
-
## v3 rebuild - background and motivation
|
145
|
-
|
146
|
-
The current Lookbook codebase has grown organically and haphazardly from a few custom ViewComponent preview templates into a standalone Rails Engine gem with support for previewing many different types of components and views.
|
147
|
-
|
148
|
-
In order to provide a solid foundation for future development this v3 branch was created with aspirations to improve the quality of the Lookbook codebase, reduce the number of third party dependencies, fix long-standing issues that are hard to address in the current implementation
|
149
|
-
and explore building out new (and experimental) feature ideas.
|
150
|
-
|
151
|
-
More concretely, a number of **key goals** are helping shape the development work:
|
152
|
-
|
153
|
-
#### UI
|
154
|
-
|
155
|
-
* Improve accessibilty and usability of the app (#17)
|
156
|
-
* Expose a better theming system using CSS variables (with light and dark modes out of the box)
|
157
|
-
* Replace ViewComponent dependency with bespoke component system for building the UI
|
158
|
-
|
159
|
-
#### Previews
|
160
|
-
|
161
|
-
* Add support for ActionMailer previews (#570)
|
162
|
-
* Implement customisable preview overview/documentation pages
|
163
|
-
* Fix compatability issues with partial/view template previews (#581, #555)
|
164
|
-
* Improve handling and logging of parser errors (#593)
|
165
|
-
|
166
|
-
#### Preview embeds
|
167
|
-
|
168
|
-
* Add more granualar security configuration options for embed iframes (#571)
|
169
|
-
* Implement `<lookbook-embed></lookbook-embed>` as a native web component
|
170
|
-
|
171
|
-
#### Pages
|
172
|
-
|
173
|
-
* Make it easier to customise the look and feel of pages
|
174
|
-
* Expand set of UI and path helpers available in pages
|
175
|
-
|
176
|
-
#### Development/Testing
|
177
|
-
|
178
|
-
* Streamline Lookbook development process - runnable test/demo/development app, simpler asset dev/build pipeline
|
179
|
-
* Improve test setup - switch to Minitest, run tests against demo app, better integration test coverage
|
180
|
-
* Make logging play nicer with standard Rails logging options and third party gems
|
181
|
-
|
182
|
-
#### Other
|
183
|
-
|
184
|
-
* Remove ActionCable requirement, use SSE for live UI updates in dev
|
185
|
-
* Improve error handling and compatability with `better_errors` etc (#528)
|
186
|
-
* Remove some of the madness from codebase 🙈
|
187
|
-
|
188
|
-
## v3 rebuild - Current status
|
189
|
-
|
190
|
-
Lookbook v3 is currently in a pre-alpha stage and is under active, exploratory development.
|
191
|
-
|
192
|
-
The 'todo' list below is intended to provide a _very rough_ overview of the current state of progress. **It is not exhaustive**. Checked off items may still be revisited/refactored/removed in the future without warning.
|
193
|
-
|
194
|
-
**Emoji key:**
|
195
|
-
|
196
|
-
* 🆕 - New feature in v3
|
197
|
-
* 🚧 - In progress or implemented but incomplete
|
198
|
-
* 🧪 - Experimental feature/implementation
|
199
|
-
|
200
|
-
### UI
|
201
|
-
|
202
|
-
#### General
|
203
|
-
|
204
|
-
* [x] Basic desktop UI implementation
|
205
|
-
* [x] Replace Tailwind with vanilla CSS
|
206
|
-
* [x] Bespoke component system to replace ViewComponent
|
207
|
-
* [x] Status bar 🆕 🚧
|
208
|
-
* [x] Notifications for parser errors
|
209
|
-
* [x] SSE-based live UI updating 🧪
|
210
|
-
* [x] Expand nav to current item when opening app
|
211
|
-
* [x] Don't fetch/render entire DOM on navigation (no need to re-render sidebar etc)
|
212
|
-
* [ ] Improve accessibilty (exact requirements tbd)
|
213
|
-
* [ ] Mobile/small screen layout optimisations
|
214
|
-
* [ ] Side-dockable preview inspector drawer
|
215
|
-
* [ ] Search fields 'clear' buttons
|
216
|
-
* [ ] Use custom icon sprite instead of inlined icons
|
217
|
-
|
218
|
-
#### Code samples
|
219
|
-
|
220
|
-
* [x] Syntax highlighting 🆕 🚧 🧪
|
221
|
-
* [ ] Replace Shiki with something lighter (server-side?)
|
222
|
-
* [ ] Click to copy
|
223
|
-
* [ ] Line wrap toggle
|
224
|
-
|
225
|
-
#### Theming/branding
|
226
|
-
|
227
|
-
* [x] Light/dark mode themes + toggle 🆕 🚧
|
228
|
-
* [x] Project links in header 🆕
|
229
|
-
* [ ] Theme system based on CSS custom properties 🚧
|
230
|
-
* [ ] Project logo customisation
|
231
|
-
|
232
|
-
### Previews
|
233
|
-
|
234
|
-
#### Preview types
|
235
|
-
|
236
|
-
* [x] ViewComponent previews
|
237
|
-
* [x] Phlex previews
|
238
|
-
* [x] Partials/templates previews
|
239
|
-
* [x] ActionMailer previews 🆕 🧪
|
240
|
-
|
241
|
-
#### Tags/annotations
|
242
|
-
|
243
|
-
* [x] Notes
|
244
|
-
* [x] `@label`
|
245
|
-
* [x] `@hidden`
|
246
|
-
* [x] `@param`
|
247
|
-
* [x] `@display`
|
248
|
-
* [x] `@!group ... @!endgroup`
|
249
|
-
* [x] `@id` 🆕
|
250
|
-
* [x] `@priority` 🆕
|
251
|
-
* [x] `@location/@logical_path`
|
252
|
-
* [ ] `@component/@renders`
|
253
|
-
* [ ] `@source`
|
254
|
-
* [ ] `@after_render`
|
255
|
-
* [ ] `@status/@wip` ?
|
256
|
-
|
257
|
-
#### Dynamic params
|
258
|
-
|
259
|
-
* [x] Text input
|
260
|
-
* [x] Textarea input
|
261
|
-
* [x] Select input
|
262
|
-
* [x] Checkbox input 🆕
|
263
|
-
* [ ] Toggle input
|
264
|
-
* [ ] Color picker input
|
265
|
-
* [ ] Range input
|
266
|
-
|
267
|
-
#### Display options
|
268
|
-
|
269
|
-
* [x] Static display options
|
270
|
-
* [x] Dynamic display options
|
271
|
-
|
272
|
-
#### Inspector
|
273
|
-
|
274
|
-
* [x] Preview panel
|
275
|
-
* [x] Output panel
|
276
|
-
* [x] Usage panel (combination of old 'source' and 'notes' panels)
|
277
|
-
* [x] Metadata panel 🚧 🆕 🧪
|
278
|
-
* [x] Params panel 🚧
|
279
|
-
* [ ] Configurable breakpoints for quick preview viewport resizing
|
280
|
-
* [ ] Embed code dropdown
|
281
|
-
* [ ] Preview URL copy button
|
282
|
-
* [ ] Manual preview refresh button
|
283
|
-
|
284
|
-
#### Other
|
285
|
-
|
286
|
-
* [x] Grouped scenarios
|
287
|
-
* [x] Preview overview pages 🚧 🆕
|
288
|
-
* [x] Custom preview controllers support
|
289
|
-
* [x] Custom preview layouts support
|
290
|
-
* [x] Preview parser error reporting
|
291
|
-
* [x] Render previews in parent app context to fix path helper issues
|
292
|
-
* [x] JSON endpoint
|
293
|
-
* [x] ActionView annotation stripping
|
294
|
-
* [ ] Option to specify order of preview directories in nav (i.e. non-alphabetical)
|
295
|
-
* [ ] Output transformation
|
296
|
-
|
297
|
-
### Preview Embeds
|
298
|
-
|
299
|
-
* [x] `<lookbook-embed>` implemented as HTML custom element
|
300
|
-
* [x] Internal embeds (within pages in Lookbook)
|
301
|
-
* [ ] External embeds (outside of Lookbook)
|
302
|
-
* [ ] Configurable frame ancestors
|
303
|
-
|
304
|
-
### Pages
|
305
|
-
|
306
|
-
* [x] Basic markdown + ERB pages system
|
307
|
-
* [x] YAML Frontmatter config
|
308
|
-
* [x] Landing page
|
309
|
-
* [ ] Tabbed pages
|
310
|
-
* [ ] Page layout and styling options 🚧
|
311
|
-
|
312
|
-
### Extending
|
313
|
-
|
314
|
-
* [x] Custom inspector panels 🚧
|
315
|
-
* [ ] Custom param inputs
|
316
|
-
* [ ] Custom tags
|
317
|
-
* [ ] Lifecycle hooks
|
318
|
-
* [ ] Global data store
|
319
|
-
* [ ] Ruby API
|
320
|
-
|
321
|
-
### Development
|
322
|
-
|
323
|
-
* [x] Replace Parcel with PostCSS + esbuild for compiling assets
|
324
|
-
* [x] Runnable, bundled demo app for development
|
325
|
-
* [x] Minitest test suite setup
|
326
|
-
* [x] Setup GH actions CI
|
327
|
-
* [ ] Comprehensive set of test components + previews 🚧
|
328
|
-
* [ ] UI integration tests 🚧
|
329
|
-
* [ ] Set up Ruby & Rails versions test matrix via Appraisal
|
330
|
-
* [ ] Release script (automate from GH?)
|
331
|
-
|
332
|
-
### Internals
|
333
|
-
|
334
|
-
* [x] Auto-mounting of Lookbook engine 🆕
|
335
|
-
* [x] Remove ActionCable dependency, use SSE for triggering UI live updates 🆕 🧪
|
336
|
-
* [x] File change detection system
|
337
|
-
* [x] Config options defined in Ruby and not YAML
|
338
|
-
* [x] Config options synced with ViewComponent where appropriate
|
339
|
-
* [x] UUID-based permalink endpoint 🆕 🧪
|
340
|
-
* [x] Improved logger implementation
|
341
|
-
* [ ] Rationalise & document entity method names
|
342
|
-
* [ ] Make debug logging more consitent
|
343
|
-
* [ ] Improve parsing/tree building performance
|
344
|
-
|
345
|
-
### Documentation
|
346
|
-
|
347
|
-
* [ ] Switch to Nanoc for static docs building?
|
348
|
-
* [ ] Document new features in v3
|
349
|
-
* [ ] Port and update existing docs to new docs site
|
350
|
-
* [ ] Automate config option documentation via YARD
|
351
|
-
* [ ] Automate API docs via YARD
|
352
|
-
* [ ] Set up automated build & deploy process for docs
|
353
|
-
|
354
|
-
### Other/Ideas/Maybe
|
355
|
-
|
356
|
-
* [ ] CLI tool
|
357
|
-
* [ ] JSON API
|
358
|
-
|
359
106
|
## License
|
360
107
|
|
361
108
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -7,6 +7,8 @@ export default AlpineComponent("router", (sseEndpoint = null) => {
|
|
7
7
|
return {
|
8
8
|
serverEventsListener: null,
|
9
9
|
routerLogger: null,
|
10
|
+
lastUpdate: Date.now(),
|
11
|
+
morphing: false,
|
10
12
|
|
11
13
|
init() {
|
12
14
|
this.routerLogger = new Logger("Router");
|
@@ -29,6 +31,7 @@ export default AlpineComponent("router", (sseEndpoint = null) => {
|
|
29
31
|
await this.updateDOM(location, "router", {
|
30
32
|
headers: { "X-Lookbook-Frame": "root" },
|
31
33
|
});
|
34
|
+
this.lastUpdate = Date.now();
|
32
35
|
this.routerLogger.info(`Page updated`);
|
33
36
|
this.$dispatch("page-update:complete");
|
34
37
|
},
|
@@ -41,16 +44,34 @@ export default AlpineComponent("router", (sseEndpoint = null) => {
|
|
41
44
|
if (updateHistory) {
|
42
45
|
history.pushState({}, "", result.url);
|
43
46
|
}
|
47
|
+
this.lastUpdate = Date.now();
|
44
48
|
this.routerLogger.debug(`Page loaded`);
|
45
49
|
this.$dispatch("page-load:complete");
|
46
50
|
},
|
47
51
|
|
52
|
+
async handleError(error) {
|
53
|
+
if (this.morphing) {
|
54
|
+
const { stack } = error.error;
|
55
|
+
if (stack.indexOf("Alpine") >= 0) {
|
56
|
+
window.location.reload();
|
57
|
+
}
|
58
|
+
}
|
59
|
+
},
|
60
|
+
|
48
61
|
async updateDOM(url, selector, options = {}) {
|
62
|
+
if (this.morphing) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
|
49
66
|
const result = await fetchHTML(url, selector, options);
|
50
67
|
if (result.status < 500) {
|
68
|
+
this.morphing = true;
|
51
69
|
document.dispatchEvent(new CustomEvent("morph:start"));
|
52
70
|
Alpine.morph(document.querySelector(selector), result.fragment);
|
53
|
-
|
71
|
+
this.$nextTick(() => {
|
72
|
+
document.dispatchEvent(new CustomEvent("morph:complete"));
|
73
|
+
this.morphing = false;
|
74
|
+
});
|
54
75
|
} else {
|
55
76
|
location.href = url;
|
56
77
|
}
|
@@ -69,8 +90,13 @@ export default AlpineComponent("router", (sseEndpoint = null) => {
|
|
69
90
|
}
|
70
91
|
},
|
71
92
|
|
72
|
-
handleVisibilityChange() {
|
73
|
-
if (this.serverEventsListener && !document.hidden)
|
93
|
+
async handleVisibilityChange() {
|
94
|
+
if (this.serverEventsListener && !document.hidden) {
|
95
|
+
const response = await fetch(`${sseEndpoint}/ping`);
|
96
|
+
const lastServerUpdate = Date.parse(await response.text());
|
97
|
+
|
98
|
+
if (lastServerUpdate > this.lastUpdate) this.updatePage();
|
99
|
+
}
|
74
100
|
},
|
75
101
|
|
76
102
|
destroy() {
|
@@ -3,12 +3,14 @@ import { getData } from "@js/alpine/utils";
|
|
3
3
|
|
4
4
|
export default AlpineComponent("navItem", ({ keywords, collection }) => {
|
5
5
|
return {
|
6
|
+
key: null,
|
6
7
|
keywords: [],
|
7
8
|
isCollection: false,
|
8
9
|
filteredOut: false,
|
9
10
|
selected: false,
|
10
11
|
|
11
12
|
init() {
|
13
|
+
this.key = this.$el.getAttribute("key");
|
12
14
|
this.keywords = keywords || [];
|
13
15
|
this.isCollection = collection || false;
|
14
16
|
this.setSelectionState();
|
@@ -52,10 +54,6 @@ export default AlpineComponent("navItem", ({ keywords, collection }) => {
|
|
52
54
|
return this.$root.getAttribute("data-url");
|
53
55
|
},
|
54
56
|
|
55
|
-
get key() {
|
56
|
-
return this.$root.getAttribute("key");
|
57
|
-
},
|
58
|
-
|
59
57
|
get expanded() {
|
60
58
|
return (
|
61
59
|
this.expandedItems && this.key && this.expandedItems.includes(this.key)
|
@@ -3,18 +3,13 @@ module Lookbook
|
|
3
3
|
class Viewport < BaseComponent
|
4
4
|
attr_reader :id, :src
|
5
5
|
|
6
|
-
def initialize(id:, src:,
|
6
|
+
def initialize(id:, src:, resize_x: true, resize_y: true, **kwargs)
|
7
7
|
@id = id
|
8
8
|
@src = src
|
9
|
-
@srcdoc = srcdoc
|
10
9
|
@resize_x = resize_x
|
11
10
|
@resize_y = resize_y
|
12
11
|
end
|
13
12
|
|
14
|
-
def srcdoc
|
15
|
-
@srcdoc&.gsub("&", "&")&.gsub("\"", """)
|
16
|
-
end
|
17
|
-
|
18
13
|
def resize_x? = @resize_x
|
19
14
|
|
20
15
|
def resize_y? = @resize_y
|
@@ -25,7 +25,6 @@
|
|
25
25
|
|
26
26
|
lb_viewport(
|
27
27
|
target.preview_path(preview_params),
|
28
|
-
srcdoc: preview_html,
|
29
28
|
id: "embed-viewport-#{target.name}",
|
30
29
|
resize_y: false
|
31
30
|
)
|
@@ -44,7 +43,7 @@
|
|
44
43
|
|
45
44
|
panels.each do |panel|
|
46
45
|
pane.with_tab_panel(panel.name, key: "embed-panel-#{target.name}-#{panel.name}", label: panel.label) do
|
47
|
-
render panel.partial, preview: preview, target: target, panel: panel
|
46
|
+
render panel.partial, preview: preview, target: target, panel: panel, preview_html: preview_html, **panel.locals
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -1,22 +1,23 @@
|
|
1
1
|
module Lookbook
|
2
2
|
module UI
|
3
3
|
class PreviewEmbed < BaseComponent
|
4
|
-
attr_reader :preview, :target, :targets, :panels, :
|
4
|
+
attr_reader :preview, :target, :targets, :panels, :preview_html, :display_options, :display_options_values
|
5
5
|
|
6
|
-
def initialize(preview:, target:,
|
6
|
+
def initialize(preview:, target:, targets: [], panels: [], preview_params: {}, preview_html: nil, display_options: {}, display_options_values: {}, **kwargs)
|
7
7
|
@preview = preview
|
8
8
|
@target = target
|
9
9
|
@targets = targets
|
10
10
|
@panels = panels
|
11
|
-
@preview_html = preview_html
|
12
11
|
@preview_params = preview_params
|
12
|
+
@preview_html = preview_html
|
13
13
|
@display_options = display_options
|
14
14
|
@display_options_values = display_options_values
|
15
15
|
end
|
16
16
|
|
17
17
|
def preview_params
|
18
18
|
@preview_params.merge({
|
19
|
-
_lookbook_embed: true
|
19
|
+
_lookbook_embed: true,
|
20
|
+
checksum: helpers.checksum(preview_html)
|
20
21
|
})
|
21
22
|
end
|
22
23
|
end
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
preview_panels.each do |panel|
|
42
42
|
pane.with_tab_panel(panel.name, key: "inspector-panel-#{@target.name}-#{panel.name}", label: panel.label) do
|
43
|
-
render panel.partial, preview: preview, target: target, panel: panel, **panel.locals
|
43
|
+
render panel.partial, preview: preview, target: target, panel: panel, preview_html: preview_html, **panel.locals
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
drawer_panels.each do |panel|
|
62
62
|
pane.with_tab_panel(panel.name, key: "inspector-panel-#{@target.name}-#{panel.name}", label: panel.label) do
|
63
|
-
render panel.partial, preview: preview, target: target, panel: panel, **panel.locals
|
63
|
+
render panel.partial, preview: preview, target: target, panel: panel, preview_html: preview_html, **panel.locals
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Lookbook
|
2
2
|
module UI
|
3
3
|
class PreviewInspector < BaseComponent
|
4
|
-
attr_reader :preview, :target, :preview_url, :preview_panels, :drawer_panels, :display_options, :display_options_values
|
4
|
+
attr_reader :preview, :target, :preview_url, :preview_panels, :preview_html, :drawer_panels, :display_options, :display_options_values
|
5
5
|
|
6
|
-
def initialize(preview:, target:, preview_url:, preview_panels: [], drawer_panels: [], display_options: {}, display_options_values: {}, **kwargs)
|
6
|
+
def initialize(preview:, target:, preview_url:, preview_panels: [], preview_html: nil, drawer_panels: [], display_options: {}, display_options_values: {}, **kwargs)
|
7
7
|
@preview = preview
|
8
8
|
@target = target
|
9
9
|
@preview_url = preview_url
|
10
10
|
@preview_panels = preview_panels
|
11
|
+
@preview_html = preview_html
|
11
12
|
@drawer_panels = drawer_panels
|
12
13
|
@display_options = display_options
|
13
14
|
@display_options_values = display_options_values
|
@@ -39,7 +39,7 @@ module Lookbook
|
|
39
39
|
@targets = @preview.inspector_targets.select { _1.name.to_sym.in?(target_names) }
|
40
40
|
@panels = Inspector.embed_panels(embed_params[:panels], **panel_context)
|
41
41
|
@actions = embed_params.fetch(:actions, [])
|
42
|
-
@preview_html = render_target_in_layout(@target
|
42
|
+
@preview_html = render_target_in_layout(@target)
|
43
43
|
|
44
44
|
render layout: "lookbook/embed"
|
45
45
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%=
|
2
2
|
render Lookbook::UI::PreviewEmbed.new(
|
3
3
|
preview: @preview,
|
4
|
-
preview_html: @preview_html,
|
5
4
|
target: @target,
|
6
5
|
targets: @targets,
|
7
6
|
panels: @panels,
|
8
7
|
actions: @actions,
|
9
8
|
preview_params: request.query_parameters,
|
9
|
+
preview_html: @preview_html,
|
10
10
|
display_options: @inspector.dynamic_display_options,
|
11
11
|
display_options_values: @display_options
|
12
12
|
)
|
@@ -5,7 +5,11 @@
|
|
5
5
|
<%= render(@render_args[:component], @render_args[:args], &@render_args[:block]) %>
|
6
6
|
<% end %>
|
7
7
|
<% elsif @render_args[:email] %>
|
8
|
-
|
8
|
+
<% if @render_args[:email].multipart? %>
|
9
|
+
<%= raw(@render_args[:email].html_part.decoded) %>
|
10
|
+
<% else %>
|
11
|
+
<%= raw(@render_args[:email].decoded) %>
|
12
|
+
<% end %>
|
9
13
|
<% else %>
|
10
14
|
<%= render(@render_args[:template], **@render_args[:locals], &@render_args[:block]) %>
|
11
15
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
if Lookbook::Engine.enabled? && Lookbook.
|
2
|
-
paths_to_add = Lookbook.
|
1
|
+
if Lookbook::Engine.enabled? && Lookbook::Previews.preview_paths.any?
|
2
|
+
paths_to_add = Lookbook::Previews.preview_paths - ActiveSupport::Dependencies.autoload_paths
|
3
3
|
filtered_paths = paths_to_add.filter { |p| !Lookbook::Engine.component_paths.include?(p) }
|
4
4
|
ActiveSupport::Dependencies.autoload_paths.concat(filtered_paths) if filtered_paths.any?
|
5
5
|
end
|
data/config/routes.rb
CHANGED
@@ -14,7 +14,8 @@ if Lookbook::Engine.enabled?
|
|
14
14
|
|
15
15
|
get "/embed", to: "embeds#show", as: :embed
|
16
16
|
|
17
|
-
|
17
|
+
get "/events", to: "events#index", as: :events
|
18
|
+
get "/events/ping", to: "events#ping", as: :ping
|
18
19
|
|
19
20
|
match "*path", to: "application#not_found", via: :all
|
20
21
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Lookbook
|
2
|
+
module FeatureChecks
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def view_component_available?
|
6
|
+
@has_view_component ||= Utils.gem_installed?("view_component")
|
7
|
+
end
|
8
|
+
|
9
|
+
def listen_available?
|
10
|
+
@has_listen ||= Utils.gem_installed?("listen") && defined?(::Listen)
|
11
|
+
end
|
12
|
+
|
13
|
+
def action_mailer_available?
|
14
|
+
@has_action_mailer ||= !!defined?(::ActionMailer)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/lookbook/config.rb
CHANGED
@@ -14,7 +14,7 @@ module Lookbook
|
|
14
14
|
preview_layout: nil,
|
15
15
|
preview_url_param: :name,
|
16
16
|
preview_overview_template: "lookbook/previews/overview",
|
17
|
-
preview_paths: ["
|
17
|
+
preview_paths: ["lookbook/previews", "test/components/previews"],
|
18
18
|
preview_watch_paths: [],
|
19
19
|
preview_watch_extensions: ["rb", "html.*"],
|
20
20
|
preview_display_options: {},
|
@@ -38,7 +38,7 @@ module Lookbook
|
|
38
38
|
inspector_param_inputs: default_inspector_param_inputs,
|
39
39
|
|
40
40
|
page_route: "pages",
|
41
|
-
page_paths: ["test/components/docs"],
|
41
|
+
page_paths: ["lookbook/docs", "test/components/docs"],
|
42
42
|
page_extensions: ["md", "html.*", "md.*"],
|
43
43
|
page_watch_paths: [],
|
44
44
|
page_watch_extensions: [],
|
@@ -128,7 +128,6 @@ module Lookbook
|
|
128
128
|
Lookbook::LabelTag,
|
129
129
|
Lookbook::LocationTag,
|
130
130
|
Lookbook::ParamTag,
|
131
|
-
Lookbook::PriorityTag,
|
132
131
|
Lookbook::StatusTag
|
133
132
|
]
|
134
133
|
end
|