lookbook 2.0.1 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/lookbook/button/component.html.erb +2 -2
  3. data/app/components/lookbook/copy_button/component.html.erb +1 -1
  4. data/app/components/lookbook/debug_menu/component.html.erb +2 -2
  5. data/app/components/lookbook/dimensions_display/component.html.erb +4 -4
  6. data/app/components/lookbook/embed/inspector/component.html.erb +2 -2
  7. data/app/components/lookbook/embed/inspector/component.js +12 -0
  8. data/app/components/lookbook/embed_code_dropdown/component.css +8 -1
  9. data/app/components/lookbook/embed_code_dropdown/component.html.erb +58 -16
  10. data/app/components/lookbook/embed_code_dropdown/component.js +1 -24
  11. data/app/components/lookbook/embed_code_dropdown/component.rb +9 -0
  12. data/app/components/lookbook/filter/component.html.erb +4 -4
  13. data/app/components/lookbook/header/component.html.erb +3 -3
  14. data/app/components/lookbook/nav/component.html.erb +1 -1
  15. data/app/components/lookbook/nav/item/component.js +1 -1
  16. data/app/components/lookbook/params/editor/component.html.erb +1 -1
  17. data/app/components/lookbook/split_layout/component.html.erb +1 -1
  18. data/app/components/lookbook/tabs/dropdown_tab/component.html.erb +1 -1
  19. data/app/components/lookbook/tabs/tab/component.html.erb +2 -2
  20. data/app/components/lookbook/viewport/component.html.erb +8 -8
  21. data/app/views/layouts/lookbook/application.html.erb +8 -8
  22. data/app/views/layouts/lookbook/embed.html.erb +2 -2
  23. data/app/views/lookbook/inspector/inputs/_color.html.erb +2 -2
  24. data/app/views/lookbook/inspector/inputs/_text_two_step.html.erb +3 -3
  25. data/app/views/lookbook/inspector/inputs/_toggle.html.erb +1 -1
  26. data/app/views/lookbook/inspector/panels/_output.html.erb +2 -2
  27. data/app/views/lookbook/inspector/show.html.erb +6 -6
  28. data/assets/js/lib/lookbook.js +3 -1
  29. data/lib/lookbook/entities/rendered_scenario_entity.rb +7 -2
  30. data/lib/lookbook/services/tags/tag_options_parser.rb +13 -4
  31. data/lib/lookbook/tags/param_tag.rb +7 -4
  32. data/lib/lookbook/tags/yard_tag.rb +3 -2
  33. data/lib/lookbook/version.rb +1 -1
  34. data/public/lookbook-assets/css/lookbook.css +49 -15
  35. data/public/lookbook-assets/css/lookbook.css.map +1 -1
  36. data/public/lookbook-assets/js/index.js +1364 -815
  37. data/public/lookbook-assets/js/index.js.map +1 -1
  38. data/public/lookbook-assets/js/lookbook-core.js +1 -1
  39. data/public/lookbook-assets/js/lookbook.js +1 -1
  40. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb6a188223d00db16e3b82a713ef7def725707c8ee410064ba4e6136675405e7
4
- data.tar.gz: 3f0e2cb77bfd507d93de8a16a13d2a0031e73f18b866cbd7804580b45451eb94
3
+ metadata.gz: bcba1f9fc2cf6c48816f0a3bb9779d035271abc06b96de49dfd529af11b1ccab
4
+ data.tar.gz: 5c8a77ea0591a494c41a6029b53a57401d2541b616091d5eea5437f1f836449a
5
5
  SHA512:
6
- metadata.gz: 242313e1f2fab8b623cd9abfb813a7ae853ac674ee724bb3bfc3b4ab133994d3cac7100145972194fb9e6ab8400937fe541784ac9bdeddddcc7c34f624096122
7
- data.tar.gz: 2027b080e94930ab0df5d0ebb3c608a467acb3b3deccb6c96cfcf31be1f4d62d71092a165d81b079d7e5506d7ff063c4b7144c94931e97313ab7a7f63ba6e4a2
6
+ metadata.gz: 5479d156972a0f078b3465cc7a53419489aa673dc110578d83263980e8944246be63065fa4f01fb431a0acfaabcd91e4a159573327fb9b504564d124a074d1f4
7
+ data.tar.gz: 301bf273975e386ee9966b0a34ef943071fb8a4fe68e3165ddc75b0e61a7f180367d3120c5df7cbc81e100e22b1f76636cc3ef28856d3c5fae7f87079fe62794
@@ -2,8 +2,8 @@
2
2
  id: id,
3
3
  icon: icon,
4
4
  **button_attrs,
5
- "@keydown.esc.stop": "hideDropdown",
6
- "@navigation:complete.window": "updateDropdown") do %>
5
+ "x-on:keydown.esc.stop": "hideDropdown",
6
+ "x-on:navigation:complete.window": "updateDropdown") do %>
7
7
  <%= content %>
8
8
  <% end %>
9
9
 
@@ -2,7 +2,7 @@
2
2
  name: "copy-button",
3
3
  **button_attrs,
4
4
  "x-data": prepare_alpine_data,
5
- "@click.prevent": "copyToClipboard" do |button| %>
5
+ "x-on:click.prevent": "copyToClipboard" do |button| %>
6
6
  <% button.with_icon name: icon, size: icon_size, "x-show": "!copied", cloak: true %>
7
7
  <% button.with_icon name: :check, size: icon_size, class: "text-green-500", "x-show": "copied", cloak: true %>
8
8
  <% if content %>
@@ -6,7 +6,7 @@
6
6
  <a href="#"
7
7
  class="text-xs flex items-center hover:underline"
8
8
  x-data="clipboardComponent"
9
- @click.prevent.stop="copyToClipboard('#debug-data')">
9
+ x-on:click.prevent.stop="copyToClipboard('#debug-data')">
10
10
  <span x-show="copied" x-cloak>
11
11
  <%= icon :check, size: 2.5, class: "text-green-600" %>
12
12
  </span>
@@ -20,7 +20,7 @@
20
20
  <li>
21
21
  <a href="#"
22
22
  class="text-xs flex items-center hover:underline"
23
- @click.stop="localStorage.clear(); window.location.reload();">
23
+ x-on:click.stop="localStorage.clear(); window.location.reload();">
24
24
  <%= icon :refresh_cw, size: 2.5 %>
25
25
  <span class="ml-2">Reset local storage</span>
26
26
  </a>
@@ -1,9 +1,9 @@
1
1
  <%= render_component_tag class: "flex items-center text-xs font-mono space-x-1 transition",
2
2
  ":class":"{'!opacity-100': resizing}",
3
- "@viewport:resize-start.window": "resizing = true",
4
- "@viewport:resize-complete.window": "resizing = false",
5
- "@dom:update-start.window": "tearDown",
6
- "@dom:update-complete.window": "createObserver",
3
+ "x-on:viewport:resize-start.window": "resizing = true",
4
+ "x-on:viewport:resize-complete.window": "resizing = false",
5
+ "x-on:dom:update-start.window": "tearDown",
6
+ "x-on:dom:update-complete.window": "createObserver",
7
7
  "x-show": "target" do %>
8
8
  <span x-text="`${width}px`"></span>
9
9
  <span class="opacity-70">x</span>
@@ -52,8 +52,8 @@
52
52
  style="border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; overflow: hidden;"
53
53
  <% end %>>
54
54
  <div
55
- @viewport:resize-progress="resizeIframe"
56
- @viewport:resize-complete="resizeIframe"
55
+ x-on:viewport:resize-progress="resizeIframe"
56
+ x-on:viewport:resize-complete="resizeIframe"
57
57
  x-ref="viewportWrapper">
58
58
  <%= lookbook_render :viewport,
59
59
  iframe_id: "#{id}-viewport",
@@ -36,6 +36,18 @@ export default function embedInspectorComponent(id, embedStore) {
36
36
  onResized({ height }) {
37
37
  if (height) {
38
38
  this.viewportHeight = height;
39
+
40
+ // Notify parent window of height resize so the parent window can implement
41
+ // its own iframe resize strategy if not using the Lookbook JS script.
42
+ // Uses Embedly-compatible postMessage format: https://docs.embed.ly/reference/provider-height-resizing
43
+ window.parent.postMessage(
44
+ JSON.stringify({
45
+ src: window.location.toString(),
46
+ context: "iframe.resize",
47
+ height,
48
+ }),
49
+ "*"
50
+ );
39
51
  }
40
52
  },
41
53
 
@@ -1,12 +1,19 @@
1
1
  @layer components {
2
2
  [data-component="embed-code-dropdown"] {
3
3
  & [data-component="code"] {
4
- @apply p-0;
4
+ @apply px-2 py-2 bg-lookbook-base-50 border border-dashed border-lookbook-divider;
5
5
  }
6
6
 
7
7
  & pre.code.highlight {
8
8
  @apply overflow-hidden whitespace-normal p-0;
9
9
  font-size: 11px;
10
10
  }
11
+
12
+ .line-clamp-2 {
13
+ overflow: hidden;
14
+ display: -webkit-box;
15
+ -webkit-box-orient: vertical;
16
+ -webkit-line-clamp: 2;
17
+ }
11
18
  }
12
19
  }
@@ -1,22 +1,64 @@
1
- <%= render_component_tag class:"p-3 w-[320px]" do %>
2
- <h4 class="text-[11px] uppercase tracking-wider mb-2 font-bold">Preview embed code</h4>
1
+ <%= render_component_tag class:"p-3 w-[360px] text-[11px] text-gray-600" do %>
3
2
 
4
- <p class="text-xs text-gray-600 mb-3">
5
- This code can be used to embed this preview in
6
- Lookbook pages<% unless policy == "SAMEORIGIN" %> or on external sites<% end %>.
7
- </p>
3
+ <!-- p class="mb-3">
4
+ Embed this preview in Lookbook pages or externally using the code or iframe URL below.
5
+ </!-->
8
6
 
9
- <div class="border-t border-lookbook-dropdown-divider pt-3 pb-3">
10
- <%= code :html do %><%= embed_code %><% end %>
7
+ <div class="mb-4 space-y-2">
8
+
9
+ <header class="flex items-center">
10
+ <h4 class=" uppercase tracking-wider font-bold">Embed Code</h4>
11
+ <span class="ml-auto" >
12
+ <a
13
+ href="https://lookbook.build/guide/sharing/embeds"
14
+ target="_blank"
15
+ title="Help"
16
+ class="text-lookbook-prose underline opacity-70 hover:opacity-100">
17
+ what's this?
18
+ </a>
19
+ </span>
20
+ </header>
21
+
22
+ <div class="relative group">
23
+ <%= code :html do %><%= embed_code %><% end %>
24
+
25
+ <span class="absolute top-px right-px bg-lookbook-base-50 rounded-md transition-opacity duration-300 opacity-0 group-hover:opacity-100">
26
+ <%= lookbook_render :copy_button, icon: :copy, tooltip: "Copy" do %>
27
+ <%= escape_once embed_code %>
28
+ <% end %>
29
+ </span>
30
+ </div>
31
+
11
32
  </div>
12
33
 
13
- <%= lookbook_render :text_button, "@click.stop.prevent": "copyEmbedCode", ":disabled": "copied" do |button| %>
14
- <% button.with_icon name: :copy, size: 3, "x-show": "!copied", "x-cloak": true %>
15
- <% button.with_icon name: :check, size: 3, "x-show": "copied", "x-cloak": true %>
16
- <span x-text="copied ? 'Copied!' : 'Copy embed code'"></span>
17
- <% end %>
34
+ <div class="space-y-2">
35
+
36
+ <header class="flex items-center">
37
+ <h4 class="text-[11px] uppercase tracking-wider font-bold">Embed URL</h4>
38
+ <span class="ml-auto" >
39
+ <a
40
+ href="https://lookbook.build/guide/sharing/embeds#other-services"
41
+ target="_blank"
42
+ title="Help"
43
+ class="text-lookbook-prose underline opacity-70 hover:opacity-100">
44
+ what's this?
45
+ </a>
46
+ </span>
47
+ </header>
48
+
49
+ <div class="relative group">
50
+ <div class="font-mono bg-lookbook-base-50 px-2 py-2 break-all border border-dashed border-lookbook-divider">
51
+ <span class="line-clamp-2">
52
+ <%= embed_url %>
53
+ </span>
54
+ </div>
55
+
56
+ <span class="absolute top-px right-px bg-lookbook-base-50 rounded-md transition-opacity duration-300 opacity-0 group-hover:opacity-100">
57
+ <%= lookbook_render :copy_button, icon: :copy, tooltip: "Copy" do %><%= embed_url %><% end %>
58
+ </span>
59
+ </div>
18
60
 
19
- <div class="hidden" x-ref="copyTarget">
20
- <%= escape_once embed_code %>
21
61
  </div>
22
- <% end %>
62
+
63
+
64
+ <% end %>
@@ -1,26 +1,3 @@
1
- import { decodeEntities } from "@helpers/string";
2
-
3
1
  export default function embedCodeDropdownComponent() {
4
- let copyTimeout = null;
5
-
6
- return {
7
- copied: false,
8
-
9
- copyEmbedCode() {
10
- this.$nextTick(async () => {
11
- const content = decodeEntities(this.$refs.copyTarget.innerHTML.trim());
12
-
13
- await window.navigator.clipboard.writeText(content);
14
- this.copied = true;
15
-
16
- if (copyTimeout) {
17
- clearTimeout(copyTimeout);
18
- }
19
-
20
- copyTimeout = setTimeout(() => {
21
- this.copied = false;
22
- }, 2000);
23
- });
24
- },
25
- };
2
+ return {};
26
3
  }
@@ -33,6 +33,15 @@ module Lookbook
33
33
  escape_once embed_tag
34
34
  end
35
35
 
36
+ def embed_url
37
+ props = {
38
+ preview: preview_name,
39
+ scenario: target.name,
40
+ **external_embed_params.transform_keys { |k| k.tr("-", "_") }
41
+ }.to_json
42
+ "#{app_path}embed?props=#{CGI.escape(props)}"
43
+ end
44
+
36
45
  private
37
46
 
38
47
  def alpine_component
@@ -7,10 +7,10 @@
7
7
  x-ref="input"
8
8
  x-model="<%= @model %>"
9
9
  x-effect="$dispatch('filter:change', { text, filter: this })"
10
- @keydown.esc.stop="clear"
11
- @keydown.f.window="if (!($event.shiftKey || $event.metaKey || $event.ctrlKey || $event.altKey)) { focus(); $event.preventDefault(); $event.stopPropagation(); }"
12
- @keydown.stop>
13
- <button class="text-lookbook-icon-button-stroke hover:text-lookbook-icon-button-stroke-hover focus:ring-0 focus:outline-none absolute top-1/2 right-3 -translate-y-1/2" @click="clear" :class="{hidden: !active}">
10
+ x-on:keydown.esc.stop="clear"
11
+ x-on:keydown.f.window="if (!($event.shiftKey || $event.metaKey || $event.ctrlKey || $event.altKey)) { focus(); $event.preventDefault(); $event.stopPropagation(); }"
12
+ x-on:keydown.stop>
13
+ <button class="text-lookbook-icon-button-stroke hover:text-lookbook-icon-button-stroke-hover focus:ring-0 focus:outline-none absolute top-1/2 right-3 -translate-y-1/2" x-on:click="clear" x-bind:class="{hidden: !active}">
14
14
  <%= icon :x, size: 3 %>
15
15
  </button>
16
16
  </div>
@@ -41,14 +41,14 @@
41
41
  <% end %>
42
42
 
43
43
  <% group.with_button icon: :menu,
44
- "@click.stop": "toggleSidebar",
44
+ "x-on:click.stop": "toggleSidebar",
45
45
  "x-show": "$store.layout.mobile && sidebarHidden",
46
46
  class: "!text-lookbook-header-text" %>
47
47
 
48
48
  <% group.with_button icon: :x,
49
- "@click.stop": "toggleSidebar",
49
+ "x-on:click.stop": "toggleSidebar",
50
50
  "x-show": "$store.layout.mobile && !sidebarHidden",
51
- "@keydown.esc.window": "closeMobileSidebar",
51
+ "x-on:keydown.esc.window": "closeMobileSidebar",
52
52
  class: "!text-lookbook-header-text" %>
53
53
  <% end %>
54
54
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= render_component_tag class: "flex flex-col overflow-hidden h-full",
2
- "@filter:change.stop": "filter($event.detail.text)" do %>
2
+ "x-on:filter:change.stop": "filter($event.detail.text)" do %>
3
3
 
4
4
  <% if toolbar %>
5
5
  <%= toolbar %>
@@ -58,7 +58,7 @@ export default function navItemComponent({ id, matchers }) {
58
58
 
59
59
  bindings: {
60
60
  toggle: {
61
- ["@click.stop"]: "toggle",
61
+ ["x-on:click.stop"]: "toggle",
62
62
  ["x-ref"]: "toggle",
63
63
  },
64
64
  link: {
@@ -1,6 +1,6 @@
1
1
  <%= render_component_tag class: "overflow-hidden" do %>
2
2
  <div class="bg-lookbook-params-editor-bg border border-lookbook-divider rounded-md overflow-x-auto">
3
- <table class="border-collapse w-full" :class="narrow && 'linear'">
3
+ <table class="border-collapse w-full" x-bind:class="narrow && 'linear'">
4
4
  <thead>
5
5
  <tr>
6
6
  <th class="param-label">Param</th>
@@ -3,7 +3,7 @@
3
3
  <%= pane %>
4
4
  <% if i < panes.size %>
5
5
  <div class="split-layout-gutter bg-lookbook-divider relative z-50" x-init="registerGutter">
6
- <div class="absolute z-10 bg-transparent hover:bg-lookbook-draggable-hint transition-all" :class="{
6
+ <div class="absolute z-10 bg-transparent hover:bg-lookbook-draggable-hint transition-all" x-bind:class="{
7
7
  'w-[9px] h-full -translate-x-1/2 cursor-[col-resize] split-layout-gutter-vertical': vertical,
8
8
  'h-[9px] w-full -translate-y-1/2 cursor-[row-resize] split-layout-gutter-horizontal': horizontal
9
9
  }"></div>
@@ -13,7 +13,7 @@
13
13
  'border-transparent text-lookbook-tabs-text hover:text-lookbook-tabs-text-hover': !isSelected($el),
14
14
  'hidden': visibleTabsCount >= #{@position}
15
15
  }",
16
- "@click.prevent": "selectTab($el)",
16
+ "x-on:click.prevent": "selectTab($el)",
17
17
  data: {
18
18
  disabled: @disabled
19
19
  } do %>
@@ -15,8 +15,8 @@
15
15
  '!text-lookbook-tabs-text-disabled': isDisabled($el),
16
16
  'invisible pointer-events-none relative z-[-1]': visibleTabsCount < #{@position}
17
17
  }",
18
- "@click.prevent": "selectTab($el)",
19
- "@keydown.window.prevent.#{@hotkey}": @hotkey.present? ? "$el.click()" : nil,
18
+ "x-on:click.prevent": "selectTab($el)",
19
+ "x-on:keydown.window.prevent.#{@hotkey}": @hotkey.present? ? "$el.click()" : nil,
20
20
  data: {
21
21
  disabled: @disabled
22
22
  },
@@ -28,17 +28,17 @@
28
28
  <iframe seamless<%= " id=#{@iframe_id}" if @iframe_id.present? %>
29
29
  x-ref="iframe"
30
30
  class="bg-lookbook-page-bg h-full w-full border border-lookbook-divider"
31
- :class="{ 'pointer-events-none': reflowing }"
31
+ x-bind:class="{ 'pointer-events-none': reflowing }"
32
32
  style="<%= "max-height: #{@max_height}px;" if @max_height.present? %>"
33
33
  src="<%= @src %>"
34
34
  frameborder="0"
35
- @load="$dispatch('viewport:loaded', {viewport: this})"
35
+ x-on:load="$dispatch('viewport:loaded', {viewport: this})"
36
36
  title="viewport"></iframe>
37
37
  <% if @resize_width %>
38
38
  <div
39
39
  class="resize-handle border-r border-t border-lookbook-divider cursor-[col-resize] <%= "border-b" unless @resize_height %>"
40
- @pointerdown="onResizeWidthStart"
41
- @dblclick="toggleFullWidth">
40
+ x-on:pointerdown="onResizeWidthStart"
41
+ x-on:dblclick="toggleFullWidth">
42
42
  <svg class="h-4 w-4 pointer-events-none" fill="currentColor" viewBox="0 0 24 24">
43
43
  <path d="M8 5h2v14H8zM14 5h2v14h-2z"></path>
44
44
  </svg>
@@ -47,8 +47,8 @@
47
47
  <% if @resize_height %>
48
48
  <div
49
49
  class="resize-handle border-b border-l border-lookbook-divider cursor-[row-resize] <%= "border-r" unless @resize_width %>"
50
- @pointerdown="onResizeHeightStart"
51
- @dblclick="toggleFullHeight">
50
+ x-on:pointerdown="onResizeHeightStart"
51
+ x-on:dblclick="toggleFullHeight">
52
52
  <svg class="h-4 w-4 pointer-events-none rotate-90" fill="currentColor" viewBox="0 0 24 24" >
53
53
  <path d="M8 5h2v14H8zM14 5h2v14h-2z"></path>
54
54
  </svg>
@@ -57,8 +57,8 @@
57
57
  <% if @resize_height && @resize_width %>
58
58
  <div
59
59
  class="resize-handle border-r border-b border-lookbook-divider cursor-[nwse-resize]"
60
- @pointerdown="onResizeStart"
61
- @dblclick="toggleFullSize">
60
+ x-on:pointerdown="onResizeStart"
61
+ x-on:dblclick="toggleFullSize">
62
62
  <svg class="h-3.5 w-3.5 pointer-events-none rotate-45 relative -top-px -left-px" fill="currentColor" viewBox="0 0 24 24" >
63
63
  <path d="M8 5h2v14H8zM14 5h2v14h-2z"></path>
64
64
  </svg>
@@ -3,10 +3,10 @@
3
3
  id="app"
4
4
  x-data="app"
5
5
  x-cloak
6
- @popstate.window="handleNavigation"
7
- @click.document="hijax"
8
- @navigation:start="closeMobileSidebar"
9
- @dom:update-complete.window="Lookbook.initEmbeds()"
6
+ x-on:popstate.window="handleNavigation"
7
+ x-on:click.document="hijax"
8
+ x-on:navigation:start="closeMobileSidebar"
9
+ x-on:dom:update-complete.window="Lookbook.initEmbeds()"
10
10
  class="w-screen h-screen grid grid-rows-[40px_1fr] relative">
11
11
 
12
12
  <%= render "lookbook/partials/user_styles" %>
@@ -29,7 +29,7 @@
29
29
  'translate-x-full': $store.layout.mobile && sidebarHidden,
30
30
  '!absolute right-0 bottom-0 top-[40px] h-[calc(100%_-_40px)] w-full max-w-[420px] z-[1001] border-l border-lookbook-divider': $store.layout.mobile
31
31
  }",
32
- "@click.outside": "closeMobileSidebar",
32
+ "x-on:click.outside": "closeMobileSidebar",
33
33
  cloak: true do %>
34
34
 
35
35
  <%= lookbook_render :split_layout,
@@ -50,7 +50,7 @@
50
50
  <%= lookbook_render :button_group, size: :xs do |group| %>
51
51
  <% group.with_button icon: :minus_square,
52
52
  tooltip: "Collapse all",
53
- "@click": "closeAll" %>
53
+ "x-on:click": "closeAll" %>
54
54
  <% end %>
55
55
  <% end %>
56
56
  <% end %>
@@ -73,7 +73,7 @@
73
73
  <%= lookbook_render :button_group, size: :xs do |group| %>
74
74
  <% group.with_button icon: :minus_square,
75
75
  tooltip: "Collapse all",
76
- "@click": "closeAll" %>
76
+ "x-on:click": "closeAll" %>
77
77
  <% end %>
78
78
  <% end %>
79
79
  <% end %>
@@ -93,7 +93,7 @@
93
93
  </div>
94
94
  <% end %>
95
95
 
96
- <div class="absolute opacity-0 bg-black inset-0 top-[39px] z-[-1] transition-opacity" :class="($store.layout.mobile && !sidebarHidden) && '!opacity-30 !z-[1000]'" data-cloak></div>
96
+ <div class="absolute opacity-0 bg-black inset-0 top-[39px] z-[-1] transition-opacity" x-bind:class="($store.layout.mobile && !sidebarHidden) && '!opacity-30 !z-[1000]'" data-cloak></div>
97
97
 
98
98
  <% if content_for? :dropdowns %>
99
99
  <div class="hidden">
@@ -3,8 +3,8 @@
3
3
  id="app"
4
4
  x-data="app"
5
5
  x-cloak
6
- @popstate.window="handleNavigation"
7
- @click.document="hijax"
6
+ x-on:popstate.window="handleNavigation"
7
+ x-on:click.document="hijax"
8
8
  class="overflow-hidden">
9
9
 
10
10
  <%= render "lookbook/partials/user_styles" %>
@@ -1,6 +1,6 @@
1
1
  <%= text_field_tag(name, value,
2
2
  **input_options,
3
3
  type: "color",
4
- "@change.stop": "",
5
- "@blur": "value = $el.value",
4
+ "x-on:change.stop": "",
5
+ "x-on:blur": "value = $el.value",
6
6
  ) %>
@@ -1,12 +1,12 @@
1
1
  <div x-data="{changed: false, applyChange(){ this.value = this.$refs.input.value; this.changed = false; }}">
2
2
 
3
- <div @change.stop="changed = ($event.target.value !== value)" class="flex items-center gap-2">
3
+ <div x-on:change.stop="changed = ($event.target.value !== value)" class="flex items-center gap-2">
4
4
  <%= text_field_tag(name, value,
5
5
  **input_options,
6
6
  type: input,
7
7
  class: "flex-grow",
8
8
  "x-ref": "input",
9
- "@keydown.enter.stop": "applyChange"
9
+ "x-on:keydown.enter.stop": "applyChange"
10
10
  ) %>
11
11
 
12
12
  <%= lookbook_render :button,
@@ -14,6 +14,6 @@
14
14
  tooltip: "Apply changes",
15
15
  class: "flex-none !bg-lookbook-button-bg hover:!bg-lookbook-button-bg-hover rounded-md !text-lookbook-button-text",
16
16
  "x-show": "changed",
17
- "@click": "applyChange" %>
17
+ "x-on:click": "applyChange" %>
18
18
  </div>
19
19
  </div>
@@ -15,6 +15,6 @@ span_classes = [
15
15
  class: class_names(button_classes),
16
16
  role: "switch",
17
17
  type: "button",
18
- "@click.stop": "value = value == 'true' ? 'false' : 'true'", escape: false do %>
18
+ "x-on:click.stop": "value = value == 'true' ? 'false' : 'true'", escape: false do %>
19
19
  <%= tag.span "aria-hidden": true, class: class_names(span_classes) %>
20
20
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <%= lookbook_render :code, line_numbers: true, full_height: true do -%>
2
2
  <% if scenarios.many? -%>
3
- <% scenarios.each do |scenario| -%><%== "<!-- #{scenario.label} -->\n#{scenario.output}\n\n" -%><% end %>
3
+ <% scenarios.each do |scenario| -%><%== "<!-- #{scenario.label} -->\n#{scenario.beautified_output}\n\n" -%><% end %>
4
4
  <%- else -%>
5
- <%== scenarios.first.output -%>
5
+ <%== scenarios.first.beautified_output -%>
6
6
  <%- end %>
7
7
  <% end %>
@@ -55,7 +55,7 @@
55
55
  <% group.with_button id: "refresh-preview-button",
56
56
  icon: :refresh_cw,
57
57
  tooltip: "Refresh preview",
58
- "@click.stop": "startSpin(); $dispatch('viewport:reload'); stopSpin(500);" %>
58
+ "x-on:click.stop": "startSpin(); $dispatch('viewport:reload'); stopSpin(500);" %>
59
59
 
60
60
  <% group.with_button id: "open-preview-button",
61
61
  icon: :external_link,
@@ -66,7 +66,7 @@
66
66
  <% group.with_button id: "show-drawer-button",
67
67
  icon: "sidebar",
68
68
  tooltip: "Show drawer",
69
- "@click": "$store.inspector.drawer.hidden = false",
69
+ "x-on:click": "$store.inspector.drawer.hidden = false",
70
70
  class: "rotate-180",
71
71
  "x-show": "$store.inspector.drawer.hidden && vertical",
72
72
  cloak: true %>
@@ -74,7 +74,7 @@
74
74
  <% group.with_button id: "show-drawer-button",
75
75
  icon: "credit-card",
76
76
  tooltip: "Show drawer",
77
- "@click": "$store.inspector.drawer.hidden = false",
77
+ "x-on:click": "$store.inspector.drawer.hidden = false",
78
78
  class: "rotate-180",
79
79
  "x-show": "$store.inspector.drawer.hidden && !vertical",
80
80
  cloak: true %>
@@ -131,7 +131,7 @@
131
131
  <% group.with_button id: "drawer-to-right-button",
132
132
  icon: :sidebar_open,
133
133
  tooltip: "Pin drawer on right",
134
- "@click": "switchOrientation",
134
+ "x-on:click": "switchOrientation",
135
135
  "x-show": "horizontal",
136
136
  ":class": "{'pointer-events-none opacity-50 !cursor-not-allowed': horizontal && layoutWidth <= $store.inspector.minVerticalSplitWidth}",
137
137
  cloak: true %>
@@ -139,7 +139,7 @@
139
139
  <% group.with_button id: "drawer-to-bottom-button",
140
140
  icon: :sidebar_open,
141
141
  tooltip: "Pin drawer on bottom",
142
- "@click": "switchOrientation",
142
+ "x-on:click": "switchOrientation",
143
143
  "x-show": "vertical",
144
144
  class: "rotate-90",
145
145
  cloak: true %>
@@ -147,7 +147,7 @@
147
147
  <% group.with_button id: "hide-drawer-button",
148
148
  icon: :x_circle,
149
149
  tooltip: "Hide drawer",
150
- "@click": "$store.inspector.drawer.hidden = true",
150
+ "x-on:click": "$store.inspector.drawer.hidden = true",
151
151
  cloak: true %>
152
152
  <% end %>
153
153
  <% end %>
@@ -114,7 +114,9 @@ function guessBasePath() {
114
114
  const scriptSrc = script.src;
115
115
 
116
116
  if (scriptSrc && scriptSrc.includes("lookbook-assets")) {
117
- return scriptSrc.replace("lookbook-assets/js/lookbook.js", "lookbook");
117
+ return scriptSrc
118
+ .split("?")[0]
119
+ .replace("lookbook-assets/js/lookbook.js", "lookbook");
118
120
  }
119
121
 
120
122
  return `//${location.host}/lookbook`;
@@ -23,8 +23,13 @@ module Lookbook
23
23
  # HTML output of the rendered scenario.
24
24
  #
25
25
  # @return [String] Rendered output
26
- def output
27
- @_output ||= CodeBeautifier.call(@output)
26
+ attr_reader :output
27
+
28
+ # 'Beautified' HTML output of the rendered scenario.
29
+ #
30
+ # @return [String] Rendered output
31
+ def beautified_output
32
+ @_beautified_output ||= CodeBeautifier.call(output)
28
33
  end
29
34
 
30
35
  # @api private
@@ -9,19 +9,28 @@ module Lookbook
9
9
 
10
10
  def initialize(input, resolver_opts = {})
11
11
  @input = input.to_s.strip
12
- @resolver_opts = resolver_opts
12
+ @resolve = resolver_opts.fetch(:resolve, true)
13
+ @resolver_opts = resolver_opts.except(:resolve)
13
14
  @fallback = resolver_opts.fetch(:fallback, {})
14
15
  end
15
16
 
16
17
  def call
17
18
  options_string, remaining_text = parse_input(@input)
18
- resolved_options = resolver(options_string).call(options_string, **@resolver_opts)
19
- options = prepare_options(resolved_options)
20
- [options, remaining_text]
19
+ if resolve?
20
+ resolved_options = resolver(options_string).call(options_string, **@resolver_opts)
21
+ options = prepare_options(resolved_options)
22
+ [options, remaining_text]
23
+ else
24
+ [options_string, remaining_text]
25
+ end
21
26
  end
22
27
 
23
28
  protected
24
29
 
30
+ def resolve?
31
+ !!@resolve
32
+ end
33
+
25
34
  def resolver(options_string)
26
35
  if options_string.present?
27
36
  handler = RESOLVERS.find { |r| r.resolveable?(options_string) }