Skip to content

Commit c49c776

Browse files
committed
Lookbook setup fixes
1 parent c61416e commit c49c776

File tree

13 files changed

+34
-272
lines changed

13 files changed

+34
-272
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= yield %>

config/initializers/lookbook.rb

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22

33
# Lookbook configuration for component previews
44
# See: https://lookbook.build/guide/configuration
5+
#
6+
# NOTE: Configuration must be set via Rails.application.config.lookbook
7+
# BEFORE the app initializes, so Lookbook's engine uses the correct paths.
58

69
if Rails.env.development?
7-
# Load preview helper first (defines namespaces like Atoms, Molecules, etc.)
8-
require Rails.root.join("spec/components/previews/preview_helper")
9-
10-
preview_path = Rails.root.join("spec/components/previews")
11-
12-
# Configure ViewComponent preview paths (required for Lookbook to discover previews)
13-
Rails.application.config.view_component.preview_paths = [preview_path]
14-
15-
# Configure Lookbook preview paths
16-
if defined?(Lookbook)
17-
Lookbook.configure do |config|
18-
config.preview_paths = [preview_path]
19-
end
10+
Rails.application.configure do
11+
config.lookbook.preview_paths = [
12+
Rails.root.join("spec/components/previews").to_s
13+
]
2014
end
2115
end

spec/components/previews/atoms.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
# Namespace for atomic design "atoms" - basic building blocks
4+
module Atoms
5+
end

spec/components/previews/atoms/skeleton_preview.rb

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
# Namespace for atomic design "molecules" - combinations of atoms
4+
module Molecules
5+
end

spec/components/previews/molecules/consent_banner_preview.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

spec/components/previews/molecules/currency_selector_preview.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

spec/components/previews/molecules/pagination_preview.rb

Lines changed: 0 additions & 55 deletions
This file was deleted.

spec/components/previews/pagination_preview.rb

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,30 @@ class PaginationPreview < Lookbook::Preview
66
# First page pagination
77
# @label First Page
88
def first_page
9-
render inline: <<~ERB
10-
<div style="padding: 2rem; background: #f5f5f5;">
11-
<h3 style="margin-bottom: 1rem;">Pagination - Page 1 of 10</h3>
12-
<%= render partial: "shared/pagination", locals: {
13-
current_page: 1,
14-
total_pages: 10,
15-
base_path: "/properties"
16-
} %>
17-
</div>
18-
ERB
9+
render partial: "shared/pagination", locals: {
10+
current_page: 1,
11+
total_pages: 10,
12+
base_path: "/properties"
13+
}
1914
end
2015

2116
# Middle page pagination
2217
# @label Middle Page
2318
def middle_page
24-
render inline: <<~ERB
25-
<div style="padding: 2rem; background: #f5f5f5;">
26-
<h3 style="margin-bottom: 1rem;">Pagination - Page 5 of 10</h3>
27-
<%= render partial: "shared/pagination", locals: {
28-
current_page: 5,
29-
total_pages: 10,
30-
base_path: "/properties"
31-
} %>
32-
</div>
33-
ERB
19+
render partial: "shared/pagination", locals: {
20+
current_page: 5,
21+
total_pages: 10,
22+
base_path: "/properties"
23+
}
3424
end
3525

3626
# Last page pagination
3727
# @label Last Page
3828
def last_page
39-
render inline: <<~ERB
40-
<div style="padding: 2rem; background: #f5f5f5;">
41-
<h3 style="margin-bottom: 1rem;">Pagination - Page 10 of 10</h3>
42-
<%= render partial: "shared/pagination", locals: {
43-
current_page: 10,
44-
total_pages: 10,
45-
base_path: "/properties"
46-
} %>
47-
</div>
48-
ERB
29+
render partial: "shared/pagination", locals: {
30+
current_page: 10,
31+
total_pages: 10,
32+
base_path: "/properties"
33+
}
4934
end
5035
end

spec/components/previews/preview_helper.rb

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)