lookbook 1.0.0.beta.3 → 1.0.0.beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -254
  3. data/app/assets/lookbook/css/lookbook.css +1 -1
  4. data/app/assets/lookbook/css/themes/blue.css +57 -36
  5. data/app/assets/lookbook/css/themes/indigo.css +57 -36
  6. data/app/assets/lookbook/css/themes/zinc.css +57 -36
  7. data/app/assets/lookbook/css/tooltip.css +5 -5
  8. data/app/components/lookbook/base_component.rb +6 -4
  9. data/app/components/lookbook/button/component.html.erb +2 -2
  10. data/app/components/lookbook/copy_button/component.html.erb +3 -3
  11. data/app/components/lookbook/embed/component.html.erb +33 -33
  12. data/app/components/lookbook/embed/component.rb +8 -0
  13. data/app/components/lookbook/filter/component.html.erb +1 -1
  14. data/app/components/lookbook/header/component.html.erb +4 -4
  15. data/app/components/lookbook/header/component.rb +5 -0
  16. data/app/components/lookbook/inspector_panel/component.html.erb +4 -0
  17. data/app/components/lookbook/inspector_panel/component.rb +36 -0
  18. data/app/components/lookbook/nav/component.html.erb +4 -8
  19. data/app/components/lookbook/nav/component.rb +5 -7
  20. data/app/components/lookbook/nav/item/component.html.erb +12 -6
  21. data/app/components/lookbook/nav/item/component.rb +9 -2
  22. data/app/components/lookbook/page_tabs/component.html.erb +1 -1
  23. data/app/components/lookbook/prose/component.html.erb +1 -1
  24. data/app/components/lookbook/split_layout/component.html.erb +1 -1
  25. data/app/components/lookbook/tab_panels/panel/component.html.erb +2 -2
  26. data/app/components/lookbook/tabs/component.html.erb +2 -2
  27. data/app/components/lookbook/tabs/dropdown_tab/component.html.erb +2 -2
  28. data/app/components/lookbook/tabs/tab/component.html.erb +2 -2
  29. data/app/components/lookbook/tag_component.rb +5 -10
  30. data/app/components/lookbook/toolbar/component.html.erb +1 -1
  31. data/app/components/lookbook/viewport/component.css +1 -1
  32. data/app/components/lookbook/viewport/component.html.erb +1 -1
  33. data/app/controllers/lookbook/application_controller.rb +1 -1
  34. data/app/controllers/lookbook/pages_controller.rb +1 -0
  35. data/app/controllers/lookbook/previews_controller.rb +15 -3
  36. data/app/helpers/lookbook/application_helper.rb +0 -6
  37. data/app/helpers/lookbook/preview_helper.rb +2 -3
  38. data/app/views/layouts/lookbook/application.html.erb +76 -58
  39. data/app/views/layouts/lookbook/page.html.erb +36 -36
  40. data/app/views/layouts/lookbook/shell.html.erb +8 -48
  41. data/app/views/layouts/lookbook/skeleton.html.erb +0 -6
  42. data/app/views/lookbook/index.html.erb +24 -11
  43. data/app/views/lookbook/pages/show.html.erb +5 -5
  44. data/app/views/lookbook/previews/panels/_content.html.erb +1 -1
  45. data/app/views/lookbook/previews/panels/_notes.html.erb +2 -2
  46. data/app/views/lookbook/previews/panels/_params.html.erb +1 -1
  47. data/app/views/lookbook/previews/show.html.erb +12 -10
  48. data/lib/lookbook/config.rb +107 -74
  49. data/lib/lookbook/engine.rb +24 -6
  50. data/lib/lookbook/markdown.rb +3 -1
  51. data/lib/lookbook/page.rb +4 -0
  52. data/lib/lookbook/params.rb +12 -0
  53. data/lib/lookbook/preview.rb +35 -5
  54. data/lib/lookbook/store.rb +8 -0
  55. data/lib/lookbook/version.rb +1 -1
  56. data/lib/tasks/lookbook_tasks.rake +1 -1
  57. data/public/lookbook-assets/css/lookbook.css +330 -182
  58. data/public/lookbook-assets/css/lookbook.css.map +1 -1
  59. data/public/lookbook-assets/css/themes/blue.css +57 -36
  60. data/public/lookbook-assets/css/themes/blue.css.map +1 -1
  61. data/public/lookbook-assets/css/themes/indigo.css +57 -36
  62. data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
  63. data/public/lookbook-assets/css/themes/zinc.css +57 -36
  64. data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
  65. data/public/lookbook-assets/js/embed.js +193 -193
  66. data/public/lookbook-assets/js/lookbook.js +1179 -1336
  67. data/public/lookbook-assets/js/lookbook.js.map +1 -1
  68. metadata +6 -4
@@ -4,23 +4,23 @@
4
4
  .tippy-box[data-theme~="tooltip"] {
5
5
  @apply text-xs opacity-90;
6
6
 
7
- background-color: var(--lookbook-tooltip);
7
+ background-color: var(--lookbook-tooltip-bg);
8
8
  color: var(--lookbook-tooltip-text);
9
9
 
10
10
  &[data-placement^="top"] > .tippy-arrow::before {
11
- border-top-color: var(--lookbook-tooltip);
11
+ border-top-color: var(--lookbook-tooltip-bg);
12
12
  }
13
13
 
14
14
  &[data-placement^="bottom"] > .tippy-arrow::before {
15
- border-bottom-color: var(--lookbook-tooltip);
15
+ border-bottom-color: var(--lookbook-tooltip-bg);
16
16
  }
17
17
 
18
18
  &[data-placement^="left"] > .tippy-arrow::before {
19
- border-left-color: var(--lookbook-tooltip);
19
+ border-left-color: var(--lookbook-tooltip-bg);
20
20
  }
21
21
 
22
22
  &[data-placement^="right"] > .tippy-arrow::before {
23
- border-right-color: var(--lookbook-tooltip);
23
+ border-right-color: var(--lookbook-tooltip-bg);
24
24
  }
25
25
  }
26
26
 
@@ -10,11 +10,13 @@ module Lookbook
10
10
 
11
11
  def render_component_tag(tag = :div, **attrs, &block)
12
12
  merged_classes = class_names(attrs[:class], @html_attrs[:class])
13
- merge_attrs = @html_attrs.except(:class).deep_merge(attrs.except(:class))
13
+ merged_attrs = @html_attrs.except(:class).deep_merge(attrs.except(:class))
14
+
15
+
14
16
  render Lookbook::TagComponent.new(tag: tag,
15
17
  name: component_name,
16
- **merge_attrs,
17
- x_data: prepare_alpine_data(attrs[:x_data]),
18
+ **merged_attrs,
19
+ "x-data": prepare_alpine_data(merged_attrs[:"x-data"]),
18
20
  class: merged_classes), &block
19
21
  end
20
22
 
@@ -31,7 +33,7 @@ module Lookbook
31
33
  end
32
34
 
33
35
  def prepare_alpine_data(x_data = nil)
34
- alpine_component_name = x_data || @html_attrs&.dig(:x_data) || alpine_component
36
+ alpine_component_name = x_data || @html_attrs&.dig(:"x-data") || alpine_component
35
37
  if alpine_component_name.present?
36
38
  args = Array.wrap(alpine_data)
37
39
  args.any? ? "#{alpine_component_name}(#{safe_join(args).gsub(""", "'").tr("\"", "'")})" : alpine_component_name
@@ -1,9 +1,9 @@
1
1
  <%= render_component_tag tag_name,
2
2
  href: @href,
3
3
  class: [
4
- "block text-lookbook-button-text focus:outline-none focus-visible:outline-none #{padding}",
4
+ "block text-lookbook-icon-button-stroke focus:outline-none focus-visible:outline-none #{padding}",
5
5
  {
6
- "hover:text-lookbook-button-text-hover": !@disabled,
6
+ "hover:text-lookbook-icon-button-stroke-hover": !@disabled,
7
7
  "cursor-[not-allowed] opacity-50": @disabled
8
8
  }
9
9
  ],
@@ -1,10 +1,10 @@
1
1
  <%= render_component :button,
2
2
  name: "copy-button",
3
3
  **@button_attrs,
4
- x_data: prepare_alpine_data,
4
+ "x-data": prepare_alpine_data,
5
5
  "@click.prevent": "copyToClipboard" do |button| %>
6
- <% button.icon name: @icon, size: icon_size, x_show: "!copied", cloak: true %>
7
- <%= icon :check, size: icon_size, class: "text-green-500", x_show: "copied", cloak: true %>
6
+ <% button.icon name: @icon, size: icon_size, "x-show": "!copied", cloak: true %>
7
+ <%= icon :check, size: icon_size, class: "text-green-500", "x-show": "copied", cloak: true %>
8
8
  <% if content %>
9
9
  <div x-ref="copyTarget" class="hidden"><%== content %></div>
10
10
  <% end %>
@@ -1,41 +1,41 @@
1
1
  <% if @example.present? %>
2
- <%= render_component_tag class: "not-prose border-b border-lookbook-divider rounded-sm overflow-hidden", "@navigation:start.window": "cleanup" do %>
2
+ <%= render_component_tag class: "not-prose border-b border-lookbook-divider rounded-sm overflow-hidden", "@navigation:start.window": "cleanup" do %>
3
3
 
4
- <%= render_component :toolbar, class: "border border-b-0 border-lookbook-divider" do |toolbar| %>
5
- <% toolbar.section padded: true do %>
6
- <h3>
7
- <%= @example.preview.label %> (<%= @example.label %>)
8
- </h3>
9
- <% end %>
10
- <% toolbar.section align: :right, divide: :left do %>
11
- <%= render_component :button_group do |group| %>
12
- <% group.button icon: :eye,
13
- href: helpers.lookbook_inspect_path(@example.path, @params),
14
- tooltip: "View in Inspector" %>
15
- <% group.button icon: :external_link,
16
- href: helpers.lookbook_inspect_path(@example.path, @params),
17
- tooltip: "Open in new window",
18
- target: "_blank" %>
19
- <% end %>
4
+ <%= render_component :toolbar, class: "border border-b-0 border-lookbook-divider" do |toolbar| %>
5
+ <% toolbar.section padded: true do %>
6
+ <h3>
7
+ <%= @example.preview.label %> (<%= @example.label %>)
8
+ </h3>
9
+ <% end %>
10
+ <% toolbar.section align: :right, divide: :left do %>
11
+ <%= render_component :button_group do |group| %>
12
+ <% group.button icon: :eye,
13
+ href: lookbook_inspect_path(@example.path, @params),
14
+ tooltip: "View in Inspector" %>
15
+ <% group.button icon: :external_link,
16
+ href: lookbook_inspect_path(@example.path, @params),
17
+ tooltip: "Open in new window",
18
+ target: "_blank" %>
20
19
  <% end %>
21
20
  <% end %>
21
+ <% end %>
22
22
 
23
- <div
24
- x-show="tab === 'preview'"
25
- @viewport:loaded="loadResizer"
26
- @dom:update-complete="loadResizer"
27
- @viewport:resize-progress="resizeIframe"
28
- @viewport:resize-complete="resizeIframe"
29
- @tabs:change.window="resizeIframe">
30
- <%= render_component :viewport,
31
- src: helpers.lookbook_preview_path(@example.path, @params.merge(lookbook_embed: true)),
32
- alpine_data: "store",
33
- resize_height: false,
34
- max_height: @max_height,
35
- class: "mb-[-2px]" %>
36
- </div>
23
+ <div
24
+ x-show="tab === 'preview'"
25
+ @viewport:loaded="loadResizer"
26
+ @dom:update-complete="loadResizer"
27
+ @viewport:resize-progress="resizeIframe"
28
+ @viewport:resize-complete="resizeIframe"
29
+ @tabs:change.window="resizeIframe">
30
+ <%= render_component :viewport,
31
+ src: lookbook_preview_path(@example.path, @params.merge(lookbook_embed: true)),
32
+ alpine_data: "store",
33
+ resize_height: false,
34
+ max_height: @max_height,
35
+ class: "mb-[-2px]" %>
36
+ </div>
37
37
 
38
- <% end %>
38
+ <% end %>
39
39
  <% else %>
40
40
  <%= render_component_tag class: "bg-white flex flex-col items-center justify-center border-2 border-dashed border-gray-200 p-6 rounded-md not-prose" do %>
41
41
  <div class="px-4 text-center">
@@ -47,5 +47,5 @@
47
47
  </p>
48
48
  </div>
49
49
  </div>
50
- <% end %>
50
+ <% end %>
51
51
  <% end %>
@@ -11,6 +11,14 @@ module Lookbook
11
11
 
12
12
  protected
13
13
 
14
+ def lookbook_inspect_path(*args)
15
+ Lookbook::Engine.routes.url_helpers.lookbook_inspect_path(*args)
16
+ end
17
+
18
+ def lookbook_preview_path(*args)
19
+ Lookbook::Engine.routes.url_helpers.lookbook_preview_path(*args)
20
+ end
21
+
14
22
  def alpine_data
15
23
  [@id.to_json, "$store.pages.embeds"].join(",")
16
24
  end
@@ -10,7 +10,7 @@
10
10
  @keydown.esc.stop="clear"
11
11
  @keydown.f.stop.prevent.window="focus"
12
12
  @keydown.stop>
13
- <button class="text-lookbook-button-text hover:text-lookbook-button-text-hover focus:ring-0 focus:outline-none absolute top-1/2 right-3 -translate-y-1/2" @click="clear" :class="{hidden: !active}">
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}">
14
14
  <%= icon :x, size: 3 %>
15
15
  </button>
16
16
  </div>
@@ -1,5 +1,5 @@
1
1
  <%= render_component_tag :header do %>
2
- <%= render_component :toolbar, class: "!bg-lookbook-header !text-lookbook-header-text !border-lookbook-header-border" do |toolbar| %>
2
+ <%= render_component :toolbar, class: "!bg-lookbook-header-bg !text-lookbook-header-text !border-lookbook-header-border" do |toolbar| %>
3
3
  <% toolbar.section padded: true do %>
4
4
  <% if branding.present? %>
5
5
  <a
@@ -12,7 +12,7 @@
12
12
 
13
13
  <% toolbar.section padded: false, align: :right, class: "flex items-center" do %>
14
14
  <%= render_component :button_group do |group| %>
15
- <% if Rails.env.development? %>
15
+ <% if @debug_menu %>
16
16
  <% group.button icon: :help_circle, class: "opacity-50 hover:opacity-100 transition !text-lookbook-header-text" do |button| %>
17
17
  <% button.dropdown do %>
18
18
  <%= tag.div class: "divide-y divide-lookbook-divider min-w-[180px]" do %>
@@ -60,11 +60,11 @@
60
60
  <% end %>
61
61
  <% group.button icon: :menu,
62
62
  "@click.stop": "toggleSidebar",
63
- x_show: "$store.layout.mobile && sidebarHidden",
63
+ "x-show": "$store.layout.mobile && sidebarHidden",
64
64
  class: "!text-lookbook-header-text" %>
65
65
  <% group.button icon: :x,
66
66
  "@click.stop": "toggleSidebar",
67
- x_show: "$store.layout.mobile && !sidebarHidden",
67
+ "x-show": "$store.layout.mobile && !sidebarHidden",
68
68
  "@keydown.esc.window": "closeMobileSidebar",
69
69
  class: "!text-lookbook-header-text" %>
70
70
  <% end %>
@@ -2,6 +2,11 @@ module Lookbook
2
2
  class Header::Component < Lookbook::BaseComponent
3
3
  renders_one :branding
4
4
 
5
+ def initialize(debug_menu: false, **html_attrs)
6
+ @debug_menu = debug_menu
7
+ super(**html_attrs)
8
+ end
9
+
5
10
  def landing_path
6
11
  helpers.landing_path if defined? helpers.landing_path
7
12
  end
@@ -0,0 +1,4 @@
1
+ <% if panel_styles %>
2
+ <% content_for :panel_css do %><%= panel_styles %><% end %>
3
+ <% end %>
4
+ <%= panel_html %>
@@ -0,0 +1,36 @@
1
+ require "css_parser"
2
+
3
+ module Lookbook
4
+ class InspectorPanel::Component < Lookbook::BaseComponent
5
+ attr_reader :panel_styles, :panel_html, :id
6
+
7
+ def initialize(id:, name:, system: false, **html_attrs)
8
+ @id = id
9
+ @name = name
10
+ @system = system
11
+ @panel_html = nil
12
+ @panel_styles = nil
13
+ super(**html_attrs)
14
+ end
15
+
16
+ def before_render
17
+ if @system == false
18
+ panel_dom = ::Nokogiri::HTML::fragment(content)
19
+ style_tags = panel_dom.css('style')
20
+ if style_tags.any?
21
+ css_parser = ::CssParser::Parser.new
22
+ @panel_styles = ""
23
+ style_tags.each do |style_tag|
24
+ css_parser.load_string! style_tag.text
25
+ css_parser.each_selector do |selector, declarations, specificity|
26
+ @panel_styles += "##{id} #{selector} { #{declarations} }\n"
27
+ end
28
+ style_tag.unlink
29
+ end
30
+ @panel_html = panel_dom.to_html.html_safe
31
+ end
32
+ end
33
+ @panel_html ||= content
34
+ end
35
+ end
36
+ end
@@ -1,12 +1,8 @@
1
1
  <%= render_component_tag class: "flex flex-col overflow-hidden h-full",
2
2
  "@filter:change.stop": "filter($event.detail.text)" do %>
3
3
 
4
- <% if label.present? %>
5
- <%= render_component :toolbar do |toolbar| %>
6
- <% toolbar.section padded: true do %>
7
- <h4 class="pt-1"><%= label %></h4>
8
- <% end %>
9
- <% end %>
4
+ <% if toolbar %>
5
+ <%= toolbar %>
10
6
  <% end %>
11
7
 
12
8
  <% if filter && items.any? %>
@@ -21,11 +17,11 @@
21
17
  <%= safe_join(items) %>
22
18
  </ul>
23
19
  <div class="p-4 text-center" x-show="empty" x-cloak>
24
- <h4 class="opacity-50 italic">No matching <%= label.downcase %>.</h4>
20
+ <h4 class="opacity-50 italic">No matching results.</h4>
25
21
  </div>
26
22
  <% else %>
27
23
  <div class="p-4 text-center">
28
- <h4 class="opacity-50 italic">No <%= label.downcase %> available.</h4>
24
+ <h4 class="opacity-50 italic">Nothing here yet.</h4>
29
25
  </div>
30
26
  <% end %>
31
27
  </div>
@@ -1,28 +1,26 @@
1
1
  module Lookbook
2
2
  class Nav::Component < Lookbook::BaseComponent
3
3
  renders_one :filter, Lookbook::Filter::Component
4
+ renders_one :toolbar, Lookbook::Toolbar::Component
4
5
 
5
6
  def initialize(
7
+ id: nil,
6
8
  collection:,
7
- label: nil,
8
9
  collapse_singles: false,
9
10
  **attrs
10
11
  )
12
+ @id = id.presence || "#{collection.id}-nav"
11
13
  @collection = collection.as_tree
12
- @label = label
13
14
  @item_args = {
14
15
  collapse_singles: collapse_singles
15
16
  }
16
- super(**attrs)
17
- end
18
-
19
- def label
20
- @label || @collection.label
17
+ super(**attrs, id: id)
21
18
  end
22
19
 
23
20
  def items
24
21
  @collection.non_empty_items.map do |item|
25
22
  render Lookbook::Nav::Item::Component.new item,
23
+ nav_id: @id,
26
24
  depth: 1,
27
25
  **@item_args
28
26
  end
@@ -1,16 +1,22 @@
1
- <%= render_component_tag :li, id: @item.id, class: "list-none", "x-show": "!filteredOut", cloak: true do %>
2
-
1
+ <%= render_component_tag :li,
2
+ id: id,
3
+ class: "list-none",
4
+ "x-show": "!filteredOut",
5
+ data: {
6
+ "entity-type": item.type
7
+ },
8
+ cloak: true do %>
3
9
  <%= render_tag href.present? ? :a : :div,
4
10
  href: href,
5
11
  class: "flex items-center py-1 select-none cursor-pointer text-lookbook-nav-text hover:bg-lookbook-nav-item-hover",
6
12
  style: "padding-left: #{left_pad}px",
7
- x_bind: "bindings.#{href.present? ? "link" : "toggle"}" do %>
13
+ "x-bind": "bindings.#{href.present? ? "link" : "toggle"}" do %>
8
14
  <div class="relative flex items-center">
9
- <%= icon nil,
15
+ <%= icon nil,
10
16
  size: 3,
11
17
  class: "mr-1 text-lookbook-nav-toggle absolute -left-4",
12
- x_effect: "iconName = open ? 'chevron-down' : 'chevron-right'" if children? %>
13
- <%= icon nav_icon(@item), size: 3.5, class: "mr-1.5 text-lookbook-nav-icon" %>
18
+ "x-effect": "iconName = open ? 'chevron-down' : 'chevron-right'" if children? %>
19
+ <%= icon nav_icon, size: 3.5, class: "mr-1.5 text-lookbook-nav-icon-stroke" %>
14
20
  <span><%= label %></span>
15
21
  </div>
16
22
  <% end %>
@@ -14,16 +14,22 @@ module Lookbook
14
14
 
15
15
  def initialize(
16
16
  item,
17
+ nav_id:,
17
18
  depth: 1,
18
19
  collapse_singles: false,
19
20
  **html_attrs
20
21
  )
22
+ @nav_id = nav_id
21
23
  @item = item
22
24
  @depth = depth
23
25
  @collapse_singles = collapse_singles
24
26
  super(**html_attrs)
25
27
  end
26
28
 
29
+ def id
30
+ "#{@nav_id}-#{@item.id}"
31
+ end
32
+
27
33
  def left_pad
28
34
  ((@depth - 1) * 12) + 24
29
35
  end
@@ -40,6 +46,7 @@ module Lookbook
40
46
  @children ||= if collection? && !collapsed?
41
47
  item.non_empty_items.map do |item|
42
48
  render Lookbook::Nav::Item::Component.new item,
49
+ nav_id: @nav_id,
43
50
  depth: (@depth + 1),
44
51
  collapse_singles: @collapse_singles
45
52
  end
@@ -52,8 +59,8 @@ module Lookbook
52
59
  collapsed? ? @item.first : @item
53
60
  end
54
61
 
55
- def nav_icon(entity)
56
- ICONS[entity.type] || :file
62
+ def nav_icon
63
+ ICONS[@item.type] || :file
57
64
  end
58
65
 
59
66
  def collection?
@@ -1,4 +1,4 @@
1
- <%= render_component_tag x_data: "{ activeTab: null }" do %>
1
+ <%= render_component_tag "x-data": "{ activeTab: null }" do %>
2
2
  <div class="flex w-full border-b border-lookbook-divider mb-6">
3
3
  <%= render_component :tabs, theme: :page do |t| %>
4
4
  <% @tabs.each do |props| %>
@@ -1,3 +1,3 @@
1
- <%= render_component_tag class: "prose #{size_class} text-lookbook-prose-text bg-lookbook-prose prose-a:text-lookbook-prose-link" do %>
1
+ <%= render_component_tag class: "prose #{size_class} text-lookbook-prose-text bg-lookbook-prose-bg prose-a:text-lookbook-prose-link" do %>
2
2
  <%== rendered_content %>
3
3
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= render_component_tag class: "grid h-full w-full", x_bind: "bindings.root", x_effect: "initSplit" do %>
1
+ <%= render_component_tag class: "grid h-full w-full", "x-bind": "bindings.root", "x-effect": "initSplit" do %>
2
2
  <% panes.each.with_index(1) do |pane, i| %>
3
3
  <%= pane %>
4
4
  <% if i < panes.size %>
@@ -1,7 +1,7 @@
1
1
  <%= render_component_tag :section,
2
2
  id: @id,
3
- x_ref: @name,
4
- x_cloak: true,
3
+ "x-ref": @name,
4
+ cloak: true,
5
5
  class: "h-full",
6
6
  ":class": "{ hidden: !isActive($el) }" do %>
7
7
  <%== content %>
@@ -9,8 +9,8 @@
9
9
  <%= safe_join(tabs) %>
10
10
  </div>
11
11
  <div x-ref="dropdownTrigger" class="absolute" x-show="hasHiddenTabs" :style="{left: `${triggerLeft}px`}">
12
- <%= render_component :button, icon: :chevrons_right, x_show: "visibleTabsCount > 0" %>
13
- <%= render_component :button, icon: :menu, class: "-ml-3", x_show: "visibleTabsCount === 0" %>
12
+ <%= render_component :button, icon: :chevrons_right, "x-show": "visibleTabsCount > 0" %>
13
+ <%= render_component :button, icon: :menu, class: "-ml-3", "x-show": "visibleTabsCount === 0" %>
14
14
  </div>
15
15
  <div class="hidden">
16
16
  <div x-ref="tabsDropdown" data-cloak>
@@ -1,5 +1,5 @@
1
1
  <%= render_component_tag :button,
2
- x_ref: @name,
2
+ "x-ref": @name,
3
3
  class: [
4
4
  "whitespace-nowrap px-4 border-l-2 cursor-pointer block w-full text-left",
5
5
  {
@@ -8,7 +8,7 @@
8
8
  }
9
9
  ],
10
10
  ":class": "{
11
- 'border-lookbook-tabs-highlight': isSelected($el),
11
+ 'border-lookbook-tabs-border-active': isSelected($el),
12
12
  'border-transparent text-lookbook-tabs-text hover:text-lookbook-tabs-text-hover': !isSelected($el),
13
13
  'hidden': visibleTabsCount >= #{@position}
14
14
  }",
@@ -1,6 +1,6 @@
1
1
  <%= render_component_tag :button,
2
2
  id: @id,
3
- x_ref: @name,
3
+ "x-ref": @name,
4
4
  class: [
5
5
  "whitespace-nowrap cursor-pointer pt-2.5 pb-1.5 border-b-2",
6
6
  {
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  ":class": "{
12
- 'border-lookbook-tabs-highlight': isSelected($el),
12
+ 'border-lookbook-tabs-border-active': isSelected($el),
13
13
  'border-transparent text-lookbook-tabs-text hover:text-lookbook-tabs-text-hover': !isSelected($el),
14
14
  '!text-lookbook-tabs-text-disabled': isDisabled($el),
15
15
  'invisible pointer-events-none relative z-[-1]': visibleTabsCount < #{@position}
@@ -4,26 +4,21 @@ module Lookbook
4
4
 
5
5
  def initialize(tag: :div, name: nil, cloak: false, **html_attrs)
6
6
  @tag = tag
7
- html_attrs[:class] = class_names(html_attrs[:class]) if html_attrs[:class]
8
7
  html_attrs[:data] ||= {}
9
8
  html_attrs[:data][:component] = name if name.present?
10
- html_attrs[:x_cloak] = true if cloak == true
11
- @html_attrs = convert_attrs(html_attrs)
9
+ html_attrs["x-cloak"] = true if cloak == true
10
+ html_attrs[self.class.escape_attribute_key] = false
11
+ @html_attrs = html_attrs
12
12
  end
13
13
 
14
14
  def call
15
- @html_attrs[Rails.version.to_f < 7.0 ? :escape_attributes : :escape] = false
16
15
  tag.public_send(@tag, **@html_attrs) do
17
16
  content
18
17
  end
19
18
  end
20
19
 
21
- protected
22
-
23
- def convert_attrs(html_attrs)
24
- html_attrs.map do |name, value|
25
- [name.to_s.tr("_", "-"), value]
26
- end.to_h
20
+ def self.escape_attribute_key
21
+ @escape_attribute_key ||= Gem::Version.new(Rails.version) < Gem::Version.new('6.1.5.1') ? :escape_attributes : :escape
27
22
  end
28
23
  end
29
24
  end
@@ -1,4 +1,4 @@
1
- <%= render_component_tag class: "h-10 border-b border-lookbook-divider w-full flex items-center text-sm flex-none bg-lookbook-toolbar" do %>
1
+ <%= render_component_tag class: "h-10 border-b border-lookbook-divider w-full flex items-center text-sm flex-none bg-lookbook-toolbar-bg" do %>
2
2
  <div class="toolbar-sections flex items-stretch w-full">
3
3
  <%= safe_join(sections) %>
4
4
  </div>
@@ -5,7 +5,7 @@
5
5
 
6
6
  .resize-handle {
7
7
  @apply flex items-center justify-center h-full w-full border-lookbook-divider bg-lookbook-viewport-handle hover:bg-indigo-100 hover:bg-opacity-20;
8
- @apply text-lookbook-viewport-handle-icon hover:text-lookbook-viewport-handle-icon-hover transition select-none touch-none;
8
+ @apply text-lookbook-viewport-handle-icon-stroke hover:text-lookbook-viewport-handle-icon-stroke-hover transition select-none touch-none;
9
9
  }
10
10
  }
11
11
  }
@@ -34,7 +34,7 @@
34
34
  <% end %>
35
35
  <% if @resize_height %>
36
36
  <div
37
- class="resize-handle border-b border-l border-lookbook-divider cursor-[col-resize] <%= "border-r" unless @resize_width %>"
37
+ class="resize-handle border-b border-l border-lookbook-divider cursor-[row-resize] <%= "border-r" unless @resize_width %>"
38
38
  @pointerdown="onResizeHeightStart"
39
39
  @dblclick="toggleFullHeight">
40
40
  <svg class="h-4 w-4 pointer-events-none rotate-90" fill="currentColor" viewBox="0 0 24 24" >
@@ -17,7 +17,7 @@ module Lookbook
17
17
  if landing.present?
18
18
  redirect_to lookbook_page_path(landing.lookup_path)
19
19
  else
20
- render "lookbook/index", layout: Lookbook.previews.any? ? "lookbook/application" : "lookbook/shell"
20
+ render "lookbook/index"
21
21
  end
22
22
  end
23
23
 
@@ -2,6 +2,7 @@ module Lookbook
2
2
  class PagesController < ApplicationController
3
3
  layout "lookbook/page"
4
4
  helper_method :page_controller
5
+ helper Lookbook::PageHelper
5
6
 
6
7
  def self.controller_path
7
8
  "lookbook/pages"
@@ -47,6 +47,16 @@ module Lookbook
47
47
  redirect_to lookbook_inspect_path params[:path]
48
48
  end
49
49
 
50
+ # Namespaced preview helpers
51
+
52
+ def lookbook_display(key, fallback = nil)
53
+ params.dig(:lookbook, :display, key.to_sym) || fallback
54
+ end
55
+
56
+ def lookbook_data(key, fallback = nil)
57
+ Lookbook.data.get(key, fallback)
58
+ end
59
+
50
60
  private
51
61
 
52
62
  def lookup_entities
@@ -98,10 +108,11 @@ module Lookbook
98
108
  preview_controller.params[param[:name]] = Lookbook::Params.cast(preview_controller.params[param[:name]], param[:type])
99
109
  end
100
110
  end
101
- # set display params
111
+ # set display and data params
102
112
  preview_controller.params.merge!({
103
113
  lookbook: {
104
- display: @example.display_params
114
+ display: @example.display_params,
115
+ data: Lookbook.data
105
116
  }
106
117
  })
107
118
  end
@@ -145,7 +156,8 @@ module Lookbook
145
156
  context: context_data,
146
157
  preview: preview,
147
158
  examples: examples,
148
- components: preview.components,
159
+ example: example,
160
+ data: Lookbook.data,
149
161
  app: Lookbook
150
162
  })
151
163
  end
@@ -20,11 +20,5 @@ module Lookbook
20
20
  def generate_id(*args)
21
21
  args.map { |args| args.delete_prefix("/").tr("&?=/_\-", "-") }.join("-")
22
22
  end
23
-
24
- def append_styles(&block)
25
- content_for :styles do
26
- capture(&block)
27
- end
28
- end
29
23
  end
30
24
  end
@@ -1,7 +1,6 @@
1
1
  module Lookbook
2
2
  module PreviewHelper
3
- def lookbook_display(key, fallback = nil)
4
- params.dig(:lookbook, :display, key.to_sym) || fallback
5
- end
3
+ # Left intentionally empty.
4
+ # Included for backwards compatability.
6
5
  end
7
6
  end